modelcontextprotocol / modelcontextprotocol/servers
McpError does not support string messages as input
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 90.5k
- Forks
- 11.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 5
Description
Describe the bug
McpError does not properly handle string messages passed during initialization.
To Reproduce
Steps to reproduce the behavior:
Calling raise McpError("Error message") results in an AttributeError, because the string object does not have a message attribute.
Python 3.11.9 (main, May 12 2025, 20:04:08) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from mcp.shared.exceptions import McpError
>>> raise McpError("Error")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".pyenv/versions/atheris-env/lib/python3.11/site-packages/mcp/shared/exceptions.py", line 13, in __init__
super().__init__(error.message)
^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'message'
There are multiple call sites in the MCP server codebase where McpError is raised with a plain string argument, leading to this error.
Expected behavior
According to the MCP SDK specification, McpError is expected to receive an ErrorData object, which includes a message attribute.
I believe either the SDK specification or its usage should be corrected:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with raise McpError("Error") and inspect mcp/shared/exceptions.py, along with the server call sites that pass plain strings. Resolve whether the intended input is a string or an ErrorData object, then add coverage for the chosen behavior and verify those call sites no longer raise an AttributeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100