-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Log MCPServer handler exceptions once, by kind #3314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ff178c7
96b5cc8
6fd5e05
d3f3f5c
d0c72f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from mcp.server import MCPServer | ||
| from mcp.server.mcpserver.exceptions import ToolError | ||
|
|
||
| mcp = MCPServer("Bookshop") | ||
|
|
||
| CATALOG = {"Dune": "Frank Herbert", "Neuromancer": "William Gibson"} | ||
|
|
||
|
|
||
| @mcp.tool() | ||
| def get_author(title: str) -> str: | ||
| """Look up the author of a book in the catalog.""" | ||
| if title not in CATALOG: | ||
| raise ToolError(f"No book titled {title!r} in the catalog.") | ||
| return CATALOG[title] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -209,5 +209,5 @@ | |
| return messages | ||
| except MCPError: | ||
| raise | ||
| except Exception as e: | ||
| raise ValueError(f"Error rendering prompt {self.name}: {e}") | ||
| except Exception as exc: | ||
| raise ValueError(f"Error rendering prompt {self.name}) from exc | ||
|
Check failure on line 213 in src/mcp/server/mcpserver/prompts/base.py
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Unterminated f-string: Extended reasoning...Any Verification: normal — the diff introduces a genuine SyntaxError. Line 213 of /home/claude/python-sdk/src/mcp/server/mcpserver/prompts/base.py now reads exactly: |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P0: This line has an unterminated f-string, so importing
mcp.server.mcpserver.prompts.basefails with aSyntaxErrorand prevents the server from starting. Close the string before the closing parenthesis.Prompt for AI agents