docs: note type vs interface for structuredContent#1784
docs: note type vs interface for structuredContent#1784felixweinberger wants to merge 1 commit intomainfrom
Conversation
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
There was a problem hiding this comment.
LGTM — straightforward docs addition noting a well-known TypeScript gotcha.
Extended reasoning...
Overview
This PR adds a single documentation note to docs/server.md explaining that users should use type aliases instead of interface when defining named types for structuredContent, due to TypeScript's implicit index signature behavior. It closes issue #837.
Security risks
None. This is a pure documentation change with no code modifications.
Level of scrutiny
Minimal scrutiny needed. This is a small, self-contained documentation addition to a markdown file. The technical content is accurate — TypeScript interfaces lack implicit index signatures, so they are not assignable to { [key: string]: unknown }. The workaround (use type or spread) is correct.
Other factors
No outstanding reviewer comments. No changeset needed for a docs-only change. The note is placed in the right location (right after the registerTool example that uses structuredContent). The formatting follows existing conventions in the file (GitHub-flavored admonition blocks).
Closes #837. Documents the TypeScript-native workaround for the named interface assignability issue with structuredContent.
Motivation and Context
Issue #837: users hit type errors when using named interfaces for structuredContent. The fix is to use type aliases instead.
Types of changes