chrisipanaque/scanner-mcp

GitHub: chrisipanaque/scanner-mcp

一个基于 tree-sitter 的 C++ 代码库 MCP 服务器,为 AI 编程智能体提供文件扫描、AST 代码提取、依赖分析和重要性排名等工具。

Stars: 18 | Forks: 2

scanner-mcp

scanner-mcp

一个用于扫描 C++ 代码库并为 AI agent 提供 4 个工具的 MCP 服务器

C++17 tree-sitter MCP Linux

## 功能 - **scan_files** — 通过轻量级文件系统遍历列出所有文件(路径、扩展名、大小) - **scan_code** — 通过 tree-sitter AST 提取 includes、classes、structs、functions 和 namespaces - **get_file_connections** — 文件之间的正向/反向依赖图 - **get_file_rankings** — 根据依赖、symbols 和 include 频率进行重要性评分 - **共享缓存** — 首次调用任何工具时会解析代码库;后续调用将瞬间返回结果 ## 为 agent 配置 克隆并构建(需要 CMake ≥ 3.14 — 从 https://cmake.org/download/ 安装): ``` git clone cd scanner-mcp cmake -B build && cmake --build build ``` 然后将其添加到 `opencode.json` 中: ``` { "mcp": { "scanner-mcp": { "type": "local", "command": ["/absolute/path/to/scanner-mcp/build/scanner-mcp"], "enabled": true } } } ``` ## 工具 | 工具 | 参数 | 返回值 | |---|---|---| | `scan_files` | `path` (必填) | `{ files: [{ path, extension, size }] }` | | `scan_code` | `path` (必填), `refresh` | `{ code: [{ file, includes, classes, structs, functions, namespaces }] }` | | `get_file_connections` | `path` (必填), `refresh` | `{ file_connections: { forward, reverse } }` | | `get_file_rankings` | `path` (必填), `refresh` | `{ file_rankings: [{ path, score, incoming_deps, outgoing_deps, symbols, include_freq }] }` | `scan_files` 仅遍历文件系统 — 不进行解析、不使用缓存,始终保持快速。 `scan_code`、`get_file_connections` 和 `get_file_rankings` 共享一个以绝对路径为键的缓存。首次调用时会解析一次代码库;后续调用将瞬间返回结果。当文件发生更改时,设置 `refresh: true` 以清除缓存。 ## 环境要求 - **CMake** ≥ 3.14 - **C++17** 编译器 (GCC 9+, Clang 10+, Apple Clang 14+) - **Linux** (x86_64) ## 架构 ``` FILE DISCOVERY → walk, filter, metadata scan_files CODE EXTRACTION → includes, symbols via tree-sitter AST scan_code DEPENDENCY ANALYSIS → forward/reverse connections get_file_connections IMPORTANCE RANKING → scoring heuristics get_file_rankings ``` ## 许可证 MIT
标签:AI辅助编程, Bash脚本, C++, MCP Server, SOC Prime, 代码分析, 依赖图, 凭证管理, 开发工具, 数据擦除