MCPcopy Create free account
hub / github.com/modelcontextprotocol/typescript-sdk / getDisplayName

Function getDisplayName

src/shared/metadataUtils.ts:13–26  ·  view source on GitHub ↗
(metadata: BaseMetadata | (BaseMetadata & { annotations?: { title?: string } }))

Source from the content-addressed store, hash-verified

11 * This implements the spec requirement: "if no title is provided, name should be used for display purposes"
12 */
13export function getDisplayName(metadata: BaseMetadata | (BaseMetadata & { annotations?: { title?: string } })): string {
14 // First check for title (not undefined and not empty string)
15 if (metadata.title !== undefined && metadata.title !== '') {
16 return metadata.title;
17 }
18
19 // Then check for annotations.title (only present in Tool objects)
20 if ('annotations' in metadata && metadata.annotations?.title) {
21 return metadata.annotations.title;
22 }
23
24 // Finally fall back to name
25 return metadata.name;
26}

Callers 5

mcp.test.tsFile · 0.85
listToolsFunction · 0.85
listToolsFunction · 0.85
listPromptsFunction · 0.85
listResourcesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…