Token导航 LogoToken导航TokenDH.com
Sgraph MCP Server logo
开发工具stdio官方级别未说明来源级核验

Sgraph MCP Server

MCP Server

SGraph MCP Server 是一个为AI代理提供即时访问软件架构、依赖关系和影响分析的MCP服务器,通过预计算的sgraph模型实现高效分析。

工具数

6

提示词数

0

GitHub Stars

3

资源数

0
PythonClaude开发工具ClaudeCursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

softagram

提供方

softagram

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run python -m src.server --profile claude-code

详细介绍

SGraph MCP服务器

![Python 3.13+](https://www.python.org/) ![License: MIT](LICENSE) ![CI](https://github.com/softagram/sgraph-mcp-server/actions/workflows/ci.yml)

为什么?

AI代理通过一次读取一个文件来发现代码结构。对于这样的问题 *“这个函数叫什么?”*,这意味着grep,read,grep again,read again。..数十次往返,数千个令牌,以及仍然错过间接呼叫者的结果。

SGraph预先计算完整的依赖图。同样的问题需要 一个电话 并返回 每位来电者 带有类型信息。

传统(grep/read)SGraph MCP
“这个函数叫什么?”多个grep+读取周期sgraph_get_element_dependencies
“如果我改变这个,会有什么问题?”手动跟踪,很容易错过sgraph_analyze_change_impact
“显示模块结构”ls+读取+滚动sgraph_get_element_structure
每次查询的时间秒(多次往返)毫秒(缓存)
准确性文本匹配(嘈杂)语义图(精确)

快速开始

1.安装

git clone https://github.com/softagram/sgraph-mcp-server.git
cd sgraph-mcp-server
uv sync

2.启动服务器

# With Claude Code profile (recommended)
uv run python -m src.server --profile claude-code

# With auto-loaded model (skip the load_model step)
uv run python -m src.server --profile claude-code \
  --auto-load /path/to/model.xml.zip \
  --default-scope /Project/src

3.连接您的AI代理

Claude Code / Cursor (.mcp.json)

创建 .mcp.json 在项目根目录中:

{
  "mcpServers": {
    "sgraph": {
      "command": "uv",
      "args": [
        "run", "--directory", "/path/to/sgraph-mcp-server",
        "python", "-m", "src.server",
        "--profile", "claude-code",
        "--transport", "stdio",
        "--auto-load", "/path/to/model.xml.zip"
      ]
    }
  }
}

Alternative: SSE transport (any MCP client, via mcp-remote)

Stdio是推荐的本地使用的传输方式——无端口、无网桥、直接IPC。SSE适用于只能使用HTTP的客户端,或者当您想在多个客户端之间共享一个长时间运行的服务器时。

以SSE模式启动服务器:

uv run python -m src.server --profile claude-code --transport sse --port 8008

然后通过以下方式连接任何MCP客户端 mcp-remote 桥梁:

{
  "mcpServers": {
    "sgraph": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "http://localhost:8008/sse"]
    }
  }
}

Where do sgraph models come from?

这些模型将您的代码库表示为层次图:

/Project
  /Project/src
    /Project/src/auth/login.py
      /Project/src/auth/login.py/LoginHandler        (class)
        /Project/src/auth/login.py/LoginHandler/validate  (method)
  /Project/External
    /Project/External/Python/requests                 (third-party)

每个元素都可以有 协会 (依赖关系)到其他元素,形成一个完整的依赖关系图。

工具

克劳德密码 profile提供了6个针对AI辅助开发进行优化的工具:

工具功能何时使用
sgraph_search_elements按模式查找符号“UserService类在哪里?”
sgraph_get_element_dependencies查询传入/传出deps“什么调用此函数?”
sgraph_get_element_structure探索层次结构“此模块中有什么?”
sgraph_analyze_change_impact多层次影响分析“如果我改变这一点,会有什么问题?”
sgraph_audit架构健康检查“是否存在循环依赖关系?”
sgraph_security_audit安全态势概述“有任何暴露的秘密或CVE吗?”

关键工具是 sgraph_get_element_dependencies 以其 result_level 用于控制抽象的参数:

result_level=None  ->  /Project/src/auth/login.py/LoginHandler/validate  (raw)
result_level=4     ->  /Project/src/auth/login.py                        (file)
result_level=3     ->  /Project/src/auth                                 (directory)
result_level=2     ->  /Project/src                                      (component)

有关工作流和示例的完整工具参考,请参阅 SGRAPH_FOR_CLAUDE_CODE.md.

Legacy profile (14 tools)

legacy profile提供了完整的原始工具集以实现向后兼容性:

基本操作: sgraph_load_model, sgraph_get_root_element, sgraph_get_element, sgraph_get_element_incoming_associations, sgraph_get_element_outgoing_associations

搜索: sgraph_search_elements_by_name, sgraph_get_elements_by_type, sgraph_search_elements_by_attributes

分析: sgraph_get_subtree_dependencies, sgraph_get_dependency_chain, sgraph_get_multiple_elements, sgraph_get_model_overview, sgraph_get_high_level_dependencies

uv run python -m src.server --profile legacy

对话示例

You: "What would break if I rename the validate() method in auth/login.py?"

Agent calls: sgraph_analyze_change_impact(element_path="/Project/src/auth/login.py/LoginHandler/validate")

Result:
  5 callers in 3 files
  - /Project/src/api/routes.py (2 call sites)
  - /Project/src/middleware/auth.py (2 call sites)
  - /Project/tests/test_auth.py (1 call site)
  Warning: bidirectional dependency with /Project/src/middleware

建筑

MCP Client Request
       |
[Tools Layer]     src/tools/        -- MCP tool definitions, input validation
       |
[Services Layer]  src/services/     -- Business logic (search, deps, security)
       |
[Core Layer]      src/core/         -- Model management, data conversion
       |
[SGraph Library]                    -- Graph operations (sgraph package)

建筑.md 详细设计。

发展

# Run tests
uv run python tests/run_all_tests.py
uv run python tests/run_all_tests.py unit          # Unit only
uv run python tests/run_all_tests.py integration   # Integration only

# Lint
uv run ruff check src/

# Run a single test file
uv run python -m pytest tests/unit/test_collect_deps.py -v

贡献.md 如何做出贡献。

关于

目录标签

目录标签

PythonClaude开发工具软件架构分析本地部署依赖关系分析代码影响分析AI辅助开发开发效率工具

支持客户端

ClaudeCursor

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

session

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

6

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiosession部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP