MCP Filesystem Server
RIG MCP 工具
一个模型上下文协议 (MCP) 服务器,为 AI 助手提供智能代码分析、基于图的架构洞察和文件操作功能。
概述
RIG MCP 工具结合了三层智能:
静态分析 — 基于 AST 解析 (ts-morph, tree-sitter) 构建并存储在 SQLite 中的仓库智能图 (RIG),实现零 LLM 成本的图查询。
语义搜索 — 使用本地模型 (nomic-embed-text 或兼容模型) 进行基于嵌入的符号检索。嵌入在首次运行后缓存于 SQLite 中。返回精确的代码片段而非整个文件 — 最大限度地减少 Token 使用。
LLM 驱动工具 — 一组调用可配置的 OpenAI 兼容 API,用于对代码进行自然语言推理的工具。
Related MCP server: PT-MCP (Paul Test Man Context Protocol)
安装
从 npm 安装
npx rig-mcp-tools从源码安装
git clone <repository-url>
cd rig-mcp-tools
npm install
npm run buildDocker
docker build -t rig-mcp-tools .
docker run rig-mcp-tools配置
MCP 客户端 (Claude Desktop, Cursor 等)
{
"mcpServers": {
"rig-tools": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"WORKSPACE_PATH": "/your/project",
"GLM_API_URL": "http://localhost:1234/v1/chat/completions",
"GLM_MODEL": "qwen2.5-coder-7b-instruct-mlx@8bit",
"EMBEDDING_API_URL": "http://localhost:1234/v1/embeddings",
"EMBEDDING_MODEL": "text-embedding-nomic-embed-text-v1.5"
}
}
}
}环境变量
变量 | 默认值 | 描述 |
|
| 根工作区路径 |
|
| LLM API 端点 (兼容 OpenAI) |
|
| LLM 驱动工具所使用的模型 |
|
| 嵌入 API 端点 |
|
| 语义搜索所使用的模型 |
LLM 和嵌入工具是可选的 — 所有静态分析工具无需任何 API 即可工作。
可用工具
RIG — 图分析
这些工具通过 AST 解析将仓库索引到 SQLite 图中,并在不调用任何 LLM 的情况下进行查询。
get_smart_context
使用图中心性和关键词评分,为查询检索最相关的文件和符号。
{ "rootPath": "/project", "text": "authentication flow" }get_architectural_metrics
仓库架构的执行摘要:按图中心性排名的核心枢纽、入口点和稳定基础。
{ "rootPath": "/project" }graph_analyzer
组件级复杂度分析,包含热点检测和重构建议。
{ "rootPath": "/project" }generate_call_graph
生成组件、文件或符号之间的调用图或依赖关系图。
{
"rootPath": "/project",
"level": "component",
"format": "mermaid",
"maxDepth": 5
}level: "component" | "file" | "symbol"format: "mermaid" | "dot" | "json"
generate_diagram
从 RIG 生成 C4 架构图、时序图、调用图或依赖关系可视化。
{
"rootPath": "/project",
"type": "c4-container",
"format": "mermaid",
"focus": "auth",
"maxDepth": 3,
"style": "default"
}type: "c4-context" | "c4-container" | "c4-component" | "sequence" | "call-graph" | "dependency-graph"format: "mermaid" | "plantuml" | "dot"style: "default" | "compact" | "detailed"
extract_method
使用 RIG 符号坐标,将函数或类从源文件手术式地提取到目标文件。
{
"rootPath": "/project",
"sourceFile": "src/utils/helpers.ts",
"symbolName": "formatDate",
"targetFile": "src/utils/date.ts"
}文件操作
纯文件系统工具,无需图或 LLM。
read_files
单次调用读取最多 10 个文件的内容。
{ "files": ["src/index.ts", "src/config.ts"] }write_code_unit
使用特定内容写入或覆盖文件。根据需要创建父目录。
{ "path": "src/utils/new-file.ts", "content": "export const foo = 1;" }ls_tree
以 ASCII 树形式列出目录结构。
{ "path": "/project/src", "maxDepth": 3 }search_code
在代码库中递归搜索文本或正则表达式模式。
{ "path": "/project/src", "pattern": "useEffect", "useRegex": false }inspect_symbols
使用 AST 分析 (ts-morph) 从文件中提取类和函数签名。
{ "file": "src/tools/index.ts" }run_shell_task
执行允许的 shell 命令。
{ "command": "npm run build", "timeout": 60000 }允许的前缀:npm test, npm run, npm list, npx vitest, npx tsc, npx eslint, node --version, tsc, git status, git diff, git log, git show, git blame, ls, pwd, cat, wc。
质量分析
静态分析工具,无需 LLM。
detect_patterns
使用 Babel AST 分析检测反模式、代码异味和安全问题。
{ "sourceCode": "...", "filePath": "src/auth/login.ts" }suggest_refactor
检测重构机会:长函数、深层嵌套、魔术数字、重复代码和缺失的类型注解。
{
"file_path": "src/services/user.ts",
"max_suggestions": 10,
"min_priority": 3,
"include_diff": true
}必须提供 file_path 或 code_snippet。
analyze_dependencies
通过导入分析构建 TypeScript 文件的轻量级依赖图。返回节点、循环依赖以及 Graphviz 的 DOT 格式。
{ "rootPath": "/project/src" }嵌入驱动
需要 EMBEDDING_API_URL 和 EMBEDDING_MODEL。嵌入为每个符号生成一次并缓存于 .rig/index.db 中 — 后续查询仅对查询字符串进行嵌入。
search_semantic
使用向量相似度的语义符号搜索。返回最相关的函数和类及其代码片段。在 read_files 之前使用此工具,以避免将整个文件加载到上下文中。嵌入为每个符号生成一次并缓存于 .rig/index.db 中。
{
"repoPath": "/project",
"query": "how is authentication handled",
"maxResults": 5,
"threshold": 0.3
}LLM 驱动
需要 GLM_API_URL 和 GLM_MODEL。
analyze_logic
针对一段代码提出自然语言问题。使用配置的 LLM 对行为、意图或逻辑进行推理。
{
"filePath": "/project/src/auth/login.ts",
"question": "What edge cases does this miss?"
}优先使用 filePath 而非 code,以避免通过上下文传递文件内容。
smart_summarize
生成代码文件的智能摘要,包括导入、导出、用途和关键依赖项。
{ "filePath": "/project/src/services/user.ts", "maxLength": 200 }generate_unit_tests
为特定函数或类生成 vitest 单元测试。使用 RIG 索引仅提取方法体(而非整个文件)— Token 高效。涵盖正常路径、边界情况和错误情况。
{
"repoPath": "/project",
"symbolName": "createUser",
"filePath": "src/services/user.ts"
}仅当符号存在于多个文件中时才需要 filePath。
investigate_ts_fix
运行 tsc --noEmit 并使用 LLM 解释并建议针对每个 TypeScript 错误的最小修复方案。Token 高效:仅传递错误行周围的代码片段(±8 行),而非整个文件。
{
"repoPath": "/project",
"filePath": "src/services/user.ts",
"maxErrors": 5
}filePath 和 maxErrors 是可选的。省略 filePath 可调查整个仓库中的所有错误。
架构
src/
├── cli/ # rig-indexer CLI (pre-index a repo into .rig/index.db)
├── graph/ # RIG graph engine (indexer, parsers, SQLite storage, types)
├── security/ # Path validation and safe extension checks
└── tools/ # MCP tool implementations (19 tools)预索引仓库
对于大型代码库,在使用 RIG 工具之前请先进行预索引:
npx tsx src/cli/index.ts /path/to/project --db /path/to/project/.rig/index.db选项:--max-files <n>, --include-tests, --json
开发
npm run build # Compile TypeScript
npm run dev # Run in development mode
npm test # Run test suite
npm run clean # Clean build artifacts许可证
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
AI-powered codebase analysis — call graphs, security, dead code, complexity. 150+ tools.
Codebase intelligence for agents: 152 structured artifacts across 21 programs, one call.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides intelligent code context and analysis through semantic compression, AST parsing, and multi-language support. Offers 60-80% token reduction while enabling AI assistants to understand codebases through local analysis, OpenAI-enhanced insights, and GitHub repository integration.6103MIT
- FlicenseBqualityNot gradedmaintenanceProvides comprehensive codebase analysis and semantic understanding through integrated knowledge graphs, enabling AI assistants to understand project structure, patterns, dependencies, and context through multiple analysis tools and format generators.9-
- FlicenseNot gradedqualityDmaintenanceEnables LLMs to perform high-performance code search and analysis across multiple languages using symbol indexing, regex text search, and structural AST pattern matching. It also provides tools for technology stack detection and dependency analysis with persistent caching for optimized performance.7-
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to query a pre-built semantic knowledge graph of code, reducing token usage and tool calls. Supports 16 tools for code exploration, analysis, and context building.147MIT
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/williamRR/mcp-filesystem-rig'
If you have feedback or need assistance with the MCP directory API, please join our Discord server