Skip to content

fix(mcp): return an object as generate-theme structuredContent - #298

Open
dpritzker0905-cmd wants to merge 2 commits into
adobe:mainfrom
dpritzker0905-cmd:fix/mcp-structured-content-object
Open

dpritzker0905-cmd wants to merge 2 commits into
adobe:mainfrom
dpritzker0905-cmd:fix/mcp-structured-content-object

Conversation

@dpritzker0905-cmd

Copy link
Copy Markdown

Description

Fixes #297.

generate-theme returned theme.contrastColors, an array, as structuredContent. The MCP spec requires structuredContent to be an object, so SDK-based clients reject every generate-theme call:

MCP error -32602: Invalid tools/call result: ... "path": ["structuredContent"], "message": "Invalid input: expected record, received array"

Changes:

  • packages/mcp/src/server.js:
    • generate-theme now returns structuredContent: {contrastColors: result}. The text content is unchanged.
    • The McpServer instance is exported so tests can connect a client; runServer() is unchanged.
  • packages/mcp/test/server.test.js (new): connects a real Client to the server over the SDK's InMemoryTransport and calls all four tools end to end.
    • It asserts each structuredContent is a plain object.
    • It asserts generate-theme's array sits under contrastColors and matches the text content.
    • Against the old handler, the two generate-theme cases fail with the error above; the other tools pass.
  • .changeset/mcp-structured-content-object.md: patch bump for @adobe/leonardo-mcp.

node --test test/*.test.js in packages/mcp: 9/9 pass (4 existing, 5 new). Locally I ran against @modelcontextprotocol/sdk 1.32.1 and the published @adobe/leonardo-contrast-colors 1.1.0, not a full pnpm install of the workspace, so CI is the authority there.

Motivation

generate-theme is the package's main tool, and it is currently unusable from Claude Code and other SDK-based MCP clients. The other three tools already return objects and work.

Screenshots

n/a

To-do list

🤖 Generated with Claude Code

generate-theme returned theme.contrastColors, an array, as structuredContent.
The MCP spec requires structuredContent to be an object, so clients reject
every call with "Invalid tools/call result ... expected record, received
array". Return {contrastColors: [...]} instead; the text content is unchanged.

Export the McpServer instance so a test can connect a real client over the
SDK's in-memory transport, and add test/server.test.js, which calls every
tool end to end and asserts its structuredContent is an object. The two
generate-theme cases fail on the old handler with the error above.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c6eab9d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@adobe/leonardo-mcp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

leonardo-mcp: generate-theme fails in MCP clients (structuredContent is an array)

1 participant