Code Scanner Server
The Code Scanner Server is a versatile tool for analyzing codebases to extract structural information with the following capabilities:
Code Definition Extraction: Identifies functions, classes, variables, methods, interfaces and more with line numbers
Multi-Language Support: Parses JavaScript, TypeScript, C#, PHP, CSS, and Python using Tree-sitter
.gitignore Aware: Respects exclusion rules to skip specified files and directories
Flexible Filtering: Filter by definition type, modifiers (e.g.,
public,private), name patterns (regex), and file pathsMultiple Output Formats: Generates results in XML, Markdown, or JSON
Configurable Detail Levels: Choose between
minimal,standard, ordetailedoutput verbosityDual Operation Modes: Functions as both an MCP server for integration with AI assistants and other clients, and as a CLI tool for direct scanning
Provides parsing and definition extraction for CSS files, identifying selectors, rules, and structure
Respects .gitignore rules when scanning codebases, ensuring ignored files are excluded from analysis
Offers parsing and code structure analysis for JavaScript files, including JSX, extracting functions, classes and other definitions
Provides output formatting in Markdown for human-readable documentation and integration with documentation systems
Built on Node.js platform for code scanning and analysis capabilities across multiple programming languages
Offers parsing and code structure analysis for PHP files, extracting functions, classes and other definitions
Provides parsing and code structure analysis for Python files, extracting functions, classes and other definitions
Offers parsing and code structure analysis for TypeScript files, including TSX, extracting functions, classes, interfaces and other definitions
Supports output formatting in XML for integration with other tools and services
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Code Scanner Serverscan ./src for public classes and output in markdown"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
code-scanner-server
A CLI tool and MCP server that scans code files for definitions (classes, functions, etc.), respects .gitignore, provides line numbers, and outputs LLM-friendly formats (XML/Markdown).
This project provides a versatile code scanning tool built with TypeScript and Node.js. It leverages the Tree-sitter parsing library to analyze source code and extract structural information. It can operate both as a command-line interface (CLI) tool and as an MCP (Model Context Protocol) server.
Note: This tool is under active development. While core functionality is operational, some features or specific language parsers may not be fully tested and might contain bugs or limitations.
Features
Code Definition Extraction: Identifies functions, classes, variables, interfaces, methods, etc.
Multi-Language Support: Parses JavaScript (
.js,.jsx), TypeScript (.ts,.tsx), C# (.cs), PHP (.php), CSS (.css), and Python (.py) via Tree-sitter..gitignore Aware: Automatically respects rules defined in
.gitignorefiles.Flexible Filtering: Filter results by definition type, modifiers (
public,private), name patterns (regex), and file path patterns.Multiple Output Formats: Generates results in Markdown (default), XML, or JSON.
Configurable Detail Levels: Output verbosity:
minimal,standard(default),detailed.Dual Mode Operation: Run as a standalone CLI tool or as an integrated MCP server.
Related MCP server: Axon.MCP.Server
Usage Modes
1. Command-Line Interface (CLI)
Run the scanner directly from your terminal. This mode requires the --directory argument specifying the target codebase.
Basic Usage:
node build/index.js --directory /path/to/your/codebaseCommon Options:
-d, --directory <path>: (Required) Absolute or relative path to the directory to scan.-p, --patterns <patterns...>: Glob patterns for file extensions (e.g.,"**/*.ts""**/*.js"). Defaults to JS, TSX, CS, PHP, CSS, PY files.-f, --format <format>: Output format (xml,markdown,json). Default:markdown.-l, --detail <level>: Level of detail (minimal,standard,detailed). Default:standard.--include-types <types...>: Only include specific definition types (e.g.,class,method).--exclude-types <types...>: Exclude specific definition types.--include-modifiers <modifiers...>: Only include definitions with specific modifiers (e.g.,public).--exclude-modifiers <modifiers...>: Exclude definitions with specific modifiers.--name-pattern <regex>: Include definitions matching a JavaScript regex pattern.--exclude-name-pattern <regex>: Exclude definitions matching a JavaScript regex pattern.--include-paths <paths...>: Additional file path patterns (glob) to include.--exclude-paths <paths...>: File path patterns (glob) to exclude.-h, --help: Display detailed help information for all options.
Example (Scan TypeScript files in src, output detailed JSON):
node build/index.js -d ./src -p "**/*.ts" -f json -l detailed2. MCP Server Mode (scan_code tool)
If run without the --directory argument, the tool starts as an MCP server, listening for requests via standard input/output. This allows integration with MCP clients like AI assistants.
Tool Name:
scan_codeDescription: Scans a specified directory for code files and returns a list of definitions according to the provided filters.
Input Schema: Accepts arguments corresponding to the CLI options. The
directoryproperty is required.{ "type": "object", "properties": { "directory": { "type": "string", "description": "Absolute path to the directory to scan." }, "filePatterns": { "type": "array", "items": { "type": "string" }, "description": "Glob patterns for files.", "default": ["**/*.js", ..., "**/*.py"] }, "outputFormat": { "type": "string", "enum": ["xml", "markdown", "json"], "default": "markdown" }, "detailLevel": { "type": "string", "enum": ["minimal", "standard", "detailed"], "default": "standard" }, "includeTypes": { "type": "array", "items": { "type": "string" } }, "excludeTypes": { "type": "array", "items": { "type": "string" } }, "includeModifiers": { "type": "array", "items": { "type": "string" } }, "excludeModifiers": { "type": "array", "items": { "type": "string" } }, "namePattern": { "type": "string", "description": "Regex pattern for names." }, "excludeNamePattern": { "type": "string", "description": "Regex pattern to exclude names." }, "includePaths": { "type": "array", "items": { "type": "string" } }, "excludePaths": { "type": "array", "items": { "type": "string" } } }, "required": ["directory"] }Example Usage with AI Assistant: "Use code-scanner-server scan_code on directory /path/to/project outputting xml format."
Installation
Prerequisites: Ensure you have Node.js and npm installed.
Clone (Optional): If you don't have the code, clone the repository.
# git clone <repository_url> # cd code-scanner-serverInstall Dependencies:
npm installBuild: Compile the TypeScript code.
npm run buildThis creates the executable JavaScript file at
build/index.js.
Configuration (MCP Server)
To use the MCP server mode, add it to your MCP client's configuration file (e.g., claude_desktop_config.json for the desktop app or cline_mcp_settings.json for the VS Code extension).
Important: Replace /path/to/code-scanner-server in the example below with the absolute path to this project's directory on your system.
Example (claude_desktop_config.json / cline_mcp_settings.json):
{
"mcpServers": {
"code-scanner-server": {
"command": "node",
"args": [
"/absolute/path/to/your/code-scanner-server/build/index.js" // <-- Replace this path! (e.g., "C:\\Users\\YourUser\\Projects\\code-scanner-server\\build\\index.js" on Windows)
],
"env": {},
"disabled": false,
"autoApprove": [] // Add tool names here for auto-approval if desired
}
}
}Remember to restart your MCP client application (IDE, Desktop App) after modifying the configuration for changes to take effect.
Development
Watch Mode: Automatically rebuild the project when source files change:
npm run watchDebugging (MCP Mode): Debugging MCP servers over stdio can be complex. Use the MCP Inspector tool for easier debugging:
npm run inspectorThis starts the server with the Node.js inspector attached and provides a URL to connect debugging tools (like Chrome DevTools).
Acknowledgments
This project was significantly developed with the assistance of AI, primarily using Google's Gemini 2.5 Pro model accessed via the Roo Code extension for Visual Studio Code.
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Available Tools
1 toolscan_codeA
Scans a directory for code files (JS, TS, C#, PHP, CSS, respecting .gitignore) and lists definitions (functions, classes, etc.) with line numbers. Supports XML, Markdown, and JSON output.
| Name | Required | Description | Default |
|---|---|---|---|
| detailLevel | No | Level of detail to include in the output. | standard |
| directory | Yes | The absolute path to the directory to scan. Relative paths are not supported. | |
| excludeModifiers | No | Modifiers to exclude. | |
| excludeNamePattern | No | Regex pattern to exclude element names. | |
| excludePaths | No | File path patterns to exclude. | |
| excludeTypes | No | Element types to exclude. | |
| filePatterns | No | Glob patterns for file extensions to include. | |
| includeModifiers | No | Modifiers to include (e.g., public, private). | |
| includePaths | No | Additional file path patterns to include. | |
| includeTypes | No | Element types to include (e.g., class, method). | |
| namePattern | No | Regex pattern to match element names. | |
| outputFormat | No | Output format for the results. | markdown |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: it scans directories, respects .gitignore, lists definitions with line numbers, and supports multiple output formats. However, it does not mention performance aspects (e.g., speed, memory usage), error handling, or whether it's read-only (implied but not stated). The description adds substantial value beyond the schema.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is appropriately sized and front-loaded, with a single sentence that efficiently conveys the core functionality (scanning, listing definitions) and key features (supported languages, .gitignore respect, output formats). Every part earns its place without redundancy or unnecessary detail.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity (12 parameters, no output schema, no annotations), the description is reasonably complete. It covers the main action, supported file types, filtering behavior (.gitignore), and output options. However, it lacks details on return values (since no output schema) and could mention more about error cases or limitations. It's sufficient but not exhaustive.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, so the schema already documents all 12 parameters thoroughly. The description does not add specific parameter semantics beyond what the schema provides (e.g., it mentions output formats but doesn't elaborate on parameter interactions). Baseline score of 3 is appropriate as the schema does the heavy lifting, and the description does not compensate with extra insights.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('scans', 'lists') and resources ('directory for code files', 'definitions with line numbers'). It distinguishes what it does by specifying supported languages (JS, TS, C#, PHP, CSS), respect for .gitignore, and output formats (XML, Markdown, JSON). No sibling tools exist, but the description is comprehensive enough to stand alone.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage context by mentioning 'scans a directory for code files' and output formats, but does not explicitly state when to use this tool versus alternatives. Since there are no sibling tools, this is less critical, but it lacks guidance on prerequisites (e.g., directory accessibility) or exclusions. The implied context is adequate but not explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
1 tool update
v1.0.0- First observed
scan_code
TDQS
With only one tool, there is no possibility of ambiguity or overlap between tools. The tool 'scan_code' has a clear, distinct purpose focused on scanning code files and listing definitions, making it impossible for an agent to misselect between non-existent alternatives.
The single tool name 'scan_code' follows a verb_noun pattern, which is consistent and predictable. Since there is only one tool, there are no deviations or mixed conventions to evaluate, resulting in perfect naming consistency.
A single tool is too few for a server named 'Code Scanner Server', which implies a broader scope of code analysis operations. While 'scan_code' is comprehensive, the lack of additional tools (e.g., for filtering results, analyzing specific file types, or managing scans) makes the set feel thin and underdeveloped for the apparent domain.
The tool set is severely incomplete for a code scanning domain. It covers scanning and listing definitions but lacks essential operations such as filtering results, analyzing code quality, detecting vulnerabilities, or integrating with version control. This creates significant gaps that will likely cause agent failures when trying to perform comprehensive code analysis tasks.
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
An MCP server that gives your AI access to the source code and docs of all public github repos
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
An MCP server that provides tools to discover and retrieve podcast episodes transcripts.
Related MCP Servers
- AlicenseCqualityDmaintenanceA MCP server that transforms code repositories from GitHub, GitLab, or local directories into LLM-friendly formats, preserving context and structure for better AI processing.311Apache 2.0
- FlicenseNot gradedqualityDmaintenanceAn MCP server that transforms codebases into intelligent, queryable knowledge bases, enabling AI assistants to perform semantic search, explore architecture, and analyze code relationships.166-
- AlicenseNot gradedqualityCmaintenanceAn MCP server that provides ultra-efficient code exploration through AST analysis, reducing LLM token usage by up to 95% while enabling instant call graph generation and dependency analysis for massive codebases.MIT
- AlicenseNot gradedqualityDmaintenanceUniversal MCP server that analyzes any codebase and provides structured context to AI assistants. Dynamic, accurate, and token-efficient.14MIT
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/Ixe1/code-scanner-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server