Summary
Wrap docmap's parser and query engine in an MCP (Model Context Protocol) server so agents can call structured tools instead of shelling out to the CLI.
Why
The plugin marketplace + SKILL.md that ship with this repo teach Claude when to use docmap. An MCP server would give it the tools to use docmap without going through Bash, which means:
- No ANSI escape codes to strip from output
- Typed JSON responses instead of text parsing
- Fewer round-trips (no subprocess spawn per call)
- Works in environments where shell access is restricted (sandboxes, remote agents)
- Consistent interface for every docmap feature, not just the ones the CLI exposes nicely
Proposed tools
Each maps to an existing CLI flag or subfeature:
- `docmap__inventory(path)` → ContentSummary for a file or directory
- `docmap__tree(file)` → full typed section tree with notable annotations
- `docmap__find_by_type(file, kind, lang?, variant?)` → typed node list with line ranges
- `docmap__at_line(file, line)` → breadcrumb + node detail at a line number
- `docmap__since(file, ref)` → constructs on lines changed since a git ref
- `docmap__search(path, query)` → AST-aware search across files
- `docmap__section(file, name)` → one section's subtree + notables
- `docmap__expand(file, name)` → raw content of a named section
- `docmap__json(file)` → full typed AST (same shape as `--json` output)
- `docmap__refs(path)` → cross-file markdown reference graph
Architecture notes
- The `parser` package is already library-shaped — `parser.Parse()` returns a `*Document` with the full typed AST. Both the CLI and an MCP server can import it directly with zero refactoring.
- Ship the server as a `docmap mcp` subcommand on the existing binary (single install path), rather than a separate `docmap-mcp` binary.
- Use the official `github.com/modelcontextprotocol/go-sdk` if it's stable, otherwise a community alternative.
- Once the server exists, ship a `.mcp.json` at the repo root so Claude Code auto-enables it when users are in a docmap-installed project. (That file is currently gitignored until the server lands.)
Non-goals
- Not replacing the CLI — both should exist and share the same parser.
- Not building a remote/hosted server — stdio MCP only, runs locally next to the agent.
Acceptance
- `docmap mcp` subcommand that speaks stdio MCP
- Every tool listed above implemented and returning typed JSON
- Tests covering each tool's contract (input/output shape, error cases)
- README section with install + config snippet for Claude Code and other MCP clients
- `.mcp.json` at the repo root (removed from `.gitignore`) that auto-enables the server when the repo is open
Summary
Wrap docmap's parser and query engine in an MCP (Model Context Protocol) server so agents can call structured tools instead of shelling out to the CLI.
Why
The plugin marketplace + SKILL.md that ship with this repo teach Claude when to use docmap. An MCP server would give it the tools to use docmap without going through
Bash, which means:Proposed tools
Each maps to an existing CLI flag or subfeature:
Architecture notes
Non-goals
Acceptance