A local-first MCP server that gives AI coding agents deep understanding of Salesforce codebases. Index your SFDX, Copado, or MDAPI project once — then search Apex classes, LWC components, Flows, triggers, and more using natural language.
Zero external dependencies. No Docker, no cloud database, no API keys. Everything runs locally in SQLite.
claude mcp add sfcontext -- npx @sfcontext/mcp-servergit clone https://github.com/kranthinb/salesforce-code-context.git
cd salesforce-code-context
npm install && npm run build
claude mcp add sfcontext -- node /path/to/salesforce-code-context/packages/mcp-server/dist/index.jsOpen your Salesforce project in Claude Code and ask:
"Index my codebase at /path/to/my-sfdx-project"
"Search for account trigger handler"
"Find the LWC component that calls AccountService"
"What depends on the Account object?"
| Tool | Description |
|---|---|
index_codebase |
Index a Salesforce project. Auto-detects SFDX/Copado/MDAPI. Incremental — only re-processes changed files. |
search_code |
Search indexed code with natural language. Returns source code snippets with file paths and line numbers. |
clear_index |
Remove the index for a project. |
get_indexing_status |
Check if a project is indexed and whether the index is up-to-date. |
| Metadata Type | What's Extracted |
|---|---|
| Apex Classes | Methods, properties, annotations, sharing model, inheritance, interfaces, SOQL references |
| Apex Triggers | SObject, DML events, class references |
| LWC | @api properties, @wire adapters, Apex imports, child components (from JS + HTML) |
| Aura | Attributes, events, controller references, child components |
| Flows | Process type, trigger object, elements, Apex actions, subflows, variables |
| Custom Objects/Fields | Field types, lookups, validation rules, record types |
| Permission Sets/Profiles | Object permissions, field permissions, class access, tab settings |
salesforce-code-context/
├── packages/
│ ├── core/ # Core engine (no server dependencies)
│ │ ├── src/
│ │ │ ├── detector/ # SFDX / Copado / MDAPI project detection
│ │ │ ├── parsers/ # 6 Salesforce metadata parsers
│ │ │ ├── indexer/ # Chunking pipeline
│ │ │ ├── embeddings/ # Embedding providers (OpenAI, NoOp)
│ │ │ ├── storage/ # SQLite FTS5 (local) + ChromaDB (optional)
│ │ │ ├── graph/ # SQLite dependency graph + traversal
│ │ │ └── sync/ # Merkle tree file sync + snapshots
│ │ └── package.json
│ └── mcp-server/ # MCP server (stdio transport)
│ ├── src/
│ │ ├── index.ts # Server entry point
│ │ ├── config.ts # Auto-configured from env vars
│ │ └── handlers.ts # Tool implementations
│ └── package.json
├── turbo.json
└── package.json
- Detect — Scans for
sfdx-project.json,.copado, orpackage.xmlto identify the project type and source directories - Parse — Reads each Salesforce source file and extracts structured metadata (classes, methods, fields, references, dependencies)
- Chunk — Splits parsed metadata into searchable units with actual source code attached (class-level, method-level, field-level)
- Index — Stores chunks in SQLite with FTS5 full-text indexing for fast keyword search
- Sync — Tracks file changes via SHA-256 Merkle hashing so re-indexing only processes changed files
- Search — Matches natural language queries against indexed chunks and returns ranked source code results
The core engine also builds a full dependency graph in SQLite:
- Impact analysis — "What depends on AccountService?" → returns triggers, LWC components, Flows, permission sets that reference it
- Dependency chain — "What does myComponent depend on?" → returns Apex classes, objects, child components
- Cross-cutting queries — "Show all trigger-to-object relationships"
The MCP server works with zero configuration. For advanced setups:
| Env Variable | Default | Description |
|---|---|---|
SFCONTEXT_DB_PATH |
~/.sfcontext/search.db |
Custom SQLite database path |
CHROMA_URL |
— | Enable ChromaDB backend (e.g., http://localhost:8000) |
OPENAI_API_KEY |
— | Enable OpenAI embeddings for semantic vector search |
EMBEDDING_MODEL |
text-embedding-3-small |
OpenAI embedding model |
COLLECTION_NAME |
sf-context |
ChromaDB collection name |
Local mode (default): SQLite FTS5 full-text search. No API keys needed.
Cloud mode (opt-in): Set CHROMA_URL + OPENAI_API_KEY to enable vector-based semantic search via ChromaDB + OpenAI embeddings.
You can use the core engine directly in your own tools:
import {
detectProject,
parseFile,
IndexingPipeline,
NoOpEmbedder,
SqliteStore,
GraphStore,
GraphBuilder,
} from '@sfcontext/core';
// Detect project type
const detection = await detectProject('/path/to/sfdx-project');
console.log(detection.project?.type); // 'sfdx' | 'sfdx2' | 'copado' | 'mdapi'
// Index and search
const store = new SqliteStore();
const pipeline = new IndexingPipeline(new NoOpEmbedder(), store);
await pipeline.index({ rootPath: '/path/to/project', skipEmbeddings: true });
const results = await store.searchText('account trigger handler', 5);
// Build dependency graph
const graph = new GraphStore();
const builder = new GraphBuilder(graph);
// ... parse files and add to builder
const impact = graph.impactAnalysis('ApexClass:AccountService');npm install
npm run build # Build all packages
npm run dev # Watch mode
npm run lint # LintAll data is stored locally:
- Search index:
~/.sfcontext/search.db(SQLite) - File snapshots:
~/.sfcontext/snapshots/(JSON, for incremental indexing)
No data is sent to any external service in the default local mode.
MIT