Skip to content

Conversation

@kmckiern
Copy link
Contributor

Summary

Simplifies MCP schema validation by removing JSON string parsing and requiring direct object inputs

Note – "prompt" and "response" (both in the evaluation payload) were union types over object and stringified JSON (which was then parsed into an object). We found that this added flexibility (which was intended to help the model) just caused more confusion. So, now we accept only objects.

Changes

  • Schema validation: Removed string-to-object parsing from PromptSchema and ResponseSchema - now requires direct object inputs for
    better type safety
  • MCP SDK upgrade: Updated @modelcontextprotocol/sdk from 1.17.5 to 1.18.0
  • Enhanced logging: Added structured logging with request IDs for evaluation creation and error handling in mandoline-client.ts
  • Schema documentation: Updated schema descriptions to clarify that prompt/response must be provided as objects

Test plan

  • Existing unit tests updated to reflect object-only validation
  • Schema validation tests confirm string inputs are properly rejected
  • MCP tool registration works with direct object schemas

kmckiern and others added 10 commits September 11, 2025 11:07
Update PromptSchema and ResponseSchema to use union types that explicitly
accept both string and object inputs at the MCP protocol level, while
preserving existing JSON string preprocessing behavior.

- Add union types to schemas: z.union([z.string(), BaseSchema])
- Add root-level descriptions for prompt and response objects
- Apply descriptions at tool input schema level following established patterns
- Maintain backward compatibility with existing preprocessing logic

Fixes: MCP error -32602: Expected object, received string

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add comprehensive tests for PromptSchema and ResponseSchema validation
- Test both string and object inputs for schema flexibility
- Update Jest config to use SWC for faster compilation (~0.4s vs 3-5s)
- Add moduleNameMapper to support .js extension imports in TypeScript

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add @swc/core and @swc/jest for fast TypeScript compilation
- Add ts-node as dev dependency for TypeScript tooling
- Update package-lock.json with new dependencies

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fixed MCP protocol validation for evaluation prompt/response parameters
and added comprehensive test coverage with optimized Jest configuration.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add focused debug logging for evaluation start/success with key identifiers
- Add error logging for missing API key in Mandoline client
- Remove verbose debug logs (payload details, client creation steps)
- Keep essential logs for troubleshooting and auditing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove JSON string input flexibility from PromptSchema and ResponseSchema
- Eliminate BasePromptSchema/BaseResponseSchema intermediate constants
- Update parameter descriptions to clarify object-only requirement
- Fix evaluation payload tests to match new schema behavior
- Clean up unused JSON parsing logic and debug logging

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Simplifies logging by using the base logger directly instead of creating
request-specific child loggers for minimal usage. Also removes verbose
debug logging for evaluation creation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@kmckiern kmckiern merged commit 2ebbb45 into main Sep 12, 2025
5 checks passed
@kmckiern kmckiern deleted the fix/mcp-schema-validation branch September 12, 2025 21:56
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.

1 participant