agentleFS
dirstraldirstral/dir2mcp/CLAUDE.md

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.

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
  1. Very specific:

    Every --question must be one the corpus can answer.

    line 102
  2. Distinctive:

    Keep changes scoped to the issue.

    line 122
  3. Distinctive:

    Do not log secrets or raw sensitive payloads.

    line 124
  4. Distinctive:

    If behavior changes, update tests and docs in the same PR.

    line 125
  5. Distinctive:

    Prefer deterministic behavior and explicit error handling.

    line 126

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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 entrypoint
  • internal/cli: CLI command orchestration (up, status, ask, reindex, config, version)
  • internal/config: config load/merge/validation
  • internal/ingest: file discovery, OCR/transcription/annotation representation generation
  • internal/pdfutil: pure-Go PDF helpers (page count, per-page extraction) for multimodal media chunks
  • internal/avutil: audio/video helpers (ffprobe duration, ffmpeg time-window extraction) for multimodal media chunks
  • internal/retrieval: search/ask/open_file logic
  • internal/secretmatch: the secret pattern and allow pattern matcher that every secret screen uses (SPEC §7.2)
  • internal/mcp: JSON-RPC/MCP server and tools
  • internal/mistral: Mistral client adapters
  • internal/x402: x402 types + facilitator client
  • internal/store: sqlite-backed metadata persistence
  • tests/*: integration-style suites by subsystem
  • docs/: 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 the dirstral-spec git 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 X402
    • go test ./tests/x402
    • go test ./tests/ingest
    • make test-annotator (Python annotator suite on its own)

Gate rules

  • make check and make ci never rewrite the tree. fmt-check reports unformatted files and fails; make fmt is the separate developer target that formats in place. Do not put fmt back in front of a gate.
  • make test-annotator installs into annotator/.venv-test, a venv it owns. A PEP 668 interpreter (Homebrew, Debian) refuses a pip install into itself, so the suite must never install into the ambient python. Rebuild the venv with rm -rf annotator/.venv-test or make 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_MistralAPI

MCP 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-mcp

Releasing

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.0

Pre-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 --question must 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_file text 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 reads PASS with 1 SKIPPED, not ALL PASS. Tag only on ALL PASS, from a corpus that holds a PDF. Run both transports: TRANSPORT=http (default) hits the daemon directly; TRANSPORT=stdio drives the same bunx mcp-remote bridge 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 of make 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 review run and findings addressed
  • make check passes locally
  • New/changed behavior has test coverage
  • README.md and docs/ remain truthful
  • No unrelated files changed

Known gotchas

  • dir2mcp has no help subcommand; usage is printed when dir2mcp is invoked without arguments, or with -h/-help/--help anywhere before a -- terminator.
  • --public requires auth unless --force-insecure is explicitly set.
  • The client name claude means Claude Desktop. Claude Code is claude-code, and Cursor is cursor (install, uninstall, doctor, print-config).
  • x402 mode semantics:
    • off: disabled
    • on: fail-open on incomplete config
    • required: strict config validation/gating

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.