Code Context Provider MCP
代码上下文提供者 MCP
MCP 服务器为 AI 助手提供代码上下文和分析。它使用 WebAssembly Tree-sitter 解析器提取目录结构和代码符号,且无需任何原生依赖。
特征
生成目录树结构
分析 JavaScript/TypeScript 和 Python 文件
提取代码符号(函数、变量、类、导入、导出)
兼容MCP协议,与AI助手无缝集成
Related MCP server: syntax-map-mcp
快速使用(MCP 设置)
通过 Smithery 安装
要通过Smithery自动为 Claude Desktop 安装 Code Context Provider:
npx -y @smithery/cli install @AB498/code-context-provider-mcp --client claude视窗
{
"mcpServers": {
"code-context-provider-mcp": {
"command": "cmd.exe",
"args": [
"/c",
"npx",
"-y",
"code-context-provider-mcp@latest"
]
}
}
}MacOS/Linux
{
"mcpServers": {
"code-context-provider-mcp": {
"command": "npx",
"args": [
"-y",
"code-context-provider-mcp@latest"
]
}
}
}或者使用npm全局安装:
npm install -g code-context-provider-mcp然后通过运行来使用它:
code-context-provider-mcp # if you're not using @latest, you may want to clear the cache for latest version using `Remove-Item -Path "$env:LOCALAPPDATA\npm-cache\_npx" -Recurse -Force` for windows and `rm -rf ~/.npm/_npx` for linux/macos可用工具
get_code_context
分析目录并返回其结构以及代码符号(可选)。
参数:
absolutePath(字符串,必需):要分析的目录的绝对路径analyzeJs(布尔值,可选):是否分析 JavaScript/TypeScript 和 Python 文件(默认值:false)includeSymbols(布尔值,可选):是否在响应中包含代码符号(默认值:false)symbolType(枚举,可选):如果 includeSymbols 为真,则包含的符号类型(选项:'functions'、'variables'、'classes'、'imports'、'exports'、'all',默认值:'all')filePatterns(字符串数组,可选):要分析的文件模式(例如 [' .js', ' .py', 'config.*'])maxDepth(数字,可选):要分析的最大目录深度(默认值:5 级)
注意:匿名函数会自动从结果中过滤掉。
工具调用时的输出文本示例
Directory structure for: C:\Users\Admin\Desktop\mcp\context-provider-mcp
Code Analysis Summary:
- Files analyzed: 3
- Total functions: 29
- Total variables: 162
- Total classes: 0
Note: Symbol analysis is supported for JavaScript/TypeScript (.js, .jsx, .ts, .tsx) and Python (.py) files only.
Code analysis limited to a maximum depth of 5 directory levels (default).
├── index.js (39 KB)
│ └── [Analyzed: 22 functions, 150 variables, 0 classes]
│ Functions:
│ - initializeTreeSitter [39:0]
│ - getLanguageFromExtension [107:0]
│ - getPosition [138:24]文件模式示例
您可以使用filePatterns参数指定要分析的文件。这对于包含多种语言或特定文件的复杂项目非常有用。
例子:
["*.js", "*.py"]- 分析所有 JavaScript 和 Python 文件["config.*"]- 分析所有配置文件,无论其扩展名是什么。["package.json", "*.config.js"]- 分析 package.json 和任何 JavaScript 配置文件[".ts", ".tsx", ".py"]- 分析 TypeScript 和 Python 文件(使用扩展格式)
文件模式匹配支持:
带有通配符 (*) 的简单 glob 模式
直接文件扩展名(带或不带点)
确切的文件名
处理大型项目
对于非常大的项目,您可以使用maxDepth参数来限制工具遍历目录的深度:
maxDepth: 2- 仅分析根目录和一层子目录maxDepth: 3- 分析根目录和两级子目录maxDepth: 0- 仅分析根目录中的文件
这在以下情况下特别有用:
使用大型 monorepos
分析具有许多依赖项的项目
只关注主要源代码,不关注第三方库
支持的语言
支持以下代码符号分析:
JavaScript (.js)
JSX(.jsx)
TypeScript(.ts)
TSX(.tsx)
Python(.py)
使用filePatterns参数允许您在目录结构中包含其他文件类型,但符号分析可能会受到限制。
发展
设置开发环境
# Clone the repository
git clone https://github.com/your-username/code-context-provider-mcp.git
cd code-context-provider-mcp
# Install dependencies
npm install
# Set up WASM parsers
npm run setup安装后
安装完成后,软件包的prepare脚本会自动运行,以下载 WASM 解析器。如果由于某种原因下载失败,用户可以手动运行安装程序:
npx code-context-provider-mcp-setup执照
麻省理工学院
如需更多信息或帮助
Available Tools
1 toolget_code_contextA
Returns Complete Context of a given project directory, including directory tree, and code symbols. Useful for getting a quick overview of a project. Use this tool when you need to get a comprehensive overview of a project's codebase. Useful at the start of a new task.
Inputs: absolutePath (required), analyzeJs, includeSymbols, maxDepth, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool has a clear and distinct purpose focused on providing project context.
The naming follows a consistent verb_noun pattern (get_code_context), and with only one tool, there is no inconsistency to evaluate. The naming is clear and descriptive.
A single tool is generally too few for most MCP server purposes, as it limits functionality and can feel thin. For a 'Code Context Provider', one tool may not cover all potential needs like updating or filtering context, making it borderline inadequate.
The tool set is severely incomplete for the implied domain of code context provision. While it offers a comprehensive overview, there are obvious gaps such as tools for updating context, filtering by file type, or handling specific symbols, which could lead to agent workarounds or failures.
Maintenance
Related MCP Connectors
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Deterministic context layer for your codebase: change impact, blast radius, answers with receipts.
Ask a codebase what calls what: search, blast radius, paths between symbols, and diffs.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI assistants to understand and navigate codebases through structural analysis. Provides code mapping, symbol search, and impact analysis using ast-grep for accurate parsing of Python, JavaScript, TypeScript, and Go projects.452MIT
- AlicenseCqualityDmaintenanceEnables code analysis of JavaScript, TypeScript, TSX, Python, and Rust files using Tree-sitter, providing symbol listing, definition/reference lookup, AST queries, LSP-style features, and SQLite indexing for efficient cross-file searches.2135 npmMIT
- AlicenseNot gradedqualityDmaintenanceProvides a semantic understanding of your codebase by parsing with tree-sitter and building a graph of symbols and dependencies. Enables AI assistants to navigate code, analyze changes, and discover architecture using 18 tools with minimal context overhead.16 npm1MIT
- AlicenseAqualityFmaintenanceA deterministic structural code map server for AI agents, giving them the shape of a codebase (imports, exports, classes, functions, signatures, comments, TODO-markers) without reading whole files into context. Powered by tree-sitter WASM grammars, it runs anywhere Node 18+ works.71AGPL 3.0