@titikaka2026/mcptools 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +328 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +17 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/create.d.ts +3 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +564 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/inspect.d.ts +3 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +140 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/test.d.ts +3 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +125 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/wrap.d.ts +3 -0
- package/dist/commands/wrap.d.ts.map +1 -0
- package/dist/commands/wrap.js +114 -0
- package/dist/commands/wrap.js.map +1 -0
- package/dist/core/client.d.ts +21 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +144 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/validator.d.ts +13 -0
- package/dist/core/validator.d.ts.map +1 -0
- package/dist/core/validator.js +120 -0
- package/dist/core/validator.js.map +1 -0
- package/dist/core/wrap-cli.d.ts +3 -0
- package/dist/core/wrap-cli.d.ts.map +1 -0
- package/dist/core/wrap-cli.js +144 -0
- package/dist/core/wrap-cli.js.map +1 -0
- package/dist/core/wrap-rest.d.ts +4 -0
- package/dist/core/wrap-rest.d.ts.map +1 -0
- package/dist/core/wrap-rest.js +157 -0
- package/dist/core/wrap-rest.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +93 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import ora from "ora";
|
|
6
|
+
export const createCommand = new Command("create")
|
|
7
|
+
.description("Scaffold a new MCP server project from a template")
|
|
8
|
+
.argument("<name>", "Name of the MCP server project")
|
|
9
|
+
.option("-t, --template <template>", "Template to use", "basic")
|
|
10
|
+
.option("-l, --language <lang>", "Language: typescript or python", "typescript")
|
|
11
|
+
.option("--no-git", "Skip git initialization")
|
|
12
|
+
.action(async (name, options) => {
|
|
13
|
+
const spinner = ora(`Creating MCP server project: ${name}`).start();
|
|
14
|
+
try {
|
|
15
|
+
const projectDir = join(process.cwd(), name);
|
|
16
|
+
await mkdir(projectDir, { recursive: true });
|
|
17
|
+
await mkdir(join(projectDir, "src"), { recursive: true });
|
|
18
|
+
if (options.language === "typescript") {
|
|
19
|
+
await scaffoldTypeScript(projectDir, name, options.template);
|
|
20
|
+
}
|
|
21
|
+
else if (options.language === "python") {
|
|
22
|
+
await scaffoldPython(projectDir, name, options.template);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
spinner.fail(`Unsupported language: ${options.language}`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
spinner.succeed(chalk.green(`Created MCP server project: ${name}`));
|
|
29
|
+
console.log();
|
|
30
|
+
console.log(chalk.bold("Next steps:"));
|
|
31
|
+
console.log(` cd ${name}`);
|
|
32
|
+
if (options.language === "typescript") {
|
|
33
|
+
console.log(" npm install");
|
|
34
|
+
console.log(" npm run build");
|
|
35
|
+
console.log(` mcptools test --command "node dist/index.js"`);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.log(" pip install -r requirements.txt");
|
|
39
|
+
console.log(` mcptools test --command "python server.py"`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
spinner.fail(chalk.red(`Failed to create project: ${err.message}`));
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
async function scaffoldTypeScript(dir, name, template) {
|
|
48
|
+
// package.json
|
|
49
|
+
await writeFile(join(dir, "package.json"), JSON.stringify({
|
|
50
|
+
name,
|
|
51
|
+
version: "0.1.0",
|
|
52
|
+
description: `${name} — an MCP server`,
|
|
53
|
+
type: "module",
|
|
54
|
+
main: "dist/index.js",
|
|
55
|
+
scripts: {
|
|
56
|
+
build: "tsc",
|
|
57
|
+
dev: "tsc --watch",
|
|
58
|
+
start: "node dist/index.js",
|
|
59
|
+
},
|
|
60
|
+
dependencies: {},
|
|
61
|
+
devDependencies: {
|
|
62
|
+
"@types/node": "^22.0.0",
|
|
63
|
+
typescript: "^5.6.0",
|
|
64
|
+
},
|
|
65
|
+
}, null, 2));
|
|
66
|
+
// tsconfig.json
|
|
67
|
+
await writeFile(join(dir, "tsconfig.json"), JSON.stringify({
|
|
68
|
+
compilerOptions: {
|
|
69
|
+
target: "ES2022",
|
|
70
|
+
module: "ES2022",
|
|
71
|
+
moduleResolution: "node16",
|
|
72
|
+
outDir: "./dist",
|
|
73
|
+
rootDir: "./src",
|
|
74
|
+
declaration: true,
|
|
75
|
+
strict: true,
|
|
76
|
+
esModuleInterop: true,
|
|
77
|
+
skipLibCheck: true,
|
|
78
|
+
},
|
|
79
|
+
include: ["src/**/*"],
|
|
80
|
+
}, null, 2));
|
|
81
|
+
// Main server file
|
|
82
|
+
const serverCode = template === "tools"
|
|
83
|
+
? getToolsTemplate(name)
|
|
84
|
+
: template === "resources"
|
|
85
|
+
? getResourcesTemplate(name)
|
|
86
|
+
: getBasicTemplate(name);
|
|
87
|
+
await writeFile(join(dir, "src", "index.ts"), serverCode);
|
|
88
|
+
// README
|
|
89
|
+
await writeFile(join(dir, "README.md"), `# ${name}
|
|
90
|
+
|
|
91
|
+
An MCP server built with [mcptools](https://github.com/titikaka2024/mcptools).
|
|
92
|
+
|
|
93
|
+
## Setup
|
|
94
|
+
|
|
95
|
+
\`\`\`bash
|
|
96
|
+
npm install
|
|
97
|
+
npm run build
|
|
98
|
+
\`\`\`
|
|
99
|
+
|
|
100
|
+
## Test
|
|
101
|
+
|
|
102
|
+
\`\`\`bash
|
|
103
|
+
mcptools test --command "node dist/index.js"
|
|
104
|
+
\`\`\`
|
|
105
|
+
|
|
106
|
+
## Usage
|
|
107
|
+
|
|
108
|
+
Add to your MCP client config:
|
|
109
|
+
|
|
110
|
+
\`\`\`json
|
|
111
|
+
{
|
|
112
|
+
"mcpServers": {
|
|
113
|
+
"${name}": {
|
|
114
|
+
"command": "node",
|
|
115
|
+
"args": ["${name}/dist/index.js"]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
\`\`\`
|
|
120
|
+
`);
|
|
121
|
+
// .gitignore
|
|
122
|
+
await writeFile(join(dir, ".gitignore"), "node_modules/\ndist/\n*.tsbuildinfo\n");
|
|
123
|
+
}
|
|
124
|
+
async function scaffoldPython(dir, name, _template) {
|
|
125
|
+
await writeFile(join(dir, "server.py"), `#!/usr/bin/env python3
|
|
126
|
+
"""${name} — an MCP server."""
|
|
127
|
+
|
|
128
|
+
import json
|
|
129
|
+
import sys
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
SERVER_INFO = {
|
|
133
|
+
"name": "${name}",
|
|
134
|
+
"version": "0.1.0",
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
TOOLS = [
|
|
138
|
+
{
|
|
139
|
+
"name": "hello",
|
|
140
|
+
"description": "Say hello to someone",
|
|
141
|
+
"inputSchema": {
|
|
142
|
+
"type": "object",
|
|
143
|
+
"properties": {
|
|
144
|
+
"name": {"type": "string", "description": "Name to greet"}
|
|
145
|
+
},
|
|
146
|
+
"required": ["name"],
|
|
147
|
+
},
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def handle_request(request: dict) -> dict | None:
|
|
153
|
+
method = request.get("method")
|
|
154
|
+
req_id = request.get("id")
|
|
155
|
+
|
|
156
|
+
if method == "initialize":
|
|
157
|
+
return {
|
|
158
|
+
"jsonrpc": "2.0",
|
|
159
|
+
"id": req_id,
|
|
160
|
+
"result": {
|
|
161
|
+
"protocolVersion": "2024-11-05",
|
|
162
|
+
"capabilities": {"tools": {}},
|
|
163
|
+
"serverInfo": SERVER_INFO,
|
|
164
|
+
},
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if method == "tools/list":
|
|
168
|
+
return {"jsonrpc": "2.0", "id": req_id, "result": {"tools": TOOLS}}
|
|
169
|
+
|
|
170
|
+
if method == "tools/call":
|
|
171
|
+
tool_name = request.get("params", {}).get("name")
|
|
172
|
+
arguments = request.get("params", {}).get("arguments", {})
|
|
173
|
+
return handle_tool_call(req_id, tool_name, arguments)
|
|
174
|
+
|
|
175
|
+
if req_id is not None:
|
|
176
|
+
return {
|
|
177
|
+
"jsonrpc": "2.0",
|
|
178
|
+
"id": req_id,
|
|
179
|
+
"error": {"code": -32601, "message": f"Method not found: {method}"},
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return None
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def handle_tool_call(req_id, tool_name: str, args: dict) -> dict:
|
|
186
|
+
if tool_name == "hello":
|
|
187
|
+
name = args.get("name", "World")
|
|
188
|
+
text = f"Hello, {name}!"
|
|
189
|
+
return {
|
|
190
|
+
"jsonrpc": "2.0",
|
|
191
|
+
"id": req_id,
|
|
192
|
+
"result": {"content": [{"type": "text", "text": text}]},
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
"jsonrpc": "2.0",
|
|
197
|
+
"id": req_id,
|
|
198
|
+
"result": {
|
|
199
|
+
"content": [{"type": "text", "text": f"Unknown tool: {tool_name}"}],
|
|
200
|
+
"isError": True,
|
|
201
|
+
},
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def main():
|
|
206
|
+
buffer = ""
|
|
207
|
+
for line in sys.stdin:
|
|
208
|
+
line = line.strip()
|
|
209
|
+
if not line:
|
|
210
|
+
continue
|
|
211
|
+
try:
|
|
212
|
+
request = json.loads(line)
|
|
213
|
+
response = handle_request(request)
|
|
214
|
+
if response:
|
|
215
|
+
sys.stdout.write(json.dumps(response) + "\\n")
|
|
216
|
+
sys.stdout.flush()
|
|
217
|
+
except json.JSONDecodeError:
|
|
218
|
+
pass
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
if __name__ == "__main__":
|
|
222
|
+
main()
|
|
223
|
+
`);
|
|
224
|
+
await writeFile(join(dir, "requirements.txt"), "# Add your dependencies here\n");
|
|
225
|
+
await writeFile(join(dir, ".gitignore"), "__pycache__/\n*.pyc\n.venv/\n");
|
|
226
|
+
await writeFile(join(dir, "README.md"), `# ${name}
|
|
227
|
+
|
|
228
|
+
An MCP server built with [mcptools](https://github.com/titikaka2024/mcptools).
|
|
229
|
+
|
|
230
|
+
## Setup
|
|
231
|
+
|
|
232
|
+
\`\`\`bash
|
|
233
|
+
pip install -r requirements.txt
|
|
234
|
+
\`\`\`
|
|
235
|
+
|
|
236
|
+
## Test
|
|
237
|
+
|
|
238
|
+
\`\`\`bash
|
|
239
|
+
mcptools test --command "python server.py"
|
|
240
|
+
\`\`\`
|
|
241
|
+
`);
|
|
242
|
+
}
|
|
243
|
+
function getBasicTemplate(name) {
|
|
244
|
+
return `#!/usr/bin/env node
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* ${name} — a basic MCP server
|
|
248
|
+
* Generated by mcptools
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
const SERVER_INFO = {
|
|
252
|
+
name: "${name}",
|
|
253
|
+
version: "0.1.0",
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const TOOLS = [
|
|
257
|
+
{
|
|
258
|
+
name: "hello",
|
|
259
|
+
description: "Say hello to someone",
|
|
260
|
+
inputSchema: {
|
|
261
|
+
type: "object",
|
|
262
|
+
properties: {
|
|
263
|
+
name: { type: "string", description: "Name to greet" },
|
|
264
|
+
},
|
|
265
|
+
required: ["name"],
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
];
|
|
269
|
+
|
|
270
|
+
function handleRequest(request: { method?: string; id?: number | string; params?: any }) {
|
|
271
|
+
const { method, id, params } = request;
|
|
272
|
+
|
|
273
|
+
switch (method) {
|
|
274
|
+
case "initialize":
|
|
275
|
+
return {
|
|
276
|
+
jsonrpc: "2.0",
|
|
277
|
+
id,
|
|
278
|
+
result: {
|
|
279
|
+
protocolVersion: "2024-11-05",
|
|
280
|
+
capabilities: { tools: {} },
|
|
281
|
+
serverInfo: SERVER_INFO,
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
case "tools/list":
|
|
286
|
+
return { jsonrpc: "2.0", id, result: { tools: TOOLS } };
|
|
287
|
+
|
|
288
|
+
case "tools/call":
|
|
289
|
+
return handleToolCall(id, params?.name, params?.arguments ?? {});
|
|
290
|
+
|
|
291
|
+
default:
|
|
292
|
+
if (id !== undefined) {
|
|
293
|
+
return {
|
|
294
|
+
jsonrpc: "2.0",
|
|
295
|
+
id,
|
|
296
|
+
error: { code: -32601, message: \`Method not found: \${method}\` },
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function handleToolCall(id: number | string | undefined, toolName: string, args: Record<string, unknown>) {
|
|
304
|
+
switch (toolName) {
|
|
305
|
+
case "hello": {
|
|
306
|
+
const name = (args.name as string) ?? "World";
|
|
307
|
+
return {
|
|
308
|
+
jsonrpc: "2.0",
|
|
309
|
+
id,
|
|
310
|
+
result: {
|
|
311
|
+
content: [{ type: "text", text: \`Hello, \${name}!\` }],
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
default:
|
|
316
|
+
return {
|
|
317
|
+
jsonrpc: "2.0",
|
|
318
|
+
id,
|
|
319
|
+
result: {
|
|
320
|
+
content: [{ type: "text", text: \`Unknown tool: \${toolName}\` }],
|
|
321
|
+
isError: true,
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// stdio transport
|
|
328
|
+
let buffer = "";
|
|
329
|
+
process.stdin.setEncoding("utf-8");
|
|
330
|
+
process.stdin.on("data", (chunk: string) => {
|
|
331
|
+
buffer += chunk;
|
|
332
|
+
const lines = buffer.split("\\n");
|
|
333
|
+
buffer = lines.pop() ?? "";
|
|
334
|
+
|
|
335
|
+
for (const line of lines) {
|
|
336
|
+
if (!line.trim()) continue;
|
|
337
|
+
try {
|
|
338
|
+
const request = JSON.parse(line);
|
|
339
|
+
const response = handleRequest(request);
|
|
340
|
+
if (response) {
|
|
341
|
+
process.stdout.write(JSON.stringify(response) + "\\n");
|
|
342
|
+
}
|
|
343
|
+
} catch {
|
|
344
|
+
// skip malformed input
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
`;
|
|
349
|
+
}
|
|
350
|
+
function getToolsTemplate(name) {
|
|
351
|
+
return `#!/usr/bin/env node
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* ${name} — an MCP server with multiple tools
|
|
355
|
+
* Generated by mcptools
|
|
356
|
+
*/
|
|
357
|
+
|
|
358
|
+
interface Tool {
|
|
359
|
+
name: string;
|
|
360
|
+
description: string;
|
|
361
|
+
inputSchema: Record<string, unknown>;
|
|
362
|
+
handler: (args: Record<string, unknown>) => unknown;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const tools: Tool[] = [
|
|
366
|
+
{
|
|
367
|
+
name: "add",
|
|
368
|
+
description: "Add two numbers together",
|
|
369
|
+
inputSchema: {
|
|
370
|
+
type: "object",
|
|
371
|
+
properties: {
|
|
372
|
+
a: { type: "number", description: "First number" },
|
|
373
|
+
b: { type: "number", description: "Second number" },
|
|
374
|
+
},
|
|
375
|
+
required: ["a", "b"],
|
|
376
|
+
},
|
|
377
|
+
handler: (args) => ({ sum: (args.a as number) + (args.b as number) }),
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
name: "timestamp",
|
|
381
|
+
description: "Get the current timestamp",
|
|
382
|
+
inputSchema: { type: "object", properties: {} },
|
|
383
|
+
handler: () => ({ timestamp: new Date().toISOString() }),
|
|
384
|
+
},
|
|
385
|
+
];
|
|
386
|
+
|
|
387
|
+
function handleRequest(request: { method?: string; id?: number | string; params?: any }) {
|
|
388
|
+
const { method, id, params } = request;
|
|
389
|
+
|
|
390
|
+
switch (method) {
|
|
391
|
+
case "initialize":
|
|
392
|
+
return {
|
|
393
|
+
jsonrpc: "2.0",
|
|
394
|
+
id,
|
|
395
|
+
result: {
|
|
396
|
+
protocolVersion: "2024-11-05",
|
|
397
|
+
capabilities: { tools: {} },
|
|
398
|
+
serverInfo: { name: "${name}", version: "0.1.0" },
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
case "tools/list":
|
|
403
|
+
return {
|
|
404
|
+
jsonrpc: "2.0",
|
|
405
|
+
id,
|
|
406
|
+
result: {
|
|
407
|
+
tools: tools.map(({ handler, ...t }) => t),
|
|
408
|
+
},
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
case "tools/call": {
|
|
412
|
+
const tool = tools.find((t) => t.name === params?.name);
|
|
413
|
+
if (!tool) {
|
|
414
|
+
return {
|
|
415
|
+
jsonrpc: "2.0",
|
|
416
|
+
id,
|
|
417
|
+
result: {
|
|
418
|
+
content: [{ type: "text", text: \`Unknown tool: \${params?.name}\` }],
|
|
419
|
+
isError: true,
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
const result = tool.handler(params?.arguments ?? {});
|
|
424
|
+
return {
|
|
425
|
+
jsonrpc: "2.0",
|
|
426
|
+
id,
|
|
427
|
+
result: {
|
|
428
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
default:
|
|
434
|
+
if (id !== undefined) {
|
|
435
|
+
return {
|
|
436
|
+
jsonrpc: "2.0",
|
|
437
|
+
id,
|
|
438
|
+
error: { code: -32601, message: \`Method not found: \${method}\` },
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
let buffer = "";
|
|
446
|
+
process.stdin.setEncoding("utf-8");
|
|
447
|
+
process.stdin.on("data", (chunk: string) => {
|
|
448
|
+
buffer += chunk;
|
|
449
|
+
const lines = buffer.split("\\n");
|
|
450
|
+
buffer = lines.pop() ?? "";
|
|
451
|
+
|
|
452
|
+
for (const line of lines) {
|
|
453
|
+
if (!line.trim()) continue;
|
|
454
|
+
try {
|
|
455
|
+
const request = JSON.parse(line);
|
|
456
|
+
const response = handleRequest(request);
|
|
457
|
+
if (response) {
|
|
458
|
+
process.stdout.write(JSON.stringify(response) + "\\n");
|
|
459
|
+
}
|
|
460
|
+
} catch {
|
|
461
|
+
// skip
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
`;
|
|
466
|
+
}
|
|
467
|
+
function getResourcesTemplate(name) {
|
|
468
|
+
return `#!/usr/bin/env node
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* ${name} — an MCP server with resources
|
|
472
|
+
* Generated by mcptools
|
|
473
|
+
*/
|
|
474
|
+
|
|
475
|
+
const RESOURCES = [
|
|
476
|
+
{
|
|
477
|
+
uri: "info://server/status",
|
|
478
|
+
name: "Server Status",
|
|
479
|
+
description: "Current server status information",
|
|
480
|
+
mimeType: "application/json",
|
|
481
|
+
},
|
|
482
|
+
];
|
|
483
|
+
|
|
484
|
+
function handleRequest(request: { method?: string; id?: number | string; params?: any }) {
|
|
485
|
+
const { method, id, params } = request;
|
|
486
|
+
|
|
487
|
+
switch (method) {
|
|
488
|
+
case "initialize":
|
|
489
|
+
return {
|
|
490
|
+
jsonrpc: "2.0",
|
|
491
|
+
id,
|
|
492
|
+
result: {
|
|
493
|
+
protocolVersion: "2024-11-05",
|
|
494
|
+
capabilities: { resources: {} },
|
|
495
|
+
serverInfo: { name: "${name}", version: "0.1.0" },
|
|
496
|
+
},
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
case "resources/list":
|
|
500
|
+
return { jsonrpc: "2.0", id, result: { resources: RESOURCES } };
|
|
501
|
+
|
|
502
|
+
case "resources/read": {
|
|
503
|
+
const uri = params?.uri;
|
|
504
|
+
if (uri === "info://server/status") {
|
|
505
|
+
return {
|
|
506
|
+
jsonrpc: "2.0",
|
|
507
|
+
id,
|
|
508
|
+
result: {
|
|
509
|
+
contents: [
|
|
510
|
+
{
|
|
511
|
+
uri,
|
|
512
|
+
mimeType: "application/json",
|
|
513
|
+
text: JSON.stringify({
|
|
514
|
+
status: "running",
|
|
515
|
+
uptime: process.uptime(),
|
|
516
|
+
timestamp: new Date().toISOString(),
|
|
517
|
+
}),
|
|
518
|
+
},
|
|
519
|
+
],
|
|
520
|
+
},
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
return {
|
|
524
|
+
jsonrpc: "2.0",
|
|
525
|
+
id,
|
|
526
|
+
error: { code: -32602, message: \`Resource not found: \${uri}\` },
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
default:
|
|
531
|
+
if (id !== undefined) {
|
|
532
|
+
return {
|
|
533
|
+
jsonrpc: "2.0",
|
|
534
|
+
id,
|
|
535
|
+
error: { code: -32601, message: \`Method not found: \${method}\` },
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
let buffer = "";
|
|
543
|
+
process.stdin.setEncoding("utf-8");
|
|
544
|
+
process.stdin.on("data", (chunk: string) => {
|
|
545
|
+
buffer += chunk;
|
|
546
|
+
const lines = buffer.split("\\n");
|
|
547
|
+
buffer = lines.pop() ?? "";
|
|
548
|
+
|
|
549
|
+
for (const line of lines) {
|
|
550
|
+
if (!line.trim()) continue;
|
|
551
|
+
try {
|
|
552
|
+
const request = JSON.parse(line);
|
|
553
|
+
const response = handleRequest(request);
|
|
554
|
+
if (response) {
|
|
555
|
+
process.stdout.write(JSON.stringify(response) + "\\n");
|
|
556
|
+
}
|
|
557
|
+
} catch {
|
|
558
|
+
// skip
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
`;
|
|
563
|
+
}
|
|
564
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,mDAAmD,CAAC;KAChE,QAAQ,CAAC,QAAQ,EAAE,gCAAgC,CAAC;KACpD,MAAM,CAAC,2BAA2B,EAAE,iBAAiB,EAAE,OAAO,CAAC;KAC/D,MAAM,CAAC,uBAAuB,EAAE,gCAAgC,EAAE,YAAY,CAAC;KAC/E,MAAM,CAAC,UAAU,EAAE,yBAAyB,CAAC;KAC7C,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,OAAO,EAAE,EAAE;IACtC,MAAM,OAAO,GAAG,GAAG,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC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