Skip to content

Commit 9d924b1

Browse files
docs: note type vs interface for structuredContent (#1784)
1 parent 9d08392 commit 9d924b1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/server.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ server.registerTool(
137137
>
138138
> For protocol details, see [Tools](https://modelcontextprotocol.io/specification/latest/server/tools) in the MCP specification.
139139
140+
> [!NOTE]
141+
> 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 }`:
142+
>
143+
> ```ts
144+
> type BmiResult = { bmi: number }; // assignable
145+
> interface BmiResult { bmi: number } // type error
146+
> ```
147+
>
148+
> Alternatively, spread the value: `structuredContent: { ...result }`.
149+
140150
#### `ResourceLink` outputs
141151
142152
Tools can return `resource_link` content items to reference large resources without embedding them directly, allowing clients to fetch only what they need:

0 commit comments

Comments
 (0)