Skip to content

feat: anf-mcp, an MCP server exposing ANF encoding to any agent - #25

Merged
shreyanshjain7174 merged 6 commits into
mainfrom
feat/anf-mcp-server
Jul 21, 2026
Merged

feat: anf-mcp, an MCP server exposing ANF encoding to any agent#25
shreyanshjain7174 merged 6 commits into
mainfrom
feat/anf-mcp-server

Conversation

@shreyanshjain7174

Copy link
Copy Markdown
Contributor

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, implements server/discover per MCP SEP-2575, keeps initialize for current clients.
  • pkg/anftools: the anf_encode and anf_encode_kubernetes tools.
  • cmd/anf-mcp: the binary. Embeds the spec as the anf://spec/format resource. go install github.com/Clawdlinux/agent-native-format/cmd/anf-mcp@latest.
  • Docs: per-command README with client configs, an examples/anf-skill/SKILL.md, README entry, LICENSE carve-out.

Honesty

anf_encode strips 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.

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>
@shreyanshjain7174
shreyanshjain7174 merged commit 530d41f into main Jul 21, 2026
6 checks passed
@shreyanshjain7174
shreyanshjain7174 deleted the feat/anf-mcp-server branch July 21, 2026 06:24
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