fix(prompts): fetch gateway-backed prompt content in server listing - #6505
Open
Ewertonslv wants to merge 1 commit into
Open
fix(prompts): fetch gateway-backed prompt content in server listing#6505Ewertonslv wants to merge 1 commit into
Ewertonslv wants to merge 1 commit into
Conversation
GET /v1/servers/{server_id}/prompts returned "template": "" for every
auto-discovered (gateway-backed) prompt. list_server_prompts() never
applied the same "does this prompt need a live fetch?" check that the
single-prompt GET /v1/prompts/{id} endpoint already applies via
_should_fetch_gateway_prompt() / _fetch_gateway_prompt_result() -
gateway-backed prompts are synced into the catalog as metadata only
(prompts/list has no content), so template stays "" until fetched.
Concurrently fetch live content for gateway-backed prompts after the
listing query, mirroring the existing single-prompt code path. A
per-prompt fetch failure is logged and leaves that prompt's template
as the empty string it already was, rather than failing the whole
list.
Closes IBM#6440
Signed-off-by: Ewerton Silva <ewertoncom297@gmail.com>
Ewertonslv
requested review from
Lang-Akshay,
brian-hussey,
crivetimihai,
ja8zyjits and
msureshkumar88
as code owners
August 31, 2026 17:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issue
Closes #6440
📝 Summary
GET /v1/servers/{server_id}/promptsreturned"template": ""for everyauto-discovered (gateway-backed) prompt. Custom prompts returned their
content correctly; getting a gateway-backed prompt's actual content required
a separate
GET /v1/prompts/{id}call per prompt.Root cause
Gateway-backed prompts are synced into the catalog as metadata only — the
MCP
prompts/listprotocol call doesn't return content, sotemplateisstored as
""at sync time. The single-prompt endpoint (GET /v1/prompts/{id}→
get_prompt()) already detects this via_should_fetch_gateway_prompt()andfetches the content live from upstream via
_fetch_gateway_prompt_result().list_server_prompts()inprompt_service.pynever applied that same check,so it always returned the empty stored value.
Fix
After the listing query, identify gateway-backed prompts with
_should_fetch_gateway_prompt()(existing helper, unchanged) and fetch theirlive content concurrently via
asyncio.gather(...), applying the fetched textonto the already-built
PromptReadobjects. A per-prompt fetch failure iscaught, logged, and leaves that prompt's
templateas the empty string italready was — one unreachable gateway doesn't fail the whole listing.
Tests (before → after)
test_gateway_backed_prompt_template_fetched_live: a gateway-backed prompt(empty template) and a local custom prompt (populated template) in the same
listing — asserts the gateway-backed one gets its live content, the local one
is untouched. Without the fix,
_fetch_gateway_prompt_resultis nevercalled (
Awaited 0 times) and the read stays empty; with the fix, bothassertions hold. Verified RED→GREEN via
git stash.test_gateway_backed_prompt_fetch_failure_leaves_template_empty: anunreachable gateway raises
PromptError— the listing still returns theprompt, with
templateleft as""(graceful degradation, no 500).pytest tests/unit/mcpgateway/services/test_prompt_service.py— full filegreen (all tests, not just the two new ones).
📏 Reviewability
triage🏷️ Type of Change