8000 Add title to tools, resources, prompts by felixweinberger · Pull Request #972 · modelcontextprotocol/python-sdk · GitHub
[go: up one dir, main page]

Skip to content

Add title to tools, resources, prompts #972

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

Merged
merged 6 commits into from
Jun 17, 2025

Conversation

felixweinberger
Copy link
Contributor
@felixweinberger felixweinberger commented Jun 17, 2025

Add support for optional title field across MCP entities to provide human-readable display names separate from programmatic identifiers.

Motivation and Context

This implements the spec change from modelcontextprotocol/modelcontextprotocol#663 to improve user experience by allowing servers to provide human-friendly names for tools, resources, and prompts.

How Has This Been Tested?

  • Added comprehensive test suite for title functionality (test_title.py)
  • Updated example servers and simple-chatbot client to demonstrate title usage
  • All existing tests pass with these changes

Breaking Changes

None - the title field is optional and all existing code continues to work unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Add optional title field to core MCP types:
- Tool: For human-readable tool display names
- Resource: For human-readable resource display names
- ResourceTemplate: For human-readable template display names
- Prompt: For human-readable prompt display names
- Implementation: For human-readable implementation display names

The title field provides a way to display user-friendly names in UIs
while keeping programmatic names stable. All fields are optional to
maintain backwards compatibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@felixweinberger felixweinberger force-pushed the fweinberger/encourage-naming branch 3 times, most recently from cbc2c20 to 68cd574 Compare June 17, 2025 12:04
felixweinberger and others added 4 commits June 17, 2025 13:05
Add BaseMetadata base class to provide common name and title fields for
consistency with TypeScript SDK implementation. This centralizes the
field definitions for Implementation, Tool, Resource, ResourceTemplate,
and Prompt classes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add optional title field to tools, resources, prompts, and resource templates
in FastMCP to enable human-readable display names. Also includes a utility
function get_display_name() for consistent title/name precedence handling.

- Add title parameter to @tool, @resource, and @prompt decorators
- Add title field to Tool, Resource, Prompt, and ResourceTemplate models
- Implement get_display_name() utility with proper precedence rules
- Add comprehensive tests for title functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update README and example servers to demonstrate the new title field feature
for better human-readable display names.

- Add title parameter to decorator examples in README
- Update simple-tool example with "Website Fetcher" title
- Update simple-resource example with resource-specific titles
- Update simple-prompt example with "Simple Assistant Prompt" title

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update simple-chatbot example to show title as separate field for LLM
- Add "Client Display Utilities" section to README with usage examples
- Enhance get_display_name() documentation to clarify client-side usage

This demonstrates best practices for displaying human-readable titles in
MCP clients while maintaining programmatic names for tool execution.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@felixweinberger felixweinberger force-pushed the fweinberger/encourage-naming branch from 68cd574 to 6fb06d7 Compare June 17, 2025 12:05
@felixweinberger felixweinberger marked this pull request as ready for review June 17, 2025 12:09
@felixweinberger felixweinberger requested a review from ihrpr June 17, 2025 12:09
@felixweinberger felixweinberger linked an issue Jun 17, 2025 that may be closed by this pull request
ihrpr
ihrpr previously approved these changes Jun 17, 2025
Copy link
Contributor
@ihrpr ihrpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments inline, also please can you add title tools, prompts in test_integration there is make_everything_fastmcp

@felixweinberger felixweinberger force-pushed the fweinberger/encourage-naming branch 2 times, most recently from 1a892bb to 36234a4 Compare June 17, 2025 13:44
ihrpr
ihrpr previously approved these changes Jun 17, 2025
Copy link
Contributor
@ihrpr ihrpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, a few more nits

@felixweinberger felixweinberger force-pushed the fweinberger/encourage-naming branch 2 times, most recently from 8a53a85 to 5f94ff7 Compare June 17, 2025 13:58
@felixweinberger felixweinberger requested a review from ihrpr June 17, 2025 14:07
- Add titles to all tools, resources, and prompts in make_everything_fastmcp test fixture
- Refactor simple-resource server to use single dict for resource data and titles
- Add MCP specification link to metadata_utils.py documentation
- Add comprehensive test_title_precedence to verify title functionality
- Fix missing title field in test_tool_manager.py Tool instantiation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@felixweinberger felixweinberger force-pushed the fweinberger/encourage-naming branch from 5f94ff7 to ef4ca88 Compare June 17, 2025 14:08
@felixweinberger felixweinberger merged commit a2f8766 into main Jun 17, 2025
27 of 30 checks passed
@felixweinberger felixweinberger deleted the fweinberger/encourage-naming branch June 17, 2025 14:53
@BhuwanPandey BhuwanPandey mentioned this pull request Jun 19, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encourage title properties/usage for objects/resources
2 participants
0