knocoph
Transforms TypeScript and JavaScript codebases into a persistent code knowledge graph in SQLite, enabling structural codebase navigation via deterministic graph queries without reading source files.
README
Knocoph
Knocoph (nok-of) is a local MCP server that transforms TypeScript and JavaScript codebases into a persistent code knowledge graph stored in SQLite.
Instead of AI assistants greedily reading entire files and burning context tokens, Knocoph enables structural codebase navigation through deterministic graph queries. Navigate call chains, import graphs, inheritance hierarchies, and symbol dependencies with near-instant responses and minimal token consumption.
Installation
Install globally so the knocoph command is available in PATH:
npm install -g knocoph
Configuring the MCP server
Add Knocoph to your MCP client configuration (e.g. .mcp.json, claude_desktop_config.json):
{
"servers": {
"knocoph": {
"type": "stdio",
"command": "knocoph",
"env": {
"knocoph_DB": "./.knocoph/graph.db",
"knocoph_ROOT": "."
}
}
}
}
Both env variables are optional — Knocoph uses sensible defaults if they are omitted:
| Variable | Default | Description |
|---|---|---|
knocoph_DB |
./.knocoph/graph.db |
Path to the SQLite database file. Relative paths resolve from the working directory (the project root). |
knocoph_ROOT |
. |
Root directory to auto-index on first run (before any index_project call). Relative paths resolve from the working directory. |
Minimal configuration with defaults (no env block required):
{
"servers": {
"knocoph": {
"type": "stdio",
"command": "knocoph"
}
}
}
Instructing AI assistants to use Knocoph
To guide your AI assistant (Claude, Copilot, etc.) to use Knocoph MCP tools effectively instead of reading files directly, copy the instructions from MCP_USAGE.md into your AI assistant's system prompt, AGENTS.md, CLAUDE.md or equivalent configuration file.
These instructions teach AI to:
- Use
find_symbolbefore opening files - Use graph queries to understand relationships instead of burning context tokens
- Call
explain_impactbefore making changes - Use
get_snippetto fetch exact code ranges rather than entire files
This approach minimizes token consumption and provides fast, accurate structural answers.
Features
- Persistent code graph — parses codebases into nodes (symbols) and edges (relationships), stored in SQLite
- Automatic indexing — file watcher keeps the graph updated as code changes
- Zero file reading — query structural questions without opening source files
- MCP tools — 7 specialized query tools for different exploration patterns
- Cross-file relationships — tracks imports, exports, calls, inheritance, and containment
- TypeScript path alias resolution — automatically reads
tsconfig.jsonto resolve@scope/...style imports
How It Works
- Parse — TypeScript ESLint parser extracts symbols, types, and relationships from source files
- Graph — Builds nodes for functions, classes, interfaces, variables, etc.
- Store — Persists all metadata and edges in SQLite
- Query — Serve structural answers via MCP tools without re-parsing
MCP Tools
| Tool | Purpose |
|---|---|
codebase_overview |
Get structural summary of entire codebase (files, symbols, kind distribution) |
find_symbol |
Locate any symbol by name; optionally include source code snippet |
get_neighbors |
Explore incoming/outgoing relationships by symbol name or ID |
get_snippet |
Fetch exact source code snippet for a symbol or line range |
explain_impact |
Blast radius and dependency analysis; understand why a symbol exists |
query_architecture |
File-level view — what symbols does a file define and import/export? |
index_project |
Trigger or refresh graph indexing; auto-detects tsconfig.json for path aliases |
TypeScript Path Aliases
If your project uses compilerOptions.paths in tsconfig.json (e.g. @myapp/*, @auth), Knocoph resolves them automatically. When index_project is called, it looks for tsconfig.json in the project root and reads compilerOptions.paths and baseUrl to resolve aliased imports to their real file paths.
No configuration needed for the standard setup:
// tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@myapp/*": ["src/*"], // @myapp/utils → src/utils.ts
"@auth": ["src/auth/index.ts"],
},
},
}
If your tsconfig.json is not at the project root, pass the path explicitly:
index_project { root_dir: ".", tsconfig_path: "./packages/app/tsconfig.json" }
Supported patterns: simple prefix wildcards (@scope/*) and exact matches (@auth). Only the first replacement in each array is used. Complex multi-wildcard patterns are skipped.
Quick Reference
# Install globally
npm install -g knocoph
# Run tests (contributors)
npm run test:ci
# Format and lint (contributors)
npm run prettier
npm run lint
Design Principles
- Graph before files — structural questions answered without file I/O
- Deterministic queries — same input always returns same result
- Token efficiency — small, precise responses instead of full file contents
- Simplicity — explicit, readable code over clever abstractions
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.