📝 feat: update TypeScript configuration and add API support
- Changed root directory in tsconfig.json to include all source files. - Updated server.json to include npm package configuration for claude-code-explorer-mcp. - Enhanced x402 command to support non-interactive mode. - Refactored x402 command call function to simplify argument handling. - Introduced .mcp.json for MCP server configuration. - Added bunfig.toml for Bun development mode configuration. - Created bridge.md documentation for IDE integration and architecture overview. - Added .npmignore to exclude unnecessary files from npm package. - Implemented build-bundle script for production and development builds. - Developed bun-plugin-shims for Bun preload plugin. - Created ci-build.sh for CI/CD build pipeline. - Added dev.ts for development launcher using Bun's TS runtime. - Implemented package-npm.ts to generate a publishable npm package. - Created test-auth.ts to verify API key configuration. - Developed test-mcp.ts for MCP client/server roundtrip testing. - Implemented test-services.ts to ensure all services initialize correctly. - Added stub.ts for bridge functionality when BRIDGE_MODE is disabled.
This commit is contained in:
4
mcp-server/.npmignore
Normal file
4
mcp-server/.npmignore
Normal file
@@ -0,0 +1,4 @@
|
||||
.mcpregistry_*
|
||||
src/
|
||||
tsconfig.json
|
||||
*.ts.new
|
||||
@@ -1,10 +1,18 @@
|
||||
# Claude Code Explorer — MCP Server
|
||||
|
||||
A standalone [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) server that lets any MCP-compatible client explore the Claude Code source code.
|
||||
A standalone [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) server that lets any MCP-compatible client explore the Claude Code source code. Supports **STDIO**, **Streamable HTTP**, and **SSE** transports.
|
||||
|
||||
## What It Does
|
||||
|
||||
Exposes 7 tools, 3 resources, and 5 prompts for navigating the ~1,900-file, 512K+ line Claude Code codebase:
|
||||
Exposes 8 tools, 3 resources, and 5 prompts for navigating the ~1,900-file, 512K+ line Claude Code codebase:
|
||||
|
||||
### Transports
|
||||
|
||||
| Transport | Endpoint | Best For |
|
||||
|-----------|----------|----------|
|
||||
| **STDIO** | `node dist/index.js` | Claude Desktop, local Claude Code, VS Code |
|
||||
| **Streamable HTTP** | `POST/GET /mcp` | Modern MCP clients, remote hosting |
|
||||
| **Legacy SSE** | `GET /sse` + `POST /messages` | Older MCP clients |
|
||||
|
||||
### Tools
|
||||
|
||||
@@ -46,6 +54,30 @@ npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Run Locally (STDIO)
|
||||
|
||||
```bash
|
||||
npm start
|
||||
# or with custom source path:
|
||||
CLAUDE_CODE_SRC_ROOT=/path/to/src npm start
|
||||
```
|
||||
|
||||
### Run Locally (HTTP)
|
||||
|
||||
```bash
|
||||
npm run start:http
|
||||
# Streamable HTTP at http://localhost:3000/mcp
|
||||
# Legacy SSE at http://localhost:3000/sse
|
||||
# Health check at http://localhost:3000/health
|
||||
```
|
||||
|
||||
### With Authentication
|
||||
|
||||
```bash
|
||||
MCP_API_KEY=your-secret-token npm run start:http
|
||||
# Clients must include: Authorization: Bearer your-secret-token
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Claude Desktop
|
||||
@@ -108,6 +140,65 @@ Add to `~/.cursor/mcp.json`:
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `CLAUDE_CODE_SRC_ROOT` | `../src` (relative to dist/) | Path to the Claude Code `src/` directory |
|
||||
| `PORT` | `3000` | HTTP server port (HTTP mode only) |
|
||||
| `MCP_API_KEY` | _(none)_ | Bearer token for HTTP auth (optional) |
|
||||
|
||||
## Remote HTTP Client Configuration
|
||||
|
||||
For Claude Desktop connecting to a remote server:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"claude-code-explorer": {
|
||||
"url": "https://your-deployment.railway.app/mcp",
|
||||
"headers": {
|
||||
"Authorization": "Bearer your-secret-key"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
### Railway
|
||||
|
||||
1. Connect your GitHub repo to [Railway](https://railway.app)
|
||||
2. Railway automatically detects the `mcp-server/Dockerfile`
|
||||
3. Set environment variables in the Railway dashboard:
|
||||
- `MCP_API_KEY` — a secret bearer token
|
||||
- `PORT` is set automatically by Railway
|
||||
4. Deploy — available at `your-app.railway.app`
|
||||
|
||||
Or via CLI:
|
||||
|
||||
```bash
|
||||
railway init
|
||||
railway up
|
||||
```
|
||||
|
||||
### Vercel
|
||||
|
||||
```bash
|
||||
npx vercel
|
||||
```
|
||||
|
||||
Set environment variables in the Vercel dashboard:
|
||||
- `CLAUDE_CODE_SRC_ROOT` — path where src/ files are bundled
|
||||
- `MCP_API_KEY` — bearer token
|
||||
|
||||
> **Note**: Vercel functions are stateless with execution time limits (10s hobby / 60s pro). Best for simple tool calls. For persistent SSE streams, use Railway or Docker.
|
||||
|
||||
### Docker
|
||||
|
||||
```bash
|
||||
# From repo root
|
||||
docker build -f mcp-server/Dockerfile -t claude-code-mcp .
|
||||
docker run -p 3000:3000 -e MCP_API_KEY=your-secret claude-code-mcp
|
||||
```
|
||||
|
||||
Works on any Docker host: Fly.io, Render, AWS ECS, Google Cloud Run, etc.
|
||||
|
||||
## Prompts
|
||||
|
||||
@@ -162,9 +253,27 @@ Registry name: `io.github.nirholas/claude-code-explorer-mcp`
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run dev # Run directly with tsx (no build needed)
|
||||
npm run dev # Watch mode TypeScript compilation
|
||||
npm run build # Compile TypeScript to dist/
|
||||
npm start # Run compiled server
|
||||
npm start # Run STDIO server
|
||||
npm run start:http # Run HTTP server
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
mcp-server/
|
||||
├── src/
|
||||
│ ├── server.ts — Shared MCP server (tools, resources, prompts) — transport-agnostic
|
||||
│ ├── index.ts — STDIO entrypoint (local)
|
||||
│ └── http.ts — HTTP + SSE entrypoint (remote)
|
||||
├── api/
|
||||
│ ├── index.ts — Vercel serverless function
|
||||
│ └── vercelApp.ts — Express app for Vercel
|
||||
├── Dockerfile — Docker build (Railway, Fly.io, etc.)
|
||||
├── railway.json — Railway deployment config
|
||||
├── package.json
|
||||
└── tsconfig.json
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
||||
"name": "io.github.nirholas/claude-code-explorer-mcp",
|
||||
"title": "Claude Code Explorer MCP",
|
||||
"description": "MCP server for exploring the Claude Code CLI source code — browse 40+ tools, 50+ commands, search the full 512K-line codebase, and get architecture overviews.",
|
||||
"description": "Explore the Claude Code CLI source — browse tools, commands, search code, and more.",
|
||||
"repository": {
|
||||
"url": "https://github.com/nirholas/claude-code",
|
||||
"source": "github",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"module": "Node16",
|
||||
"moduleResolution": "Node16",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"rootDir": ".",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
@@ -14,7 +14,7 @@
|
||||
"declarationMap": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"include": ["src/**/*", "api/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user