Skip to content

Commit f6f7627

Browse files
committed
Close the f-string in Prompt.render and pin the shorter message
The applied suggestion dropped the closing quote along with the interpolated exception text, so prompts/base.py no longer parsed. With the message now just "Error rendering prompt <name>", the legacy-path interaction test snapshots that instead of matching the pydantic prefix.
1 parent d0c72f2 commit f6f7627

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/mcp/server/mcpserver/prompts/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,4 @@ async def render(
210210
except MCPError:
211211
raise
212212
except Exception as exc:
213-
raise ValueError(f"Error rendering prompt {self.name}) from exc
213+
raise ValueError(f"Error rendering prompt {self.name}") from exc

tests/interaction/mcpserver/test_prompts.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ async def test_get_prompt_with_a_wrong_type_argument_is_rejected_before_the_func
123123
124124
The decorated function is wrapped in pydantic's validate_call, so a value that cannot be
125125
coerced to the parameter's annotation fails before the body executes. The function body
126-
raises NotImplementedError to prove it never ran. The error is wrapped in the SDK's stable
127-
rendering-error prefix; the body of the message is raw pydantic output and is not asserted.
126+
raises NotImplementedError to prove it never ran. The client sees only the SDK's
127+
rendering-error message naming the prompt, with the pydantic detail withheld.
128128
"""
129129
mcp = MCPServer("prompter")
130130

@@ -137,8 +137,7 @@ def repeat(phrase: str, count: int) -> str:
137137
with pytest.raises(MCPError) as exc_info:
138138
await client.get_prompt("repeat", {"phrase": "hi", "count": "many"})
139139

140-
assert exc_info.value.error.code == 0
141-
assert exc_info.value.error.message.startswith("Error rendering prompt repeat: 1 validation error")
140+
assert exc_info.value.error == snapshot(ErrorData(code=0, message="Error rendering prompt repeat"))
142141

143142

144143
@requirement("mcpserver:prompt:optional-args")

0 commit comments

Comments
 (0)