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 code_search({
  action: "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 code_search({
  action: "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
code_searchSemantic + keyword search over all symbols
code_search({ action: "find" })Exact symbol lookup by name
code_inspect({ action: "symbol" })Full details: callers, callees, cluster, linked tasks
code_search({ action: "file" })All symbols in a file with call context
code_inspect({ action: "blast" })Blast radius: what breaks if this symbol changes
code_inspect({ action: "tests" })Which test files cover a given source file
code_inspect({ action: "diff_impact" })Given changed files, what else is affected
code_manage({ action: "claim" })Declare which files you're editing (multi-agent coordination)

Multi-Agent Coordination

When multiple agents are working in the same repo, use code_manage({ action: "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 code_manage({
  action: "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: [...] }] }

Quick Reference

Install & index

npm install -g @momentalos/cli

momental-indexer \
  --dir . \
  --api-key mmt_YOUR_KEY \
  --name my-repo \
  --ts-calls \
  --ts-tests \
  --git-cochange

Keep current

# Watch mode
momental-indexer ... --watch 30

# CI incremental
momental-indexer ... \
  --incremental-files \
  $(git diff --name-only HEAD~1)

Supported languages

TypeScript  ✓ calls + tests
JavaScript  ✓
Python      ✓
Go          ✓
Swift       ✓

Key search tools

code_search            semantic
code_search (find)     exact
code_inspect (blast)   impact
code_manage (claim)    coordinate