#
tokens: 1366/50000 4/4 files
lines: off (toggle) GitHub
raw markdown copy
# Directory Structure

```
├── .gitignore
├── Dockerfile
├── index.ts
├── LICENSE
├── package-lock.json
├── package.json
├── README.md
└── tsconfig.json
```

# Files

--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------

```
node_modules
dist
build
```

--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------

```markdown
# MCP Create Server

A dynamic MCP server management service that creates, runs, and manages Model Context Protocol (MCP) servers dynamically. This service itself functions as an MCP server and launches/manages other MCP servers as child processes, enabling a flexible MCP ecosystem.

<a href="https://glama.ai/mcp/servers/lnl6xjkkeq">
  <img width="380" height="200" src="https://glama.ai/mcp/servers/lnl6xjkkeq/badge" alt="Create Server MCP server" />
</a>

## Key Features

- Dynamic creation and execution of MCP server code
- Support for TypeScript only (JavaScript and Python support planned for future releases)
- Tool execution on child MCP servers
- Server code updates and restarts
- Removal of unnecessary servers

## Installation

**Note: Docker is the recommended way to run this service**

### Docker Installation (Recommended)

```bash
# Build Docker image
docker build -t mcp-create .

# Run Docker container
docker run -it --rm mcp-create
```

### Manual Installation (TypeScript Only)

```bash
# Clone repository
git clone https://github.com/tesla0225/mcp-create.git
cd mcp-create

# Install dependencies
npm install

# Build
npm run build

# Run
npm start
```

## Integration with Claude Desktop

Add the following to your Claude Desktop configuration file (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "mcp-create": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "mcp-create"]
    }
  }
}
```

## Available Tools

| Tool Name | Description | Input Parameters | Output |
|-----------|-------------|-----------------|--------|
| create-server-from-template | Create MCP server from template | language: string | { serverId: string, message: string } |
| execute-tool | Execute tool on server | serverId: string<br>toolName: string<br>args: object | Tool execution result |
| get-server-tools | Get list of server tools | serverId: string | { tools: ToolDefinition[] } |
| delete-server | Delete server | serverId: string | { success: boolean, message: string } |
| list-servers | Get list of running servers | none | { servers: string[] } |

## Usage Examples

### Creating a New Server

```json
{
  "name": "create-server-from-template",
  "arguments": {
    "language": "typescript"
  }
}
```

### Executing a Tool

```json
{
  "name": "execute-tool",
  "arguments": {
    "serverId": "ba7c9a4f-6ba8-4cad-8ec8-a41a08c19fac",
    "toolName": "echo",
    "args": {
      "message": "Hello, dynamic MCP server!"
    }
  }
}
```

## Technical Specifications

- Node.js 18 or higher
- TypeScript (required)
- Dependencies:
  - @modelcontextprotocol/sdk: MCP client/server implementation
  - child_process (Node.js built-in): Child process management
  - fs/promises (Node.js built-in): File operations
  - uuid: Unique server ID generation

## Security Considerations

- **Code Execution Restrictions:** Consider sandboxing as the service executes arbitrary code
- **Resource Limitations:** Set limits on memory, CPU usage, number of files, etc.
- **Process Monitoring:** Monitor and forcibly terminate zombie or runaway processes
- **Path Validation:** Properly validate file paths to prevent directory traversal attacks

## License

MIT
```

--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------

```json
{
  "name": "mcp-create",
  "version": "1.0.0",
  "main": "build/index.js",
  "type": "module",
  "bin": {
    "mcp-create": "./build/index.js"
  },
  "dependencies": {
    "@modelcontextprotocol/sdk": "^1.0.0",
    "uuid": "^9.0.1",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@types/node": "^20.10.0",
    "@types/uuid": "^9.0.8",
    "typescript": "^5.3.2"
  },
  "scripts": {
    "build": "tsc",
    "postbuild": "chmod +x build/index.js",
    "start": "node build/index.js"
  },
  "files": [
    "build"
  ]
}

```

--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------

```dockerfile
# ビルドステージ
FROM node:20-slim AS builder

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# 実行ステージ
FROM node:20-slim

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    python3-minimal \
    python3-pip \
    curl \
    which && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* && \
    ln -sf /usr/bin/python3 /usr/bin/python && \
    npm install -g ts-node typescript

ENV PATH="/usr/local/bin:/usr/bin:/bin:${PATH}"
ENV NODE_PATH="/app/node_modules"
ENV PYTHONUNBUFFERED=1

WORKDIR /app
COPY --from=builder /app/build ./build
COPY --from=builder /app/node_modules ./node_modules
# package.jsonをコピーして"type": "module"設定を確実に継承
COPY --from=builder /app/package*.json ./

RUN chmod +x build/index.js && \
    mkdir -p /tmp/mcp-create-servers && \
    chmod 777 /tmp/mcp-create-servers

CMD ["node", "build/index.js"]
```