Skip to main content
Glama
MCP TypeScript Server

MCP TypeScript Server

by umutc
README.md
# ๐Ÿš€ MCP TypeScript Server

[![npm version](https://badge.fury.io/js/mcp-typescript-server.svg)](https://badge.fury.io/js/mcp-typescript-server)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue.svg)](https://www.typescriptlang.org/)
[![Node.js](https://img.shields.io/badge/Node.js-16%2B-green.svg)](https://nodejs.org/)

A powerful **Model Context Protocol (MCP) server** that provides TypeScript compilation, type checking, and project management capabilities to AI assistants like Claude.

> ๐ŸŽฏ **Zero Configuration** โ€ข โšก **Lightning Fast** โ€ข ๐Ÿ›ก๏ธ **Production Ready** โ€ข ๐Ÿงช **Battle Tested**

## โœจ Features

### ๐Ÿ”ง **Core Compilation**
- **Single File Compilation**: Compile individual TypeScript files to JavaScript
- **Project Compilation**: Full project compilation with `tsconfig.json` support
- **Watch Mode**: Continuous compilation on file changes
- **Source Maps**: Generate source maps for debugging
- **Multiple Targets**: Support for ES5, ES6, ES2020, and more

### ๐Ÿ” **Advanced Type Checking**
- **Comprehensive Type Analysis**: Full TypeScript type checking
- **Diagnostic Reports**: Detailed error and warning information
- **Strict Mode Support**: Configurable strict type checking
- **Declaration Files**: Support for `.d.ts` files
- **Syntax Validation**: Quick syntax validation without full compilation

### โš™๏ธ **Configuration Management**
- **Dynamic Config Updates**: Modify `tsconfig.json` programmatically
- **Config Creation**: Generate new TypeScript configurations
- **Option Validation**: Validate compiler options before applying
- **Smart Defaults**: Sensible default configurations for new projects

### ๐ŸŽจ **Beautiful Output**
- **Colored Diagnostics**: Beautiful, readable error formatting
- **Progress Indicators**: Real-time compilation progress
- **Summary Reports**: Comprehensive compilation summaries
- **JSON Export**: Machine-readable diagnostic output

## ๐Ÿš€ Quick Start

### Installation

```bash
# Install globally via npm (recommended)
npm install -g mcp-typescript-server

# Or install locally in your project
npm install mcp-typescript-server
```

### Claude Desktop Configuration

Add to your Claude Desktop configuration file:

**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "typescript": {
      "command": "npx",
      "args": ["mcp-typescript-server"]
    }
  }
}
```

### Alternative: Manual Installation

```bash
git clone https://github.com/umutc/mcp-typescript.git
cd mcp-typescript
npm install
npm run build
npm link
```

## ๐Ÿ“š Usage Examples

### ๐Ÿ”จ Compiling TypeScript Files

#### Single File Compilation
```typescript
// Compile a single TypeScript file
compile_typescript({
  filePath: "./src/utils.ts",
  outputDir: "./dist",
  sourceMap: true
})
```

#### Project Compilation
```typescript
// Compile entire project using tsconfig.json
compile_typescript({
  projectPath: "./my-project",
  outputDir: "./build"
})
```

#### Watch Mode
```typescript
// Enable continuous compilation
compile_typescript({
  filePath: "./src/app.ts",
  watch: true,
  sourceMap: true
})
```

### ๐Ÿ” Type Checking

#### Basic Type Checking
```typescript
// Check types for a single file
check_types({
  filePath: "./src/models.ts"
})
```

#### Strict Type Checking
```typescript
// Enable strict mode type checking
check_types({
  filePath: "./src/services/",
  strict: true,
  includeDeclarations: true
})
```

#### Get Detailed Diagnostics
```typescript
// Get formatted diagnostic output
get_diagnostics({
  filePath: "./src/components/Button.tsx",
  formatOutput: "formatted"  // or "json" or "text"
})
```

### โš™๏ธ Configuration Management

#### Update TypeScript Config
```typescript
// Update compiler options
update_tsconfig({
  configPath: "./tsconfig.json",
  options: {
    target: "ES2022",
    strict: true,
    sourceMap: true,
    declaration: true
  }
})
```

#### Create New Config
```typescript
// Create new tsconfig.json with defaults
create_tsconfig({
  projectPath: "./new-project",
  options: {
    target: "ES2020",
    module: "commonjs",
    outDir: "./dist"
  }
})
```

#### Syntax Validation
```typescript
// Quick syntax check without full compilation
validate_syntax({
  filePath: "./src/suspicious-file.ts"
})
```

## ๐Ÿ› ๏ธ Available Tools

| Tool | Description | Parameters |
|------|-------------|------------|
| `compile_typescript` | Compile TypeScript files or projects | `filePath`, `projectPath`, `outputDir`, `sourceMap`, `watch` |
| `check_types` | Perform type checking | `filePath`, `strict`, `includeDeclarations` |
| `get_diagnostics` | Get detailed error information | `filePath`, `formatOutput` |
| `update_tsconfig` | Update TypeScript configuration | `configPath`, `options` |
| `create_tsconfig` | Create new TypeScript configuration | `projectPath`, `options` |
| `validate_syntax` | Quick syntax validation | `filePath` |

## ๐Ÿ’ก Real-World Examples

### ๐ŸŽฏ **React Component Development**
Perfect for developing React components with full type safety:

```bash
# Check types for React components
check_types({ filePath: "./src/components/", strict: true })

# Compile with JSX support
compile_typescript({
  projectPath: "./react-app",
  outputDir: "./build"
})
```

### ๐Ÿš€ **Node.js Backend Development**
Ideal for backend TypeScript projects:

```bash
# Watch mode for development
compile_typescript({
  filePath: "./src/server.ts",
  watch: true,
  outputDir: "./dist"
})

# Strict type checking for production
check_types({
  filePath: "./src/",
  strict: true,
  includeDeclarations: false
})
```

### ๐Ÿ“ฆ **Library Development**
Perfect for TypeScript library development:

```bash
# Generate declaration files
update_tsconfig({
  configPath: "./tsconfig.json",
  options: {
    declaration: true,
    declarationMap: true,
    outDir: "./lib"
  }
})

# Compile library
compile_typescript({
  projectPath: "./",
  sourceMap: true
})
```

## ๐Ÿ”ง Configuration Options

### Compiler Options Support
All standard TypeScript compiler options are supported:

- **Target**: `ES3`, `ES5`, `ES6`, `ES2015`, `ES2016`, `ES2017`, `ES2018`, `ES2019`, `ES2020`, `ES2021`, `ES2022`, `ESNext`
- **Module**: `None`, `CommonJS`, `AMD`, `System`, `UMD`, `ES6`, `ES2015`, `ES2020`, `ES2022`, `ESNext`
- **Module Resolution**: `node`, `classic`
- **And many more...**

### Default Configuration
When creating new `tsconfig.json` files, sensible defaults are applied:

```json
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "moduleResolution": "node",
    "lib": ["ES2020"],
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "declaration": true,
    "sourceMap": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"]
}
```

## ๐ŸŽจ Output Examples

### โœ… Successful Compilation
```
โœ… Compilation successful! (245ms)

Files generated:
- /project/dist/utils.js
- /project/dist/utils.js.map
- /project/dist/models.js
- /project/dist/models.js.map
```

### โŒ Compilation Errors
```
โŒ Compilation failed!

3 error(s):
1. src/utils.ts:15:23 - Type 'string' is not assignable to type 'number' (TS2322)
2. src/models.ts:8:12 - Property 'id' does not exist on type 'User' (TS2339)
3. src/app.ts:45:8 - Cannot find module './missing-file' (TS2307)
```

### ๐Ÿ” Type Checking Results
```
โœ… Type checking passed!

Summary:
- Errors: 0
- Warnings: 2
- Info: 1

Diagnostics:
1. src/components/Button.tsx:12:5 - warning: Unused variable 'theme'
2. src/utils/helpers.ts:34:12 - warning: Parameter 'callback' implicitly has an 'any' type
```

## ๐Ÿค Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

### Development Setup

```bash
git clone https://github.com/umutc/mcp-typescript.git
cd mcp-typescript
npm install
npm run build
npm test
```

### Running Tests

```bash
# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch
```

## ๐Ÿ“‹ Requirements

- **Node.js**: 16.0.0 or higher
- **TypeScript**: 4.5.0 or higher (automatically included)
- **Operating System**: macOS, Linux, Windows

## ๐Ÿšจ Common Issues & Solutions

### Issue: "Cannot find tsconfig.json"
**Solution**: Ensure you're running the command from the project root or specify the correct `projectPath`.

### Issue: "Module resolution failed"
**Solution**: Check your `tsconfig.json` `baseUrl` and `paths` configuration.

### Issue: "Out of memory"
**Solution**: Increase Node.js memory limit: `node --max-old-space-size=4096`

## ๐Ÿ“š Resources

- [TypeScript Documentation](https://www.typescriptlang.org/docs/)
- [Model Context Protocol](https://modelcontextprotocol.io/)
- [Claude Desktop](https://claude.ai/desktop)
- [Issue Tracker](https://github.com/umutc/mcp-typescript/issues)

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐ŸŒŸ Acknowledgments

- [TypeScript Team](https://github.com/microsoft/TypeScript) for the incredible TypeScript compiler
- [Anthropic](https://anthropic.com) for the Model Context Protocol
- [Node.js](https://nodejs.org) community for the excellent ecosystem

---

<div align="center">

**[โญ Star us on GitHub](https://github.com/umutc/mcp-typescript)** โ€ข **[๐Ÿ› Report Bug](https://github.com/umutc/mcp-typescript/issues)** โ€ข **[โœจ Request Feature](https://github.com/umutc/mcp-typescript/issues)**

Made with โค๏ธ by the MCP community

</div>

TDQS

B3.4/5.0

Scored across 6 tools

Disambiguation3/5

compile_typescript, check_types, and validate_syntax are distinguishable by intent (emit vs. type-check vs. syntax-only), but check_types and get_diagnostics blur together: it's unclear whether type checking already returns errors or whether diagnostics must be fetched separately, and no description clarifies their relationship. An agent could reasonably call get_diagnostics after a check or instead of one, leading to misselection.

Naming Consistency5/5

All six tools follow a consistent snake_case verb_noun pattern (compile_typescript, check_types, get_diagnostics, update_tsconfig, create_tsconfig, validate_syntax). The verbs accurately signal read/write/mutate intent, and the only mild inconsistency (tsconfig vs. typescript) is a conventional abbreviation.

Tool Count5/5

Six tools is well-scoped for a TypeScript tooling server: one per major operation (compile, type-check, diagnostics, syntax validate, config create/update). No tool looks like filler, and the surface is small enough to avoid selection overload.

Completeness4/5

Core workflows โ€” compiling, type checking, diagnostics, syntax validation, and tsconfig creation/updating โ€” are all covered. Minor gaps: there is no read/get_tsconfig tool to inspect current configuration before updating, and no way to delete/reset a config, but agents can work around these via compile or update output.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues