
MCP服务器通过静态分析提供代码智能
概览
一个代码分析与检索系统,结合了图数据库、向量搜索和大型语言模型,通过自然语言理解和查询代码库。 它将 JavaScript/TypeScript 代码库索引到 Neo4j 图数据库和 PostgreSQL 向量数据库,支持对代码结构、依赖关系和语义关系的复杂查询。 - : 结合基于图的结构分析与语义向量搜索。- : 用通俗易懂的英语询问你的代码库问题。- : 基于语义相似性和结构关系查找函数。- : 理解导入关系和函数调用层级结构。- : 自动生成使用大型语言模型的函数摘要。- : 通过文件监控增量处理代码库。- : 通过MCP与你的文本编辑器或AI代理集成。 注意:你需要在 ~/.graphsense/ 中声明环境变量。
概述(AI 翻译)
一个代码分析与检索系统,结合了图数据库、向量搜索和大型语言模型,通过自然语言理解和查询代码库。
它将 JavaScript/TypeScript 代码库索引到 Neo4j 图数据库和 PostgreSQL 向量数据库,支持对代码结构、依赖关系和语义关系的复杂查询。
特色
- 多模态代码分析:结合基于图的结构分析与语义向量搜索。
- 自然语言查询:用通俗易懂的英语询问你的代码库问题。
- 功能发现:基于语义相似性和结构关系查找功能。
- 依赖跟踪:理解导入关系和函数调用层级结构。
- AI驱动摘要:自动生成使用大型语言模型的函数摘要。
- 实时分析:通过文件监控逐步处理代码库。
- MCP 集成:通过 MCP 与你的文本编辑器或 AI 代理集成。
快速启动
注意:你需要在 ~/.graphsense/.env 中声明环境变量:
环境变量
必需变量(必须设置):
ANTHROPIC_API_KEY- Claude API 密钥
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
GraphSense Code Graph RAG
A code analysis and retrieval system that combines graph databases, vector search, and LLMs to understand and query codebases through natural language.
It indexes JavaScript/TypeScript codebases into both a Neo4j graph database and a PostgreSQL vector database, enabling sophisticated queries about code structure, dependencies, and semantic relationships.
Features
- Multi-Modal Code Analysis: Combines graph-based structural analysis with semantic vector search.
- Natural Language Queries: Ask questions about your codebase in plain English.
- Function Discovery: Find functions based on semantic similarity and structural relationships.
- Dependency Tracking: Understand import relationships and function call hierarchies.
- AI-Powered Summaries: Automatically generates summaries for functions using LLMs.
- Real-time Analysis: Processes codebases incrementally with file watching.
- MCP Integration: Integrates with your text editor or AI agent via MCP.
Quick Start
# Navigate to your git repository
$ cd ~/path/to/repo
# Run GraphSense from within the repository
$ npx graphsense
Note: You will need environment variables declared in ~/.graphsense/.env:
Environment Variables
Required variables (must be set):
ANTHROPIC_API_KEY- Claude API keyPINECONE_API_KEY- Pinecone API key
Prerequisites
- Node.js 16+
- Docker
- Must be run from within a git repository (GraphSense will exit if not)
- API Keys for:
- Anthropic (Claude) - Get API Key
- Pinecone - Get API Key
Model Context Protocol (MCP) Integration
GraphSense provides an MCP server to integrate with AI assistants like Claude Desktop, enabling natural language queries about your codebase.
MCP Configuration
The MCP server uses stdio transport and is automatically started when you run the main application.
Starting GraphSense MCP
# Navigate to your git repository
$ cd ~/path/to/repo
# Run GraphSense from within the repository
$ npx graphsense
Claude Desktop Configuration
Add this to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"graphsense": {
"command": "npx",
"args": ["graphsense"],
"env": {}
}
}
}
Note: Your preferred AI coding editor/agent will have similar configuration options.
Available MCP Tools
-
similar_functions- Find functions based on semantic description- Parameters:
function_description(string),topK(number, optional) - Returns: Array of similar functions with similarity scores
- Parameters:
-
function_callers- Find functions that call a specific function- Parameters:
functionId(string) - The element ID of the target function
- Parameters:
安装
npx graphsense配置
{
"mcpServers": {
"graphsense": {
"command": "npx",
"args": ["graphsense"],
"env": {}
}
}
}