Skip to content

Add title to tools, resources, prompts #631

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 9 commits into from
Jun 16, 2025
Merged

Add title to tools, resources, prompts #631

merged 9 commits into from
Jun 16, 2025

Conversation

ihrpr
Copy link
Contributor

@ihrpr ihrpr commented Jun 15, 2025

Background: https://github.com/modelcontextprotocol/modelcontextprotocol/pull/663/files
Closes: #624

Changes

  • Added BaseMetadata interface with name (required) and title (optional) fields
  • Updated Resource, Tool, Prompt, and Implementation types to extend BaseMetadata
  • Added register* methods (registerTool, registerPrompt, registerResource) for consistent API patterns
  • Created metadataUtils with getDisplayName() helper function for title fallback logic
  • Updated server implementations to include title in list responses when defined
  • Added comprehensive tests for title functionality and backwards compatibility
  • Updated README documentation to showcase the new patterns
@ihrpr ihrpr requested a review from bhosmer-ant June 15, 2025 19:48
@ihrpr ihrpr changed the base branch from main to ihrpr/additinal-meta June 15, 2025 21:21
Copy link
Contributor

@bhosmer-ant bhosmer-ant left a comment

Choose a reason for hiding this comment

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

Left a few comments inline, but accepting to unblock

delete this._registeredResources[uriOrTemplate]
if (updates.uri) this._registeredResources[updates.uri] = registeredResource
}
if (typeof updates.name !== "undefined") registeredResource.name = updates.name
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a title updater here (same for resource() if not factored into something common)?

src/types.ts Outdated
name: z.string(),
version: z.string(),
/** Intended for UI and end-user contexts — optimized to be human-readable */
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't know if it's worth adding the language about tool.annotations.title from the spec here

Base automatically changed from ihrpr/additinal-meta to main June 16, 2025 08:13
@ihrpr ihrpr merged commit ddc1a0c into main Jun 16, 2025
5 checks passed
@ihrpr ihrpr deleted the ihrpr/title branch June 16, 2025 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants