# Directory Structure
```
├── .gitignore
├── Dockerfile
├── index.ts
├── LICENSE
├── package-lock.json
├── package.json
├── README.md
└── tsconfig.json
```
# Files
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
```
1 | node_modules
2 | dist
3 | build
```
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
```markdown
1 | # MCP Create Server
2 |
3 | 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.
4 |
5 | <a href="https://glama.ai/mcp/servers/lnl6xjkkeq">
6 | <img width="380" height="200" src="https://glama.ai/mcp/servers/lnl6xjkkeq/badge" alt="Create Server MCP server" />
7 | </a>
8 |
9 | ## Key Features
10 |
11 | - Dynamic creation and execution of MCP server code
12 | - Support for TypeScript only (JavaScript and Python support planned for future releases)
13 | - Tool execution on child MCP servers
14 | - Server code updates and restarts
15 | - Removal of unnecessary servers
16 |
17 | ## Installation
18 |
19 | **Note: Docker is the recommended way to run this service**
20 |
21 | ### Docker Installation (Recommended)
22 |
23 | ```bash
24 | # Build Docker image
25 | docker build -t mcp-create .
26 |
27 | # Run Docker container
28 | docker run -it --rm mcp-create
29 | ```
30 |
31 | ### Manual Installation (TypeScript Only)
32 |
33 | ```bash
34 | # Clone repository
35 | git clone https://github.com/tesla0225/mcp-create.git
36 | cd mcp-create
37 |
38 | # Install dependencies
39 | npm install
40 |
41 | # Build
42 | npm run build
43 |
44 | # Run
45 | npm start
46 | ```
47 |
48 | ## Integration with Claude Desktop
49 |
50 | Add the following to your Claude Desktop configuration file (`claude_desktop_config.json`):
51 |
52 | ```json
53 | {
54 | "mcpServers": {
55 | "mcp-create": {
56 | "command": "docker",
57 | "args": ["run", "-i", "--rm", "mcp-create"]
58 | }
59 | }
60 | }
61 | ```
62 |
63 | ## Available Tools
64 |
65 | | Tool Name | Description | Input Parameters | Output |
66 | |-----------|-------------|-----------------|--------|
67 | | create-server-from-template | Create MCP server from template | language: string | { serverId: string, message: string } |
68 | | execute-tool | Execute tool on server | serverId: string<br>toolName: string<br>args: object | Tool execution result |
69 | | get-server-tools | Get list of server tools | serverId: string | { tools: ToolDefinition[] } |
70 | | delete-server | Delete server | serverId: string | { success: boolean, message: string } |
71 | | list-servers | Get list of running servers | none | { servers: string[] } |
72 |
73 | ## Usage Examples
74 |
75 | ### Creating a New Server
76 |
77 | ```json
78 | {
79 | "name": "create-server-from-template",
80 | "arguments": {
81 | "language": "typescript"
82 | }
83 | }
84 | ```
85 |
86 | ### Executing a Tool
87 |
88 | ```json
89 | {
90 | "name": "execute-tool",
91 | "arguments": {
92 | "serverId": "ba7c9a4f-6ba8-4cad-8ec8-a41a08c19fac",
93 | "toolName": "echo",
94 | "args": {
95 | "message": "Hello, dynamic MCP server!"
96 | }
97 | }
98 | }
99 | ```
100 |
101 | ## Technical Specifications
102 |
103 | - Node.js 18 or higher
104 | - TypeScript (required)
105 | - Dependencies:
106 | - @modelcontextprotocol/sdk: MCP client/server implementation
107 | - child_process (Node.js built-in): Child process management
108 | - fs/promises (Node.js built-in): File operations
109 | - uuid: Unique server ID generation
110 |
111 | ## Security Considerations
112 |
113 | - **Code Execution Restrictions:** Consider sandboxing as the service executes arbitrary code
114 | - **Resource Limitations:** Set limits on memory, CPU usage, number of files, etc.
115 | - **Process Monitoring:** Monitor and forcibly terminate zombie or runaway processes
116 | - **Path Validation:** Properly validate file paths to prevent directory traversal attacks
117 |
118 | ## License
119 |
120 | MIT
```
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
```json
1 | {
2 | "name": "mcp-create",
3 | "version": "1.0.0",
4 | "main": "build/index.js",
5 | "type": "module",
6 | "bin": {
7 | "mcp-create": "./build/index.js"
8 | },
9 | "dependencies": {
10 | "@modelcontextprotocol/sdk": "^1.0.0",
11 | "uuid": "^9.0.1",
12 | "zod": "^3.22.4"
13 | },
14 | "devDependencies": {
15 | "@types/node": "^20.10.0",
16 | "@types/uuid": "^9.0.8",
17 | "typescript": "^5.3.2"
18 | },
19 | "scripts": {
20 | "build": "tsc",
21 | "postbuild": "chmod +x build/index.js",
22 | "start": "node build/index.js"
23 | },
24 | "files": [
25 | "build"
26 | ]
27 | }
28 |
```
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
```dockerfile
1 | # ビルドステージ
2 | FROM node:20-slim AS builder
3 |
4 | WORKDIR /app
5 | COPY package*.json ./
6 | RUN npm install
7 | COPY . .
8 | RUN npm run build
9 |
10 | # 実行ステージ
11 | FROM node:20-slim
12 |
13 | RUN apt-get update && \
14 | apt-get install -y --no-install-recommends \
15 | python3-minimal \
16 | python3-pip \
17 | curl \
18 | which && \
19 | apt-get clean && \
20 | rm -rf /var/lib/apt/lists/* && \
21 | ln -sf /usr/bin/python3 /usr/bin/python && \
22 | npm install -g ts-node typescript
23 |
24 | ENV PATH="/usr/local/bin:/usr/bin:/bin:${PATH}"
25 | ENV NODE_PATH="/app/node_modules"
26 | ENV PYTHONUNBUFFERED=1
27 |
28 | WORKDIR /app
29 | COPY --from=builder /app/build ./build
30 | COPY --from=builder /app/node_modules ./node_modules
31 | # package.jsonをコピーして"type": "module"設定を確実に継承
32 | COPY --from=builder /app/package*.json ./
33 |
34 | RUN chmod +x build/index.js && \
35 | mkdir -p /tmp/mcp-create-servers && \
36 | chmod 777 /tmp/mcp-create-servers
37 |
38 | CMD ["node", "build/index.js"]
```