Set Up Code Intelligence
Code Intelligence (MCI) builds a semantic map of your codebase — every function, class, and route, who calls them, and what breaks if you change them. Once indexed, Huginn, Heimdall, Thor, and your own agents can search code by meaning rather than text pattern.
Prerequisites
- Node.js 20 or later
- A Momental API key (Authentication guide)
- A git repository (TypeScript, JavaScript, Python, Go, or Swift)
Step 1 — Install the CLI
npm install -g @momentalos/cli Verify:
momental-indexer --version Step 2 — Run the initial index
cd /path/to/your-repo
momental-indexer \
--dir . \
--api-key mmt_YOUR_KEY \
--name my-repo This command:
- Registers
my-repoin your Momental workspace - Scans all source files and extracts symbols (functions, classes, types, routes)
- Builds the call graph (who calls what)
- Computes semantic embeddings for every symbol
- Uploads everything to Momental
You'll see progress as files are processed:
[indexer] Scanning 847 files...
[indexer] Extracted 12,340 symbols
[indexer] Building call graph...
[indexer] Uploading batch 1/13...
[indexer] Done. Repo ID: repo_abc123 Step 3 — Enable advanced features (optional)
Call graph (TypeScript/JavaScript)
momental-indexer --dir . --api-key mmt_YOUR_KEY --name my-repo \
--ts-calls Traces which functions call which others. Powers blast radius analysis — before changing a function, see every caller that could be affected.
Test mapping
momental-indexer --dir . --api-key mmt_YOUR_KEY --name my-repo \
--ts-calls --ts-tests Maps source files to their test files. When Heimdall or Thor modifies a file, they know exactly which tests to run.
Co-change intelligence
momental-indexer --dir . --api-key mmt_YOUR_KEY --name my-repo \
--ts-calls --ts-tests --git-cochange
Analyzes git history to surface files that tend to change together. If you edit auth.service.ts,
and it historically co-changes with session.middleware.ts, you'll be reminded to check both.
Step 4 — Run your first search
From Claude Code or any MCP client:
// Semantic search — finds by meaning, not just text
const results = await momental_code_search({
query: "user authentication and token refresh",
repoId: "repo_abc123"
});
// results[0] =>
// {
// name: "refreshAccessToken",
// filePath: "src/services/auth.service.ts",
// docstring: "Refreshes the user's JWT...",
// callers: [...],
// callees: [...]
// } // Exact symbol lookup — fast, no embeddings
const symbol = await momental_code_find({
name: "createUser",
repoId: "repo_abc123"
}); Step 5 — Keep the index current
Watch mode (development)
momental-indexer --dir . --api-key mmt_YOUR_KEY --name my-repo \
--watch 30 Re-indexes changed files every 30 seconds. Peer agents see your changes in near real-time.
Incremental (CI/CD)
Add to your CI pipeline after each commit:
# Re-index only changed files
momental-indexer --dir . --api-key mmt_YOUR_KEY --name my-repo \
--incremental-files $(git diff --name-only HEAD~1 HEAD) Full re-index (weekly)
Run the full command weekly or after large refactors to ensure the graph stays accurate.
Key MCI Tools
Once indexed, these tools are available via MCP:
| Tool | What it does |
|---|---|
momental_code_search | Semantic + keyword search over all symbols |
momental_code_find | Exact symbol lookup by name |
momental_code_symbol | Full details: callers, callees, cluster, linked tasks |
momental_code_file | All symbols in a file with call context |
momental_code_blast | Blast radius: what breaks if this symbol changes |
momental_code_tests | Which test files cover a given source file |
momental_code_diff_impact | Given changed files, what else is affected |
momental_code_claim | Declare which files you're editing (multi-agent coordination) |
Multi-Agent Coordination
When multiple agents are working in the same repo, use momental_code_claim before
editing files. It surfaces conflicts — if another agent has claimed a file, you're warned before
writing to it.
// Declare files before editing
await momental_code_claim({
repoId: "repo_abc123",
filePaths: ["src/services/auth.service.ts"],
taskId: "task_uuid"
});
// If a peer agent has claimed these files, you'll see:
// { conflicts: [{ agentName: "Thor", filePaths: [...] }] }