You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add explicit `| undefined` to optional properties on the `Transport` interface and `TransportSendOptions` (`onclose`, `onerror`, `onmessage`, `sessionId`, `setProtocolVersion`, `setSupportedProtocolVersions`, `onresumptiontoken`).
6
+
7
+
This fixes TS2420 errors for consumers using `exactOptionalPropertyTypes: true` without `skipLibCheck`, where the emitted `.d.ts` for implementing classes included `| undefined` but the interface did not.
8
+
9
+
Workaround for older SDK versions: enable `skipLibCheck: true` in your tsconfig.
Copy file name to clipboardExpand all lines: docs/server.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,6 +137,16 @@ server.registerTool(
137
137
>
138
138
> For protocol details, see [Tools](https://modelcontextprotocol.io/specification/latest/server/tools) in the MCP specification.
139
139
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
+
>typeBmiResult= { bmi:number }; // assignable
145
+
>interfaceBmiResult { bmi:number } // type error
146
+
>```
147
+
>
148
+
> Alternatively, spread the value: `structuredContent: { ...result }`.
149
+
140
150
#### `ResourceLink` outputs
141
151
142
152
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