Commit 24f138f
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
11028 | 11028 | | |
11029 | 11029 | | |
11030 | 11030 | | |
11031 | | - | |
| 11031 | + | |
11032 | 11032 | | |
11033 | 11033 | | |
11034 | 11034 | | |
11035 | 11035 | | |
11036 | 11036 | | |
11037 | 11037 | | |
11038 | 11038 | | |
11039 | | - | |
| 11039 | + | |
11040 | 11040 | | |
11041 | 11041 | | |
11042 | 11042 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
849 | 849 | | |
850 | 850 | | |
851 | 851 | | |
| 852 | + | |
852 | 853 | | |
853 | 854 | | |
854 | 855 | | |
| |||
0 commit comments