Skip to content

MCP Client doesn't capture title #1360

@jer-k

Description

@jer-k

What is missing

The MCP Spec updated awhile back to include a title attribute - https://modelcontextprotocol.io/specification/2025-06-18/changelog. I found a similar issue and PR in the AI SDK

I want to be able to display the friendly title attribute in our UI rather than the name

Clanker investigation

File: tmp/agents/packages/agents/src/mcp/client.ts
Function: getAITools() at lines 1319–1379. The exact tool-object build is lines 1337–1371.

The fix mirrors the Vercel PR — add one line resolving the title and one line including it in the emitted object:

  // inside the for-of at line 1334
  for (const tool of getNamespacedData(connections, "tools")) {
    try {
      const toolKey = `tool_${tool.serverId.replace(/-/g, "")}_${tool.name}`;
      const title = tool.title ?? tool.annotations?.title;   // ← add
      entries.push([
        toolKey,
        {
          description: tool.description,
          title,                                              // ← add
          execute: async (args) => { /* ...unchanged... */ },
          inputSchema: /* ...unchanged... */,
          outputSchema: /* ...unchanged... */
        }
      ]);
    } ...

Why the types already work

The MCP SDK's ToolSchema at @modelcontextprotocol/sdk/dist/esm/types.d.ts:2381-2419 already declares both title: z.ZodOptional<z.ZodString> (line 2418, top-level per the 2025-11 spec) and annotations.title (line 2394, legacy). Since getNamespacedData(connections, "tools") returns (Tool & { serverId: string })[] (tmp/agents/packages/agents/src/mcp/client.ts:1590), tool.title and tool.annotations?.title are already type-safe — no type changes needed in agents.

Downstream, ToolSet in ai@6.0.58 accepts title?: string on each tool (Tool in @ai-sdk/provider-utils/dist/index.d.ts:1065), so there's nothing to widen there either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions