codebase-map

An architecture reference for the datatorag-mcp monorepo, a single repository containing multiple related applications and packages. It maps the folders, request flow, authentication, data systems, and important design rules.

In plain words
What is it for?
Orienting work in the monorepo, locating gateway, database, configuration, and authentication code, and preserving project invariants.
Why use it?
It helps an agent find the right code and understand existing decisions before exploring or changing the repository.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/datatorag/mcp-gateway/codebase-map
Any agent
npx skills add datatorag/mcp-gateway --skill codebase-map
Clone the repo
git clone --depth 1 https://github.com/datatorag/mcp-gateway

Made for: Claude Code, Codex.

Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 11,304 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00061 $0.11304
Opus 5 $0.00030 $0.05652
Sonnet 5 $0.00012 $0.02261
Haiku 4.5 $0.00006 $0.01130

Measured yesterday against content hash add2188beef0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

codebase-map scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

| `execFileSync` (never `execSync`) for git clone / installs | Prevents shell injection via malicious `githubRepoUrl` | commit `70cc29a` |
.claude/skills/codebase-map/SKILL.md · 223 lines

How it starts

The opening of the file, as written. The whole thing — 223 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Codebase Map

Architecture reference for the datatorag-mcp monorepo. Read this instead of re-exploring source. This repo is public — no live infrastructure values here; operational details (hosts, profiles, DB project ids) live in private memory (reference_* entries) and the deploy / db-query skills.

Monorepo layout

pnpm workspace (pnpm-workspace.yaml: apps/* + packages/*), turbo topological builds (turbo.json: build depends on ^build). All packages are private ESM built with tsup.

Package Role Internal deps
apps/gateway The whole product: Express + Next.js server — MCP gateway, OAuth server, marketing site, dashboard, cron jobs auth, config, db, types
packages/db Drizzle schema (15 tables, one file per table under src/schema/) + createDb() (prepare: false for Neon's pooled endpoint); dual exports . and ./schema none
packages/config Single zod env schema; getEnv() memoized, process.exit(1) on invalid. DATABASE_URL is the only var without a default none
packages/auth hashApiKey, safeStringEqual (constant-time SHA-256 compare), ApiKeyValidator (LRU-cached). Consumed only by the OAuth routes db
packages/types zod status enums + McpGatewayManifest (the datatorag.json plugin manifest shape) none

(packages/docker-manager used to exist as dead code from the abandoned container-per-plugin design — it was deleted; see decisions.)

Gateway request flow

MCP client
  │ POST /mcp  (Authorization: Bearer <OAuth access token>)
  ▼
apps/gateway/server.ts          validateBearer → oauthAccessTokens (not revoked/expired)
  │                             sessions: in-memory Map keyed by mcp-session-id
  │                             (wiped on every deploy — an unknown session id gets a
  │                             spec-compliant 404 via classifyMcpRequest (mcp-session.ts),
  │                             and clients silently re-initialize on the same bearer; SCRUM-23)
  ▼ new session → createMcpServer(userId, db, pool)
apps/gateway/src/gateway/mcp-server.ts
  │ ListTools: enabled tools ⋈ active mcpServers, filtered to the user's
  │           connected services ("lazy tool loading"); injects `account` param
  │ CallTool:  split tool name on "__" → serverSlug / toolName
  ▼
  ├─ service-mapped plugin → getServiceToken() → ONE-SHOT client,
  │                          token in X-User-Token header (never pooled)
  └─ generic plugin        → ConnectionPool (per-server, max 5, 5min idle,
                             5s acquire timeout, wait-queue)
  ▼ Streamable HTTP → http://<host>:<containerPort>/mcp
plugin child process            spawn("node", entrypoint), ports 40000+
                                managed by src/gateway/plugin-manager.ts

Read the full file on GitHub · 223 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 223 lines · 61 tokens per session scan A add2188beef0

Subscribe to this mod's changes

codebase-map is a skill published in the GitHub repository datatorag/mcp-gateway (3 stars, last pushed yesterday), licensed MIT. It adds 61 tokens to every session and 11,304 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens