Skip to content

Conversation

@tommy-mor
Copy link

or am I missing something?

@hugoduncan hugoduncan closed this in #2 Mar 8, 2025
hugoduncan added a commit that referenced this pull request Mar 8, 2025
- Add a polylith style project for the mcp server
- Update README to show usage depending on this project

Closes #1
@hugoduncan
Copy link
Owner

I've added a polylith style project that you can depend on.

hugoduncan added a commit that referenced this pull request Oct 23, 2025
Replace org.clojure/data.json with cheshire/cheshire (v5.13.0) in:
- components/json-rpc/deps.edn
- components/http-client/deps.edn

This change improves babashka compatibility (cheshire is built-in)
and provides better performance (approximately 2x faster).

Part of story #1: Switch from clojure.data.json to cheshire
hugoduncan added a commit that referenced this pull request Oct 23, 2025
Update stdio-related files to use cheshire instead of clojure.data.json:
- stdio.clj: replace read-str/write-str with parse-string/generate-string
- stdio_server.clj: update JSON generation calls
- stdio_server_test.clj: update test assertions to use cheshire API

All tests pass with no behavioral changes.

Part of story #1: Switch from clojure.data.json to cheshire
hugoduncan added a commit that referenced this pull request Oct 23, 2025
Update http-client and http components to use cheshire for JSON:
- Change namespace requires from clojure.data.json to cheshire.core
- Replace json/read-str with json/parse-string
- Replace json/write-str with json/generate-string

Part of story #1: Switch from clojure.data.json to cheshire
hugoduncan added a commit that referenced this pull request Oct 23, 2025
Cheshire has two incompatibilities with clojure.data.json that caused
test failures after the migration:

1. **Integer vs Long**: Cheshire parses JSON integers as java.lang.Integer
   when they fit in int range, while clojure.data.json uses Long. This
   caused ConcurrentHashMap lookup failures because Integer(1) and Long(1)
   are not equal as Java map keys.

2. **LazySeq vs Vector**: Cheshire parses JSON arrays as LazySeq, while
   clojure.data.json returns PersistentVector. This broke code using
   vector? checks and indexed access.

Added `normalize-parsed-json` function that uses clojure.walk/postwalk to:
- Convert all Integer values to Long
- Convert all sequences to vectors (preserving maps)

This ensures cheshire produces the same data structures as clojure.data.json,
maintaining behavioral compatibility across the codebase.

Relates to story #1 (Switch from clojure.data.json to cheshire)
hugoduncan added a commit that referenced this pull request Oct 23, 2025
Add error handling tests across JSON and transport layers to ensure
consistent behavior when processing malformed JSON inputs.

Changes:
- json_test.clj: Add parse-error-test covering various malformed JSON
  edge cases (unclosed structures, invalid syntax, trailing commas,
  invalid escapes, numbers, and keywords)
- http_server_test.clj: Add json-parse-error-handling-test verifying
  HTTP 400 responses for malformed JSON and recovery behavior
- sse_server_test.clj: Add json-parse-error-handling-test verifying
  BadRequest responses for malformed JSON in SSE transport
- stdio_server_test.clj: Enhance test-error-handling with comprehensive
  malformed JSON cases and document current error handling behavior

All tests verify that transports handle parse errors gracefully and
continue processing valid requests after encountering malformed input.

Related to story #1 (cheshire migration)
hugoduncan added a commit that referenced this pull request Oct 23, 2025
Replaces clojure.data.json with cheshire throughout the codebase for improved performance and babashka compatibility.

## Key Changes

- Updated dependencies in json-rpc and http-client components
- Migrated all JSON parsing from `read-str` to `parse-string`
- Migrated all JSON generation from `write-str` to `generate-string`
- Created centralized json component for consistent JSON handling
- Fixed HTTP/SSE server error handling to return 400 for parse errors
- Fixed stdio server test cases to properly test empty line handling

## Benefits

- 2x performance improvement (cheshire benchmarks)
- Built into Babashka (removes dependency barrier)
- Better error handling with specific exception types
- Maintains full API compatibility and test coverage

## Testing

- All 285 tests passing across unit and integration test suites
- HTTP, SSE, and STDIO transports validated
- JSON roundtrip conversion verified
- Error handling maintains consistent behavior

Closes story #1
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