Skip to content

Commit 24f138f

Browse files
bogdanmariusc10Bogdan-Marius-Catanuscrivetimihai
authored andcommitted
fix(mcp): convert PromptArgument types in prompts/list MCP handler (#3953)
* fix: convert PromptArgument types in prompts/list MCP handler Fixes #3939 The prompts/list MCP JSON-RPC method was returning empty arrays due to a Pydantic v2 type validation error. The root cause was a type mismatch between mcpgateway.schemas.PromptArgument (from the database layer) and mcp.types.PromptArgument (expected by the MCP SDK). Changes: - Add explicit type conversion in list_prompts() for both code paths (with and without server_id) to convert schema PromptArgument to MCP PromptArgument by mapping name, description, and required fields - Update test to use mcpgateway.schemas.PromptArgument instead of mcp.types.PromptArgument to properly test the conversion - Fix test data to use required=True instead of required=None The fix ensures MCP clients receive valid prompt lists through /servers/{UUID}/mcp/ and /mcp/ endpoints. Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * chore: update secrets baseline Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
1 parent 4716344 commit 24f138f

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

.secrets.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "package-lock.json|Cargo.lock|^.secrets.baseline$|scripts/sign_image.sh|scripts/zap|sonar-project.properties|^/Users/brian/dev/github.ibm.com/contextforge-org/sps-pipeline-config/.secrets.baseline$|^./.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2026-04-04T15:50:18Z",
6+
"generated_at": "2026-04-04T22:57:41Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -11028,15 +11028,15 @@
1102811028
"hashed_secret": "b4c9248600a42f8c38c01b632f392dbcb4c7b19a",
1102911029
"is_secret": false,
1103011030
"is_verified": false,
11031-
"line_number": 11072,
11031+
"line_number": 11073,
1103211032
"type": "Hex High Entropy String",
1103311033
"verified_result": null
1103411034
},
1103511035
{
1103611036
"hashed_secret": "90bd1b48e958257948487b90bee080ba5ed00caa",
1103711037
"is_secret": false,
1103811038
"is_verified": false,
11039-
"line_number": 12209,
11039+
"line_number": 12210,
1104011040
"type": "Hex High Entropy String",
1104111041
"verified_result": null
1104211042
}

tests/unit/mcpgateway/transports/test_streamablehttp_transport.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ async def fake_get_db():
849849
assert len(result[0].arguments) == 1
850850
assert isinstance(result[0].arguments[0], PromptArgument)
851851
assert result[0].arguments[0].name == "arg1"
852+
assert result[0].arguments[0].required is False
852853

853854

854855
@pytest.mark.asyncio

0 commit comments

Comments
 (0)