fix(mcp): forward prompt arg descriptions & standardise error format

- Propagate `description` from MCP prompt arguments into the JSON
  Schema so LLMs can better understand prompt parameters.
- Align generic-exception error message with tool/resource wrappers
  (drop redundant `{exc}` detail).
- Extend test fixture to mock `mcp.shared.exceptions.McpError`.
- Add tests for argument description forwarding and McpError handling.

Made-with: Cursor
This commit is contained in:
Xubin Ren
2026-04-08 00:28:04 +08:00
committed by Xubin Ren
parent 7cc527cf65
commit 8871a57b4c
2 changed files with 39 additions and 2 deletions
+5 -2
View File
@@ -228,7 +228,10 @@ class MCPPromptWrapper(Tool):
properties: dict[str, Any] = {}
required: list[str] = []
for arg in prompt_def.arguments or []:
properties[arg.name] = {"type": "string"}
prop: dict[str, Any] = {"type": "string"}
if getattr(arg, "description", None):
prop["description"] = arg.description
properties[arg.name] = prop
if arg.required:
required.append(arg.name)
self._parameters: dict[str, Any] = {
@@ -284,7 +287,7 @@ class MCPPromptWrapper(Tool):
"MCP prompt '{}' failed: {}: {}",
self._name, type(exc).__name__, exc,
)
return f"(MCP prompt call failed: {type(exc).__name__}: {exc})"
return f"(MCP prompt call failed: {type(exc).__name__})"
parts: list[str] = []
for message in result.messages: