knocoph

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.

Category
访问服务器

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_symbol before opening files
  • Use graph queries to understand relationships instead of burning context tokens
  • Call explain_impact before making changes
  • Use get_snippet to 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.json to resolve @scope/... style imports

How It Works

  1. Parse — TypeScript ESLint parser extracts symbols, types, and relationships from source files
  2. Graph — Builds nodes for functions, classes, interfaces, variables, etc.
  3. Store — Persists all metadata and edges in SQLite
  4. 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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选