@musashishao/agent-kit 1.0.0 → 1.0.1
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.
Potentially problematic release.
This version of @musashishao/agent-kit might be problematic. Click here for more details.
- package/.agent/ARCHITECTURE.md +4 -2
- package/.agent/skills/mcp-builder/SKILL.md +583 -97
- package/.agent/skills/mcp-builder/python-template.md +522 -0
- package/.agent/skills/mcp-builder/tool-patterns.md +642 -0
- package/.agent/skills/mcp-builder/typescript-template.md +361 -0
- package/.agent/skills/problem-solving/SKILL.md +556 -0
- package/.agent/skills/problem-solving/collision-zone-thinking.md +285 -0
- package/.agent/skills/problem-solving/inversion-exercise.md +205 -0
- package/.agent/skills/problem-solving/meta-pattern-recognition.md +313 -0
- package/.agent/skills/problem-solving/scale-game.md +300 -0
- package/.agent/skills/problem-solving/simplification-cascades.md +321 -0
- package/.agent/skills/problem-solving/when-stuck.md +146 -0
- package/package.json +2 -2
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# TypeScript MCP Server Template
|
|
2
|
+
|
|
3
|
+
> Copy this template to quickly start a new MCP server.
|
|
4
|
+
|
|
5
|
+
## Project Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
my-mcp-server/
|
|
9
|
+
├── src/
|
|
10
|
+
│ ├── index.ts # Entry point
|
|
11
|
+
│ ├── tools/ # Tool implementations
|
|
12
|
+
│ │ ├── index.ts
|
|
13
|
+
│ │ └── example.ts
|
|
14
|
+
│ ├── resources/ # Resource handlers
|
|
15
|
+
│ │ └── index.ts
|
|
16
|
+
│ └── utils/ # Utilities
|
|
17
|
+
│ └── index.ts
|
|
18
|
+
├── package.json
|
|
19
|
+
├── tsconfig.json
|
|
20
|
+
└── README.md
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Files
|
|
24
|
+
|
|
25
|
+
### package.json
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"name": "my-mcp-server",
|
|
30
|
+
"version": "1.0.0",
|
|
31
|
+
"description": "My MCP Server",
|
|
32
|
+
"type": "module",
|
|
33
|
+
"main": "dist/index.js",
|
|
34
|
+
"bin": {
|
|
35
|
+
"my-mcp-server": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc",
|
|
39
|
+
"dev": "tsx watch src/index.ts",
|
|
40
|
+
"start": "node dist/index.js",
|
|
41
|
+
"test": "vitest",
|
|
42
|
+
"lint": "eslint src",
|
|
43
|
+
"prepublishOnly": "npm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
47
|
+
"zod": "^3.23.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
51
|
+
"tsx": "^4.0.0",
|
|
52
|
+
"typescript": "^5.0.0",
|
|
53
|
+
"vitest": "^2.0.0",
|
|
54
|
+
"eslint": "^9.0.0"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=18.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### tsconfig.json
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"compilerOptions": {
|
|
67
|
+
"target": "ES2022",
|
|
68
|
+
"module": "NodeNext",
|
|
69
|
+
"moduleResolution": "NodeNext",
|
|
70
|
+
"outDir": "dist",
|
|
71
|
+
"rootDir": "src",
|
|
72
|
+
"strict": true,
|
|
73
|
+
"esModuleInterop": true,
|
|
74
|
+
"skipLibCheck": true,
|
|
75
|
+
"declaration": true,
|
|
76
|
+
"sourceMap": true
|
|
77
|
+
},
|
|
78
|
+
"include": ["src/**/*"],
|
|
79
|
+
"exclude": ["node_modules", "dist"]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### src/index.ts
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
#!/usr/bin/env node
|
|
87
|
+
|
|
88
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
89
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
90
|
+
|
|
91
|
+
import { registerTools } from "./tools/index.js";
|
|
92
|
+
import { registerResources } from "./resources/index.js";
|
|
93
|
+
|
|
94
|
+
// Configuration
|
|
95
|
+
const SERVER_NAME = "my-mcp-server";
|
|
96
|
+
const SERVER_VERSION = "1.0.0";
|
|
97
|
+
|
|
98
|
+
// Create server instance
|
|
99
|
+
const server = new McpServer({
|
|
100
|
+
name: SERVER_NAME,
|
|
101
|
+
version: SERVER_VERSION,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Register tools and resources
|
|
105
|
+
registerTools(server);
|
|
106
|
+
registerResources(server);
|
|
107
|
+
|
|
108
|
+
// Error handling
|
|
109
|
+
process.on("uncaughtException", (error) => {
|
|
110
|
+
console.error("Uncaught exception:", error);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
process.on("unhandledRejection", (reason) => {
|
|
115
|
+
console.error("Unhandled rejection:", reason);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Start server
|
|
120
|
+
async function main() {
|
|
121
|
+
const transport = new StdioServerTransport();
|
|
122
|
+
|
|
123
|
+
await server.connect(transport);
|
|
124
|
+
|
|
125
|
+
console.error(`${SERVER_NAME} v${SERVER_VERSION} running on stdio`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
main().catch((error) => {
|
|
129
|
+
console.error("Failed to start server:", error);
|
|
130
|
+
process.exit(1);
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### src/tools/index.ts
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
138
|
+
import { z } from "zod";
|
|
139
|
+
|
|
140
|
+
export function registerTools(server: McpServer) {
|
|
141
|
+
// Example: Greet tool
|
|
142
|
+
server.tool(
|
|
143
|
+
"greet",
|
|
144
|
+
"Greet a user by name",
|
|
145
|
+
{
|
|
146
|
+
name: z.string().describe("The name of the user to greet"),
|
|
147
|
+
language: z.enum(["en", "es", "fr"]).default("en").describe("Language for greeting"),
|
|
148
|
+
},
|
|
149
|
+
async ({ name, language }) => {
|
|
150
|
+
const greetings = {
|
|
151
|
+
en: `Hello, ${name}!`,
|
|
152
|
+
es: `¡Hola, ${name}!`,
|
|
153
|
+
fr: `Bonjour, ${name}!`,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
content: [
|
|
158
|
+
{
|
|
159
|
+
type: "text",
|
|
160
|
+
text: greetings[language],
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
// Example: Calculate tool
|
|
168
|
+
server.tool(
|
|
169
|
+
"calculate",
|
|
170
|
+
"Perform a mathematical calculation",
|
|
171
|
+
{
|
|
172
|
+
operation: z.enum(["add", "subtract", "multiply", "divide"]).describe("The operation to perform"),
|
|
173
|
+
a: z.number().describe("First number"),
|
|
174
|
+
b: z.number().describe("Second number"),
|
|
175
|
+
},
|
|
176
|
+
async ({ operation, a, b }) => {
|
|
177
|
+
let result: number;
|
|
178
|
+
|
|
179
|
+
switch (operation) {
|
|
180
|
+
case "add":
|
|
181
|
+
result = a + b;
|
|
182
|
+
break;
|
|
183
|
+
case "subtract":
|
|
184
|
+
result = a - b;
|
|
185
|
+
break;
|
|
186
|
+
case "multiply":
|
|
187
|
+
result = a * b;
|
|
188
|
+
break;
|
|
189
|
+
case "divide":
|
|
190
|
+
if (b === 0) {
|
|
191
|
+
return {
|
|
192
|
+
content: [{ type: "text", text: "Error: Division by zero" }],
|
|
193
|
+
isError: true,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
result = a / b;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
content: [
|
|
202
|
+
{
|
|
203
|
+
type: "text",
|
|
204
|
+
text: JSON.stringify({ operation, a, b, result }),
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
// Add more tools here...
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### src/resources/index.ts
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
219
|
+
|
|
220
|
+
export function registerResources(server: McpServer) {
|
|
221
|
+
// Example: Status resource
|
|
222
|
+
server.resource(
|
|
223
|
+
"status",
|
|
224
|
+
"status://server",
|
|
225
|
+
async (uri) => ({
|
|
226
|
+
contents: [
|
|
227
|
+
{
|
|
228
|
+
uri: uri.href,
|
|
229
|
+
mimeType: "application/json",
|
|
230
|
+
text: JSON.stringify({
|
|
231
|
+
status: "running",
|
|
232
|
+
timestamp: new Date().toISOString(),
|
|
233
|
+
uptime: process.uptime(),
|
|
234
|
+
}),
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
})
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
// Example: Config resource
|
|
241
|
+
server.resource(
|
|
242
|
+
"config",
|
|
243
|
+
"config://settings",
|
|
244
|
+
async (uri) => ({
|
|
245
|
+
contents: [
|
|
246
|
+
{
|
|
247
|
+
uri: uri.href,
|
|
248
|
+
mimeType: "application/json",
|
|
249
|
+
text: JSON.stringify({
|
|
250
|
+
version: "1.0.0",
|
|
251
|
+
features: ["tools", "resources"],
|
|
252
|
+
environment: process.env.NODE_ENV || "development",
|
|
253
|
+
}),
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
})
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
// Add more resources here...
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### src/utils/index.ts
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
/**
|
|
267
|
+
* Generate a unique ID
|
|
268
|
+
*/
|
|
269
|
+
export function generateId(): string {
|
|
270
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Validate environment variable
|
|
275
|
+
*/
|
|
276
|
+
export function requireEnv(name: string): string {
|
|
277
|
+
const value = process.env[name];
|
|
278
|
+
if (!value) {
|
|
279
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
280
|
+
}
|
|
281
|
+
return value;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Optional environment variable with default
|
|
286
|
+
*/
|
|
287
|
+
export function getEnv(name: string, defaultValue: string): string {
|
|
288
|
+
return process.env[name] || defaultValue;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Safe JSON parse with fallback
|
|
293
|
+
*/
|
|
294
|
+
export function safeJsonParse<T>(json: string, fallback: T): T {
|
|
295
|
+
try {
|
|
296
|
+
return JSON.parse(json);
|
|
297
|
+
} catch {
|
|
298
|
+
return fallback;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Delay utility
|
|
304
|
+
*/
|
|
305
|
+
export function delay(ms: number): Promise<void> {
|
|
306
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Claude Desktop Configuration
|
|
311
|
+
|
|
312
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
313
|
+
|
|
314
|
+
```json
|
|
315
|
+
{
|
|
316
|
+
"mcpServers": {
|
|
317
|
+
"my-server": {
|
|
318
|
+
"command": "node",
|
|
319
|
+
"args": ["/path/to/my-mcp-server/dist/index.js"],
|
|
320
|
+
"env": {
|
|
321
|
+
"MY_API_KEY": "your-api-key"
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Development Commands
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
# Install dependencies
|
|
332
|
+
npm install
|
|
333
|
+
|
|
334
|
+
# Development mode (auto-reload)
|
|
335
|
+
npm run dev
|
|
336
|
+
|
|
337
|
+
# Build for production
|
|
338
|
+
npm run build
|
|
339
|
+
|
|
340
|
+
# Test with MCP Inspector
|
|
341
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
342
|
+
|
|
343
|
+
# Run production
|
|
344
|
+
npm start
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## Publishing to npm
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
# 1. Update version
|
|
351
|
+
npm version patch # or minor, major
|
|
352
|
+
|
|
353
|
+
# 2. Build
|
|
354
|
+
npm run build
|
|
355
|
+
|
|
356
|
+
# 3. Publish
|
|
357
|
+
npm publish --access public
|
|
358
|
+
|
|
359
|
+
# Users can then run:
|
|
360
|
+
npx your-package-name
|
|
361
|
+
```
|