Skip to content

fix(client): prefer .title over .name for prompt, resource, and template labels (closes #1226, #1227)#1341

Open
adityachilka1 wants to merge 1 commit into
modelcontextprotocol:mainfrom
adityachilka1:fix/title-in-prompts-resources
Open

fix(client): prefer .title over .name for prompt, resource, and template labels (closes #1226, #1227)#1341
adityachilka1 wants to merge 1 commit into
modelcontextprotocol:mainfrom
adityachilka1:fix/title-in-prompts-resources

Conversation

@adityachilka1
Copy link
Copy Markdown

Closes #1226 and closes #1227 (two-for-one).

Why

The MCP spec's BaseMetadata gives every named entity an optional
attribute title, aimed explicitly at UI display:

Intended for UI and end-user contexts — optimized to be human-readable
and easily understood, even by those unfamiliar with domain-specific
terminology. If not provided, the name should be used for display.

The Tools tab already follows tool.title || tool.name (e.g.
client/src/components/ToolsTab.tsx:293). PromptsTab and ResourcesTab
(and the Resource Templates list) rendered the raw name.

Changes

  • client/src/components/PromptsTab.tsx
    • Add title?: string to the local Prompt type (mirrors the SDK
      BaseMetadataSchema field).
    • List position: {prompt.name}{prompt.title || prompt.name}
    • Selected header: selectedPrompt.nametitle || name
  • client/src/components/ResourcesTab.tsx
    • List position (resources): resource.nametitle || name
    • List position (resource templates): template.nametitle || name
    • Selected header + its title attribute: title || name for
      both selectedResource and selectedTemplate

The SDK-exported Resource and ResourceTemplate types already declare
title via BaseMetadataSchema, so no type changes were needed there.

No type changes for SDK-imported types

The local Prompt type in PromptsTab.tsx is hand-maintained and is where
the new field goes.

Verification

npm test -- --testPathPattern='ResourcesTab|PromptsTab'
npm run prettier-check
  • 10 / 10 tests pass in ResourcesTab.test.tsx (no PromptsTab test
    file in the repo, so this is the closest coverage).
  • prettier-check passes for the whole repo.

No behavioral regression

When title is absent (null | undefined | empty string), the || name
fallback kick in, returning the exact same string the UI previously showed.
Only change: when the server does provide a title, it's used.

…ate labels

The MCP spec's `BaseMetadata` gives every named entity an optional
`title` aimed at human-readable UI display; `name` is the programmatic
identifier. The Tools tab already followed the idiomatic `title || name`
pattern, but PromptsTab and ResourcesTab (including resource templates)
rendered the raw `name` even when a title was available.

Mirror the ToolsTab pattern for parity. Also adds the already-spec'red
`title?: string` field to the local `Prompt` type in PromptsTab.tsx
(SDK types for Resource and ResourceTemplate already carry it).

Closes modelcontextprotocol#1226, closes modelcontextprotocol#1227.
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.

List resources shows resource name as label instead of resource title List Prompts uses prompt name instead of prompt title as display label

2 participants