feat: anf-mcp, an MCP server exposing ANF encoding to any agent - #25
Merged
Conversation
Deterministic structural mapping of arbitrary JSON into an ANF document. Sorted keys, no semantic inference, lossless (name/id kept as props). Basis for the anf_encode MCP tool. Apache-2.0. Signed-off-by: Shreyansh Sancheti <43677304+shreyanshjain7174@users.noreply.github.com>
JSON-RPC 2.0 over stdio, no third-party deps, Apache-2.0. Register tools and resources, then Serve. Implements server/discover per MCP SEP-2575 and keeps initialize for current clients. No per-session state is retained. Signed-off-by: Shreyansh Sancheti <43677304+shreyanshjain7174@users.noreply.github.com>
Registers two tools on an anfmcp.Server: anf_encode (generic lossless JSON to ANF) and anf_encode_kubernetes (domain translator). Apache-2.0. Signed-off-by: Shreyansh Sancheti <43677304+shreyanshjain7174@users.noreply.github.com>
cmd/anf-mcp wires the ANF tools and embeds the spec as the anf://spec/format resource, so the binary is self-contained. A drift test guards the embedded spec against the canonical FORMAT.md. Adds the Makefile build target and a LICENSE note marking cmd/anf-mcp and translators/generic as Apache-2.0 so the whole packaging is open source. go install .../cmd/anf-mcp@latest. Signed-off-by: Shreyansh Sancheti <43677304+shreyanshjain7174@users.noreply.github.com>
cmd/anf-mcp/README.md with Claude/Cursor/VS Code/Codex configs and honest token caveats. examples/anf-skill/SKILL.md packages ANF as an agent skill. README lists the MCP server under what ships today. Signed-off-by: Shreyansh Sancheti <43677304+shreyanshjain7174@users.noreply.github.com>
Independent review found real issues; fixes: - preserve large integers: decode tool args with json.Number, render verbatim (float64 was silently corrupting integers above 2^53) - never reply to JSON-RPC notifications (no-id requests) for any method - reword docs from 'lossless' to 'structure-preserving; no fields dropped' and document the newline caveat (ANF is line-oriented and unescaped) - guard generic translator recursion depth (reject pathological nesting) - scalarString handles json.Number and stringifies unexpected types - sort alert/action map keys so anf_encode_kubernetes output is deterministic - LICENSE marks all of translators/ Apache-2.0 - tests for big-int precision, depth limit, empty containers, notifications Signed-off-by: Shreyansh Sancheti <43677304+shreyanshjain7174@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Wraps the ANF encoder as an MCP stdio server so any MCP client (Claude, Cursor, VS Code, Codex) can turn verbose JSON state into token-minimal ANF for context engineering. All Apache-2.0, so it is genuinely open source and usable.
What it adds
translators/generic: deterministic, structure-preserving JSON to ANF. No fields dropped, no semantics invented.pkg/anfmcp: a dependency-free JSON-RPC 2.0 stdio MCP server. Stateless, implementsserver/discoverper MCP SEP-2575, keepsinitializefor current clients.pkg/anftools: theanf_encodeandanf_encode_kubernetestools.cmd/anf-mcp: the binary. Embeds the spec as theanf://spec/formatresource.go install github.com/Clawdlinux/agent-native-format/cmd/anf-mcp@latest.examples/anf-skill/SKILL.md, README entry, LICENSE carve-out.Honesty
anf_encodestrips JSON syntax (braces, quotes, commas). It does not infer health or status. Docs say "structure-preserving" not "lossless" and document that line-oriented ANF does not escape newlines. Big integers are preserved (json.Number, no float rounding).Quality
Built with a subagent-driven loop and an independent code review. The review caught and we fixed: big-int precision loss, a JSON-RPC notification-reply bug, the lossless overclaim, recursion depth, and non-deterministic alert/action output. gofmt, go vet, race tests, staticcheck, and govulncheck all pass. New tests cover big ints, depth limits, empty containers, and notification handling.