dir2mcp
CLAUDE.md5 starsChanged 2 months agoMITView on GitHub
dir2mcp is a Go monorepo for deploying a directory as an MCP knowledge server. It supports indexing, retrieval, citations, and optional x402 request gating (an HTTP 402‑based payment challenge system). See x402 request gating docs for details (canonical spec lives in the dirstral-spec submodule; docs/SPEC.md, docs/VISION.md, docs/ECOSYSTEM.md and docs/x402-payment-adapter-spec.md are pointer stubs). - Build: make build - Full checks: make check (the local merge-readiness gate: Go plus the Python annotator suite) - CI-safe checks: make ci - Focused suites: -…
- Reads credentials
- Deletes or force-pushes
- Installs packages
- Commits and pushes
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 102
Every --question must be one the corpus can answer.
- Distinctive: line 122
Keep changes scoped to the issue.
- Distinctive: line 124
Do not log secrets or raw sensitive payloads.
- Distinctive: line 125
If behavior changes, update tests and docs in the same PR.
- Distinctive: line 126
Prefer deterministic behavior and explicit error handling.
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Project
dir2mcp is a Go monorepo for deploying a directory as an MCP knowledge server. It supports indexing, retrieval, citations, and optional x402 request gating (an HTTP 402‑based payment challenge system). See x402 request gating docs for details (canonical spec lives in the dirstral-spec submodule; docs/SPEC.md, docs/VISION.md, docs/ECOSYSTEM.md and docs/x402-payment-adapter-spec.md are pointer stubs).
Repository layout
cmd/dir2mcp: binary entrypointinternal/cli: CLI command orchestration (up,status,ask,reindex,config,version)internal/config: config load/merge/validationinternal/ingest: file discovery, OCR/transcription/annotation representation generationinternal/pdfutil: pure-Go PDF helpers (page count, per-page extraction) for multimodal media chunksinternal/avutil: audio/video helpers (ffprobe duration, ffmpeg time-window extraction) for multimodal media chunksinternal/retrieval: search/ask/open_file logicinternal/secretmatch: the secret pattern and allow pattern matcher that every secret screen uses (SPEC §7.2)internal/mcp: JSON-RPC/MCP server and toolsinternal/mistral: Mistral client adaptersinternal/x402: x402 types + facilitator clientinternal/store: sqlite-backed metadata persistencetests/*: integration-style suites by subsystemdocs/: user guides (install, configuration, cli, mcp-tools, security, deployment, x402, dual-machine-deployment) plus pointer stubs for the normative docs (SPEC, VISION, ECOSYSTEM, x402 adapter), which live in thedirstral-specgit submodule (dirstral-spec/docs/). The README stays short: put reference material in a guide and link it.
Build and test
- Build:
make build - Full checks:
make check(the local merge-readiness gate: Go plus the Python annotator suite) - CI-safe checks:
make ci - Focused suites:
go test ./tests/mcp -run X402go test ./tests/x402go test ./tests/ingestmake test-annotator(Python annotator suite on its own)
Gate rules
make checkandmake cinever rewrite the tree.fmt-checkreports unformatted files and fails;make fmtis the separate developer target that formats in place. Do not putfmtback in front of a gate.make test-annotatorinstalls intoannotator/.venv-test, a venv it owns. A PEP 668 interpreter (Homebrew, Debian) refuses apip installinto itself, so the suite must never install into the ambient python. Rebuild the venv withrm -rf annotator/.venv-testormake clean-all.
Integration tests
Integration tests are skipped by default. To run them:
RUN_INTEGRATION_TESTS=1 MISTRAL_API_KEY=... go test -v ./tests/mistral -run Integration
RUN_INTEGRATION_TESTS=1 MISTRAL_API_KEY=... MISTRAL_OCR_SAMPLE=/path/to/file.pdf go test -v ./tests/mistral -run MistralOCR
RUN_INTEGRATION_TESTS=1 MISTRAL_API_KEY=... MISTRAL_STT_SAMPLE=/path/to/file.mp3 go test -v ./tests/mistral -run Transcribe_Integration_MistralAPIMCP dev servers (Claude Code)
These are optional local development and testing servers for Claude Code integration. Register them when you want richer tooling (web browsing, sequential reasoning, GitHub access, up-to-date library docs) available to Claude Code during development sessions.
claude mcp add --transport stdio everything -- npx -y @modelcontextprotocol/server-everything
claude mcp add --transport stdio sequential-thinking -- npx -y @modelcontextprotocol/server-sequential-thinking
claude mcp add --transport stdio playwright -- npx -y @playwright/mcp
claude mcp add --transport stdio github -- npx -y @modelcontextprotocol/server-github
claude mcp add --transport stdio context7 -- npx -y @upstash/context7-mcpReleasing
Releases are automated via GoReleaser and triggered by pushing a version tag. The tag must point to a commit on main — tagging mid-PR or branch commits will release whatever that commit contains.
# 1. Merge all PRs first, then:
git checkout main && git pull
git tag v0.1.0
git push origin v0.1.0Pre-release smoke gate (run before tagging)
make ci/make check validate code, but they do NOT exercise the live
retrieval surface (ask/search/open_file) end-to-end — the surface that
broke repeatedly across v0.9.x (empty embeddings, broken docling, BM25 NULL,
open_file page reads). Before tagging, build the candidate binary, (re)index a
representative corpus with it, wait for indexing to finish (pending=0), then
run the gate against the running daemon:
make build
# point a daemon at a freshly-reindexed corpus on THIS binary, wait for pending=0, then:
make release-smoke STATE_DIR=/path/to/corpus/.dir2mcp # server contract (HTTP)
make release-smoke STATE_DIR=/path/to/corpus/.dir2mcp TRANSPORT=stdio # full mcp-remote bridge
# the default questions are for the stas-legal corpus; for another corpus pass its own:
make release-smoke STATE_DIR=... ARGS='--question "What is the leave policy?"'It speaks MCP to the daemon and asserts: indexing stopped + errors=0 +
embedded_ok>0; each question returns a grounded answer with citations;
search returns hits; open_file page=1 on an extracted PDF returns text. Any
failure exits non-zero: do not tag until it is all-pass. Three rules (#1101):
- Every
--questionmust be one the corpus can answer. An answer that abstains ("there is no information", "the context does not contain", a server refusal,evidence=insufficient) is a FAIL, even with citations. open_filetext that is raw PDF syntax (%PDF-,endobj,endstream,xref) is a FAIL, and so is a corpus whose PDFs were all skipped.- A corpus with no PDF reports the open_file check as
SKIPPED. A skip exits 0, but the summary readsPASS with 1 SKIPPED, notALL PASS. Tag only onALL PASS, from a corpus that holds a PDF. Run both transports:TRANSPORT=http(default) hits the daemon directly;TRANSPORT=stdiodrives the samebunx mcp-remotebridge Claude Desktop uses, so it also catches client/bridge-layer regressions (the "Failed to call tool" class). (Manual gate: needs a live daemon + the corpus's provider credentials, so it is not part ofmake ci.)
The release workflow will build binaries for darwin/linux × amd64/arm64 (tar.gz) and windows × amd64/arm64 (zip), publish a GitHub release with checksums, and push updated formulas to Dirstral/homebrew-tap automatically. The Homebrew formula and the nix derivation take only the darwin/linux archives; Windows ships as release zips only.
Requires HOMEBREW_TAP_GITHUB_TOKEN to be set as a repository secret (a PAT with repo scope on Dirstral/homebrew-tap).
Working conventions
- Keep changes scoped to the issue.
- Preserve existing tool/error contracts and structured fields.
- Do not log secrets or raw sensitive payloads.
- If behavior changes, update tests and docs in the same PR.
- Prefer deterministic behavior and explicit error handling.
PR checklist
coderabbit reviewrun and findings addressedmake checkpasses locally- New/changed behavior has test coverage
README.mdanddocs/remain truthful- No unrelated files changed
Known gotchas
dir2mcphas nohelpsubcommand; usage is printed whendir2mcpis invoked without arguments, or with-h/-help/--helpanywhere before a--terminator.--publicrequires auth unless--force-insecureis explicitly set.- The client name
claudemeans Claude Desktop. Claude Code isclaude-code, and Cursor iscursor(install,uninstall,doctor,print-config). - x402 mode semantics:
off: disabledon: fail-open on incomplete configrequired: strict config validation/gating
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

