docs: note type vs interface for structuredContent (#1784)

This commit is contained in:
Felix Weinberger 2026-03-30 18:27:34 +01:00 • committed by GitHub
commit 9d924b1550
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -137,6 +137,16 @@ server.registerTool(
>
> For protocol details, see [Tools](https://modelcontextprotocol.io/specification/latest/server/tools) in the MCP specification.
> [!NOTE]
> When defining a named type for `structuredContent`, use a `type` alias rather than an `interface`. Named interfaces lack implicit index signatures in TypeScript, so they aren't assignable to `{ [key: string]: unknown }`:
>
> ```ts
> type BmiResult = { bmi: number }; // assignable
> interface BmiResult { bmi: number } // type error
> ```
>
> Alternatively, spread the value: `structuredContent: { ...result }`.
#### `ResourceLink` outputs
Tools can return `resource_link` content items to reference large resources without embedding them directly, allowing clients to fetch only what they need: