CIE如何通过MCP工具集为AI代理提供本地化代码智能?
AI Summary (BLUF)
CIE is a local-first code intelligence engine that indexes codebases to provide semantic search, call graph analysis, and endpoint discovery through MCP, reducing AI agent tool calls by up to 90% while keeping all data private.
原文翻译: CIE是一个本地优先的代码智能引擎,通过索引代码库提供语义搜索、调用图分析和端点发现功能,通过MCP协议工作,可将AI代理工具调用减少高达90%,同时保持所有数据私有。
超过 20 个 MCP 工具,为 AI 代理提供语义代码搜索、调用图分析和端点发现功能 —— 100% 本地运行,数秒内索引 10 万行代码。
20+ MCP tools that give AI agents semantic code search, call graph analysis, and endpoint discovery — 100% local, indexes 100k LOC in seconds.
实践案例:在追踪 MIE 代码库的调用图时,Claude Code 在没有 CIE 的情况下需要 34 次工具调用。使用 CIE 后,仅需 3 次。具体结果因查询而异,但结构化的代码智能持续减少了代理的往返次数。
In practice: Tracing a call graph through MIE's codebase, Claude Code needed 34 tool calls without CIE. With CIE, it needed 3. Results vary by query, but structured code intelligence consistently reduces agent round-trips.
CIE 能够索引您的代码库,并通过模型上下文协议(Model Context Protocol, MCP)提供语义搜索、调用图分析和 AI 驱动的代码理解能力。
CIE indexes your codebase and provides semantic search, call graph analysis, and AI-powered code understanding through the Model Context Protocol (MCP).
为什么选择 CIE?
Why CIE?
- 语义搜索 - 通过含义而非简单的文本匹配来查找代码 (Semantic Search - Find code by meaning, not just text matching)
- 调用图分析 - 追踪执行路径,包括接口派发解析 (Call Graph Analysis - Trace execution paths including interface dispatch resolution)
- 原生 MCP 支持 - 与 Claude Code、Cursor 及任何 MCP 客户端无缝协作 (MCP Native - Works seamlessly with Claude Code, Cursor, and any MCP client)
- 快速 - 数秒内索引 10 万行代码,查询在毫秒级完成 (Fast - Indexes 100k LOC in seconds, queries in milliseconds)
- 私密 - 所有数据保留在本地,您的代码永不离开您的机器 (Private - All data stays local, your code never leaves your machine)
- 准确 - 关键词增强确保函数搜索的相关性 (Accurate - Keyword boosting ensures relevant results for function searches)
安装
Installation
| 方法 | 命令 |
|---|---|
| Homebrew | brew tap kraklabs/cie && brew install cie |
| 安装脚本 | curl -sSL https://raw.githubusercontent.com/kraklabs/cie/main/install.sh | sh |
| GitHub Releases | 下载二进制文件 |
Method Command Homebrew brew tap kraklabs/cie && brew install cieInstall Script curl -sSL https://raw.githubusercontent.com/kraklabs/cie/main/install.sh | shGitHub Releases Download binary
功能特性
Features
语义代码搜索
Semantic Code Search
通过含义查找代码,而非关键词:
Find code by meaning, not keywords:
# 提问:"认证中间件在哪里?"
# 通过 MCP 使用 cie_semantic_search 工具
# Ask: "Where is authentication middleware?" # Use cie_semantic_search tool via MCP
示例输出:
Example output:
[95%] AuthMiddleware (internal/http/auth.go:42)
[76%] ValidateToken (internal/auth/jwt.go:103)
调用图分析
Call Graph Analysis
追踪执行如何到达任何函数:
Trace how execution reaches any function:
# 问题:"main() 如何到达 database.Connect()?"
# 使用 cie_trace_path 工具
# Question: "How does main() reach database.Connect()?" # Use cie_trace_path tool
示例输出:
Example output:
main → InitApp → SetupDatabase → database.Connect
├─ File: cmd/server/main.go:25
├─ File: internal/app/init.go:42
└─ File: internal/database/setup.go:18
HTTP 端点发现
HTTP Endpoint Discovery
自动列出所有 API 端点:
List all API endpoints automatically:
# 使用 cie_list_endpoints 工具
# Use cie_list_endpoints tool
示例输出:
Example output:
[GET] /api/v1/users → HandleGetUsers
[POST] /api/v1/users → HandleCreateUser
[DELETE] /api/v1/users/:id → HandleDeleteUser
多语言支持
Multi-Language Support
通过 Tree-sitter 解析器支持 Go、Python、JavaScript、TypeScript 等多种语言。
Supports Go, Python, JavaScript, TypeScript, and more through Tree-sitter parsers.
快速开始
Quick Start
1. 安装 CLI
- Install the CLI
Homebrew (macOS/Linux):
brew tap kraklabs/cie
brew install cie
脚本安装:
Script:
curl -sSL https://raw.githubusercontent.com/kraklabs/cie/main/install.sh | sh
手动下载:
从 GitHub Releases 下载。
Manual download:
Download from GitHub Releases.
2. 索引您的代码库
- Index Your Repository
cd /path/to/your/repo
cie init -y # 初始化项目配置
cie index # 索引代码库(无需 Ollama 也可工作)
cd /path/to/your/repo cie init -y # Initialize project configuration cie index # Index the codebase (works without Ollama too)
示例输出:
Example output:
Project: your-repo-name
Files: 1,234
Functions: 5,678
Types: 890
Last indexed: 2 minutes ago
注意: CIE 无需 Ollama 即可工作 —— 您将可以访问包括 grep、调用图、函数查找器等在内的 20 多种工具。语义搜索需要来自 Ollama 或其他提供商的嵌入模型。
Note: CIE works without Ollama -- you'll have access to 20+ tools including grep, call graph, function finder, and more. Semantic search requires embeddings from Ollama or another provider.
管理命令
Management Commands
| 命令 | 描述 |
|---|---|
cie init -y |
初始化项目配置 |
cie index |
索引(或重新索引)代码库 |
cie reset --yes |
删除项目的所有索引数据 |
Command Description cie init -yInitialize project configuration cie indexIndex (or re-index) the codebase cie reset --yesDelete all indexed data for the project
MCP 服务器模式
MCP Server Mode
CIE 可以作为 MCP 服务器运行,以便与 Claude Code 集成:
CIE can run as an MCP server for integration with Claude Code:
cie --mcp
在您的 Claude Code 设置中进行配置:
Configure in your Claude Code settings:
{
"mcpServers": {
"cie": {
"command": "cie",
"args": ["--mcp"]
}
}
}
配置
Configuration
CIE 使用 YAML 配置文件 (/.cie/project.yaml):
CIE uses a YAML configuration file (
/.cie/project.yaml):
version: "1"
project_id: my-project
embedding:
provider: ollama
base_url: http://localhost:11434
model: nomic-embed-text
嵌入模型是可选的。 CIE 无需 Ollama 或任何嵌入模型提供商即可工作。您可以完全访问所有结构化工具(grep、调用图、函数查找器等)。只有语义搜索 (
cie_semantic_search) 需要嵌入模型。Embeddings are optional. CIE works without Ollama or any embedding provider. You get full access to all structural tools (grep, call graph, function finder, etc.). Only semantic search (
cie_semantic_search) requires embeddings.
您也可以为 cie_analyze 的叙述生成配置一个 LLM:
You can also configure an LLM for
cie_analyzenarrative generation:
# 可选:用于 cie_analyze 叙述生成的 LLM
llm:
enabled: true
base_url: http://localhost:11434 # Ollama
model: llama3
# 对于 OpenAI: base_url: https://api.openai.com/v1, model: gpt-4o-mini
# Optional: LLM for cie_analyze narrative generation llm: enabled: true base_url: http://localhost:11434 # Ollama model: llama3 # For OpenAI: base_url: https://api.openai.com/v1, model: gpt-4o-mini
注意: llm 部分是可选的。没有它,cie_analyze 将返回原始分析数据。配置后,您将获得综合的叙述性摘要。
Note: The
llmsection is optional. Without it,cie_analyzereturns raw analysis data. With it configured, you get synthesized narrative summaries.
MCP 工具
MCP Tools
当作为 MCP 服务器运行时,CIE 提供超过 20 种按类别组织的工具:
When running as an MCP server, CIE provides 20+ tools organized by category:
导航与搜索
Navigation & Search
| 工具 | 描述 |
|---|---|
cie_grep |
快速字面文本搜索(无正则表达式) |
cie_semantic_search |
使用嵌入模型的基于含义的搜索 |
cie_find_function |
按名称查找函数(处理接收器语法) |
cie_find_type |
查找类型/接口/结构体 |
cie_find_similar_functions |
查找名称相似的函数 |
cie_list_files |
列出带过滤器的索引文件 |
cie_list_functions_in_file |
列出文件中的所有函数 |
Tool Description cie_grepFast literal text search (no regex) cie_semantic_searchMeaning-based search using embeddings cie_find_functionFind functions by name (handles receiver syntax) cie_find_typeFind types/interfaces/structs cie_find_similar_functionsFind functions with similar names cie_list_filesList indexed files with filters cie_list_functions_in_fileList all functions in a file 调用图分析
Call Graph Analysis
工具 描述 cie_find_callers查找调用某函数的代码 cie_find_callees查找某函数调用的代码 cie_trace_path追踪从入口点到目标的调用路径 cie_get_call_graph获取函数的完整调用图
Tool Description cie_find_callersFind what calls a function cie_find_calleesFind what a function calls cie_trace_pathTrace call paths from entry points to target cie_get_call_graphGet complete call graph for a function 代码理解
Code Understanding
工具 描述 cie_analyze架构分析(LLM 叙述可选) cie_get_function_code获取函数源代码 cie_directory_summary获取包含主要函数的目录概览 cie_find_implementations查找实现某个接口的类型 cie_get_file_summary获取文件中所有实体的摘要
Tool Description cie_analyzeArchitectural analysis (LLM narrative optional) cie_get_function_codeGet function source code cie_directory_summaryGet directory overview with main functions cie_find_implementationsFind types that implement an interface cie_get常见问题(FAQ)
CIE 如何帮助 AI 代理减少工具调用次数?
CIE 通过 MCP 协议提供结构化的代码智能(如语义搜索、调用图分析),使 AI 代理能一次性获取深层代码信息,无需多次往返查询。实践案例显示,追踪调用图时工具调用从 34 次降至 3 次,减少高达 90%。
CIE 的本地优先设计如何保障代码隐私?
CIE 完全在本地运行,所有代码索引、分析和查询数据均保留在用户机器上,代码永不离开本地环境。这确保了 100% 的数据私有性,无需担心云端传输或第三方存储风险。
CIE 支持哪些编程语言和开发工具?
CIE 提供多语言支持(如 Go 等),并原生集成 MCP 协议,可与 Claude Code、Cursor 及任何 MCP 客户端无缝协作。安装后即可通过语义搜索、调用图分析等功能增强现有开发流程。
版权与免责声明:本文仅用于信息分享与交流,不构成任何形式的法律、投资、医疗或其他专业建议,也不构成对任何结果的承诺或保证。
文中提及的商标、品牌、Logo、产品名称及相关图片/素材,其权利归各自合法权利人所有。本站内容可能基于公开资料整理,亦可能使用 AI 辅助生成或润色;我们尽力确保准确与合规,但不保证完整性、时效性与适用性,请读者自行甄别并以官方信息为准。
若本文内容或素材涉嫌侵权、隐私不当或存在错误,请相关权利人/当事人联系本站,我们将及时核实并采取删除、修正或下架等处理措施。 也请勿在评论或联系信息中提交身份证号、手机号、住址等个人敏感信息。
