Skip to content

fix: resolve JSON schema missing items error for polar chart dataTable#6

Open
xile611 wants to merge 2 commits intomainfrom
fix/polar-chart-dataTable-schema
Open

fix: resolve JSON schema missing items error for polar chart dataTable#6
xile611 wants to merge 2 commits intomainfrom
fix/polar-chart-dataTable-schema

Conversation

@xile611
Copy link
Copy Markdown
Contributor

@xile611 xile611 commented Mar 26, 2026

Summary

  • Fix generate_polar_chart function's dataTable parameter JSON schema error
  • Replace z.array(z.any()) with z.array(z.object({}).passthrough()) to generate valid schema with items property
  • Replace deprecated .nonempty() with .min(1)
  • Add type assertion in convertZodToJsonSchema to fix TypeScript type inference issue

Problem

The MCP server reported the following error when calling generate_polar_chart:

code: invalid_function_parameters; message: Invalid schema for function 'vchart-mcp-server_generate_polar_chart': In context=('properties', 'dataTable'), array schema missing items.

Solution

The z.array(z.any()) schema was generating an invalid JSON schema without the items property. By changing to z.array(z.object({}).passthrough()), the generated schema now correctly includes:

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {},
    "additionalProperties": true
  },
  "minItems": 1
}

Test plan

  • Run pnpm build - builds successfully
  • Run pnpm test - all 16 tests pass
  • Verify generated JSON schema contains items property

🤖 Generated with Claude Code

xile611 and others added 2 commits March 26, 2026 18:38
The generate_polar_chart function's dataTable parameter used z.array(z.any())
which resulted in an invalid JSON schema without the 'items' property, causing
MCP to report: "array schema missing items"

Changes:
- Replace z.array(z.any()) with z.array(z.object({}).passthrough()) to generate
  a valid schema with items: { type: "object" }
- Replace deprecated .nonempty() with .min(1)
- Add type assertion in convertZodToJsonSchema to fix TypeScript type inference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants