rag-drg
Fetches and indexes documentation, examples, and source code from GitHub repositories such as ARC, Psi4, and PySCF into the shared knowledge base.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
rag-drg: a shared knowledge base for the group's coding agents
Coding agents (Claude Code, local models) keep making the same mistakes with our tools:
ORCA %maxcore taken as total memory, PySCF spin taken as the multiplicity, invented Psi4
keywords, ARC input keys that don't exist, submit scripts that don't match the cluster.
Each person then corrects them again, and agents spend tokens re-reading the same manuals.
rag-drg fixes this with one shared, searchable knowledge base that every agent queries
before it writes ESS inputs, ARC code or HPC scripts. Corrections are written back into it,
so a mistake only has to be fixed once.
sources index agents
┌──────────────────────────────┐ rag-drg ingest ┌─────────────────┐ MCP ┌───────────────┐
│ knowledge/ curated cards │ ─────────────────▶ │ SQLite │ ◀────▶ │ Claude Code │
│ knowledge/lessons/ (agents) │ │ FTS5 (BM25) │ stdio/ │ local models │
│ ARC repo: docs, examples, │ │ + vectors │ HTTP │ (MCP clients) │
│ source, output.yml schema │ │ (optional) │ └───────────────┘
│ Psi4 docs + read_options.cc │ └─────────────────┘ CLI ┌───────────────┐
│ PySCF examples │ ▲ ◀────▶ │ scripts, other│
│ ORCA/Gaussian/Molpro manuals │ │ │ agents (JSON) │
│ cluster guides, papers │ record_lesson ◀───────────── └───────────────┘
└──────────────────────────────┘What's in it
Domain | Content | Where it comes from |
ESS | Essentials + gotchas for ORCA 5/6, Gaussian 09/16 (CPU/GPU), Q-Chem 6.1, Psi4, Molpro 2024/2026, PySCF; cross-code spin-convention and naming matrix |
|
ESS | Level-of-theory support table: which code supports each method/functional/dispersion/solvation model and how each one writes it |
|
ESS | Psi4 manual + every Psi4 keyword with default/allowed values (parsed from | Psi4 GitHub (auto-fetched) |
ESS | PySCF | PySCF GitHub (auto-fetched) |
ESS | ORCA / Gaussian / Q-Chem / Molpro manuals as PDFs or many HTML pages (saved, wget-mirrored or crawled), split by bookmarks/headings and labelled |
|
ARC | Input reference, examples, settings, source code, and the | ARC GitHub (auto-fetched) + |
HPC | Slurm/PBS essentials (submit, query, quota), submit templates for each ESS (programs called by absolute path, no |
|
Projects | Per-project protocol/convention cards, paper notes, paper PDFs |
|
Lessons | Corrections recorded by agents/people, reviewed via PR |
|
Related MCP server: engineering-knowledge-mcp
Quick start
Which setup?
Who | Setup | Why |
Group members (most people) | Shared server: register a URL + personal token, install nothing | Everyone sees new lessons at once; one index, one set of licensed manuals |
Maintainer, or offline use | Local tool install with | Isolated install with one fixed |
Developing rag-drg itself | Repo | Tests, lint, |
These are the usual patterns for MCP servers: remote servers for teams, and uv tool / pipx /
uvx installs for local Python servers.
Connect: shared server (group members)
# on the server, once (see deploy/rag-drg.service and deploy/refresh.sh)
rag-drg serve --transport http --host 0.0.0.0 --port 8765
rag-drg tokens add <member> # once per person; see docs/auth.md
# each member
claude mcp add --scope user --transport http rag-drg http://<server>:8765/mcp \
--header "Authorization: Bearer $RAG_DRG_TOKEN"
codex mcp add rag-drg --url http://<server>:8765/mcp --bearer-token-env-var RAG_DRG_TOKENFor the Codex config.toml form, see
integrations/codex/config.toml.example; check
codex mcp add --help for the HTTP flags your version has. Input checks and searches from the
terminal need only one standard-library file, integrations/rag-drg-remote
(see "Using the shared server without installing anything" below).
Install locally (maintainer / offline)
rag-drg is a normal Python package (Python >= 3.10). Extras: mcp (MCP server), pdf (PDF
manuals), chem (basis-set checks, SMILES via RDKit), st (local embeddings), dev (tests).
Recommended: uv tool. This works on a machine with conda, and doesn't care which env is active.
git clone <this repo> ~/code/rag_drg
uv tool install --python 3.12 --editable "$HOME/code/rag_drg[mcp,pdf,chem]"
uv tool dir --bin # where the `rag-drg` command is, usually ~/.local/bin--python 3.12makes uv use its own Python. Otherwise uv may base the tool on the active conda env's Python, and the tool breaks if that env is removed.--editablemeansgit pullupdates the code. rag-drg then finds the repo'srag_drg.yaml(and so itsindex/,sources/andknowledge/) from any directory. With a non-editable install, setRAG_DRG_CONFIG=/path/to/rag_drg/rag_drg.yaml.When a pull changes dependencies (
pyproject.toml), re-run the install command with--reinstall.pipx install --editable "$HOME/code/rag_drg[mcp,pdf,chem]"is the pipx equivalent.
For developing rag-drg (tests, lint): use an environment inside the repo.
python -m venv .venv && .venv/bin/pip install -e '.[mcp,pdf,chem,dev]' # or:
uv venv --python 3.12 && uv pip install --python .venv/bin/python -e '.[mcp,pdf,chem,dev]' # or:
conda create -n rag-drg python=3.12 && conda activate rag-drg && pip install -e '.[mcp,pdf,chem,dev]'Run conda deactivate before the uv venv line, or uv installs into the active conda env.
Everything in the repo calls bin/rag-drg: .mcp.json, the hooks, deploy/refresh.sh and
deploy/rag-drg.service. That launcher finds whichever install you have, trying in order:
$RAG_DRG_BIN;.venv/bin/rag-drg;the active conda env, unless it is conda's
base;a conda env named
rag-drg/rag_drg(or$RAG_DRG_CONDA_ENV), then an activebase(base is active in every shell, so a copy installed there must not shadow the named env);rag-drgon PATH, which includes auv toolinstall.
It also points RAG_DRG_CONFIG at the repo's rag_drg.yaml. In a service or cron job, set
RAG_DRG_BIN unless one of those already matches.
For the MCP server, don't use conda run -n rag-drg rag-drg serve: conda run captures the
program's output by default, and MCP talks over that output.
First steps
rag-drg ingest --fetch # clones ARC/Psi4/PySCF docs (~200 MB) and builds index/ (~15 MB), ~15 s
rag-drg search "ORCA TS optimisation hessian" --software orca
rag-drg search "GEOM_MAXITER"
rag-drg search "output.yml transition_states" --software arc
rag-drg search "CASSCF orbital optimisation" --software orca --doc-type theory
rag-drg level "wb97xd/def2tzvp" --software orca # is it supported, and how is it written?Add your group's cluster data (the private site repository)
This repository is public, so it holds no cluster details. Login hosts, queues and their access
lists, node names and install paths live in a second, private repository that is cloned into
site/ inside this one (site/ is git-ignored). Skip this and everything still works, just with
no clusters: list_servers() is empty and no submit scripts are rendered.
Your group already has a site repository (you need read access to it):
cd ~/code/rag_drg
git clone git@github.com:<your-org>/<your-site-repo>.git site
rag-drg servers validate # prints "servers.yaml: ok"
rag-drg servers list # your clusters, queues and installs
rag-drg ingest # indexes site/knowledge as the source `site`Starting one for a new group:
cd ~/code/rag_drg
mkdir -p site/knowledge/hpc/servers && cd site && git init -b main
cp ../servers.example.yaml servers.yaml # then replace the example clusters with yours
cd .. && rag-drg servers validate
rag-drg servers render-cards # writes site/knowledge/hpc/servers/generated/<cluster>.md
rag-drg ingest
git -C site add -A && git -C site commit -m "Cluster registry"
gh repo create <your-org>/<your-site-repo> --private --source site --pushKeeping it up to date:
git pullin this repository does not updatesite/. Rungit -C site pull --ff-only, thenrag-drg ingest. On a shared server the nightlydeploy/refresh.shpulls both; the account that runs it needs read access to the site repository (e.g. a read-only deploy key).On the shared server only the server needs the clone; members who connect over HTTP get the cluster data through the MCP tools.
Never copy hosts, IP addresses, node lists or queue access lists from
site/into this repository. What goes where, and how each part is read: docs/site.md.
Connect a local install
Register the absolute path of the command, because MCP clients start the server themselves and don't activate environments:
RAG="$(uv tool dir --bin)/rag-drg" # or /path/to/rag_drg/bin/rag-drg for a dev install
claude mcp add --scope user rag-drg -- "$RAG" serve
codex mcp add rag-drg -- "$RAG" serve # or ~/.codex/config.toml, see integrations/codex/
claude mcp list; codex mcp list # both should show rag-drg connectedInside this repo, .mcp.json already registers the server through bin/rag-drg.
Many agents on one machine. Every MCP client started as above runs its own rag-drg
process: about 100 MB with keyword search, but about 900 MB with local embeddings
(provider: sentence-transformers loads torch and the model into each one). With several agents
open, run one local server and point them all at it:
cp deploy/rag-drg-local.service ~/.config/systemd/user/ # fix the paths inside
systemctl --user daemon-reload && systemctl --user enable --now rag-drg-local
curl http://127.0.0.1:8765/api/health
claude mcp remove rag-drg # the entry that starts its own process
claude mcp add --scope user --transport http rag-drg http://127.0.0.1:8765/mcp
codex mcp remove rag-drg
codex mcp add rag-drg --url http://127.0.0.1:8765/mcp # or url = "..." in ~/.codex/config.toml(Without systemd: bin/rag-drg serve --transport http --host 127.0.0.1 --port 8765 --auth none
in a tmux session.) It listens on loopback only, so it needs no tokens. One process also means
one writer for record_lesson. The server must be running before you start agents; restart it
after pulling code changes (systemctl --user restart rag-drg-local). The HTTP transport is
stateless (no MCP session IDs), so agents that are already open keep working across a restart
(--stateful turns sessions back on). For semantic search with
many agents, an embedding server (provider: openai with Ollama or vLLM) keeps the model in one
place as well.
GET /mcp 400 and /.well-known/oauth-* 404 lines in the server log are clients probing (for an
event stream, for a login) and are harmless when claude mcp list / codex mcp list show rag-drg
connected. If a client never connects, check it is registered as HTTP (Claude Code:
--transport http, not sse) and that your Codex version supports URL servers (codex mcp add --help lists --url). Codex reads $CODEX_HOME/config.toml (default ~/.codex): edit the one
codex mcp list actually uses.
Then give agents the habit:
copy
integrations/claude-code/skills/group-knowledge/to~/.claude/skills/, and/orappend
integrations/claude-code/CLAUDE.md.snippetto~/.claude/CLAUDE.mdor to your project'sCLAUDE.md.
Codex reads AGENTS.md, not CLAUDE.md, and has no skills or hooks for this, so the snippet is
the only thing that tells it to use rag-drg. Without it, Codex answers from memory or greps
whatever files it can find (a local ARC settings file, the rag_drg checkout).
echo "${CODEX_HOME:-$HOME/.codex}" # Codex's home; the global AGENTS.md goes here
cat integrations/claude-code/CLAUDE.md.snippet >> "${CODEX_HOME:-$HOME/.codex}/AGENTS.md"Or append it to a project's AGENTS.md to scope it to that project. Then, in a new Codex session:
/mcpshould list rag-drg with its tools. If there are none, the server wasn't reachable when Codex started (with the shared local server: start it first).Ask "What's the Q-Chem path on zeus?". The answer should come from a
server_infoorsearch_knowledgecall, not fromrgover files: the install path, the environment script to source and the Unix group the licence is limited to, as in yourservers.yaml.
If you already have a Codex skill or AGENTS.md rule about a cluster, add a line to it that points
to server_info(<cluster>), so the two don't send the agent in different directions.
The Claude Code PostToolUse hook (below) does not carry over to Codex, so in Codex, input
checks rely on that instruction (check_input via MCP, or rag-drg check-input <file>).
Recording lessons. When you correct an agent, turn the correction into a lesson so the next agent doesn't repeat it:
Claude Code:
cp integrations/claude-code/commands/lesson.md ~/.claude/commands/, then type/lesson(optionally/lesson the Q-Chem path was wrong). The agent drafts the lesson from the conversation, shows it to you, and records it withrecord_lessonafter your OK.Codex:
cp integrations/codex/prompts/lesson.md ~/.codex/prompts/. Invoke it as a custom prompt; recent Codex versions list custom prompts under/, so check/in your version.Terminal:
rag-drg lessonasks for the title, mistake, correction, domain and so on. Scripts pass them as flags instead.
Lessons start as unreviewed; rag-drg lessons report lists them for review (docs/lessons.md).
Local models: see integrations/local-models.md (MCP, or the
rag-drg search --json CLI as a tool).
MCP tools
Tool | Purpose |
| Hybrid search; results show scope, doc type, review status, |
| Surrounding chunks from the same file |
| A whole card or template (e.g. |
| Browse what exists (e.g. all HPC templates) |
| Support/keyword table for a method across Gaussian, ORCA, Q-Chem, Psi4, Molpro, PySCF |
| Index statistics: sources, software, versions |
| Write + index a correction; flags near-duplicates and can open a GitHub PR (disabled with |
| Check an ESS input (+ submit script) for known mistakes: spin/electron parity, memory/cores vs allocation, section structure, missing aux basis, functional/basis support, cluster limits |
| Is this basis defined for these elements (Basis Set Exchange)? ECPs, auxiliary sets, spelling |
| What went wrong in a failed ESS job, and the ordered fixes |
| The group's clusters from |
| A ready-to-run Slurm/PBS script with the registered absolute paths, checked against partition limits |
| Does a request fit the partition? |
| Read-only live queries (jobs, quota, partitions); off unless enabled |
Tool profiles. rag-drg serve --profile minimal exposes only search_knowledge,
find_tool and run_tool (about 650 tokens instead of 4,800) for clients that load every tool
schema up front, e.g. local models; see integrations/local-models.md.
Command line
Command | Purpose | Docs |
| Search from a terminal or a script | |
| Compose a checked ESS input + submit script from an explicit spec or your project's protocol file | |
| ARC: validate input.yml against a schema generated from ARC | |
| Input checker; | |
| Add that hook to Claude Code's | |
| Basis coverage check | |
| Diagnose a failed job | |
| Level-of-theory support table | |
| Cluster registry | |
| Retrieval test set, query log reports | |
| Real group tasks run by an agent with and without rag-drg, graded pass/fail | |
| Lesson review workflow | |
| Zotero library sync | |
| Per-person tokens for the HTTP server | |
| Tool definitions for local-model frameworks | |
| Content management |
Using the shared server without installing anything
Group members only need one file: integrations/rag-drg-remote
(standard-library Python) plus their token. It checks inputs, diagnoses outputs and searches via
the server, and works as the Claude Code hook. What runs where (shared server vs. your machine
vs. a per-user install for live cluster queries) is explained in
docs/remote-client.md.
Automatic input checks in Claude Code
Local install: bin/rag-drg install-hook adds the hook to ~/.claude/settings.json (--project
for one project). It writes the absolute launcher path, tests the command before saving, and
replaces an earlier (or broken) rag-drg hook. Writing it by hand is error-prone, see
docs/input-checker.md. Thin client, no install: add the hook from
integrations/claude-code/hooks.remote.json. Every time an agent
writes an input file or submit script, it is checked; errors are fed back to the agent, which
then fixes them before anything is submitted.
Growing the knowledge base (the part that matters)
The tool is only as good as what's in it. In order of value:
Describe your clusters in
servers.yaml(copyservers.example.yaml; keep the real file in the privatesite/repository, docs/site.md; see docs/servers.md): partitions and limits, absolute install paths of each ESS, scratch, storage and quota commands.rag-drg servers render-cardsthen generates the cluster cards,rag-drg servers arc-settingsthe ARCserversblock, and submit scripts and input checks use the real limits and paths.Review the draft cards in
knowledge/ess/,knowledge/arc/,knowledge/hpc/. They were written from general knowledge and markedstatus: draft; check each against the manual/your experience, fix, and setstatus: verified.Add the licensed manuals, one PDF per manual and version, no manual splitting needed (see
sources/README.md): ORCA insources/orca/{5,6}/, Gaussian insources/gaussian/{09,16}/, Q-Chem insources/qchem/6.1/, Molpro insources/molpro/{2024,2026}/. HTML manuals (ORCA 6, Gaussian keyword pages) can be saved, wget-mirrored or crawled; books go in e.g.sources/gaussian/book/with a_meta.yaml; runrag-drg check-pdfto see whether a PDF needs OCR first. Exported cluster docs insources/hpc/<cluster>/. These are git-ignored, so they go on the shared server or each person's copy.rag-drg fetch --manualsfetches every manual the vendors publish openly (ORCA 5 and 6, Q-Chem 6.1, Gaussian 09 and 16, the current Molpro manual as one PDF, which needs Chrome/Chromium); seesources/README.md. Also fill theunknowncells inknowledge/ess/levels_of_theory.yamlas you check them.Only group-wide knowledge belongs here. Project-specific protocols and notes stay in each project's own repository (the compose tools accept a protocol file by path);
knowledge/projects/_TEMPLATE.mdis there for anything a project wants to share group-wide.Review lessons that agents record: they arrive as
status: unreviewedfiles inknowledge/lessons/; merge them via PR (verify, or fold into a card).
rag-drg lint validates front matter (run in CI). See knowledge/README.md for the card format.
How retrieval works
Chunking follows document structure: Markdown/RST headings, Python functions/classes (ARC source), JSON-schema properties (ARC
output.yml), Psi4 option subsections, PDF bookmarks (with page ranges; theory vs. keyword sections labelled), HTML headings, and one chunk per method in the level-of-theory table. Every chunk carries a heading breadcrumb title and metadata (domain,software,version,doc_type,status,url).Hybrid ranking: SQLite FTS5 BM25 over the whole query, an exact-phrase pass for identifiers (
GEOM_MAXITER,opt=(ts,calcfc),def2-TZVP), and, if configured, dense-vector similarity, fused with reciprocal-rank fusion.Curated knowledge first: lessons/gotchas/cards get a ranking boost,
verified>draft>unreviewed, and at most 2 chunks per file are returned so one manual can't flood the results. When several manuals still fill every slot (ORCA 5 and 6 are separate files), the best curated card or lesson takes the last one. A chunk whose title names an identifier from the query (wB97M-V,GEOM_MAXITER) ranks above chunks that only mention it.Version-aware filters:
version="6"matches chunks tagged 6, 6.0, or5|6, plus every chunk without a version.Incremental: re-ingest only touches changed chunks; embeddings are only computed for new ones.
Embeddings are optional. Keyword search already handles most agent queries (they are mostly
exact keywords); enable sentence-transformers or an OpenAI-compatible endpoint (Ollama,
vLLM) in rag_drg.yaml for paraphrased questions.
Repository layout
rag_drg/ python package (chunking, store, search, ingest, lessons, MCP server, CLI)
rag_drg.yaml source configuration
knowledge/ curated cards, templates, lessons (committed, reviewed via PR)
papers/ sources/ local PDFs/HTML (git-ignored)
site/ your group's private site repository: servers.yaml, cluster cards (git-ignored)
integrations/ Claude Code skill + CLAUDE.md snippet, local-model notes
deploy/ systemd unit and nightly refresh script for a shared server
tests/ pytest suiteLicence
MIT, see LICENSE. Vendor manuals fetched into sources/ keep their own licences and are not part of this repository.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
A shared team wiki your coding agents read and write — across every repo and every MCP client.
A second brain for your AI agent. Shared memory for your team's AI agents, plus public and private knowledge bases — works with ChatGPT, Claude, Cursor and any MCP client.
Shared, peer-validated knowledge archive for AI agents — search, contribute, and validate via MCP
Shared memory for coding agents. Stop re-explaining your codebase every session.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceA machine-local, agent-writable knowledge base MCP server that lets coding agents autonomously record and retrieve hard-won operational facts, incidents, and corrections as markdown pages in a git repo, with provenance, talk pages, and search.7 npmMIT
- FlicenseAqualityDmaintenanceProvides coding agents with a shared, Markdown-based engineering knowledge base to search, capture, create, and update internal conventions, API details, infrastructure configs, and development setup via lightweight MCP tools.6-
- AlicenseNot gradedqualityBmaintenanceGives coding agents a persistent memory by searching a local, read-only index of existing markdown and letting them write findings back as notes that the next session can retrieve. It serves ranked, context-sized results over MCP, injects standing conventions at session start, and keeps data on your machine with secret redaction and archive-only deletion.MIT
- AlicenseNot gradedqualityCmaintenanceConnects any number of AI agents — Claude Code, Codex, or any MCP client — to one git-backed Markdown vault of shared team memory, exposing tools for briefings, search, reading, recent changes, sharing facts, transcripts, and urgent-item acknowledgments. Agent writes are queued and reviewed by a librarian model, then privacy-checked, linted, and committed as attributed git changes, so every agent reads the same current truth.MIT