fix: Prevent JSON serialization errors and accept keyword keys in tool properties #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two issues encountered when building an MCP server with the SDK.
Context
While developing emacs-mcp, an MCP server that integrates Claude Code with Emacs, we encountered a crash on server startup:
Investigating the stack trace led us to
validate-spec!, which was trying to log the fullserver-spec(including handler functions) when validation failed. This revealed a second issue: the spec validation itself was failing because our tool definitions used keyword keys ininputSchema.properties(e.g.,:function_name), but the spec only accepted string keys.Changes
server.cljvalidate-spec!to strip:handlerkeys from tools, prompts, and resources before loggingspecs.clj:tool/propertiesspec from(s/map-of string? any?)to(s/map-of (s/or :str string? :kw keyword?) any?)to accept both string and keyword keysTest plan
🤖 Generated with Claude Code
Co-Authored-By: Pedro Branquinho [email protected]
Co-Authored-By: Claude Opus 4.5 [email protected]