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.

Expected time: 10 minutes for setup. First index takes 1–5 minutes depending on repo size. All subsequent updates are incremental and finish in seconds.

Prerequisites

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:

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:

ToolWhat it does
momental_code_searchSemantic + keyword search over all symbols
momental_code_findExact symbol lookup by name
momental_code_symbolFull details: callers, callees, cluster, linked tasks
momental_code_fileAll symbols in a file with call context
momental_code_blastBlast radius: what breaks if this symbol changes
momental_code_testsWhich test files cover a given source file
momental_code_diff_impactGiven changed files, what else is affected
momental_code_claimDeclare 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: [...] }] }