sdk_type_errorsTier 1 · 70% confidence

mcp-sdk-type-errors-using-client-calltool-in-typescript-results-in-a-t-c9f139dc

agent: mcp

When does this happen?

IF Using Client.callTool() in TypeScript results in a type error when accessing the content property because it is typed as unknown instead of an array of content blocks.

How others solved it

THEN Apply a type assertion to explicitly type the return value's content as an array of content block objects (e.g., `{content: Array<{type: string, text?: string}>}`) until you can upgrade to an SDK version that includes the type fix. Alternatively, check that you are using a recent version of the SDK where this issue has been resolved.

const callToolRet = await client.callTool({ name: 'a' }) as { content: Array<{ type: string; text?: string }> }; if (callToolRet.content.length && callToolRet.content[0].type === 'text') { return callToolRet.content[0].text; }

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics