pi-cmp

pi-cmp

Codebase Memory for pi. Provides cbm_* tools that answer structural questions about a codebase (symbol search, call chains, architecture, git change blast radius, and more) by querying a local tree-sitter knowledge graph, avoiding slow grep/read fallbacks.

Category
访问服务器

README

pi-cmp · Codebase Memory

Codebase Memory tools (cbm_*) for pi. They answer structural questions about a codebase from a local tree-sitter knowledge graph — before pi falls back to slow grep/read loops.

The extension proxies each tool call to the codebase-memory-mcp server, which maintains a graph of symbols, call chains, and relationships per project.

Quick start

cd /path/to/this/repo
pi install "$(pwd)"

Then /reload in pi (or restart pi) and verify:

pi list

What's included

Extension tools only — no MCP configuration to maintain. The extension spawns and talks to the local codebase-memory-mcp server itself.

Tool Description
cbm_search_graph Symbol search by name pattern or natural-language query
cbm_trace_path Call chains: who calls a function (inbound), what it calls (outbound)
cbm_get_code_snippet Full source for one symbol with metrics
cbm_get_architecture High-level codebase overview (languages, entry points, hotspots)
cbm_search_code Literal text / exact identifier search over indexed files
cbm_get_graph_schema Node/edge labels and relationship patterns
cbm_query_graph Read-only openCypher queries
cbm_detect_changes Map git changes to affected symbols with blast radius
cbm_list_projects All indexed projects with node/edge counts
cbm_index_status Index health (indexed, stale, or missing) with git-HEAD freshness proof
cbm_index_repository Index a repository (one-time; auto-sync keeps it fresh)
cbm_delete_project Remove a project from the knowledge graph (requires UI confirmation)
cbm_manage_adr Create, update, or read Architecture Decision Records
cbm_ingest_traces Ingest runtime traces to validate service-to-service edges

Requirements

  • Node.js 22.19.0 or newer
  • The codebase-memory-mcp server binary on PATH, or point the CBM_BINARY environment variable at it

codebase-memory-mcp is a separate project; install it from its own source before using these tools.

Usage

1. Start pi inside a project

cd /path/to/project
pi

2. Index the project (once)

Ask pi:

Index this project with cbm_index_repository.

Subsequent queries use the local .codebase-memory/ index in the project.

3. Ask structural questions

Good prompts:

Use Codebase Memory. Explain how authentication reaches the request handler.
Use Codebase Memory. What calls PlanBoostSession?
Use Codebase Memory. What would break if I change UserRepository?
Use Codebase Memory. Show files under internal/services and important symbols.

Tool choice

  • cbm_get_architecture / cbm_search_graph for broad "how does this work?" questions
  • cbm_trace_path when you already know a function name and want callers/callees
  • cbm_search_graph for declarations and symbol names, not arbitrary text
  • cbm_search_code for literal text, exact identifiers, or distinctive strings
  • cbm_detect_changes before refactors — blast radius of uncommitted changes

How it works

pi extensions are not MCP configuration files. This package registers native pi tools, and each tool proxies one JSON-RPC request to the local codebase-memory-mcp process over stdio:

pi agent
  -> pi-cmp extension tool
  -> codebase-memory-mcp process (cwd = your project)
  -> .codebase-memory/ graph database in the current project
  -> structured result back to pi

Additional behavior:

  • On session_start the project cache is reset; before_agent_start injects tool-choice guidance into the system prompt.
  • Tools default to the project matching pi's current working directory; pass project explicitly (see cbm_list_projects) to query others.
  • cbm_index_status compares the indexed git HEAD against the repository's current HEAD for real freshness proof (no fabricated timestamps).
  • cbm_delete_project requires interactive confirmation when pi has a UI.
  • Long-running tools (cbm_index_repository) use a 10-minute timeout; others default to 20 seconds. Errors surface as diagnostics with secrets redacted.

Development

npm install
npm run typecheck   # tsc --noEmit
npm test            # vitest run

Install the local checkout into pi:

pi install /path/to/pi-cmp

Repository layout

pi-cmp/
├── extensions/     # extension source only (logic lives here)
│   ├── index.ts        # entry point: registers tools, injects guidance
│   ├── tools.ts        # cbm_* tool definitions (typebox schemas)
│   ├── mcp-client.ts   # spawns codebase-memory-mcp, JSON-RPC over stdio
│   ├── project.ts      # project resolution from list_projects output
│   └── sync-check.ts   # git-HEAD freshness annotation for index_status
├── __tests__/      # vitest tests (mirror the files above)
├── package.json    # pi manifest: "pi": { "extensions": ["./extensions"] }
└── tsconfig.json

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选