Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (typeref-mcp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
๐ TypeRef-MCP
Professional TypeScript Type Inference & Symbol Navigation for Claude Code
Bringing IDE-grade TypeScript intelligence to your AI coding assistant
โจ Features
- ๐ฏ Precise Type Inference: Get exact TypeScript type information using the compiler API
- ๐งญ Symbol Navigation: Find definitions, references, and usages with full type context
- ๐ก IntelliSense Intelligence: Professional IDE-grade type analysis and suggestions
- โก Real-time Analysis: Live type checking and diagnostics as you code
- ๐๏ธ Extensible Architecture: Designed to support multiple typed languages
- ๐ Hot Reload Support: Watches for file changes and updates analysis automatically
๐ Installation
Prerequisites: Node.js 18+ required
Option 1: NPM (Recommended)
# Global installation
npm install -g typeref-mcp
# Or with pnpm
pnpm add -g typeref-mcp
# Or with yarn
yarn global add typeref-mcpOption 2: From GitHub
# Install directly from GitHub
npm install -g github:Coldsewoo/typeref-mcpOption 3: From Source
# Clone and build
git clone https://github.com/Coldsewoo/typeref-mcp.git
cd typeref-mcp
npm install
npm run build
npm link๐ง Configuration
Claude Code Setup
Add TypeRef-MCP to your Claude Code MCP configuration:
{
"mcpServers": {
"typeref": {
"command": "typeref-mcp",
"args": [],
"env": {
"NODE_ENV": "production"
}
}
}
}Alternative Configurations
Local Installation
If installed locally in your project:
{
"mcpServers": {
"typeref": {
"command": "node",
"args": ["./node_modules/.bin/typeref-mcp"],
"env": {}
}
}
}Development Mode
For development with hot reload:
{
"mcpServers": {
"typeref": {
"command": "typeref-mcp",
"args": ["--watch"],
"env": {
"NODE_ENV": "development",
"DEBUG": "typeref:*"
}
}
}
}Custom TypeScript Config
Specify a custom tsconfig.json:
{
"mcpServers": {
"typeref": {
"command": "typeref-mcp",
"args": ["--config", "./custom-tsconfig.json"],
"env": {}
}
}
}๐ ๏ธ Available Tools
TypeRef-MCP provides the following tools for Claude Code:
| Tool | Description | Usage |
|---|---|---|
infer_type |
Get precise type information for any TypeScript expression | Analyze variable types, function signatures, complex expressions |
find_definition |
Navigate to symbol definitions with type context | Jump to function/class/interface definitions |
find_references |
Locate all usages of a symbol | Find where variables, functions, types are used |
analyze_project |
Get comprehensive project analysis | Overview of modules, exports, dependencies |
check_diagnostics |
Get real-time type checking errors | Identify compilation errors and warnings |
๐ Usage Examples
Basic Type Inference
// Ask Claude: "What's the type of this variable?"
const user = { name: "John", age: 30, active: true };
// TypeRef-MCP will return:
// Type: { name: string; age: number; active: boolean; }Advanced Type Analysis
// Complex generic types
function createStore<T extends Record<string, any>>(initial: T) {
return {
state: initial,
update: (partial: Partial<T>) => ({ ...initial, ...partial })
};
}
// TypeRef-MCP provides complete generic resolution and return typesSymbol Navigation
// Find all references to a function across your project
export function calculateTax(amount: number): number {
return amount * 0.1;
}
// TypeRef-MCP will show all imports and usages with context๐๏ธ Architecture
graph TB
A[Claude Code] --> B[TypeRef-MCP Server]
B --> C[Language Adapters]
C --> D[TypeScript Adapter]
D --> E[ts-morph + TS Compiler API]
B --> F[Core Services]
F --> G[Project Indexer]
F --> H[Type Resolver]
F --> I[Symbol Navigator]
F --> J[Cache Manager]
B --> K[MCP Tools]
K --> L[infer_type]
K --> M[find_definition]
K --> N[find_references]
K --> O[analyze_project]
K --> P[check_diagnostics]๐ง Development
# Development mode with hot reload
npm run dev
# Watch mode for file changes
npm run watch
# Build for production
npm run build
# Code quality
npm run lint
npm run format
# Testing
npm test
npm run test:watchโก Performance Features
TypeRef-MCP includes advanced performance optimizations for handling large TypeScript projects:
๐ Automatic Optimizations
- Smart Exclusions: Automatically excludes
node_modules, test files, and build directories - Incremental Compilation: Uses TypeScript's incremental mode with
.tsbuildinfocaching - Memory Management: Automatic cleanup of idle projects and memory monitoring
- Intelligent Caching: Multi-level caching with TTL and pattern-based invalidation
๐ง Development Mode Features
Enable development mode for enhanced monitoring and debugging:
# Enable development monitoring
NODE_ENV=development typeref-mcp
# Or with debug output
DEBUG=typeref:* typeref-mcpDevelopment Features:
- ๐ Performance metrics every 5 minutes
- โ ๏ธ Slow operation warnings (>1s)
- ๐ Memory usage tracking
- ๐ Tool call statistics and timing
๐งน Automatic Cleanup
- Idle Projects: Removes unused projects after 20 minutes of inactivity
- Memory Limits: Cleans up projects exceeding 100MB memory usage
- Cache Expiration: Intelligent cache cleanup every 5 minutes
- Graceful Shutdown: Proper resource cleanup on server stop
๐ Troubleshooting
TypeRef-MCP not starting
Check Node.js version: Ensure you're running Node.js 18+
node --version
Verify installation:
npm list -g typeref-mcp
Check TypeScript project: Ensure your project has a valid
tsconfig.json
Type inference not working
- Project indexing: TypeRef-MCP automatically indexes your project on first use
- Large projects: Initial analysis is optimized but may take a few moments
- TypeScript errors: The server handles most compilation errors gracefully
Performance optimization
TypeRef-MCP handles performance issues automatically with built-in optimizations.
For monitoring performance in development:
DEBUG=typeref:* NODE_ENV=development typeref-mcp๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with โค๏ธ by Coldsewoo
If you find TypeRef-MCP useful, please consider giving it a โญ on GitHub!