From 59d0165a21424bd10f6ccfe59bf433080a7b1272 Mon Sep 17 00:00:00 2001 From: Felix Weinberger Date: Fri, 27 Mar 2026 11:51:38 +0000 Subject: [PATCH] docs: note type vs interface for structuredContent (#837) --- docs/server.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/server.md b/docs/server.md index 3c246ac12..fbeaff0bb 100644 --- a/docs/server.md +++ b/docs/server.md @@ -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: