This system programmatically collects all Salesforce documentation from developer.salesforce.com (129 domains, 35,000+ pages), processes it into structured, curated knowledge files, and serves them to LLM agents via:
Context Engineering — Pre-compiled Markdown files with routing tables
Salesforce documentation knowledge system — MCP server + Knowledge Graph for AI agents
_index.md
MCP Server — 12 tools + 4 prompts + 5 resources via Model Context Protocol
Knowledge Graph — 53,000+ nodes and 450,000+ edges connecting SF concepts, namespaces, services, and cross-references
No embeddings. No vector stores. No blind chunking.
Quick Start
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
The server uses stdio transport and is compatible with any MCP client.
Why -p + sf-docs-mcp?
The package ships two binaries: sf-knowledge (the data pipeline CLI) and sf-docs-mcp (the MCP server). Using -p installs the package and then explicitly calls the sf-docs-mcp binary, ensuring you get the MCP server and not the CLI.
Use from Source
git clone https://github.com/Avinava/sf-documentation-knowledge.git
cd sf-documentation-knowledge
npm install
npm run build
npm run mcp:start
MCP Server
The MCP server loads the full 53k-node knowledge graph and 18,000+ code snippets into memory on startup (~5s) and serves all queries instantly.
Compare Salesforce products by documentation coverage
services: categories (e.g., "analytics vs commerce")
write_apex
Write production-ready Apex — gathers limits, patterns, examples first
task: what to build (e.g., "batch job to update Accounts")
Resources (5)
Agents can read these without making a tool call:
Resource URI
Content
sf://overview
System stats, available tools, quick start guide
sf://domains
All documentation domains with descriptions
sf://namespaces
All Apex namespaces with doc counts
sf://services
All service categories with domain counts
sf://config
Current domain restriction state and runtime controls
Domain Restriction
When working on a specific Salesforce product area (e.g., Revenue Cloud, Apex development), you can restrict all tools to only search within relevant domains. This reduces noise and improves result quality.
How It Works
At startup: Set SF_ACTIVE_DOMAINS as a comma-separated list of domain IDs in your MCP client config
At runtime: Use sf_set_active_domains to change the active domains without restarting
Not set: All 129 domains are searched (default, no breaking change)
Per-call domain filter outside active set: Returns empty results with a warning (not an error)
sf_read_topic outside active set: Shows a gentle note but still allows reading
Discovering Domains
# Let the AI suggest domains for your task
sf_suggest_domains("building LWC components with Apex backend")
→ Suggests: lwc, apex-guide, apex-reference, lightning
# Set the suggested domains
sf_set_active_domains(domains: ["lwc", "apex-guide", "apex-reference", "lightning"])
# Check current state
sf_set_active_domains()
# Clear restrictions
sf_set_active_domains(clear: true)
Behavior by Tool
Tool
Domain Restriction Behavior
sf_search
Filters via Orama where clause + keyword fallback filtering
sf_semantic_search
Filters via Orama where clause on expanded + original queries
Warns if apex-reference/apex-guide not in active set
sf_object_reference
Warns if sfFieldRef/object-reference not in active set
sf_list_domains
Shows all domains, marks active ones with checkmark
sf_read_topic
Gentle warning (still allows reads outside active set)
sf_limits
No filtering (hardcoded data, no graph search)
All 129 Domain IDs
See docs/domains.md for the full list organized by service category, or use sf_list_domains at runtime.
Knowledge Base
The repository comes pre-loaded with 35,000+ curated markdown files and a Knowledge Graph (53,000+ nodes, 450,000+ edges) covering 129 domains of Salesforce documentation.
Option A: Context Engineering (File-based)
Point your AI agent to the _index.md file in any domain folder. The index acts as a routing table telling the AI which files contain which topics:
knowledge/current/<domain-name>/_index.md
Each domain folder also has a SKILL.md in skills/<domain-name>/SKILL.md that teaches AI agents how to navigate the knowledge.
Option B: Knowledge Graph
The graph at knowledge/current/graph.json connects all documentation with semantic relationships:
See Graph Schema Documentation for the full schema with node/edge types, ID conventions, and a visual diagram.
Data Pipeline
To update the knowledge base with the latest Salesforce releases, run the pipeline in order:
Step 1: Discover Available Deliverables
npm run discover
Lists all documentation deliverables available from the Salesforce Index API (~127 deliverables).
Step 2: Collect Raw Data
# Collect a specific domain
npm run collect -- --domain cli-commands
# Collect all configured (P0) domains
npm run collect
# Collect ALL deliverables from the SF index API (121 domains, ~31k pages)
npm run collect -- --discover
Step 3: Process HTML to Markdown
# Process a specific domain
npm run process -- --domain cli-commands
# Process ALL collected domains
npm run process -- --discover
Automatically cleans HTML, strips noise, parses tables, formats code blocks, creates clean Markdown, and redacts any Salesforce tokens or secrets.
Step 4: Generate Knowledge Files & Graph
# Generate ALL collected domains and rebuild the full Knowledge Graph
npm run generate -- --discover
Builds the knowledge graph (cross-references, namespaces, service categories, doctype clustering), generates context files, and updates inventory docs.
Step 5: Inspect the Graph
npm run graph:stats
Full Pipeline (One-liner)
npm run collect -- --discover && npm run process -- --discover && npm run generate -- --discover
CLI Reference
Command
Description
npm run discover
List available SF documentation deliverables
npm run collect
Download raw HTML documentation
npm run process
Convert HTML → Markdown with tagging
npm run generate
Generate knowledge files + graph
npm run graph:stats
Analyze the knowledge graph
npm run mcp:start
Start the MCP server (stdio)
npm run build
Compile TypeScript
npm run test
Run test suite
npm run lint
Run ESLint
All pipeline commands support --domain <name> for single-domain processing and --discover for all-domain processing.