-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: support setting title and description for server #1799
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?
feat: support setting title and description for server #1799
Conversation
b832792 to
c6247a6
Compare
c6247a6 to
39145f3
Compare
tests/server/test_session.py
Outdated
| async def message_handler( | ||
| message: RequestResponder[types.ServerRequest, types.ClientResult] | types.ServerNotification | Exception, | ||
| ) -> None: | ||
| if isinstance(message, Exception): # pragma: no cover |
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.
remove all pragmas from the test suite, instead use asserts
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.
Since those pragmas are already used extensively throughout this file, removing them all would significantly expand the scope of this PR. I'm happy to stick to the 'no new pragmas' rule for this change to keep the focus on the title and description support.
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.
Sorry yea that is what I mean, just removing the ones you added, not the existing one!
39145f3 to
777141e
Compare
555e72e to
ee18a6f
Compare
ee18a6f to
e05c684
Compare
| if present). | ||
| """ | ||
|
|
||
| description: str | None = None |
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.
This shouldn't have a description field, only Implementation should. Check the spec schema here: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/6e924e6f587f30aa810325c0985e2da0b257d4eb/schema/draft/schema.ts#L526
This PR is based on another draft PR.
Core Type Changes
src/mcp/types.py: Addeddescription: str | Nonefield toImplementationclassServer Model Changes
src/mcp/server/models.py: Addedtitleanddescriptionfields toInitializationOptionsLow-Level Server Changes
src/mcp/server/lowlevel/server.py:Server.__init__()to accepttitleanddescriptionparameterscreate_initialization_options()to include these fieldsSession Changes
src/mcp/server/session.py: Updated to passtitleanddescriptiontoserverInfoinInitializeResultFastMCP Changes
src/mcp/server/fastmcp/server.py:titleanddescriptionparameters to__init__()@propertymethods for read accessMCPServerGithub-Issue:#1783
Motivation and Context
The MCP specification defines an
Implementationschema (used for bothclientInfoandserverInfoin initialization) that includes bothtitleanddescriptionfields for providing human-readable metadata to MCP hosts. However, the Python SDK had several gaps:Missing
descriptionfield: WhileImplementationinheritedtitlefromBaseMetadata, it was missing thedescriptionfield entirely, even though the MCP spec supports it.Server initialization limitations: The server only accepted
InitializationOptionswhich didn't support settingtitleordescription, making it impossible for servers to provide this metadata to clients.Inconsistent support: Clients could at least set
titleviaclientInfo(anImplementationobject), but servers had no way to set either field.This PR addresses the server-side implementation, allowing MCP servers to provide human-readable titles and descriptions that can be displayed by MCP hosts in their user interfaces, improving the user experience when working with multiple MCP servers.
How Has This Been Tested?
Tests
tests/server/test_session.py: Added test for low-level server title/descriptiontests/server/fastmcp/test_server.py: Added tests for FastMCP with and without title/descriptionBreaking Changes
Types of changes
Checklist
Additional context