fix: resolve MCP server compatibility issues with Gemini and fix URL generation#17
fix: resolve MCP server compatibility issues with Gemini and fix URL generation#17chrichts wants to merge 3 commits into
Conversation
- Add proper Zod schemas to fix 'missing types in parameter schema' errors that made the server unusable by Gemini - Replace z.any() with strongly typed schemas for create-dashboard-widget, create-inline-question-rule, update-inline-question-rule, and execute-j1ql-query tools - Rename environment variable from JUPITERONE_BASE_URL to JUPITERONE_GRAPHQL_URL to match remote MCP server configuration - Fix URL generation in execute-j1ql-query by fetching account info to get subdomain This ensures the MCP server works with AI assistants that require typed schemas (like Gemini) and correctly generates JupiterOne URLs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
This PR fixes compatibility issues with Gemini AI and resolves URL generation problems in the MCP server by implementing proper type definitions and correcting environment variable references.
- Replaces generic
z.any()schemas with strongly typed Zod schemas for all MCP tools - Renames environment variable from
JUPITERONE_BASE_URLtoJUPITERONE_GRAPHQL_URLacross the codebase - Adds comprehensive schema validation tests
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/server/schemas.ts | New file containing comprehensive Zod type definitions for all MCP tool parameters |
| src/server/mcp-server.ts | Updates tool schemas to use proper types instead of z.any() |
| src/tests/schemas.test.ts | New test suite validating all schema definitions |
| src/index.ts | Updates environment variable name for GraphQL URL |
| src/utils/getEnv.ts | Updates environment variable reference |
| test-connection.js | Updates environment variable reference |
| example.env | Updates environment variable name |
| README.md | Updates documentation with correct environment variable name |
| package.json | Version bump to 0.0.13 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| area: z.record(z.any()).optional(), | ||
| graph: z.record(z.any()).optional(), | ||
| matrix: z.record(z.any()).optional(), | ||
| table: z.record(z.any()).optional(), | ||
| status: z.record(z.any()).optional(), |
There was a problem hiding this comment.
These chart type settings still use z.any() which defeats the purpose of adding proper type definitions. Consider defining proper schemas for these chart types or use z.unknown() with proper documentation explaining why specific typing isn't available.
| area: z.record(z.any()).optional(), | |
| graph: z.record(z.any()).optional(), | |
| matrix: z.record(z.any()).optional(), | |
| table: z.record(z.any()).optional(), | |
| status: z.record(z.any()).optional(), | |
| area: z | |
| .record(z.unknown()) | |
| .optional() | |
| .describe('No specific schema is defined for area chart settings; values are unknown.'), | |
| graph: z | |
| .record(z.unknown()) | |
| .optional() | |
| .describe('No specific schema is defined for graph chart settings; values are unknown.'), | |
| matrix: z | |
| .record(z.unknown()) | |
| .optional() | |
| .describe('No specific schema is defined for matrix chart settings; values are unknown.'), | |
| table: z | |
| .record(z.unknown()) | |
| .optional() | |
| .describe('No specific schema is defined for table chart settings; values are unknown.'), | |
| status: z | |
| .record(z.unknown()) | |
| .optional() | |
| .describe('No specific schema is defined for status chart settings; values are unknown.'), |
| .array(WidgetQuerySchema) | ||
| .describe('Array of J1QL queries for the widget'), | ||
| settings: WidgetSettingsSchema.optional().describe('Chart-specific settings'), | ||
| postQueryFilters: z.record(z.any()).optional().describe('Filters to apply after query execution'), |
There was a problem hiding this comment.
The postQueryFilters field uses z.any() which reduces type safety. Consider defining a proper schema for post-query filters or use z.unknown() with documentation explaining the expected structure.
| postQueryFilters: z.record(z.any()).optional().describe('Filters to apply after query execution'), | |
| postQueryFilters: z | |
| .record(z.unknown()) | |
| .optional() | |
| .describe('Filters to apply after query execution. Each key is a filter name, and the value is an application-defined filter object. The structure of each filter is intentionally left unknown for flexibility; see documentation for expected usage.'), |
| z.array(z.any()), | ||
| z.record(z.any()), |
There was a problem hiding this comment.
Multiple schemas still use z.any() for arrays and records. While this provides more flexibility than the original implementation, consider using z.unknown() or more specific types where possible to maintain type safety benefits.
| z.array(z.any()), | ||
| z.record(z.any()), |
There was a problem hiding this comment.
Multiple schemas still use z.any() for arrays and records. While this provides more flexibility than the original implementation, consider using z.unknown() or more specific types where possible to maintain type safety benefits.
| z.number(), | ||
| z.boolean(), | ||
| z.array(z.any()), | ||
| z.record(z.any()), |
There was a problem hiding this comment.
Multiple schemas still use z.any() for arrays and records. While this provides more flexibility than the original implementation, consider using z.unknown() or more specific types where possible to maintain type safety benefits.
- Replace all remaining z.any() usages with z.unknown() to ensure Gemini compatibility - Use proper union types with z.unknown() for flexible but typed schemas - This should resolve the 'missing types in parameter schema' errors completely
Summary
This PR fixes two critical issues that were preventing the MCP server from working correctly:
Changes Made
1. Added Proper Zod Schemas
src/server/schemas.tswith strongly typed Zod schemasz.any()usage with proper type definitions for:create-dashboard-widgettoolcreate-inline-question-ruletoolupdate-inline-question-ruletoolexecute-j1ql-querytoolsrc/__tests__/schemas.test.ts2. Fixed Environment Variable Name
JUPITERONE_BASE_URLtoJUPITERONE_GRAPHQL_URLthroughout the codebasesrc/index.tssrc/utils/getEnv.tsexample.envREADME.mdtest-connection.js3. Fixed URL Generation
execute-j1ql-querytool to fetch account info and use subdomain for URL constructionhttps://${subdomain}.apps.${environment}.jupiterone.io/...Testing
Impact
🤖 Generated with Claude Code