Provide Code Context for AI Assistants
MCP server that maps a codebase for AI assistants: directory trees plus functions, classes and imports via WASM Tree-sitter.
1.0.0Add to Favorites
Why it matters
Enhance AI coding assistants by providing detailed code context, including directory structure and code symbols, extracted efficiently using WebAssembly Tree-sitter parsers.
Outcomes
What it gets done
Generate directory tree structures.
Extract code symbols (functions, variables, classes) from JavaScript, TypeScript, and Python files.
Filter code context based on file patterns and directory depth.
Integrate seamlessly with AI assistants via the MCP protocol.
Source
Get it from source
Spark does not host a copy of it.
Open sourceReports
Agent outcome reports
No reports yet
Capabilities
Tools your agent gets
Analyzes a directory and returns its structure along with code symbols like functions, variables, and classes.
Overview
An MCP server with one get_code_context tool. It returns a directory tree and, optionally, symbols for JavaScript, TypeScript and Python files. Use to orient an assistant in a project. Symbol analysis is limited to JS, TS, JSX, TSX and Python files.
What it does
Code Context Provider MCP is an MCP server that gives AI assistants code context and analysis. It extracts a directory structure and code symbols using WebAssembly Tree-sitter parsers, with zero native dependencies. Its features are generating a directory tree, analyzing JavaScript, TypeScript and Python files, extracting code symbols (functions, variables, classes, imports and exports), and staying compatible with the MCP protocol for integration with assistants.
When to use - and when NOT to
Use it when an assistant needs a quick map of a codebase before working on it: what files exist, how deep the tree goes, and which functions, variables and classes each analyzable file defines. It suits large monorepos and projects with many dependencies when you cap the traversal depth and focus on the main source code rather than third-party libraries.
Its symbol analysis has limits, and the maxDepth and filePatterns parameters control how far it looks. It is supported only for JavaScript (.js), JSX (.jsx), TypeScript (.ts), TSX (.tsx) and Python (.py) files. Other file types can be included in the directory structure through the file patterns parameter, but symbolic analysis of them may be limited. Anonymous functions are automatically filtered out of the results, and analysis stops at a maximum depth of five directory levels by default.
Capabilities
The server offers one tool, get_code_context, which analyzes a directory and returns its structure along with optional code symbols. Its parameters are:
- absolutePath (required): the absolute path to the directory to analyze
- analyzeJs (optional, default false): whether to analyze JavaScript, TypeScript and Python files
- includeSymbols (optional, default false): whether to include code symbols in the response
- symbolType (optional, default all): functions, variables, classes, imports, exports or all
- filePatterns (optional): an array of patterns such as *.js, .py or config.
- maxDepth (optional, default 5): the maximum directory depth
File patterns support simple glob patterns with wildcards, direct file extensions with or without the dot, and exact file names. For example, a pattern list of package.json and *.config.js analyzes package.json and any JavaScript config files. For very large projects, a maxDepth of 2 analyzes only the root and one level of subdirectories, 3 covers the root and two levels, and 0 covers only files in the root directory.
The tool output starts with the directory name, then a Code Analysis Summary listing the files analyzed and the total functions, variables and classes, followed by a note about supported file types and the depth limit. A file tree follows, where each analyzed file shows its size and counts, with functions listed together with their line and column positions.
How to install
To install for Claude Desktop automatically through Smithery:
npx -y @smithery/cli install @AB498/code-context-provider-mcp --client claude
Otherwise, add an mcpServers entry that runs npx with code-context-provider-mcp@latest. On Windows the command runs through cmd.exe with a /c argument, and on macOS and Linux it calls npx directly. You can also install globally with npm and then run the code-context-provider-mcp command. If you do not use the latest tag, clear the npx cache to get the newest version.
After installation, the package's prepare script downloads the WASM parsers automatically. If the download fails, run the code-context-provider-mcp-setup command manually. For development, clone the repository, run npm install and then npm run setup.
Who it's for
Developers building coding assistants and people who want their assistant to understand project structure without local native tooling. The project is MIT licensed and lists a Discord community and an email address for help.
Source README
Code Context Provider MCP
MCP server that provides code context and analysis for AI assistants. Extracts directory structure and code symbols using WebAssembly Tree-sitter parsers with Zero Native Dependencies.
Features
- Generate directory tree structure
- Analyze JavaScript/TypeScript and Python files
- Extract code symbols (functions, variables, classes, imports, exports)
- Compatible with the MCP protocol for seamless integration with AI assistants
Quick Usage (MCP Setup)
Installing via Smithery
To install Code Context Provider for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @AB498/code-context-provider-mcp --client claude
Windows
{
"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"
]
}
}
}
OR install globally with npm:
npm install -g code-context-provider-mcp
Then use it by running:
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
Available Tools
get_code_context
Analyzes a directory and returns its structure along with code symbols (optional).
Parameters:
absolutePath(string, required): Absolute path to the directory to analyzeanalyzeJs(boolean, optional): Whether to analyze JavaScript/TypeScript and Python files (default: false)includeSymbols(boolean, optional): Whether to include code symbols in the response (default: false)symbolType(enum, optional): Type of symbols to include if includeSymbols is true (options: 'functions', 'variables', 'classes', 'imports', 'exports', 'all', default: 'all')filePatterns(array of strings, optional): File patterns to analyze (e.g. ['.js', '.py', 'config.*'])maxDepth(number, optional): Maximum directory depth to analyze (default: 5 levels)
Note: Anonymous functions are automatically filtered out of the results.
Example Output Text On Tool Call
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]
File Pattern Examples
You can use the filePatterns parameter to specify which files to analyze. This is useful for complex projects with multiple languages or specific files of interest.
Examples:
["*.js", "*.py"]- Analyze all JavaScript and Python files["config.*"]- Analyze all configuration files regardless of extension["package.json", "*.config.js"]- Analyze package.json and any JavaScript config files[".ts", ".tsx", ".py"]- Analyze TypeScript and Python files (using extension format)
The file pattern matching supports:
- Simple glob patterns with wildcards (*)
- Direct file extensions (with or without the dot)
- Exact file names
Handling Large Projects
For very large projects, you can use the maxDepth parameter to limit how deeply the tool will traverse directories:
maxDepth: 2- Only analyze the root directory and one level of subdirectoriesmaxDepth: 3- Analyze the root, and two levels of subdirectoriesmaxDepth: 0- Only analyze files in the root directory
This is particularly useful when:
- Working with large monorepos
- Analyzing projects with many dependencies
- Focusing only on the main source code and not third-party libraries
Supported Languages
Code symbol analysis is supported for:
- JavaScript (.js)
- JSX (.jsx)
- TypeScript (.ts)
- TSX (.tsx)
- Python (.py)
Using the filePatterns parameter allows you to include other file types in the directory structure, though symbolic analysis may be limited.
Development
[Development] Setting up the Development Environment
# 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
[Development] Post-Installation
After installation, the package's prepare script automatically runs to download the WASM parsers. If for some reason the download fails, users can manually run the setup:
npx code-context-provider-mcp-setup
For more information or help
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.