A Model Context Protocol (MCP) server for TypeScript static code analysis using ts-morph. This tool provides deep code analysis capabilities for understanding TypeScript codebases.
- File Analysis: Extract symbols, imports, and exports from TypeScript files
- Symbol Analysis: Get detailed information about functions, classes, interfaces, and types
- Reference Finding: Track all usages of a symbol across your codebase
- Compilation Errors: Get TypeScript compilation diagnostics without building
npm install # Install dependencies
npm run build # Build the TypeScript projectThe server can be installed to multiple MCP-compatible clients. Each installation method configures the client to use the published npm package (@r-mcp/static-analysis), ensuring you always get the latest version.
npm run install-server # Installs to all supported clients# Production Clients (using npm package)
npm run install-cursor # Cursor IDE (~/.cursor/mcp.json)
npm run install-desktop # Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json)
npm run install-code # Claude Code CLI (~/.claude/mcp.json)
# Development/Testing
npm run install-mcp # Local development (.mcp.json in project root)The installation scripts automatically:
- Build the TypeScript project
- Configure the client to use
npx -y @r-mcp/static-analysis@latest - Include any environment variables from
.env.localif present - Update the client's MCP configuration file
- Cursor IDE: Restart or refresh MCP settings
- Claude Desktop: Restart the application
- Claude Code: Restart the CLI with the new configuration
- Local Development: The
.mcp.jsonfile is created for testing
Quickly analyze a TypeScript file to extract all symbols, imports, and exports.
Parameters:
filePath(string, required): Path to the TypeScript fileanalysisType(enum): "symbols", "dependencies", or "all" (default: "all")includeDefinition(boolean): Include symbol definition locations (default: false)
Get detailed analysis of a specific symbol including parameters, return types, and members.
Parameters:
symbolIdentifier(object, required):filePath(string): Path to the filesymbolName(string): Name of the symbolline(number): Line number where symbol appears (1-based)
maxTypeLength(number): Maximum type string length (default: unlimited)
Find all references to a symbol across the codebase for understanding usage patterns.
Parameters:
symbolIdentifier(object, required):filePath(string): Path to the filesymbolName(string): Name of the symbolline(number): Line number where symbol appears (1-based)
maxResults(number): Maximum references to return (default: 100)
Get TypeScript compilation errors without building the project.
Parameters:
path(string, required): File or directory path to analyzeincludeWarnings(boolean): Include warnings (default: true)includeInfo(boolean): Include info messages (default: false)filePattern(string): Glob pattern for files (default: "**/*.{ts,tsx}")maxFiles(number): Maximum files to analyze (default: 25)verbosity(enum): "minimal", "normal", or "detailed" (default: "normal")
- Intelligent Caching: Automatically caches parsed files for faster analysis
- Parallel Processing: Handles multiple files concurrently
- Memory Management: Built-in memory monitoring to prevent crashes
- Error Recovery: Graceful handling of TypeScript errors and invalid files
The server automatically detects and uses your project's tsconfig.json file for accurate type analysis. No additional configuration is required.
// Analyze src/index.ts
await mcp.analyze_file({
filePath: "./src/index.ts",
analysisType: "all"
})// Get details about a UserService class on line 25
await mcp.analyze_symbol({
symbolIdentifier: {
filePath: "./src/services/user.ts",
symbolName: "UserService",
line: 25
}
})// Find where getUserById is used
await mcp.find_references({
symbolIdentifier: {
filePath: "./src/api/users.ts",
symbolName: "getUserById",
line: 42
}
})// Check entire src directory for errors
await mcp.get_compilation_errors({
path: "./src",
verbosity: "normal"
})To release a new version to npm:
npm run release # Builds, commits, and publishes to npmThis command handles the complete release process including version bumping, git operations, and npm publishing.
- Node.js 18+
- TypeScript project with
tsconfig.json
MIT