@agentailor/create-mcp-server 0.8.0 → 0.10.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/README.md +12 -47
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +20 -10
- package/dist/cli.test.js +32 -20
- package/dist/index.js +0 -2
- package/dist/interactive.js +1 -48
- package/dist/project-generator.d.ts +1 -4
- package/dist/project-generator.js +8 -23
- package/dist/templates/common/agents.md.js +9 -30
- package/dist/templates/common/agents.md.test.js +4 -21
- package/dist/templates/common/env.example.js +2 -5
- package/dist/templates/common/package.json.js +3 -17
- package/dist/templates/common/templates.test.js +9 -44
- package/dist/templates/common/tsconfig.json.d.ts +1 -3
- package/dist/templates/common/tsconfig.json.js +2 -5
- package/dist/templates/common/types.d.ts +0 -11
- package/package.json +1 -1
- package/dist/templates/fastmcp/index.d.ts +0 -5
- package/dist/templates/fastmcp/index.js +0 -32
- package/dist/templates/fastmcp/readme.d.ts +0 -2
- package/dist/templates/fastmcp/readme.js +0 -240
- package/dist/templates/fastmcp/server.d.ts +0 -1
- package/dist/templates/fastmcp/server.js +0 -66
- package/dist/templates/fastmcp/templates.test.d.ts +0 -1
- package/dist/templates/fastmcp/templates.test.js +0 -109
|
@@ -2,16 +2,15 @@ import { describe, it, expect } from 'vitest';
|
|
|
2
2
|
import { getAgentsMdTemplate } from './agents.md.js';
|
|
3
3
|
describe('getAgentsMdTemplate', () => {
|
|
4
4
|
const projectName = 'test-project';
|
|
5
|
-
const sdkHttp = {
|
|
6
|
-
const sdkStdio = {
|
|
7
|
-
const fastmcp = { framework: 'fastmcp', transport: 'http' };
|
|
5
|
+
const sdkHttp = { transport: 'http' };
|
|
6
|
+
const sdkStdio = { transport: 'stdio' };
|
|
8
7
|
it('should title the document with the project name', () => {
|
|
9
8
|
expect(getAgentsMdTemplate(projectName, sdkHttp)).toContain(`# ${projectName}`);
|
|
10
9
|
});
|
|
11
10
|
// The shipped example is meant to be deleted once real tools exist, but
|
|
12
11
|
// AGENTS.md stays. Anything naming the example rots the moment it goes.
|
|
13
12
|
it('should not reference the shipped example', () => {
|
|
14
|
-
for (const options of [sdkHttp, sdkStdio
|
|
13
|
+
for (const options of [sdkHttp, sdkStdio]) {
|
|
15
14
|
const template = getAgentsMdTemplate(projectName, options);
|
|
16
15
|
expect(template).not.toContain('notes-store');
|
|
17
16
|
expect(template).not.toContain('list_notes');
|
|
@@ -21,7 +20,7 @@ describe('getAgentsMdTemplate', () => {
|
|
|
21
20
|
}
|
|
22
21
|
});
|
|
23
22
|
it('should say the example is meant to be replaced', () => {
|
|
24
|
-
for (const options of [sdkHttp,
|
|
23
|
+
for (const options of [sdkHttp, sdkStdio]) {
|
|
25
24
|
expect(getAgentsMdTemplate(projectName, options)).toContain('meant to be replaced');
|
|
26
25
|
}
|
|
27
26
|
});
|
|
@@ -84,12 +83,6 @@ describe('getAgentsMdTemplate', () => {
|
|
|
84
83
|
expect(template).toContain('not a quota to match');
|
|
85
84
|
expect(template).toContain('src/server.test.ts');
|
|
86
85
|
});
|
|
87
|
-
it('should not promise tests FastMCP projects do not ship', () => {
|
|
88
|
-
const template = getAgentsMdTemplate(projectName, fastmcp);
|
|
89
|
-
expect(template).toContain('ships without a test setup');
|
|
90
|
-
expect(template).not.toContain('src/server.test.ts');
|
|
91
|
-
expect(template).not.toContain('npm test');
|
|
92
|
-
});
|
|
93
86
|
});
|
|
94
87
|
describe('layout', () => {
|
|
95
88
|
it('should describe the split primitives for SDK projects', () => {
|
|
@@ -98,11 +91,6 @@ describe('getAgentsMdTemplate', () => {
|
|
|
98
91
|
expect(template).toContain('MCP imports');
|
|
99
92
|
expect(template).toContain('Keep that seam');
|
|
100
93
|
});
|
|
101
|
-
it('should describe the single-file layout for FastMCP projects', () => {
|
|
102
|
-
const template = getAgentsMdTemplate(projectName, fastmcp);
|
|
103
|
-
expect(template).toContain('the FastMCP server and its tools');
|
|
104
|
-
expect(template).not.toContain('src/tools.ts');
|
|
105
|
-
});
|
|
106
94
|
});
|
|
107
95
|
describe('commands', () => {
|
|
108
96
|
it('should use the selected package manager', () => {
|
|
@@ -111,11 +99,6 @@ describe('getAgentsMdTemplate', () => {
|
|
|
111
99
|
expect(template).toContain('yarn build');
|
|
112
100
|
expect(template).not.toContain('npm run');
|
|
113
101
|
});
|
|
114
|
-
it('should omit the test command for FastMCP projects', () => {
|
|
115
|
-
const template = getAgentsMdTemplate(projectName, fastmcp);
|
|
116
|
-
expect(template).toContain('npm run build');
|
|
117
|
-
expect(template).not.toContain('npm test');
|
|
118
|
-
});
|
|
119
102
|
});
|
|
120
103
|
describe('tool-design skill', () => {
|
|
121
104
|
it('should point at the installed skill and how to update it', () => {
|
|
@@ -4,13 +4,10 @@ export function getEnvExampleTemplate(options) {
|
|
|
4
4
|
return `# No environment variables required for stdio transport\n`;
|
|
5
5
|
}
|
|
6
6
|
const withOAuth = options?.withOAuth ?? false;
|
|
7
|
-
const
|
|
8
|
-
const allowedHostsVar = isSdk
|
|
9
|
-
? `
|
|
7
|
+
const allowedHostsVar = `
|
|
10
8
|
# Comma-separated list of additional allowed hosts (for deployment behind reverse proxies)
|
|
11
9
|
# ALLOWED_HOSTS=my-server.example.com,my-server.us-central1.run.app
|
|
12
|
-
|
|
13
|
-
: '';
|
|
10
|
+
`;
|
|
14
11
|
const oauthVars = withOAuth
|
|
15
12
|
? `
|
|
16
13
|
# OAuth Configuration
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export function getPackageJsonTemplate(projectName, options) {
|
|
2
2
|
const withOAuth = options?.withOAuth ?? false;
|
|
3
|
-
const framework = options?.framework ?? 'sdk';
|
|
4
3
|
const transport = options?.transport ?? 'http';
|
|
5
|
-
// Tests ship with SDK projects only; FastMCP has no test setup yet.
|
|
6
|
-
const withTests = framework === 'sdk';
|
|
7
4
|
let dependencies;
|
|
8
5
|
let devDependencies;
|
|
9
6
|
const commonDevDependencies = {
|
|
@@ -19,19 +16,7 @@ export function getPackageJsonTemplate(projectName, options) {
|
|
|
19
16
|
vitest: '^5.0.1',
|
|
20
17
|
'@modelcontextprotocol/client': '^2.0.0',
|
|
21
18
|
};
|
|
22
|
-
if (
|
|
23
|
-
// FastMCP pulls in @modelcontextprotocol/sdk v1 itself, so this branch
|
|
24
|
-
// stays on v1 and must not gain the v2 packages.
|
|
25
|
-
dependencies = {
|
|
26
|
-
fastmcp: '^4.20.14',
|
|
27
|
-
...zodDependency,
|
|
28
|
-
...dotEnvDependency,
|
|
29
|
-
};
|
|
30
|
-
devDependencies = {
|
|
31
|
-
...commonDevDependencies,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
else if (transport === 'stdio') {
|
|
19
|
+
if (transport === 'stdio') {
|
|
35
20
|
// Official SDK v2 stdio - no express needed
|
|
36
21
|
dependencies = {
|
|
37
22
|
'@modelcontextprotocol/server': '^2.0.0',
|
|
@@ -80,7 +65,8 @@ export function getPackageJsonTemplate(projectName, options) {
|
|
|
80
65
|
build: 'tsc',
|
|
81
66
|
dev: 'tsc && node dist/index.js',
|
|
82
67
|
start: 'node dist/index.js',
|
|
83
|
-
|
|
68
|
+
test: 'vitest run',
|
|
69
|
+
'test:watch': 'vitest',
|
|
84
70
|
...inspectScripts,
|
|
85
71
|
},
|
|
86
72
|
dependencies,
|
|
@@ -31,44 +31,18 @@ describe('common templates', () => {
|
|
|
31
31
|
const pkg = JSON.parse(template);
|
|
32
32
|
expect(pkg.dependencies['dotenv']).toBeDefined();
|
|
33
33
|
});
|
|
34
|
-
it('should use FastMCP package when framework is fastmcp', () => {
|
|
35
|
-
const template = getPackageJsonTemplate(projectName, { framework: 'fastmcp' });
|
|
36
|
-
const pkg = JSON.parse(template);
|
|
37
|
-
expect(pkg.dependencies['fastmcp']).toBeDefined();
|
|
38
|
-
// FastMCP depends on the v1 SDK transitively, never directly
|
|
39
|
-
expect(pkg.dependencies['@modelcontextprotocol/sdk']).toBeUndefined();
|
|
40
|
-
expect(pkg.dependencies['express']).toBeUndefined();
|
|
41
|
-
});
|
|
42
|
-
it('should NOT pull SDK v2 packages into FastMCP projects', () => {
|
|
43
|
-
const template = getPackageJsonTemplate(projectName, { framework: 'fastmcp' });
|
|
44
|
-
const pkg = JSON.parse(template);
|
|
45
|
-
expect(pkg.dependencies['@modelcontextprotocol/server']).toBeUndefined();
|
|
46
|
-
expect(pkg.dependencies['@modelcontextprotocol/express']).toBeUndefined();
|
|
47
|
-
expect(pkg.dependencies['@modelcontextprotocol/node']).toBeUndefined();
|
|
48
|
-
});
|
|
49
|
-
it('should include dotenv for FastMCP', () => {
|
|
50
|
-
const template = getPackageJsonTemplate(projectName, { framework: 'fastmcp' });
|
|
51
|
-
const pkg = JSON.parse(template);
|
|
52
|
-
expect(pkg.dependencies['dotenv']).toBeDefined();
|
|
53
|
-
});
|
|
54
34
|
it('should include jose dependency when withOAuth is true for SDK', () => {
|
|
55
|
-
const template = getPackageJsonTemplate(projectName, {
|
|
35
|
+
const template = getPackageJsonTemplate(projectName, { withOAuth: true });
|
|
56
36
|
const pkg = JSON.parse(template);
|
|
57
37
|
expect(pkg.dependencies['jose']).toBeDefined();
|
|
58
38
|
});
|
|
59
|
-
it('should not include @types/express for FastMCP', () => {
|
|
60
|
-
const template = getPackageJsonTemplate(projectName, { framework: 'fastmcp' });
|
|
61
|
-
const pkg = JSON.parse(template);
|
|
62
|
-
expect(pkg.devDependencies['@types/express']).toBeUndefined();
|
|
63
|
-
});
|
|
64
39
|
it('should include @types/express for SDK', () => {
|
|
65
|
-
const template = getPackageJsonTemplate(projectName, {
|
|
40
|
+
const template = getPackageJsonTemplate(projectName, {});
|
|
66
41
|
const pkg = JSON.parse(template);
|
|
67
42
|
expect(pkg.devDependencies['@types/express']).toBeDefined();
|
|
68
43
|
});
|
|
69
44
|
it('should NOT include express or @types/express for SDK stdio', () => {
|
|
70
45
|
const template = getPackageJsonTemplate(projectName, {
|
|
71
|
-
framework: 'sdk',
|
|
72
46
|
transport: 'stdio',
|
|
73
47
|
});
|
|
74
48
|
const pkg = JSON.parse(template);
|
|
@@ -81,7 +55,6 @@ describe('common templates', () => {
|
|
|
81
55
|
});
|
|
82
56
|
it('should use inspect:tools, inspect:prompts, inspect:resources scripts for stdio transport', () => {
|
|
83
57
|
const template = getPackageJsonTemplate(projectName, {
|
|
84
|
-
framework: 'sdk',
|
|
85
58
|
transport: 'stdio',
|
|
86
59
|
});
|
|
87
60
|
const pkg = JSON.parse(template);
|
|
@@ -91,18 +64,14 @@ describe('common templates', () => {
|
|
|
91
64
|
expect(pkg.scripts['inspect']).toBeUndefined();
|
|
92
65
|
});
|
|
93
66
|
it('should use http inspect script for http transport (default)', () => {
|
|
94
|
-
const template = getPackageJsonTemplate(projectName, {
|
|
67
|
+
const template = getPackageJsonTemplate(projectName, { transport: 'http' });
|
|
95
68
|
const pkg = JSON.parse(template);
|
|
96
69
|
expect(pkg.scripts.inspect).toContain('http://localhost:3000/mcp');
|
|
97
70
|
});
|
|
98
71
|
// The inspector devDependency requires >=22.19.0; a lower floor makes npm
|
|
99
72
|
// emit an EBADENGINE warning on install.
|
|
100
73
|
it('should declare a node engine satisfying the inspector requirement', () => {
|
|
101
|
-
for (const options of [
|
|
102
|
-
{ framework: 'sdk', transport: 'http' },
|
|
103
|
-
{ framework: 'sdk', transport: 'stdio' },
|
|
104
|
-
{ framework: 'fastmcp' },
|
|
105
|
-
]) {
|
|
74
|
+
for (const options of [{ transport: 'http' }, { transport: 'stdio' }]) {
|
|
106
75
|
const pkg = JSON.parse(getPackageJsonTemplate(projectName, options));
|
|
107
76
|
expect(pkg.engines.node).toBe('>=22.19.0');
|
|
108
77
|
}
|
|
@@ -124,6 +93,10 @@ describe('common templates', () => {
|
|
|
124
93
|
const template = getTsconfigTemplate();
|
|
125
94
|
expect(() => JSON.parse(template)).not.toThrow();
|
|
126
95
|
});
|
|
96
|
+
it('should keep test files out of the build', () => {
|
|
97
|
+
const config = JSON.parse(getTsconfigTemplate());
|
|
98
|
+
expect(config.exclude).toContain('src/**/*.test.ts');
|
|
99
|
+
});
|
|
127
100
|
it('should target ES2022 with NodeNext modules', () => {
|
|
128
101
|
const template = getTsconfigTemplate();
|
|
129
102
|
const config = JSON.parse(template);
|
|
@@ -147,18 +120,10 @@ describe('common templates', () => {
|
|
|
147
120
|
const template = getEnvExampleTemplate();
|
|
148
121
|
expect(template).toContain('PORT=');
|
|
149
122
|
});
|
|
150
|
-
it('should include ALLOWED_HOSTS hint for
|
|
151
|
-
const template = getEnvExampleTemplate({ framework: 'sdk' });
|
|
152
|
-
expect(template).toContain('ALLOWED_HOSTS');
|
|
153
|
-
});
|
|
154
|
-
it('should include ALLOWED_HOSTS hint by default (no framework specified)', () => {
|
|
123
|
+
it('should include ALLOWED_HOSTS hint for HTTP transport', () => {
|
|
155
124
|
const template = getEnvExampleTemplate();
|
|
156
125
|
expect(template).toContain('ALLOWED_HOSTS');
|
|
157
126
|
});
|
|
158
|
-
it('should NOT include ALLOWED_HOSTS for FastMCP framework', () => {
|
|
159
|
-
const template = getEnvExampleTemplate({ framework: 'fastmcp' });
|
|
160
|
-
expect(template).not.toContain('ALLOWED_HOSTS');
|
|
161
|
-
});
|
|
162
127
|
it('should NOT include PORT for stdio transport', () => {
|
|
163
128
|
const template = getEnvExampleTemplate({ transport: 'stdio' });
|
|
164
129
|
expect(template).not.toContain('PORT=');
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
export function getTsconfigTemplate(
|
|
2
|
-
const withTests = options?.withTests ?? false;
|
|
1
|
+
export function getTsconfigTemplate() {
|
|
3
2
|
// Test files are type-checked by the editor and by vitest, but kept out of
|
|
4
3
|
// the build so they never reach dist/ or the production Docker image.
|
|
5
|
-
const exclude =
|
|
6
|
-
? ['node_modules', 'dist', 'src/**/*.test.ts']
|
|
7
|
-
: ['node_modules', 'dist'];
|
|
4
|
+
const exclude = ['node_modules', 'dist', 'src/**/*.test.ts'];
|
|
8
5
|
const tsconfig = {
|
|
9
6
|
compilerOptions: {
|
|
10
7
|
target: 'ES2022',
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export type PackageManager = 'npm' | 'pnpm' | 'yarn';
|
|
2
|
-
export type Framework = 'sdk' | 'fastmcp';
|
|
3
2
|
export type TransportType = 'http' | 'stdio';
|
|
4
3
|
/**
|
|
5
4
|
* Base template options shared across all templates
|
|
@@ -14,20 +13,10 @@ export interface SdkTemplateOptions extends BaseTemplateOptions {
|
|
|
14
13
|
withOAuth?: boolean;
|
|
15
14
|
transport?: TransportType;
|
|
16
15
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Template options for FastMCP templates
|
|
19
|
-
*/
|
|
20
|
-
export interface FastMCPTemplateOptions extends BaseTemplateOptions {
|
|
21
|
-
stateless?: boolean;
|
|
22
|
-
transport?: TransportType;
|
|
23
|
-
}
|
|
24
16
|
/**
|
|
25
17
|
* Template options for common templates (package.json, env.example)
|
|
26
|
-
* Includes all options since these are used across all frameworks
|
|
27
18
|
*/
|
|
28
19
|
export interface CommonTemplateOptions extends BaseTemplateOptions {
|
|
29
20
|
withOAuth?: boolean;
|
|
30
|
-
framework?: Framework;
|
|
31
|
-
stateless?: boolean;
|
|
32
21
|
transport?: TransportType;
|
|
33
22
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type { FastMCPTemplateOptions as TemplateOptions } from '../common/types.js';
|
|
2
|
-
import type { FastMCPTemplateOptions } from '../common/types.js';
|
|
3
|
-
export declare function getIndexTemplate(options?: FastMCPTemplateOptions): string;
|
|
4
|
-
export { getServerTemplate } from './server.js';
|
|
5
|
-
export { getReadmeTemplate } from './readme.js';
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export function getIndexTemplate(options) {
|
|
2
|
-
const transport = options?.transport ?? 'http';
|
|
3
|
-
if (transport === 'stdio') {
|
|
4
|
-
return `import { server } from './server.js';
|
|
5
|
-
|
|
6
|
-
server.start({
|
|
7
|
-
transportType: "stdio",
|
|
8
|
-
});
|
|
9
|
-
`;
|
|
10
|
-
}
|
|
11
|
-
const stateless = options?.stateless ?? false;
|
|
12
|
-
const statelessConfig = stateless ? '\n stateless: true,' : '';
|
|
13
|
-
return `import { config } from 'dotenv';
|
|
14
|
-
import { server } from './server.js';
|
|
15
|
-
|
|
16
|
-
// quiet: dotenv >=18 logs a summary line on load; keep startup output clean.
|
|
17
|
-
config({ quiet: true });
|
|
18
|
-
|
|
19
|
-
const PORT = Number(process.env.PORT) || 3000;
|
|
20
|
-
|
|
21
|
-
server.start({
|
|
22
|
-
transportType: 'httpStream',
|
|
23
|
-
httpStream: {
|
|
24
|
-
port: PORT,${statelessConfig}
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
console.log(\`MCP Server listening on port \${PORT}\`);
|
|
29
|
-
`;
|
|
30
|
-
}
|
|
31
|
-
export { getServerTemplate } from './server.js';
|
|
32
|
-
export { getReadmeTemplate } from './readme.js';
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
export function getReadmeTemplate(projectName, options) {
|
|
2
|
-
const packageManager = options?.packageManager ?? 'npm';
|
|
3
|
-
const stateless = options?.stateless ?? false;
|
|
4
|
-
const transport = options?.transport ?? 'http';
|
|
5
|
-
const commands = {
|
|
6
|
-
npm: {
|
|
7
|
-
install: 'npm install',
|
|
8
|
-
dev: 'npm run dev',
|
|
9
|
-
build: 'npm run build',
|
|
10
|
-
start: 'npm start',
|
|
11
|
-
inspect: 'npm run inspect',
|
|
12
|
-
inspectTools: 'npm run inspect:tools',
|
|
13
|
-
inspectPrompts: 'npm run inspect:prompts',
|
|
14
|
-
inspectResources: 'npm run inspect:resources',
|
|
15
|
-
},
|
|
16
|
-
pnpm: {
|
|
17
|
-
install: 'pnpm install',
|
|
18
|
-
dev: 'pnpm dev',
|
|
19
|
-
build: 'pnpm build',
|
|
20
|
-
start: 'pnpm start',
|
|
21
|
-
inspect: 'pnpm inspect',
|
|
22
|
-
inspectTools: 'pnpm inspect:tools',
|
|
23
|
-
inspectPrompts: 'pnpm inspect:prompts',
|
|
24
|
-
inspectResources: 'pnpm inspect:resources',
|
|
25
|
-
},
|
|
26
|
-
yarn: {
|
|
27
|
-
install: 'yarn',
|
|
28
|
-
dev: 'yarn dev',
|
|
29
|
-
build: 'yarn build',
|
|
30
|
-
start: 'yarn start',
|
|
31
|
-
inspect: 'yarn inspect',
|
|
32
|
-
inspectTools: 'yarn inspect:tools',
|
|
33
|
-
inspectPrompts: 'yarn inspect:prompts',
|
|
34
|
-
inspectResources: 'yarn inspect:resources',
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
const cmd = commands[packageManager];
|
|
38
|
-
if (transport === 'stdio') {
|
|
39
|
-
return `# ${projectName}
|
|
40
|
-
|
|
41
|
-
A stdio MCP server built with FastMCP.
|
|
42
|
-
|
|
43
|
-
## About
|
|
44
|
-
|
|
45
|
-
This project was created with [@agentailor/create-mcp-server](https://www.npmjs.com/package/@agentailor/create-mcp-server) using [FastMCP](https://github.com/punkpeye/fastmcp).
|
|
46
|
-
|
|
47
|
-
## Getting Started
|
|
48
|
-
|
|
49
|
-
\`\`\`bash
|
|
50
|
-
# Install dependencies
|
|
51
|
-
${cmd.install}
|
|
52
|
-
|
|
53
|
-
# Build and run
|
|
54
|
-
${cmd.dev}
|
|
55
|
-
|
|
56
|
-
# Or build and start separately
|
|
57
|
-
${cmd.build}
|
|
58
|
-
${cmd.start}
|
|
59
|
-
\`\`\`
|
|
60
|
-
|
|
61
|
-
## Testing with MCP Inspector
|
|
62
|
-
|
|
63
|
-
This project includes [MCP Inspector](https://github.com/modelcontextprotocol/inspector) as a dev dependency. Build the project first (\`${cmd.build}\`), then use the inspect scripts:
|
|
64
|
-
|
|
65
|
-
\`\`\`bash
|
|
66
|
-
# List tools
|
|
67
|
-
${cmd.inspectTools}
|
|
68
|
-
|
|
69
|
-
# List prompts
|
|
70
|
-
${cmd.inspectPrompts}
|
|
71
|
-
|
|
72
|
-
# List resources
|
|
73
|
-
${cmd.inspectResources}
|
|
74
|
-
\`\`\`
|
|
75
|
-
|
|
76
|
-
You can also call tools directly:
|
|
77
|
-
|
|
78
|
-
\`\`\`bash
|
|
79
|
-
# Call a tool
|
|
80
|
-
npx @modelcontextprotocol/inspector --cli node dist/index.js --method tools/call --tool-name start-notification-stream --tool-arg interval=100 --tool-arg count=5
|
|
81
|
-
|
|
82
|
-
# Call a tool with JSON arguments
|
|
83
|
-
npx @modelcontextprotocol/inspector --cli node dist/index.js --method tools/call --tool-name start-notification-stream --tool-arg 'options={"interval": 100, "count": 5}'
|
|
84
|
-
\`\`\`
|
|
85
|
-
|
|
86
|
-
## Included Examples
|
|
87
|
-
|
|
88
|
-
This server comes with example implementations to help you get started:
|
|
89
|
-
|
|
90
|
-
### Prompts
|
|
91
|
-
|
|
92
|
-
- **greeting-template** - A simple greeting prompt that takes a name parameter
|
|
93
|
-
|
|
94
|
-
### Tools
|
|
95
|
-
|
|
96
|
-
- **start-notification-stream** - Sends periodic notifications for testing. Parameters:
|
|
97
|
-
- \`interval\`: Milliseconds between notifications (default: 100)
|
|
98
|
-
- \`count\`: Number of notifications to send (default: 10, use 0 for unlimited)
|
|
99
|
-
|
|
100
|
-
### Resources
|
|
101
|
-
|
|
102
|
-
- **greeting-resource** - A simple text resource at \`https://example.com/greetings/default\`
|
|
103
|
-
|
|
104
|
-
## Project Structure
|
|
105
|
-
|
|
106
|
-
\`\`\`
|
|
107
|
-
${projectName}/
|
|
108
|
-
├── src/
|
|
109
|
-
│ ├── server.ts # FastMCP server definition (tools, prompts, resources)
|
|
110
|
-
│ └── index.ts # Server startup configuration
|
|
111
|
-
├── package.json
|
|
112
|
-
├── tsconfig.json
|
|
113
|
-
└── README.md
|
|
114
|
-
\`\`\`
|
|
115
|
-
|
|
116
|
-
## Customization
|
|
117
|
-
|
|
118
|
-
- Add new tools, prompts, and resources in \`src/server.ts\`
|
|
119
|
-
- Modify transport configuration in \`src/index.ts\`
|
|
120
|
-
|
|
121
|
-
## Tool design skill
|
|
122
|
-
|
|
123
|
-
Agentailor's [tool-design](https://github.com/agentailor/skills) skill is
|
|
124
|
-
included at \`.agents/skills/tool-design/\`, so a coding agent working here has
|
|
125
|
-
the guidance on hand. Commit it so the whole team gets the same copy.
|
|
126
|
-
|
|
127
|
-
It is the version that shipped with the scaffolding CLI. To check for a newer
|
|
128
|
-
one — your call, not automatic:
|
|
129
|
-
|
|
130
|
-
\`\`\`bash
|
|
131
|
-
npx skills update -p -y
|
|
132
|
-
\`\`\`
|
|
133
|
-
|
|
134
|
-
## Learn More
|
|
135
|
-
|
|
136
|
-
- [FastMCP](https://github.com/punkpeye/fastmcp) - The framework powering this server
|
|
137
|
-
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
|
138
|
-
`;
|
|
139
|
-
}
|
|
140
|
-
const modeDescription = stateless
|
|
141
|
-
? 'A stateless streamable HTTP MCP server built with FastMCP.'
|
|
142
|
-
: 'A stateful streamable HTTP MCP server built with FastMCP.';
|
|
143
|
-
return `# ${projectName}
|
|
144
|
-
|
|
145
|
-
${modeDescription}
|
|
146
|
-
|
|
147
|
-
## About
|
|
148
|
-
|
|
149
|
-
This project was created with [@agentailor/create-mcp-server](https://www.npmjs.com/package/@agentailor/create-mcp-server) using [FastMCP](https://github.com/punkpeye/fastmcp).
|
|
150
|
-
|
|
151
|
-
## Getting Started
|
|
152
|
-
|
|
153
|
-
\`\`\`bash
|
|
154
|
-
# Install dependencies
|
|
155
|
-
${cmd.install}
|
|
156
|
-
|
|
157
|
-
# Build and run in development
|
|
158
|
-
${cmd.dev}
|
|
159
|
-
|
|
160
|
-
# Or build and start separately
|
|
161
|
-
${cmd.build}
|
|
162
|
-
${cmd.start}
|
|
163
|
-
\`\`\`
|
|
164
|
-
|
|
165
|
-
The server will start on port 3000 by default. You can change this by setting the \`PORT\` environment variable.
|
|
166
|
-
|
|
167
|
-
## Testing with MCP Inspector
|
|
168
|
-
|
|
169
|
-
This project includes [MCP Inspector](https://github.com/modelcontextprotocol/inspector) as a dev dependency for testing and debugging.
|
|
170
|
-
|
|
171
|
-
First, start the server in one terminal:
|
|
172
|
-
|
|
173
|
-
\`\`\`bash
|
|
174
|
-
${cmd.dev}
|
|
175
|
-
\`\`\`
|
|
176
|
-
|
|
177
|
-
Then, in another terminal, launch the inspector:
|
|
178
|
-
|
|
179
|
-
\`\`\`bash
|
|
180
|
-
${cmd.inspect}
|
|
181
|
-
\`\`\`
|
|
182
|
-
|
|
183
|
-
## API Endpoints
|
|
184
|
-
|
|
185
|
-
- **POST /mcp** - Main MCP endpoint for JSON-RPC messages
|
|
186
|
-
- **GET /health** - Health check endpoint (returns 200 OK)
|
|
187
|
-
|
|
188
|
-
## Included Examples
|
|
189
|
-
|
|
190
|
-
This server comes with example implementations to help you get started:
|
|
191
|
-
|
|
192
|
-
### Prompts
|
|
193
|
-
|
|
194
|
-
- **greeting-template** - A simple greeting prompt that takes a name parameter
|
|
195
|
-
|
|
196
|
-
### Tools
|
|
197
|
-
|
|
198
|
-
- **start-notification-stream** - Sends periodic notifications for testing. Parameters:
|
|
199
|
-
- \`interval\`: Milliseconds between notifications (default: 100)
|
|
200
|
-
- \`count\`: Number of notifications to send (default: 10, use 0 for unlimited)
|
|
201
|
-
|
|
202
|
-
### Resources
|
|
203
|
-
|
|
204
|
-
- **greeting-resource** - A simple text resource at \`https://example.com/greetings/default\`
|
|
205
|
-
|
|
206
|
-
## Project Structure
|
|
207
|
-
|
|
208
|
-
\`\`\`
|
|
209
|
-
${projectName}/
|
|
210
|
-
├── src/
|
|
211
|
-
│ ├── server.ts # FastMCP server definition (tools, prompts, resources)
|
|
212
|
-
│ └── index.ts # Server startup configuration
|
|
213
|
-
├── Dockerfile # Multi-stage Docker build
|
|
214
|
-
├── package.json
|
|
215
|
-
├── tsconfig.json
|
|
216
|
-
└── README.md
|
|
217
|
-
\`\`\`
|
|
218
|
-
|
|
219
|
-
## Deployment
|
|
220
|
-
|
|
221
|
-
### Docker
|
|
222
|
-
|
|
223
|
-
Build and run the Docker container:
|
|
224
|
-
|
|
225
|
-
\`\`\`bash
|
|
226
|
-
docker build -t ${projectName} .
|
|
227
|
-
docker run -p 3000:3000 ${projectName}
|
|
228
|
-
\`\`\`
|
|
229
|
-
## Customization
|
|
230
|
-
|
|
231
|
-
- Add new tools, prompts, and resources in \`src/server.ts\`
|
|
232
|
-
- Modify transport configuration in \`src/index.ts\`
|
|
233
|
-
|
|
234
|
-
## Learn More
|
|
235
|
-
|
|
236
|
-
- [FastMCP](https://github.com/punkpeye/fastmcp) - The framework powering this server
|
|
237
|
-
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
|
238
|
-
- [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
|
|
239
|
-
`;
|
|
240
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getServerTemplate(projectName: string): string;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export function getServerTemplate(projectName) {
|
|
2
|
-
return `import { FastMCP } from 'fastmcp';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
const server = new FastMCP({
|
|
6
|
-
name: '${projectName}',
|
|
7
|
-
version: '1.0.0',
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
// Register a simple prompt
|
|
11
|
-
server.addPrompt({
|
|
12
|
-
name: 'greeting-template',
|
|
13
|
-
description: 'A simple greeting prompt template',
|
|
14
|
-
arguments: [
|
|
15
|
-
{
|
|
16
|
-
name: 'name',
|
|
17
|
-
description: 'Name to include in greeting',
|
|
18
|
-
required: true,
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
load: async ({ name }) => {
|
|
22
|
-
return \`Please greet \${name} in a friendly manner.\`;
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Register a tool for testing resumability
|
|
27
|
-
server.addTool({
|
|
28
|
-
name: 'start-notification-stream',
|
|
29
|
-
description: 'Starts sending periodic notifications for testing resumability',
|
|
30
|
-
parameters: z.object({
|
|
31
|
-
interval: z
|
|
32
|
-
.number()
|
|
33
|
-
.describe('Interval in milliseconds between notifications')
|
|
34
|
-
.default(100),
|
|
35
|
-
count: z.number().describe('Number of notifications to send (0 for 100)').default(10),
|
|
36
|
-
}),
|
|
37
|
-
execute: async ({ interval, count }) => {
|
|
38
|
-
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
39
|
-
let counter = 0;
|
|
40
|
-
|
|
41
|
-
while (count === 0 || counter < count) {
|
|
42
|
-
counter++;
|
|
43
|
-
console.log(\`Periodic notification #\${counter} at \${new Date().toISOString()}\`);
|
|
44
|
-
await sleep(interval);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return \`Sent \${counter} periodic notifications every \${interval}ms\`;
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Create a simple resource at a fixed URI
|
|
52
|
-
server.addResource({
|
|
53
|
-
uri: 'https://example.com/greetings/default',
|
|
54
|
-
name: 'greeting-resource',
|
|
55
|
-
description: 'A simple greeting resource',
|
|
56
|
-
mimeType: 'text/plain',
|
|
57
|
-
load: async () => {
|
|
58
|
-
return {
|
|
59
|
-
text: 'Hello, world!',
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
export { server };
|
|
65
|
-
`;
|
|
66
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|