-
Notifications
You must be signed in to change notification settings - Fork 690
feat: Add title field support for human-friendly display names #431
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?
Conversation
- Implement BaseMetadata interface for consistent title handling - Add Title field to Tool, Prompt, Resource, ResourceTemplate - Add GetDisplayName() helper with title → annotations.title → name fallback - Add WithTitle/WithPromptTitle/WithResourceTitle/WithTemplateTitle options - Fix Tool JSON serialization to include title field - Add comprehensive tests and update examples - Fully backward compatible Resolves Task mark3labs#418
WalkthroughThe changes introduce a new optional Changes
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes found. Possibly related PRs
Suggested labels
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (5)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Update all example applications to demonstrate new title functionality: - custom_context: Add WithTitle for authenticated request tool - dynamic_path: Add WithTitle for echo tool - everything: Add comprehensive title support for all resources, prompts, and tools - in_process: Add WithTitle for dummy tool - typed_tools: Add WithTitle for greeting tool
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.
Do we need to have different functions like WithResourceTitle, WithPromptTitle, and WithTitle? Seems a bit unnecessary. Can we provide better APIs?
I feel that, at least for the DisplayName topic, we should try to provide helper functions to make it easier for users. Or do you have any good ideas regarding the API design? I’d be happy to try making some adjustments. |
Add Title Field Support for Human-Friendly Display Names
Resolves #418
Description
This PR implements Task #418 by adding comprehensive title field support across all MCP object types to provide human-friendly display names while maintaining programmatic identification through the existing name fields.
What We've Implemented
Core Infrastructure:
BaseMetadata
interface withGetName()
andGetTitle()
methods for consistent behavior across all typesGetDisplayName()
helper function that implements the fallback logic:title → annotations.title → name
Title Field Support:
Title
field to all relevant structs withjson:"title,omitempty"
for optional serializationAPI Enhancements:
WithTitle()
- Configure Tool title (takes precedence over annotation title)WithPromptTitle()
- Configure Prompt titleWithResourceTitle()
- Configure Resource titleWithTemplateTitle()
- Configure ResourceTemplate titleTool.MarshalJSON()
to properly serialize the title fieldCurrent Behavior
Fallback Priority:
title
→annotations.title
→name
title
→name
Testing & Compatibility
Fixes #418
Type of Change
Checklist
MCP Spec Compliance
Additional Information
Design Decisions:
BaseMetadata
interface for consistency rather than individual methods per typeannotations.title
while adding directtitle
supportTesting Coverage:
This implementation provides a clean foundation for human-readable display names across the MCP ecosystem. Any feedback on the design approach, additional test scenarios, or edge cases would be greatly appreciated. Thank you for taking the time to review this PR!
Summary by CodeRabbit
New Features
Tests