Skip to content

fix: wrap MCP tool array outputs in objects to satisfy SDK schema - #10443

Merged
joehan merged 4 commits into
mainfrom
jh-fix-mcp-array-input
Apr 30, 2026
Merged

joehan merged 4 commits into
mainfrom
jh-fix-mcp-array-input

Conversation

@joehan

@joehan joehan commented Apr 30, 2026

Copy link
Copy Markdown
Member

Description

Fixes an issue where some MCP tools fail with 'Invalid input: expected record, received array' due to SDK upgrade enforcing record type for structuredContent.

Wrapped arrays in objects at call sites and added safety check in toContent.

Scenarios Tested

  • Unit tests for get_users and util.ts passed.

Sample Commands

npx mocha src/mcp/tools/auth/get_users.spec.ts
npx mocha src/mcp/util.spec.ts

Fixes #10437

### Description
Fixes an issue where some MCP tools fail with 'Invalid input: expected record, received array' due to SDK upgrade enforcing record type for structuredContent.

Wrapped arrays in objects at call sites and added safety check in toContent.

### Scenarios Tested
- Unit tests for get_users and util.ts passed.

### Sample Commands
npx mocha src/mcp/tools/auth/get_users.spec.ts
npx mocha src/mcp/util.spec.ts

Fixes #10437

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes an MCP server error where arrays were incorrectly passed as records by wrapping them in objects at the call sites and adding a safety check in the toContent utility. The changes include updates to the auth, firestore, and functions tools, along with new unit tests for toContent. Feedback was provided to remove the use of as any type assertions in both the implementation and tests, suggesting more idiomatic TypeScript and Chai patterns to maintain type safety as per the repository style guide.

Comment thread src/mcp/util.ts Resolved
Comment thread src/mcp/util.spec.ts Resolved
Comment thread src/mcp/util.spec.ts Resolved
Comment thread src/mcp/util.spec.ts Resolved
@joehan
joehan merged commit 94da71d into main Apr 30, 2026
43 of 45 checks passed
@joehan
joehan deleted the jh-fix-mcp-array-input branch April 30, 2026 20:23
bkendall pushed a commit that referenced this pull request Jul 9, 2026
…0443)

* fix: wrap MCP tool array outputs in objects to satisfy SDK schema

### Description
Fixes an issue where some MCP tools fail with 'Invalid input: expected record, received array' due to SDK upgrade enforcing record type for structuredContent.

Wrapped arrays in objects at call sites and added safety check in toContent.

### Scenarios Tested
- Unit tests for get_users and util.ts passed.

### Sample Commands
npx mocha src/mcp/tools/auth/get_users.spec.ts
npx mocha src/mcp/util.spec.ts

Fixes #10437

* chore: remove as any assertions and update changelog

* chore: remove headers from CHANGELOG.md to match repo style
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.

MCP: structuredContent returns array instead of object for list-type tools (breaks MCP clients)

2 participants