@aws/nx-plugin 0.34.0 → 0.35.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/package.json +1 -1
- package/src/mcp-server/tools/create-workspace-command.js +1 -8
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +41 -314
- package/src/ts/mcp-server/files/index.ts.template +17 -0
- package/src/ts/mcp-server/files/resources/sample-guidance.ts.template +9 -0
- package/src/ts/mcp-server/files/server.ts.template +18 -0
- package/src/ts/mcp-server/files/tools/add.ts.template +11 -0
- package/src/ts/mcp-server/generator.js +42 -31
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.d.ts +4 -2
- package/src/ts/mcp-server/schema.json +9 -16
- package/src/ts/mcp-server/files/README.md.template +0 -108
- package/src/ts/mcp-server/files/src/global.d.ts.template +0 -4
- package/src/ts/mcp-server/files/src/index.ts.template +0 -6
- package/src/ts/mcp-server/files/src/resources/example-context.md +0 -3
- package/src/ts/mcp-server/files/src/server.ts.template +0 -28
package/package.json
CHANGED
|
@@ -17,14 +17,7 @@ const addCreateWorkspaceCommandTool = (server) => {
|
|
|
17
17
|
npx create-nx-workspace@~21.0.3 ${workspaceName} --pm=${packageManager} --preset=@aws/nx-plugin --ci=skip
|
|
18
18
|
\`\`\`
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
you would like for your workspace, you can move all the files up one level and delete the empty directory afterwards, eg:
|
|
22
|
-
|
|
23
|
-
\`\`\`bash
|
|
24
|
-
mv ${workspaceName}/{*,.*} ./ && rm -rf ${workspaceName}
|
|
25
|
-
\`\`\`
|
|
26
|
-
|
|
27
|
-
(Note that the above command will complain about moving . and .. but that is expected and ok!)
|
|
20
|
+
This will create a new workspace within the ${workspaceName} directory.
|
|
28
21
|
`,
|
|
29
22
|
},
|
|
30
23
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-workspace-command.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/mcp-server/tools/create-workspace-command.ts"],"names":[],"mappings":";;;AAKA,6BAAwB;AACxB,sCAAiD;AAEjD;;GAEG;AACI,MAAM,6BAA6B,GAAG,CAAC,MAAiB,EAAE,EAAE;IACjE,MAAM,CAAC,IAAI,CACT,0BAA0B,EAC1B,oEAAoE,EACpE,EAAE,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,6BAAoB,EAAE,EACnE,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC;QACtC,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE;;;kCAGkB,aAAa,SAAS,cAAc;;;
|
|
1
|
+
{"version":3,"file":"create-workspace-command.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/mcp-server/tools/create-workspace-command.ts"],"names":[],"mappings":";;;AAKA,6BAAwB;AACxB,sCAAiD;AAEjD;;GAEG;AACI,MAAM,6BAA6B,GAAG,CAAC,MAAiB,EAAE,EAAE;IACjE,MAAM,CAAC,IAAI,CACT,0BAA0B,EAC1B,oEAAoE,EACpE,EAAE,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,6BAAoB,EAAE,EACnE,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC;QACtC,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE;;;kCAGkB,aAAa,SAAS,cAAc;;;8CAGxB,aAAa;GACxD;aACM;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,6BAA6B,iCAqBxC"}
|
|
@@ -1,335 +1,62 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`ts#mcp-server generator > should match snapshot > mcp-server-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Documentation
|
|
14
|
-
|
|
15
|
-
- [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
|
|
16
|
-
- [MCP TypeScript SDK Documentation](https://github.com/modelcontextprotocol/sdk-typescript)
|
|
17
|
-
|
|
18
|
-
## Developer Guide
|
|
19
|
-
|
|
20
|
-
### Getting Started
|
|
21
|
-
|
|
22
|
-
This MCP server is built using the MCP TypeScript SDK. Here's how to work with it:
|
|
23
|
-
|
|
24
|
-
1. **Server Structure**: The main server code is in \`src/server.ts\`. This file defines the server, its tools, and resources.
|
|
25
|
-
|
|
26
|
-
2. **Adding Tools**: Tools are functions that the LLM can call to perform actions. Add new tools using the \`server.tool()\` method:
|
|
27
|
-
|
|
28
|
-
\`\`\`typescript
|
|
29
|
-
server.tool(
|
|
30
|
-
'toolName',
|
|
31
|
-
{ param1: z.string(), param2: z.number() }, // Input schema using Zod
|
|
32
|
-
async ({ param1, param2 }) => {
|
|
33
|
-
// Tool implementation
|
|
34
|
-
return {
|
|
35
|
-
content: [{ type: 'text', text: 'Result' }],
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
);
|
|
39
|
-
\`\`\`
|
|
40
|
-
|
|
41
|
-
3. **Adding Resources**: Resources provide context to the LLM. You can add static resources from files or dynamic resources:
|
|
42
|
-
|
|
43
|
-
\`\`\`typescript
|
|
44
|
-
// Static resource from a file
|
|
45
|
-
import resourceContent from './resources/my-resource.md';
|
|
46
|
-
|
|
47
|
-
server.resource('resource-name', 'example://resource', async (uri) => ({
|
|
48
|
-
contents: [{ uri: uri.href, text: resourceContent }],
|
|
49
|
-
}));
|
|
50
|
-
|
|
51
|
-
// Dynamic resource
|
|
52
|
-
server.resource('dynamic-resource', 'dynamic://resource', async (uri) => {
|
|
53
|
-
const data = await fetchSomeData();
|
|
54
|
-
return {
|
|
55
|
-
contents: [{ uri: uri.href, text: data }],
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
\`\`\`
|
|
59
|
-
|
|
60
|
-
### Building the Server
|
|
61
|
-
|
|
62
|
-
To build the server for use with AI assistants:
|
|
63
|
-
|
|
64
|
-
\`\`\`bash
|
|
65
|
-
nx run <project-name>:bundle
|
|
66
|
-
\`\`\`
|
|
67
|
-
|
|
68
|
-
This creates a bundled version of your server in \`dist/<project-path>/bundle/index.js\`.
|
|
69
|
-
|
|
70
|
-
## Using with AI Assistants
|
|
71
|
-
|
|
72
|
-
To use your MCP server with AI assistants, you need to build it first to create the bundle:
|
|
73
|
-
|
|
74
|
-
\`\`\`bash
|
|
75
|
-
nx run <project-name>:bundle
|
|
76
|
-
\`\`\`
|
|
77
|
-
|
|
78
|
-
### Configuration
|
|
79
|
-
|
|
80
|
-
Most AI assistants (Amazon Q Developer CLI, Cline, Cursor, Claude Code, etc.) use a similar configuration approach. You'll need to create or update a configuration file with your MCP server details:
|
|
81
|
-
|
|
82
|
-
\`\`\`json
|
|
83
|
-
{
|
|
84
|
-
"mcpServers": {
|
|
85
|
-
"test-server": {
|
|
86
|
-
"command": "node",
|
|
87
|
-
"args": ["/path/to/workspace/dist/test-server/bundle/index.js"],
|
|
88
|
-
"transportType": "stdio"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
\`\`\`
|
|
93
|
-
|
|
94
|
-
Replace \`/path/to/workspace/dist/test-server/bundle/index.js\` with the actual path to your bundled MCP server.
|
|
95
|
-
|
|
96
|
-
Note that if you receive an error due to \`node\` missing (eg \`ENOENT node\`), you might need to specify the full path to \`node\` which you can obtain by running \`which node\`.
|
|
97
|
-
|
|
98
|
-
### Development Mode
|
|
99
|
-
|
|
100
|
-
During development, you can use the \`dev\` target to continuously rebuild the bundle whenever you make changes:
|
|
101
|
-
|
|
102
|
-
\`\`\`bash
|
|
103
|
-
nx run <project-name>:dev
|
|
104
|
-
\`\`\`
|
|
105
|
-
|
|
106
|
-
This will watch for changes in your project files and automatically rebuild the bundle.
|
|
107
|
-
|
|
108
|
-
Whenever you've made changes, you'll need to restart the MCP server in your AI assistant to test it out. The exact process depends on the assistant, but generally:
|
|
109
|
-
|
|
110
|
-
1. Find your MCP server in the assistant's settings or configuration
|
|
111
|
-
2. Look for a "Restart" or "Reload" option
|
|
112
|
-
",
|
|
113
|
-
"test-server/eslint.config.mjs": "import baseConfig from '../eslint.config.mjs';
|
|
3
|
+
exports[`ts#mcp-server generator > should match snapshot for generated files > mcp-server-index.ts 1`] = `
|
|
4
|
+
"#!/usr/bin/env node
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { createServer } from './server';
|
|
7
|
+
|
|
8
|
+
export const startMcpServer = async () => {
|
|
9
|
+
const transport = new StdioServerTransport();
|
|
10
|
+
await createServer().connect(transport);
|
|
11
|
+
console.error('MCP Server listening on STDIO');
|
|
12
|
+
};
|
|
114
13
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
'@nx/dependency-checks': [
|
|
121
|
-
'warn',
|
|
122
|
-
{
|
|
123
|
-
ignoredFiles: [
|
|
124
|
-
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
125
|
-
'{projectRoot}/vite.config.{js,ts,mjs,mts}',
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
},
|
|
130
|
-
languageOptions: {
|
|
131
|
-
parser: await import('jsonc-eslint-parser'),
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
];
|
|
135
|
-
",
|
|
136
|
-
"test-server/project.json": "{
|
|
137
|
-
"name": "@proj/test-server",
|
|
138
|
-
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
|
139
|
-
"sourceRoot": "test-server/src",
|
|
140
|
-
"projectType": "library",
|
|
141
|
-
"tags": [],
|
|
142
|
-
"metadata": {
|
|
143
|
-
"generator": "ts#mcp-server"
|
|
144
|
-
},
|
|
145
|
-
"targets": {
|
|
146
|
-
"build": {
|
|
147
|
-
"dependsOn": ["lint", "compile", "test", "bundle"]
|
|
148
|
-
},
|
|
149
|
-
"compile": {
|
|
150
|
-
"executor": "nx:run-commands",
|
|
151
|
-
"outputs": ["{workspaceRoot}/dist/test-server/tsc"],
|
|
152
|
-
"options": {
|
|
153
|
-
"command": "tsc --build tsconfig.lib.json",
|
|
154
|
-
"cwd": "{projectRoot}"
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
"test": {
|
|
158
|
-
"executor": "@nx/vite:test",
|
|
159
|
-
"outputs": ["{options.reportsDirectory}"],
|
|
160
|
-
"options": {
|
|
161
|
-
"reportsDirectory": "../coverage/test-server"
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
"bundle": {
|
|
165
|
-
"executor": "nx:run-commands",
|
|
166
|
-
"options": {
|
|
167
|
-
"commands": [
|
|
168
|
-
"esbuild \\"test-server/src/index.ts\\" --bundle --platform=node --format=esm --loader:.md=text --outfile=dist/test-server/bundle/index.js"
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
"dev": {
|
|
173
|
-
"executor": "nx:run-commands",
|
|
174
|
-
"options": {
|
|
175
|
-
"commands": [
|
|
176
|
-
"nx watch --projects=@proj/test-server --includeDependentProjects -- nx run @proj/test-server:bundle"
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
}
|
|
14
|
+
void (async () => {
|
|
15
|
+
try {
|
|
16
|
+
await startMcpServer();
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.error(e);
|
|
180
19
|
}
|
|
181
|
-
}
|
|
182
|
-
"
|
|
183
|
-
|
|
184
|
-
const content: string;
|
|
185
|
-
export default content;
|
|
186
|
-
}
|
|
187
|
-
",
|
|
188
|
-
"test-server/src/index.ts": "import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
189
|
-
import { createServer } from './server.js';
|
|
190
|
-
|
|
191
|
-
// Start receiving messages on stdin and sending messages on stdout
|
|
192
|
-
const transport = new StdioServerTransport();
|
|
193
|
-
await createServer().connect(transport);
|
|
194
|
-
",
|
|
195
|
-
"test-server/src/resources/example-context.md": "## Example Context
|
|
20
|
+
})();
|
|
21
|
+
"
|
|
22
|
+
`;
|
|
196
23
|
|
|
197
|
-
|
|
198
|
-
"
|
|
199
|
-
|
|
200
|
-
import {
|
|
201
|
-
import exampleContext from './resources/example-context.md';
|
|
24
|
+
exports[`ts#mcp-server generator > should match snapshot for generated files > mcp-server-server.ts 1`] = `
|
|
25
|
+
"import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
26
|
+
import { registerAddTool } from './tools/add';
|
|
27
|
+
import { registerSampleGuidanceResource } from './resources/sample-guidance';
|
|
202
28
|
|
|
203
29
|
/**
|
|
204
30
|
* Create the MCP Server
|
|
205
31
|
*/
|
|
206
32
|
export const createServer = () => {
|
|
207
33
|
const server = new McpServer({
|
|
208
|
-
name: '
|
|
34
|
+
name: 'snapshot-server',
|
|
209
35
|
version: '1.0.0',
|
|
210
36
|
});
|
|
211
37
|
|
|
212
|
-
|
|
213
|
-
server
|
|
214
|
-
'add',
|
|
215
|
-
'adds two numbers',
|
|
216
|
-
{ a: z.number(), b: z.number() },
|
|
217
|
-
async ({ a, b }) => ({
|
|
218
|
-
content: [{ type: 'text', text: String(a + b) }],
|
|
219
|
-
}),
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
// Add a resource which provides context from a markdown file
|
|
223
|
-
server.resource('example-context', 'example://context', async (uri) => ({
|
|
224
|
-
contents: [{ uri: uri.href, text: exampleContext }],
|
|
225
|
-
}));
|
|
38
|
+
registerAddTool(server);
|
|
39
|
+
registerSampleGuidanceResource(server);
|
|
226
40
|
|
|
227
41
|
return server;
|
|
228
42
|
};
|
|
229
|
-
"
|
|
230
|
-
|
|
231
|
-
"extends": "../tsconfig.base.json",
|
|
232
|
-
"files": [],
|
|
233
|
-
"include": [],
|
|
234
|
-
"references": [
|
|
235
|
-
{
|
|
236
|
-
"path": "./tsconfig.lib.json"
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
"path": "./tsconfig.spec.json"
|
|
240
|
-
}
|
|
241
|
-
],
|
|
242
|
-
"compilerOptions": {}
|
|
243
|
-
}
|
|
244
|
-
",
|
|
245
|
-
"test-server/tsconfig.lib.json": "{
|
|
246
|
-
"extends": "../tsconfig.base.json",
|
|
247
|
-
"compilerOptions": {
|
|
248
|
-
"rootDir": ".",
|
|
249
|
-
"outDir": "../dist/test-server/tsc",
|
|
250
|
-
"tsBuildInfoFile": "../dist/test-server/tsc/tsconfig.lib.tsbuildinfo",
|
|
251
|
-
"emitDeclarationOnly": false,
|
|
252
|
-
"module": "nodenext",
|
|
253
|
-
"moduleResolution": "nodenext",
|
|
254
|
-
"types": ["node"]
|
|
255
|
-
},
|
|
256
|
-
"include": ["src/**/*.ts"],
|
|
257
|
-
"references": [],
|
|
258
|
-
"exclude": [
|
|
259
|
-
"vite.config.ts",
|
|
260
|
-
"vite.config.mts",
|
|
261
|
-
"vitest.config.ts",
|
|
262
|
-
"vitest.config.mts",
|
|
263
|
-
"src/**/*.test.ts",
|
|
264
|
-
"src/**/*.spec.ts",
|
|
265
|
-
"src/**/*.test.tsx",
|
|
266
|
-
"src/**/*.spec.tsx",
|
|
267
|
-
"src/**/*.test.js",
|
|
268
|
-
"src/**/*.spec.js",
|
|
269
|
-
"src/**/*.test.jsx",
|
|
270
|
-
"src/**/*.spec.jsx"
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
",
|
|
274
|
-
"test-server/tsconfig.spec.json": "{
|
|
275
|
-
"extends": "../tsconfig.base.json",
|
|
276
|
-
"compilerOptions": {
|
|
277
|
-
"outDir": "./out-tsc/vitest",
|
|
278
|
-
"types": [
|
|
279
|
-
"vitest/globals",
|
|
280
|
-
"vitest/importMeta",
|
|
281
|
-
"vite/client",
|
|
282
|
-
"node",
|
|
283
|
-
"vitest"
|
|
284
|
-
],
|
|
285
|
-
"module": "nodenext",
|
|
286
|
-
"moduleResolution": "nodenext"
|
|
287
|
-
},
|
|
288
|
-
"include": [
|
|
289
|
-
"vite.config.ts",
|
|
290
|
-
"vite.config.mts",
|
|
291
|
-
"vitest.config.ts",
|
|
292
|
-
"vitest.config.mts",
|
|
293
|
-
"src/**/*.test.ts",
|
|
294
|
-
"src/**/*.spec.ts",
|
|
295
|
-
"src/**/*.test.tsx",
|
|
296
|
-
"src/**/*.spec.tsx",
|
|
297
|
-
"src/**/*.test.js",
|
|
298
|
-
"src/**/*.spec.js",
|
|
299
|
-
"src/**/*.test.jsx",
|
|
300
|
-
"src/**/*.spec.jsx",
|
|
301
|
-
"src/**/*.d.ts"
|
|
302
|
-
],
|
|
303
|
-
"references": [
|
|
304
|
-
{
|
|
305
|
-
"path": "./tsconfig.lib.json"
|
|
306
|
-
}
|
|
307
|
-
]
|
|
308
|
-
}
|
|
309
|
-
",
|
|
310
|
-
"test-server/vite.config.ts": "import { defineConfig } from 'vite';
|
|
43
|
+
"
|
|
44
|
+
`;
|
|
311
45
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
globals: true,
|
|
323
|
-
environment: 'jsdom',
|
|
324
|
-
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
325
|
-
reporters: ['default'],
|
|
326
|
-
coverage: {
|
|
327
|
-
reportsDirectory: './test-output/vitest/coverage',
|
|
328
|
-
provider: 'v8' as const,
|
|
329
|
-
},
|
|
330
|
-
passWithNoTests: true,
|
|
46
|
+
exports[`ts#mcp-server generator > should match snapshot for generated files > updated-package.json 1`] = `
|
|
47
|
+
"{
|
|
48
|
+
"name": "test-project",
|
|
49
|
+
"version": "1.0.0",
|
|
50
|
+
"bin": {
|
|
51
|
+
"snapshot-server": "./src/snapshot-server/index.js"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@modelcontextprotocol/sdk": "^1.11.3",
|
|
55
|
+
"zod": "^3.25.50"
|
|
331
56
|
},
|
|
332
|
-
|
|
333
|
-
"
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"tsx": "4.20.1"
|
|
59
|
+
}
|
|
334
60
|
}
|
|
61
|
+
"
|
|
335
62
|
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { createServer } from './server<% if (esm) { %>.js<% } %>';
|
|
4
|
+
|
|
5
|
+
export const startMcpServer = async () => {
|
|
6
|
+
const transport = new StdioServerTransport();
|
|
7
|
+
await createServer().connect(transport);
|
|
8
|
+
console.error('MCP Server listening on STDIO');
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
void (async () => {
|
|
12
|
+
try {
|
|
13
|
+
await startMcpServer();
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.error(e);
|
|
16
|
+
}
|
|
17
|
+
})();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
|
|
3
|
+
export const registerSampleGuidanceResource = (server: McpServer) => {
|
|
4
|
+
server.resource('example-context', 'example://context', async (uri) => ({
|
|
5
|
+
contents: [{ uri: uri.href, text: `## Sample Guidance
|
|
6
|
+
|
|
7
|
+
This is some guidance in markdown format!`}],
|
|
8
|
+
}));
|
|
9
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp<% if (esm) { %>.js<% } %>";
|
|
2
|
+
import { registerAddTool } from './tools/add<% if (esm) { %>.js<% } %>';
|
|
3
|
+
import { registerSampleGuidanceResource } from './resources/sample-guidance<% if (esm) { %>.js<% } %>';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create the MCP Server
|
|
7
|
+
*/
|
|
8
|
+
export const createServer = () => {
|
|
9
|
+
const server = new McpServer({
|
|
10
|
+
name: "<%- name %>",
|
|
11
|
+
version: "1.0.0"
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
registerAddTool(server);
|
|
15
|
+
registerSampleGuidanceResource(server);
|
|
16
|
+
|
|
17
|
+
return server;
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export const registerAddTool = (server: McpServer) => {
|
|
5
|
+
server.tool("add", "adds two numbers",
|
|
6
|
+
{ a: z.number(), b: z.number() },
|
|
7
|
+
async ({ a, b }) => ({
|
|
8
|
+
content: [{ type: "text", text: String(a + b) }]
|
|
9
|
+
})
|
|
10
|
+
);
|
|
11
|
+
};
|
|
@@ -10,47 +10,58 @@ const devkit_1 = require("@nx/devkit");
|
|
|
10
10
|
const nx_1 = require("../../utils/nx");
|
|
11
11
|
const metrics_1 = require("../../utils/metrics");
|
|
12
12
|
const format_1 = require("../../utils/format");
|
|
13
|
-
const generator_1 = tslib_1.__importStar(require("../lib/generator"));
|
|
14
13
|
const versions_1 = require("../../utils/versions");
|
|
14
|
+
const names_1 = require("../../utils/names");
|
|
15
15
|
exports.TS_MCP_SERVER_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
16
16
|
const tsMcpServerGenerator = (tree, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
var _a, _b
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const project = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.project);
|
|
19
|
+
if (!tree.exists((0, devkit_1.joinPathFragments)(project.root, 'tsconfig.json'))) {
|
|
20
|
+
throw new Error(`Unsupported project ${options.project}. Expected a TypeScript project (with a tsconfig.json)`);
|
|
21
|
+
}
|
|
22
|
+
const defaultName = `${(0, names_1.kebabCase)(project.name.split('/').pop())}-mcp-server`;
|
|
23
|
+
const name = (0, names_1.kebabCase)((_a = options.name) !== null && _a !== void 0 ? _a : defaultName);
|
|
24
|
+
const targetSourceDir = (0, devkit_1.joinPathFragments)((_b = project.sourceRoot) !== null && _b !== void 0 ? _b : `${project.root}/src`, options.name ? name : 'mcp-server');
|
|
25
|
+
const relativeSourceDir = targetSourceDir.replace(project.root + '/', './');
|
|
26
|
+
// Create a package.json if one doesn't exist, since we want to add the server as a bin target
|
|
27
|
+
const projectPackageJsonPath = (0, devkit_1.joinPathFragments)(project.root, 'package.json');
|
|
28
|
+
if (!tree.exists(projectPackageJsonPath)) {
|
|
29
|
+
// Default to esm if no package.json found
|
|
30
|
+
(0, devkit_1.writeJson)(tree, projectPackageJsonPath, {
|
|
31
|
+
name: project.name,
|
|
32
|
+
type: 'module',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// Generate esm if the package.json is of type module, otherwise we generate commonjs
|
|
36
|
+
// We support commonjs here because nx plugins must be commonjs
|
|
37
|
+
// https://github.com/nrwl/nx/issues/15682
|
|
38
|
+
const esm = (0, devkit_1.readJson)(tree, projectPackageJsonPath).type === 'module';
|
|
39
|
+
// Add a target for running the MCP server
|
|
40
|
+
(0, devkit_1.updateJson)(tree, projectPackageJsonPath, (pkg) => {
|
|
41
|
+
var _a;
|
|
42
|
+
(_a = pkg.bin) !== null && _a !== void 0 ? _a : (pkg.bin = {});
|
|
43
|
+
pkg.bin[name] = `${relativeSourceDir}/index.js`;
|
|
44
|
+
return pkg;
|
|
45
|
+
});
|
|
22
46
|
// Add dependencies
|
|
23
47
|
const deps = (0, versions_1.withVersions)(['@modelcontextprotocol/sdk', 'zod']);
|
|
24
|
-
const devDeps = (0, versions_1.withVersions)(['tsx'
|
|
48
|
+
const devDeps = (0, versions_1.withVersions)(['tsx']);
|
|
25
49
|
(0, devkit_1.addDependenciesToPackageJson)(tree, deps, devDeps);
|
|
50
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, deps, devDeps, projectPackageJsonPath);
|
|
26
51
|
// Generate example server
|
|
27
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'),
|
|
28
|
-
name
|
|
29
|
-
|
|
30
|
-
}, { overwriteStrategy: devkit_1.OverwriteStrategy.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
bundle: {
|
|
52
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), targetSourceDir, {
|
|
53
|
+
name,
|
|
54
|
+
esm,
|
|
55
|
+
}, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
56
|
+
(0, devkit_1.updateProjectConfiguration)(tree, project.name, Object.assign(Object.assign({}, project), { targets: Object.assign(Object.assign({}, project.targets), {
|
|
57
|
+
// Add target for running the MCP server
|
|
58
|
+
[`${options.name ? name : 'mcp-server'}-serve`]: {
|
|
35
59
|
executor: 'nx:run-commands',
|
|
36
60
|
options: {
|
|
37
|
-
commands: [
|
|
38
|
-
|
|
39
|
-
],
|
|
61
|
+
commands: [`tsx --watch ${relativeSourceDir}/index.ts`],
|
|
62
|
+
cwd: '{projectRoot}',
|
|
40
63
|
},
|
|
41
|
-
}
|
|
42
|
-
// Dev task for bundling whenever changes are made
|
|
43
|
-
dev: {
|
|
44
|
-
executor: 'nx:run-commands',
|
|
45
|
-
options: {
|
|
46
|
-
commands: [
|
|
47
|
-
`nx watch --projects=${fullyQualifiedName} --includeDependentProjects -- nx run ${fullyQualifiedName}:bundle`,
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
// Ensure bundle runs as part of build
|
|
52
|
-
build: Object.assign(Object.assign({}, (_a = project === null || project === void 0 ? void 0 : project.targets) === null || _a === void 0 ? void 0 : _a.build), { dependsOn: [...((_d = (_c = (_b = project === null || project === void 0 ? void 0 : project.targets) === null || _b === void 0 ? void 0 : _b.build) === null || _c === void 0 ? void 0 : _c.dependsOn) !== null && _d !== void 0 ? _d : []), 'bundle'] }) }) }));
|
|
53
|
-
(0, nx_1.addGeneratorMetadata)(tree, fullyQualifiedName, exports.TS_MCP_SERVER_GENERATOR_INFO);
|
|
64
|
+
} }) }));
|
|
54
65
|
yield (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [exports.TS_MCP_SERVER_GENERATOR_INFO]);
|
|
55
66
|
yield (0, format_1.formatFilesInSubtree)(tree);
|
|
56
67
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/mcp-server/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/mcp-server/generator.ts"],"names":[],"mappings":"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"}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import { TsProjectGeneratorSchema } from '../lib/schema';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* TypeScript types for options defined in schema.json
|
|
9
8
|
* Update this to match schema.json if you make changes.
|
|
10
9
|
*/
|
|
11
|
-
export
|
|
10
|
+
export interface TsMcpServerGeneratorSchema {
|
|
11
|
+
project: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
}
|
|
@@ -2,31 +2,24 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "ts#mcp-server",
|
|
4
4
|
"title": "ts#mcp-server",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Add a Model Context Protocol (MCP) server to an existing TypeScript project",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
|
-
"
|
|
8
|
+
"project": {
|
|
9
9
|
"type": "string",
|
|
10
|
-
"description": "MCP server
|
|
10
|
+
"description": "The project to add an MCP server to",
|
|
11
11
|
"$default": {
|
|
12
12
|
"$source": "argv",
|
|
13
13
|
"index": 0
|
|
14
14
|
},
|
|
15
|
-
"x-prompt": "
|
|
16
|
-
"x-
|
|
17
|
-
},
|
|
18
|
-
"directory": {
|
|
19
|
-
"type": "string",
|
|
20
|
-
"description": "Parent directory where the MCP server is placed.",
|
|
21
|
-
"default": "packages",
|
|
22
|
-
"x-prompt": "Which directory do you want to create the MCP server in?",
|
|
23
|
-
"x-priority": "important"
|
|
15
|
+
"x-prompt": "Select the TypeScript project to add the MCP server to",
|
|
16
|
+
"x-dropdown": "projects"
|
|
24
17
|
},
|
|
25
|
-
"
|
|
18
|
+
"name": {
|
|
26
19
|
"type": "string",
|
|
27
|
-
"description": "The
|
|
28
|
-
"x-prompt": "
|
|
20
|
+
"description": "The name of your MCP server (default: mcp-server)",
|
|
21
|
+
"x-prompt": "What would you like to call your MCP server? (default: mcp-server)"
|
|
29
22
|
}
|
|
30
23
|
},
|
|
31
|
-
"required": ["
|
|
24
|
+
"required": ["project"]
|
|
32
25
|
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
# <%- name %>
|
|
2
|
-
|
|
3
|
-
This package defines a Model Context Protocol (MCP) Server in TypeScript.
|
|
4
|
-
|
|
5
|
-
## What is MCP?
|
|
6
|
-
|
|
7
|
-
The Model Context Protocol (MCP) is a standardized protocol for providing context to Large Language Models (LLMs). It allows AI assistants to access external tools and resources through a consistent interface.
|
|
8
|
-
|
|
9
|
-
## Documentation
|
|
10
|
-
|
|
11
|
-
- [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
|
|
12
|
-
- [MCP TypeScript SDK Documentation](https://github.com/modelcontextprotocol/sdk-typescript)
|
|
13
|
-
|
|
14
|
-
## Developer Guide
|
|
15
|
-
|
|
16
|
-
### Getting Started
|
|
17
|
-
|
|
18
|
-
This MCP server is built using the MCP TypeScript SDK. Here's how to work with it:
|
|
19
|
-
|
|
20
|
-
1. **Server Structure**: The main server code is in `src/server.ts`. This file defines the server, its tools, and resources.
|
|
21
|
-
|
|
22
|
-
2. **Adding Tools**: Tools are functions that the LLM can call to perform actions. Add new tools using the `server.tool()` method:
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
server.tool("toolName",
|
|
26
|
-
{ param1: z.string(), param2: z.number() }, // Input schema using Zod
|
|
27
|
-
async ({ param1, param2 }) => {
|
|
28
|
-
// Tool implementation
|
|
29
|
-
return {
|
|
30
|
-
content: [{ type: "text", text: "Result" }]
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
3. **Adding Resources**: Resources provide context to the LLM. You can add static resources from files or dynamic resources:
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
// Static resource from a file
|
|
40
|
-
import resourceContent from './resources/my-resource.md';
|
|
41
|
-
|
|
42
|
-
server.resource('resource-name', 'example://resource', async (uri) => ({
|
|
43
|
-
contents: [{ uri: uri.href, text: resourceContent }],
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
// Dynamic resource
|
|
47
|
-
server.resource('dynamic-resource', 'dynamic://resource', async (uri) => {
|
|
48
|
-
const data = await fetchSomeData();
|
|
49
|
-
return {
|
|
50
|
-
contents: [{ uri: uri.href, text: data }],
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Building the Server
|
|
56
|
-
|
|
57
|
-
To build the server for use with AI assistants:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
nx run <project-name>:bundle
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
This creates a bundled version of your server in `dist/<project-path>/bundle/index.js`.
|
|
64
|
-
|
|
65
|
-
## Using with AI Assistants
|
|
66
|
-
|
|
67
|
-
To use your MCP server with AI assistants, you need to build it first to create the bundle:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
nx run <project-name>:bundle
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Configuration
|
|
74
|
-
|
|
75
|
-
Most AI assistants (Amazon Q Developer CLI, Cline, Cursor, Claude Code, etc.) use a similar configuration approach. You'll need to create or update a configuration file with your MCP server details:
|
|
76
|
-
|
|
77
|
-
```json
|
|
78
|
-
{
|
|
79
|
-
"mcpServers": {
|
|
80
|
-
"<%- name %>": {
|
|
81
|
-
"command": "node",
|
|
82
|
-
"args": [
|
|
83
|
-
"/path/to/workspace/dist/<%- dir %>/bundle/index.js"
|
|
84
|
-
],
|
|
85
|
-
"transportType": "stdio"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Replace `/path/to/workspace/dist/<%- dir %>/bundle/index.js` with the actual path to your bundled MCP server.
|
|
92
|
-
|
|
93
|
-
Note that if you receive an error due to `node` missing (eg `ENOENT node`), you might need to specify the full path to `node` which you can obtain by running `which node`.
|
|
94
|
-
|
|
95
|
-
### Development Mode
|
|
96
|
-
|
|
97
|
-
During development, you can use the `dev` target to continuously rebuild the bundle whenever you make changes:
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
nx run <project-name>:dev
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
This will watch for changes in your project files and automatically rebuild the bundle.
|
|
104
|
-
|
|
105
|
-
Whenever you've made changes, you'll need to restart the MCP server in your AI assistant to test it out. The exact process depends on the assistant, but generally:
|
|
106
|
-
|
|
107
|
-
1. Find your MCP server in the assistant's settings or configuration
|
|
108
|
-
2. Look for a "Restart" or "Reload" option
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2
|
-
import { createServer } from './server.js';
|
|
3
|
-
|
|
4
|
-
// Start receiving messages on stdin and sending messages on stdout
|
|
5
|
-
const transport = new StdioServerTransport();
|
|
6
|
-
await createServer().connect(transport);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import exampleContext from './resources/example-context.md';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Create the MCP Server
|
|
7
|
-
*/
|
|
8
|
-
export const createServer = () => {
|
|
9
|
-
const server = new McpServer({
|
|
10
|
-
name: "<%- name %>",
|
|
11
|
-
version: "1.0.0"
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// Add an addition tool
|
|
15
|
-
server.tool("add", "adds two numbers",
|
|
16
|
-
{ a: z.number(), b: z.number() },
|
|
17
|
-
async ({ a, b }) => ({
|
|
18
|
-
content: [{ type: "text", text: String(a + b) }]
|
|
19
|
-
})
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
// Add a resource which provides context from a markdown file
|
|
23
|
-
server.resource('example-context', 'example://context', async (uri) => ({
|
|
24
|
-
contents: [{ uri: uri.href, text: exampleContext }],
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
return server;
|
|
28
|
-
};
|