@agentailor/create-mcp-server 0.10.0 → 0.11.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.
Files changed (45) hide show
  1. package/README.md +2 -2
  2. package/dist/cli.d.ts +1 -2
  3. package/dist/cli.js +10 -7
  4. package/dist/cli.test.js +29 -48
  5. package/dist/project-generator.js +3 -13
  6. package/dist/templates/common/package.json.js +13 -12
  7. package/dist/templates/common/types.d.ts +1 -1
  8. package/dist/templates/sdk/{stateless → http}/index.d.ts +2 -1
  9. package/dist/templates/sdk/{stateless → http}/index.js +2 -1
  10. package/dist/templates/sdk/{stateless → http}/templates.test.js +90 -1
  11. package/dist/templates/sdk/stdio/index.d.ts +6 -6
  12. package/dist/templates/sdk/stdio/index.js +6 -6
  13. package/dist/templates/sdk/stdio/server.d.ts +1 -1
  14. package/dist/templates/sdk/stdio/server.js +2 -2
  15. package/dist/templates/sdk/stdio/templates.test.js +2 -2
  16. package/package.json +1 -1
  17. package/dist/templates/sdk/stateful/index.d.ts +0 -11
  18. package/dist/templates/sdk/stateful/index.js +0 -12
  19. package/dist/templates/sdk/stateful/readme.d.ts +0 -1
  20. package/dist/templates/sdk/stateful/readme.js +0 -3
  21. package/dist/templates/sdk/stateful/server.d.ts +0 -1
  22. package/dist/templates/sdk/stateful/server.js +0 -2
  23. package/dist/templates/sdk/stateful/templates.test.js +0 -198
  24. package/dist/templates/sdk/stateless/templates.test.d.ts +0 -1
  25. /package/dist/templates/sdk/{stateful → http}/auth.d.ts +0 -0
  26. /package/dist/templates/sdk/{stateful → http}/auth.js +0 -0
  27. /package/dist/templates/sdk/{stateful → http}/auth.test.d.ts +0 -0
  28. /package/dist/templates/sdk/{stateful → http}/auth.test.js +0 -0
  29. /package/dist/templates/sdk/{stateless → http}/prompts.d.ts +0 -0
  30. /package/dist/templates/sdk/{stateless → http}/prompts.js +0 -0
  31. /package/dist/templates/sdk/{stateless → http}/readme.d.ts +0 -0
  32. /package/dist/templates/sdk/{stateless → http}/readme.js +0 -0
  33. /package/dist/templates/sdk/{stateless → http}/resources.d.ts +0 -0
  34. /package/dist/templates/sdk/{stateless → http}/resources.js +0 -0
  35. /package/dist/templates/sdk/{stateless → http}/server-test.d.ts +0 -0
  36. /package/dist/templates/sdk/{stateless → http}/server-test.js +0 -0
  37. /package/dist/templates/sdk/{stateless → http}/server.d.ts +0 -0
  38. /package/dist/templates/sdk/{stateless → http}/server.js +0 -0
  39. /package/dist/templates/sdk/{stateless → http}/store-test.d.ts +0 -0
  40. /package/dist/templates/sdk/{stateless → http}/store-test.js +0 -0
  41. /package/dist/templates/sdk/{stateless → http}/store.d.ts +0 -0
  42. /package/dist/templates/sdk/{stateless → http}/store.js +0 -0
  43. /package/dist/templates/sdk/{stateful → http}/templates.test.d.ts +0 -0
  44. /package/dist/templates/sdk/{stateless → http}/tools.d.ts +0 -0
  45. /package/dist/templates/sdk/{stateless → http}/tools.js +0 -0
package/README.md CHANGED
@@ -31,7 +31,7 @@ npx @agentailor/create-mcp-server --name=my-server
31
31
  | `--package-manager` | `-p` | `npm` | Package manager: npm, pnpm, yarn |
32
32
  | `--framework` | `-f` | `sdk` | Accepted for compatibility; `sdk` is the only framework |
33
33
  | `--stdio` | — | `false` | Use stdio transport (for local clients) |
34
- | `--template` | `-t` | `stateless` | Accepted for compatibility; SDK v2 serves both modes through one per-request idiom |
34
+ | `--template` | `-t` | — | **Deprecated**, no effect; prints a warning and will be removed in a future release |
35
35
  | `--oauth` | — | `false` | Enable OAuth (HTTP only, incompatible with --stdio) |
36
36
  | `--no-git` | — | `false` | Skip git initialization |
37
37
  | `--no-skills` | — | `false` | Skip adding the tool-design skill |
@@ -94,7 +94,7 @@ HTTP servers are built on `createMcpHandler`, which runs the server factory once
94
94
 
95
95
  SDK v2 serves every HTTP request through a single per-request idiom: `createMcpHandler` builds a fresh `McpServer` for each call, and 2025-era clients are served through the same path. The `stateless`/`stateful` distinction that v1 required no longer changes the generated project.
96
96
 
97
- `--template` is still accepted so existing invocations keep working, but both values produce the same output. If you need session-based serving with SSE resumability, the SDK still offers `NodeStreamableHTTPServerTransport` — see the [SDK v2 sessions guide](https://ts.sdk.modelcontextprotocol.io/v2/serving/sessions-state-scaling.html).
97
+ `--template` is deprecated: both values produce the same output and the CLI prints a warning when it is passed. It will be removed in a future release, so drop it from scripts. If you need session-based serving with SSE resumability, the SDK still offers `NodeStreamableHTTPServerTransport` — see the [SDK v2 sessions guide](https://ts.sdk.modelcontextprotocol.io/v2/serving/sessions-state-scaling.html).
98
98
 
99
99
  ## Generated Project
100
100
 
package/dist/cli.d.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import type { PackageManager, TransportType } from './templates/common/types.js';
2
- export type TemplateType = 'stateless' | 'stateful';
3
2
  export interface CLIOptions {
4
3
  name: string;
5
4
  packageManager: PackageManager;
6
5
  transport: TransportType;
7
- template: TemplateType;
8
6
  oauth: boolean;
9
7
  git: boolean;
10
8
  skills: boolean;
@@ -14,4 +12,5 @@ export interface ParseResult {
14
12
  options?: CLIOptions;
15
13
  }
16
14
  export declare const FASTMCP_REMOVED_MESSAGE: string;
15
+ export declare const TEMPLATE_DEPRECATED_MESSAGE: string;
17
16
  export declare function parseArguments(): ParseResult;
package/dist/cli.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import { Command, Option, InvalidArgumentError } from 'commander';
2
2
  const NAME_REGEX = /^[a-z0-9-_]+$/i;
3
- const VERSION = '0.10.0';
3
+ const VERSION = '0.11.0';
4
4
  export const FASTMCP_REMOVED_MESSAGE = [
5
5
  'FastMCP support was removed in 0.10.0. New projects use the Official MCP SDK;',
6
6
  'drop --framework, or pass --framework=sdk.',
7
7
  'To scaffold a FastMCP project, pin the last release that supports it:',
8
8
  ' npx @agentailor/create-mcp-server@0.9 --framework=fastmcp',
9
9
  ].join('\n');
10
+ export const TEMPLATE_DEPRECATED_MESSAGE = '--template is deprecated and has no effect: stateless and stateful generate the same project. ' +
11
+ 'It will be removed in a future release; drop it from your command.';
10
12
  function validateName(value) {
11
13
  if (!NAME_REGEX.test(value)) {
12
14
  throw new InvalidArgumentError('Project name can only contain letters, numbers, hyphens, and underscores');
@@ -27,9 +29,12 @@ export function parseArguments() {
27
29
  // `--framework=sdk` invocations keep working, and so `fastmcp` gets a
28
30
  // removal message instead of Commander's generic invalid-choice error.
29
31
  .addOption(new Option('-f, --framework <framework>', 'Framework (sdk only; accepted for compatibility)').default('sdk'))
30
- .addOption(new Option('-t, --template <type>', 'Template type (no effect on SDK projects; both generate the same server)')
32
+ // Deprecated: SDK v2 serves every HTTP request the same way, so both values
33
+ // generate the same project. Still parsed so existing scripts get a warning
34
+ // rather than Commander's unknown-option error.
35
+ .addOption(new Option('-t, --template <type>', 'Deprecated; has no effect')
31
36
  .choices(['stateless', 'stateful'])
32
- .default('stateless'))
37
+ .hideHelp())
33
38
  .option('--stdio', 'Use stdio transport instead of HTTP', false)
34
39
  .option('--oauth', 'Enable OAuth authentication (sdk HTTP only)', false)
35
40
  .option('--no-git', 'Skip git repository initialization')
@@ -64,9 +69,8 @@ export function parseArguments() {
64
69
  console.error('\nError: --stdio cannot be combined with --oauth\n');
65
70
  process.exit(1);
66
71
  }
67
- if (opts.stdio && opts.template === 'stateful') {
68
- console.error('\nError: --template=stateful is not applicable with --stdio (stdio is inherently stateless)\n');
69
- process.exit(1);
72
+ if (opts.template !== undefined) {
73
+ console.warn(`\nWarning: ${TEMPLATE_DEPRECATED_MESSAGE}\n`);
70
74
  }
71
75
  return {
72
76
  mode: 'cli',
@@ -74,7 +78,6 @@ export function parseArguments() {
74
78
  name: opts.name,
75
79
  packageManager: opts.packageManager,
76
80
  transport: (opts.stdio ? 'stdio' : 'http'),
77
- template: opts.template,
78
81
  oauth: opts.oauth,
79
82
  git: opts.git, // Commander handles --no-git -> git: false
80
83
  skills: opts.skills, // Commander handles --no-skills -> skills: false
package/dist/cli.test.js CHANGED
@@ -32,7 +32,6 @@ describe('CLI argument parsing', () => {
32
32
  const result = parseArguments();
33
33
  expect(result.options?.packageManager).toBe('npm');
34
34
  expect(result.options?.transport).toBe('http');
35
- expect(result.options?.template).toBe('stateless');
36
35
  expect(result.options?.oauth).toBe(false);
37
36
  expect(result.options?.git).toBe(true);
38
37
  });
@@ -43,7 +42,6 @@ describe('CLI argument parsing', () => {
43
42
  '--name=test-project',
44
43
  '--package-manager=pnpm',
45
44
  '--framework=sdk',
46
- '--template=stateful',
47
45
  '--no-git',
48
46
  ];
49
47
  const { parseArguments } = await import('./cli.js');
@@ -52,53 +50,51 @@ describe('CLI argument parsing', () => {
52
50
  name: 'test-project',
53
51
  packageManager: 'pnpm',
54
52
  transport: 'http',
55
- template: 'stateful',
56
53
  oauth: false,
57
54
  git: false,
58
55
  skills: true,
59
56
  });
60
57
  });
61
58
  it('parses short flags correctly', async () => {
62
- process.argv = [
63
- 'node',
64
- 'create-mcp-server',
65
- '-n',
66
- 'my-project',
67
- '-p',
68
- 'yarn',
69
- '-f',
70
- 'sdk',
71
- '-t',
72
- 'stateful',
73
- ];
59
+ process.argv = ['node', 'create-mcp-server', '-n', 'my-project', '-p', 'yarn', '-f', 'sdk'];
74
60
  const { parseArguments } = await import('./cli.js');
75
61
  const result = parseArguments();
76
62
  expect(result.options?.name).toBe('my-project');
77
63
  expect(result.options?.packageManager).toBe('yarn');
78
- expect(result.options?.template).toBe('stateful');
79
64
  });
80
- it('parses oauth flag correctly for sdk+stateful', async () => {
81
- process.argv = [
82
- 'node',
83
- 'create-mcp-server',
84
- '--name=my-auth-server',
85
- '--framework=sdk',
86
- '--template=stateful',
87
- '--oauth',
88
- ];
65
+ it('parses the oauth flag', async () => {
66
+ process.argv = ['node', 'create-mcp-server', '--name=my-auth-server', '--oauth'];
89
67
  const { parseArguments } = await import('./cli.js');
90
68
  const result = parseArguments();
91
69
  expect(result.options?.oauth).toBe(true);
92
- expect(result.options?.template).toBe('stateful');
93
70
  });
94
- // SDK v2 collapsed the stateless/stateful distinction, and OAuth is
95
- // orthogonal to sessions, so --oauth no longer requires --template=stateful.
96
- it('parses oauth flag correctly for sdk without --template=stateful', async () => {
97
- process.argv = ['node', 'create-mcp-server', '--name=my-auth-server', '--oauth'];
98
- const { parseArguments } = await import('./cli.js');
71
+ // Deprecated, not removed: existing scripts must keep working, with a warning.
72
+ it.each(['stateless', 'stateful'])('warns that --template=%s is deprecated and still generates', async (value) => {
73
+ process.argv = ['node', 'create-mcp-server', '--name=test', '--template=' + value];
74
+ const consoleWarn = vi.spyOn(console, 'warn').mockImplementation(() => { });
75
+ const { parseArguments, TEMPLATE_DEPRECATED_MESSAGE } = await import('./cli.js');
99
76
  const result = parseArguments();
100
- expect(result.options?.oauth).toBe(true);
101
- expect(result.options?.template).toBe('stateless');
77
+ expect(result.mode).toBe('cli');
78
+ expect(result.options?.transport).toBe('http');
79
+ expect(consoleWarn).toHaveBeenCalledWith(expect.stringContaining(TEMPLATE_DEPRECATED_MESSAGE));
80
+ consoleWarn.mockRestore();
81
+ });
82
+ // stdio has no sessions either, so the old stdio+stateful error is now just the warning.
83
+ it('accepts --template=stateful with --stdio, with a warning', async () => {
84
+ process.argv = ['node', 'create-mcp-server', '--name=test', '--stdio', '-t', 'stateful'];
85
+ const consoleWarn = vi.spyOn(console, 'warn').mockImplementation(() => { });
86
+ const { parseArguments } = await import('./cli.js');
87
+ expect(parseArguments().options?.transport).toBe('stdio');
88
+ expect(consoleWarn).toHaveBeenCalledWith(expect.stringContaining('--template is deprecated'));
89
+ consoleWarn.mockRestore();
90
+ });
91
+ it('does not warn when --template is omitted', async () => {
92
+ process.argv = ['node', 'create-mcp-server', '--name=test'];
93
+ const consoleWarn = vi.spyOn(console, 'warn').mockImplementation(() => { });
94
+ const { parseArguments } = await import('./cli.js');
95
+ parseArguments();
96
+ expect(consoleWarn).not.toHaveBeenCalled();
97
+ consoleWarn.mockRestore();
102
98
  });
103
99
  it('exits with error when --name is missing in CLI mode', async () => {
104
100
  process.argv = ['node', 'create-mcp-server', '--package-manager=npm'];
@@ -196,7 +192,6 @@ describe('CLI argument parsing', () => {
196
192
  '--stdio',
197
193
  '--oauth',
198
194
  '--framework=sdk',
199
- '--template=stateful',
200
195
  ];
201
196
  let exitCode;
202
197
  process.exit = vi.fn((code) => {
@@ -210,20 +205,6 @@ describe('CLI argument parsing', () => {
210
205
  expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('--stdio cannot be combined with --oauth'));
211
206
  consoleError.mockRestore();
212
207
  });
213
- it('exits with error when --stdio combined with --template=stateful', async () => {
214
- process.argv = ['node', 'create-mcp-server', '--name=test', '--stdio', '--template=stateful'];
215
- let exitCode;
216
- process.exit = vi.fn((code) => {
217
- exitCode = code;
218
- throw new Error('process.exit called');
219
- });
220
- const consoleError = vi.spyOn(console, 'error').mockImplementation(() => { });
221
- const { parseArguments } = await import('./cli.js');
222
- expect(() => parseArguments()).toThrow('process.exit called');
223
- expect(exitCode).toBe(1);
224
- expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('--template=stateful is not applicable with --stdio'));
225
- consoleError.mockRestore();
226
- });
227
208
  it('installs the tool-design skill by default', async () => {
228
209
  process.argv = ['node', 'create-mcp-server', '--name=test'];
229
210
  const { parseArguments } = await import('./cli.js');
@@ -7,18 +7,9 @@ import { getGitignoreTemplate } from './templates/common/gitignore.js';
7
7
  import { getEnvExampleTemplate } from './templates/common/env.example.js';
8
8
  import { getAgentsMdTemplate } from './templates/common/agents.md.js';
9
9
  import { copySkill, SKILLS_UPDATE_COMMAND, SKILLS_INSTALL_HINT, SKILLS_DIR } from './skills.js';
10
- import { getServerTemplate as getSdkStatelessServerTemplate, getIndexTemplate as getSdkStatelessIndexTemplate, getReadmeTemplate as getSdkStatelessReadmeTemplate, getStoreTemplate as getSdkStoreTemplate, getToolsTemplate as getSdkToolsTemplate, getPromptsTemplate as getSdkPromptsTemplate, getResourcesTemplate as getSdkResourcesTemplate, getStoreTestTemplate as getSdkStoreTestTemplate, getServerTestTemplate as getSdkServerTestTemplate, } from './templates/sdk/stateless/index.js';
11
- import { getAuthTemplate as getSdkAuthTemplate } from './templates/sdk/stateful/index.js';
10
+ import { getServerTemplate as getSdkHttpServerTemplate, getIndexTemplate as getSdkHttpIndexTemplate, getReadmeTemplate as getSdkHttpReadmeTemplate, getAuthTemplate as getSdkAuthTemplate, getStoreTemplate as getSdkStoreTemplate, getToolsTemplate as getSdkToolsTemplate, getPromptsTemplate as getSdkPromptsTemplate, getResourcesTemplate as getSdkResourcesTemplate, getStoreTestTemplate as getSdkStoreTestTemplate, getServerTestTemplate as getSdkServerTestTemplate, } from './templates/sdk/http/index.js';
12
11
  import { getServerTemplate as getSdkStdioServerTemplate, getIndexTemplate as getSdkStdioIndexTemplate, getReadmeTemplate as getSdkStdioReadmeTemplate, } from './templates/sdk/stdio/index.js';
13
12
  import { getDockerfileTemplate, getDockerignoreTemplate } from './templates/deployment/index.js';
14
- // Auth is keyed off `withOAuth`, never off the template type - see
15
- // "Why stateless and stateful are identical" in AGENTS.md.
16
- const sdkHttpTemplateFunctions = {
17
- getServerTemplate: getSdkStatelessServerTemplate,
18
- getIndexTemplate: getSdkStatelessIndexTemplate,
19
- getReadmeTemplate: getSdkStatelessReadmeTemplate,
20
- getAuthTemplate: getSdkAuthTemplate,
21
- };
22
13
  export const packageManagerCommands = {
23
14
  npm: { install: 'npm install', dev: 'npm run dev' },
24
15
  pnpm: { install: 'pnpm install', dev: 'pnpm dev' },
@@ -42,10 +33,9 @@ export async function generateProject(config) {
42
33
  filesToWrite.push(writeFile(join(srcPath, 'server.ts'), getSdkStdioServerTemplate(projectName)), writeFile(join(srcPath, 'index.ts'), getSdkStdioIndexTemplate(templateOptions)), writeFile(join(projectPath, 'README.md'), getSdkStdioReadmeTemplate(projectName, templateOptions)));
43
34
  }
44
35
  else {
45
- const templates = sdkHttpTemplateFunctions;
46
- filesToWrite.push(writeFile(join(srcPath, 'server.ts'), templates.getServerTemplate(projectName)), writeFile(join(srcPath, 'index.ts'), templates.getIndexTemplate(templateOptions)), writeFile(join(projectPath, 'README.md'), templates.getReadmeTemplate(projectName, templateOptions)));
36
+ filesToWrite.push(writeFile(join(srcPath, 'server.ts'), getSdkHttpServerTemplate(projectName)), writeFile(join(srcPath, 'index.ts'), getSdkHttpIndexTemplate(templateOptions)), writeFile(join(projectPath, 'README.md'), getSdkHttpReadmeTemplate(projectName, templateOptions)));
47
37
  if (withOAuth) {
48
- filesToWrite.push(writeFile(join(srcPath, 'auth.ts'), templates.getAuthTemplate()));
38
+ filesToWrite.push(writeFile(join(srcPath, 'auth.ts'), getSdkAuthTemplate()));
49
39
  }
50
40
  }
51
41
  // server.ts only composes these; they are identical on both transports.
@@ -5,21 +5,21 @@ export function getPackageJsonTemplate(projectName, options) {
5
5
  let devDependencies;
6
6
  const commonDevDependencies = {
7
7
  typescript: '^7.0.2',
8
- '@modelcontextprotocol/inspector': '^2.7.0',
9
- '@types/node': '^26.6.2',
8
+ '@modelcontextprotocol/inspector': '^2.9.0',
9
+ '@types/node': '^26.6.4',
10
10
  };
11
11
  const zodDependency = { zod: '^4.6.5' };
12
- const dotEnvDependency = { dotenv: '^18.0.1' };
12
+ const dotEnvDependency = { dotenv: '^18.0.5' };
13
13
  // The client drives the server over an in-memory transport in the generated
14
14
  // tests, so it must track @modelcontextprotocol/server's major.
15
15
  const testDevDependencies = {
16
- vitest: '^5.0.1',
17
- '@modelcontextprotocol/client': '^2.0.0',
16
+ vitest: '^5.0.3',
17
+ '@modelcontextprotocol/client': '^2.3.0',
18
18
  };
19
19
  if (transport === 'stdio') {
20
20
  // Official SDK v2 stdio - no express needed
21
21
  dependencies = {
22
- '@modelcontextprotocol/server': '^2.0.0',
22
+ '@modelcontextprotocol/server': '^2.3.0',
23
23
  ...zodDependency,
24
24
  ...dotEnvDependency,
25
25
  };
@@ -32,11 +32,11 @@ export function getPackageJsonTemplate(projectName, options) {
32
32
  // hono is a peer dependency of @modelcontextprotocol/node, so the generated
33
33
  // project must declare it even though no template code imports it.
34
34
  dependencies = {
35
- '@modelcontextprotocol/server': '^2.0.0',
36
- '@modelcontextprotocol/express': '^2.0.0',
37
- '@modelcontextprotocol/node': '^2.0.0',
35
+ '@modelcontextprotocol/server': '^2.3.0',
36
+ '@modelcontextprotocol/express': '^2.0.2',
37
+ '@modelcontextprotocol/node': '^2.1.1',
38
38
  express: '^5.2.1',
39
- hono: '^4.13.8',
39
+ hono: '^4.13.13',
40
40
  ...zodDependency,
41
41
  ...dotEnvDependency,
42
42
  };
@@ -72,8 +72,9 @@ export function getPackageJsonTemplate(projectName, options) {
72
72
  dependencies,
73
73
  devDependencies,
74
74
  engines: {
75
- // Floor set by @modelcontextprotocol/inspector, which requires >=22.19.0.
76
- // The SDK v2 packages themselves only need >=20.
75
+ // Floor set by @modelcontextprotocol/inspector, which requires >=22.19.0
76
+ // (vitest 5 alone needs ^22.12.0). The SDK v2 packages only need >=20.
77
+ // Node 20 is end-of-life, so this floor costs no supported user anything.
77
78
  node: '>=22.19.0',
78
79
  },
79
80
  };
@@ -7,7 +7,7 @@ export interface BaseTemplateOptions {
7
7
  packageManager?: PackageManager;
8
8
  }
9
9
  /**
10
- * Template options for SDK templates (stateless and stateful)
10
+ * Template options for SDK templates (http and stdio)
11
11
  */
12
12
  export interface SdkTemplateOptions extends BaseTemplateOptions {
13
13
  withOAuth?: boolean;
@@ -1,7 +1,7 @@
1
1
  export type { SdkTemplateOptions as TemplateOptions } from '../../common/types.js';
2
2
  import type { SdkTemplateOptions } from '../../common/types.js';
3
3
  /**
4
- * Shared HTTP entrypoint template, used by both SDK HTTP template types.
4
+ * HTTP entrypoint template.
5
5
  * Varies only by `options.withOAuth`.
6
6
  */
7
7
  export declare function getIndexTemplate(options?: SdkTemplateOptions): string;
@@ -13,3 +13,4 @@ export { getPromptsTemplate } from './prompts.js';
13
13
  export { getResourcesTemplate } from './resources.js';
14
14
  export { getStoreTestTemplate } from './store-test.js';
15
15
  export { getServerTestTemplate } from './server-test.js';
16
+ export { getAuthTemplate } from './auth.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Shared HTTP entrypoint template, used by both SDK HTTP template types.
2
+ * HTTP entrypoint template.
3
3
  * Varies only by `options.withOAuth`.
4
4
  */
5
5
  export function getIndexTemplate(options) {
@@ -99,3 +99,4 @@ export { getPromptsTemplate } from './prompts.js';
99
99
  export { getResourcesTemplate } from './resources.js';
100
100
  export { getStoreTestTemplate } from './store-test.js';
101
101
  export { getServerTestTemplate } from './server-test.js';
102
+ export { getAuthTemplate } from './auth.js';
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect } from 'vitest';
2
2
  import { getServerTemplate, getIndexTemplate, getReadmeTemplate, getStoreTemplate, getToolsTemplate, getPromptsTemplate, getResourcesTemplate, getStoreTestTemplate, getServerTestTemplate, } from './index.js';
3
- describe('sdk/stateless templates', () => {
3
+ describe('sdk/http templates', () => {
4
4
  const projectName = 'test-project';
5
5
  describe('getServerTemplate', () => {
6
6
  it('should include project name in server config', () => {
@@ -284,4 +284,93 @@ describe('sdk/stateless templates', () => {
284
284
  }
285
285
  });
286
286
  });
287
+ describe('getIndexTemplate with OAuth', () => {
288
+ it('should include auth imports when OAuth enabled', () => {
289
+ const template = getIndexTemplate({ withOAuth: true });
290
+ expect(template).toContain("from './auth.js'");
291
+ expect(template).toContain('setupAuthMetadataRouter');
292
+ expect(template).toContain('authMiddleware');
293
+ expect(template).toContain('getOAuthMetadataUrl');
294
+ });
295
+ it('should import validateOAuthConfig when OAuth enabled', () => {
296
+ const template = getIndexTemplate({ withOAuth: true });
297
+ expect(template).toContain('validateOAuthConfig');
298
+ });
299
+ it('should setup auth metadata router when OAuth enabled', () => {
300
+ const template = getIndexTemplate({ withOAuth: true });
301
+ expect(template).toContain('setupAuthMetadataRouter(app)');
302
+ });
303
+ it('should apply auth middleware to the /mcp route when OAuth enabled', () => {
304
+ const template = getIndexTemplate({ withOAuth: true });
305
+ expect(template).toContain("app.all('/mcp', authMiddleware,");
306
+ });
307
+ it('should log OAuth metadata URL on startup when OAuth enabled', () => {
308
+ const template = getIndexTemplate({ withOAuth: true });
309
+ expect(template).toContain('getOAuthMetadataUrl()');
310
+ });
311
+ it('should call validateOAuthConfig before starting server when OAuth enabled', () => {
312
+ const template = getIndexTemplate({ withOAuth: true });
313
+ expect(template).toContain('await validateOAuthConfig()');
314
+ });
315
+ it('should wrap server startup in async main function when OAuth enabled', () => {
316
+ const template = getIndexTemplate({ withOAuth: true });
317
+ expect(template).toContain('async function main()');
318
+ expect(template).toContain('main().catch');
319
+ });
320
+ it('should exit with error if OAuth validation fails', () => {
321
+ const template = getIndexTemplate({ withOAuth: true });
322
+ expect(template).toContain('Failed to start server');
323
+ expect(template).toContain('process.exit(1)');
324
+ });
325
+ it('should NOT include auth imports when OAuth disabled', () => {
326
+ const template = getIndexTemplate({ withOAuth: false });
327
+ expect(template).not.toContain("from './auth.js'");
328
+ expect(template).not.toContain('authMiddleware');
329
+ });
330
+ it('should NOT include auth imports by default', () => {
331
+ const template = getIndexTemplate();
332
+ expect(template).not.toContain("from './auth.js'");
333
+ });
334
+ it('should NOT wrap in async main when OAuth disabled', () => {
335
+ const template = getIndexTemplate({ withOAuth: false });
336
+ expect(template).not.toContain('async function main()');
337
+ });
338
+ });
339
+ describe('getReadmeTemplate with OAuth', () => {
340
+ it('should include OAuth section when enabled', () => {
341
+ const template = getReadmeTemplate(projectName, { withOAuth: true });
342
+ expect(template).toContain('## OAuth Authentication');
343
+ expect(template).toContain('OAUTH_ISSUER_URL');
344
+ expect(template).toContain('OAUTH_AUDIENCE');
345
+ expect(template).toContain('Bearer token');
346
+ });
347
+ it('should list supported OAuth providers', () => {
348
+ const template = getReadmeTemplate(projectName, { withOAuth: true });
349
+ expect(template).toContain('Auth0');
350
+ expect(template).toContain('Keycloak');
351
+ expect(template).toContain('Azure AD');
352
+ expect(template).toContain('Okta');
353
+ });
354
+ it('should document JWKS-based JWT validation', () => {
355
+ const template = getReadmeTemplate(projectName, { withOAuth: true });
356
+ expect(template).toContain('JWT');
357
+ expect(template).toContain('.well-known/jwks.json');
358
+ });
359
+ it('should document where auth info surfaces to handlers', () => {
360
+ const template = getReadmeTemplate(projectName, { withOAuth: true });
361
+ expect(template).toContain('ctx.http.authInfo');
362
+ });
363
+ it('should include auth.ts in project structure when OAuth enabled', () => {
364
+ const template = getReadmeTemplate(projectName, { withOAuth: true });
365
+ expect(template).toContain('auth.ts');
366
+ });
367
+ it('should NOT include OAuth section when disabled', () => {
368
+ const template = getReadmeTemplate(projectName, { withOAuth: false });
369
+ expect(template).not.toContain('## OAuth Authentication');
370
+ });
371
+ it('should NOT include OAuth section by default', () => {
372
+ const template = getReadmeTemplate(projectName);
373
+ expect(template).not.toContain('## OAuth Authentication');
374
+ });
375
+ });
287
376
  });
@@ -3,9 +3,9 @@ import type { SdkTemplateOptions } from '../../common/types.js';
3
3
  export declare function getIndexTemplate(_options?: SdkTemplateOptions): string;
4
4
  export { getServerTemplate } from './server.js';
5
5
  export { getReadmeTemplate } from './readme.js';
6
- export { getStoreTemplate } from '../stateless/store.js';
7
- export { getToolsTemplate } from '../stateless/tools.js';
8
- export { getPromptsTemplate } from '../stateless/prompts.js';
9
- export { getResourcesTemplate } from '../stateless/resources.js';
10
- export { getStoreTestTemplate } from '../stateless/store-test.js';
11
- export { getServerTestTemplate } from '../stateless/server-test.js';
6
+ export { getStoreTemplate } from '../http/store.js';
7
+ export { getToolsTemplate } from '../http/tools.js';
8
+ export { getPromptsTemplate } from '../http/prompts.js';
9
+ export { getResourcesTemplate } from '../http/resources.js';
10
+ export { getStoreTestTemplate } from '../http/store-test.js';
11
+ export { getServerTestTemplate } from '../http/server-test.js';
@@ -12,9 +12,9 @@ console.error('MCP Server running on stdio');
12
12
  }
13
13
  export { getServerTemplate } from './server.js';
14
14
  export { getReadmeTemplate } from './readme.js';
15
- export { getStoreTemplate } from '../stateless/store.js';
16
- export { getToolsTemplate } from '../stateless/tools.js';
17
- export { getPromptsTemplate } from '../stateless/prompts.js';
18
- export { getResourcesTemplate } from '../stateless/resources.js';
19
- export { getStoreTestTemplate } from '../stateless/store-test.js';
20
- export { getServerTestTemplate } from '../stateless/server-test.js';
15
+ export { getStoreTemplate } from '../http/store.js';
16
+ export { getToolsTemplate } from '../http/tools.js';
17
+ export { getPromptsTemplate } from '../http/prompts.js';
18
+ export { getResourcesTemplate } from '../http/resources.js';
19
+ export { getStoreTestTemplate } from '../http/store-test.js';
20
+ export { getServerTestTemplate } from '../http/server-test.js';
@@ -1 +1 @@
1
- export { getServerTemplate } from '../stateless/server.js';
1
+ export { getServerTemplate } from '../http/server.js';
@@ -1,2 +1,2 @@
1
- // Re-export from stateless template - server logic is identical for stdio
2
- export { getServerTemplate } from '../stateless/server.js';
1
+ // Re-export from the HTTP template - server logic is identical for stdio
2
+ export { getServerTemplate } from '../http/server.js';
@@ -12,8 +12,8 @@ describe('sdk/stdio templates', () => {
12
12
  expect(template).toContain("from '@modelcontextprotocol/server'");
13
13
  expect(template).not.toContain('@modelcontextprotocol/sdk');
14
14
  });
15
- // The server is re-exported from stateless/, so this only checks that the
16
- // same composition arrives here - its detail is tested in stateless/.
15
+ // The server is re-exported from http/, so this only checks that the
16
+ // same composition arrives here - its detail is tested in http/.
17
17
  it('should compose the shared primitives', () => {
18
18
  const template = getServerTemplate(projectName);
19
19
  expect(template).toContain('registerTools(server)');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentailor/create-mcp-server",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Create a new MCP (Model Context Protocol) server project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,11 +0,0 @@
1
- export type { SdkTemplateOptions as TemplateOptions } from '../../common/types.js';
2
- export { getIndexTemplate } from '../stateless/index.js';
3
- export { getServerTemplate } from './server.js';
4
- export { getReadmeTemplate } from './readme.js';
5
- export { getAuthTemplate } from './auth.js';
6
- export { getStoreTemplate } from '../stateless/store.js';
7
- export { getToolsTemplate } from '../stateless/tools.js';
8
- export { getPromptsTemplate } from '../stateless/prompts.js';
9
- export { getResourcesTemplate } from '../stateless/resources.js';
10
- export { getStoreTestTemplate } from '../stateless/store-test.js';
11
- export { getServerTestTemplate } from '../stateless/server-test.js';
@@ -1,12 +0,0 @@
1
- // Intentionally identical to the stateless template - see "Why stateless and
2
- // stateful are identical" in AGENTS.md. Edit behaviour in stateless/, not here.
3
- export { getIndexTemplate } from '../stateless/index.js';
4
- export { getServerTemplate } from './server.js';
5
- export { getReadmeTemplate } from './readme.js';
6
- export { getAuthTemplate } from './auth.js';
7
- export { getStoreTemplate } from '../stateless/store.js';
8
- export { getToolsTemplate } from '../stateless/tools.js';
9
- export { getPromptsTemplate } from '../stateless/prompts.js';
10
- export { getResourcesTemplate } from '../stateless/resources.js';
11
- export { getStoreTestTemplate } from '../stateless/store-test.js';
12
- export { getServerTestTemplate } from '../stateless/server-test.js';
@@ -1 +0,0 @@
1
- export { getReadmeTemplate } from '../stateless/readme.js';
@@ -1,3 +0,0 @@
1
- // Intentionally identical to the stateless template - see "Why stateless and
2
- // stateful are identical" in AGENTS.md. Edit behaviour in stateless/, not here.
3
- export { getReadmeTemplate } from '../stateless/readme.js';
@@ -1 +0,0 @@
1
- export { getServerTemplate } from '../stateless/server.js';
@@ -1,2 +0,0 @@
1
- // Re-export from stateless template - server logic is identical
2
- export { getServerTemplate } from '../stateless/server.js';
@@ -1,198 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { getServerTemplate, getIndexTemplate, getReadmeTemplate } from './index.js';
3
- import { getIndexTemplate as getStatelessIndexTemplate, getReadmeTemplate as getStatelessReadmeTemplate, } from '../stateless/index.js';
4
- describe('sdk/stateful templates', () => {
5
- const projectName = 'test-project';
6
- // Pins the re-export: shared behaviour is covered by the stateless suite.
7
- describe('convergence with the stateless template', () => {
8
- it('should produce the same index template as stateless', () => {
9
- expect(getIndexTemplate()).toBe(getStatelessIndexTemplate());
10
- });
11
- it('should produce the same index template as stateless with OAuth', () => {
12
- expect(getIndexTemplate({ withOAuth: true })).toBe(getStatelessIndexTemplate({ withOAuth: true }));
13
- });
14
- it('should produce the same readme as stateless', () => {
15
- expect(getReadmeTemplate(projectName)).toBe(getStatelessReadmeTemplate(projectName));
16
- });
17
- });
18
- describe('getServerTemplate', () => {
19
- it('should include project name in server config', () => {
20
- const template = getServerTemplate(projectName);
21
- expect(template).toContain(`name: '${projectName}'`);
22
- });
23
- it('should use SDK v2 imports', () => {
24
- const template = getServerTemplate(projectName);
25
- expect(template).toContain("from '@modelcontextprotocol/server'");
26
- expect(template).not.toContain('@modelcontextprotocol/sdk');
27
- });
28
- // The server is re-exported from stateless/, so this only checks that the
29
- // same composition arrives here - its detail is tested in stateless/.
30
- it('should compose the shared primitives', () => {
31
- const template = getServerTemplate(projectName);
32
- expect(template).toContain('registerTools(server)');
33
- expect(template).toContain('registerPrompts(server)');
34
- expect(template).toContain('registerResources(server)');
35
- });
36
- });
37
- describe('getIndexTemplate', () => {
38
- it('should use SDK v2 serving imports', () => {
39
- const template = getIndexTemplate();
40
- expect(template).toContain("import { createMcpHandler } from '@modelcontextprotocol/server'");
41
- expect(template).toContain("import { createMcpExpressApp } from '@modelcontextprotocol/express'");
42
- expect(template).toContain("import { toNodeHandler } from '@modelcontextprotocol/node'");
43
- });
44
- it('should mount the /mcp endpoint with app.all', () => {
45
- const template = getIndexTemplate();
46
- expect(template).toContain("app.all('/mcp'");
47
- });
48
- it('should use PORT from environment variable', () => {
49
- const template = getIndexTemplate();
50
- expect(template).toContain('process.env.PORT');
51
- });
52
- it('should not carry over v1 session machinery', () => {
53
- const template = getIndexTemplate();
54
- expect(template).not.toContain('sessionIdGenerator');
55
- expect(template).not.toContain('isInitializeRequest');
56
- expect(template).not.toContain('randomUUID');
57
- expect(template).not.toContain('mcp-session-id');
58
- expect(template).not.toContain('const transports');
59
- });
60
- });
61
- describe('getReadmeTemplate', () => {
62
- it('should include project name', () => {
63
- const template = getReadmeTemplate(projectName);
64
- expect(template).toContain(`# ${projectName}`);
65
- });
66
- it('should include getting started instructions with npm by default', () => {
67
- const template = getReadmeTemplate(projectName);
68
- expect(template).toContain('npm install');
69
- expect(template).toContain('npm run dev');
70
- expect(template).toContain('npm run build');
71
- expect(template).toContain('npm start');
72
- });
73
- it('should document the /mcp endpoint', () => {
74
- const template = getReadmeTemplate(projectName);
75
- expect(template).toContain('/mcp');
76
- });
77
- it('should not document removed session management', () => {
78
- const template = getReadmeTemplate(projectName);
79
- expect(template).not.toContain('mcp-session-id');
80
- expect(template).not.toContain('DELETE /mcp');
81
- expect(template).not.toContain('SSE');
82
- });
83
- });
84
- describe('getReadmeTemplate with package manager', () => {
85
- it('should use npm commands when packageManager is npm', () => {
86
- const template = getReadmeTemplate(projectName, { packageManager: 'npm' });
87
- expect(template).toContain('npm install');
88
- expect(template).toContain('npm run dev');
89
- expect(template).toContain('npm run build');
90
- expect(template).toContain('npm start');
91
- });
92
- it('should use pnpm commands when packageManager is pnpm', () => {
93
- const template = getReadmeTemplate(projectName, { packageManager: 'pnpm' });
94
- expect(template).toContain('pnpm install');
95
- expect(template).toContain('pnpm dev');
96
- expect(template).toContain('pnpm build');
97
- expect(template).toContain('pnpm start');
98
- expect(template).not.toContain('npm run');
99
- });
100
- it('should use yarn commands when packageManager is yarn', () => {
101
- const template = getReadmeTemplate(projectName, { packageManager: 'yarn' });
102
- expect(template).toContain('yarn\n');
103
- expect(template).toContain('yarn dev');
104
- expect(template).toContain('yarn build');
105
- expect(template).toContain('yarn start');
106
- expect(template).not.toContain('npm run');
107
- });
108
- });
109
- describe('getIndexTemplate with OAuth', () => {
110
- it('should include auth imports when OAuth enabled', () => {
111
- const template = getIndexTemplate({ withOAuth: true });
112
- expect(template).toContain("from './auth.js'");
113
- expect(template).toContain('setupAuthMetadataRouter');
114
- expect(template).toContain('authMiddleware');
115
- expect(template).toContain('getOAuthMetadataUrl');
116
- });
117
- it('should import validateOAuthConfig when OAuth enabled', () => {
118
- const template = getIndexTemplate({ withOAuth: true });
119
- expect(template).toContain('validateOAuthConfig');
120
- });
121
- it('should setup auth metadata router when OAuth enabled', () => {
122
- const template = getIndexTemplate({ withOAuth: true });
123
- expect(template).toContain('setupAuthMetadataRouter(app)');
124
- });
125
- it('should apply auth middleware to the /mcp route when OAuth enabled', () => {
126
- const template = getIndexTemplate({ withOAuth: true });
127
- expect(template).toContain("app.all('/mcp', authMiddleware,");
128
- });
129
- it('should log OAuth metadata URL on startup when OAuth enabled', () => {
130
- const template = getIndexTemplate({ withOAuth: true });
131
- expect(template).toContain('getOAuthMetadataUrl()');
132
- });
133
- it('should call validateOAuthConfig before starting server when OAuth enabled', () => {
134
- const template = getIndexTemplate({ withOAuth: true });
135
- expect(template).toContain('await validateOAuthConfig()');
136
- });
137
- it('should wrap server startup in async main function when OAuth enabled', () => {
138
- const template = getIndexTemplate({ withOAuth: true });
139
- expect(template).toContain('async function main()');
140
- expect(template).toContain('main().catch');
141
- });
142
- it('should exit with error if OAuth validation fails', () => {
143
- const template = getIndexTemplate({ withOAuth: true });
144
- expect(template).toContain('Failed to start server');
145
- expect(template).toContain('process.exit(1)');
146
- });
147
- it('should NOT include auth imports when OAuth disabled', () => {
148
- const template = getIndexTemplate({ withOAuth: false });
149
- expect(template).not.toContain("from './auth.js'");
150
- expect(template).not.toContain('authMiddleware');
151
- });
152
- it('should NOT include auth imports by default', () => {
153
- const template = getIndexTemplate();
154
- expect(template).not.toContain("from './auth.js'");
155
- });
156
- it('should NOT wrap in async main when OAuth disabled', () => {
157
- const template = getIndexTemplate({ withOAuth: false });
158
- expect(template).not.toContain('async function main()');
159
- });
160
- });
161
- describe('getReadmeTemplate with OAuth', () => {
162
- it('should include OAuth section when enabled', () => {
163
- const template = getReadmeTemplate(projectName, { withOAuth: true });
164
- expect(template).toContain('## OAuth Authentication');
165
- expect(template).toContain('OAUTH_ISSUER_URL');
166
- expect(template).toContain('OAUTH_AUDIENCE');
167
- expect(template).toContain('Bearer token');
168
- });
169
- it('should list supported OAuth providers', () => {
170
- const template = getReadmeTemplate(projectName, { withOAuth: true });
171
- expect(template).toContain('Auth0');
172
- expect(template).toContain('Keycloak');
173
- expect(template).toContain('Azure AD');
174
- expect(template).toContain('Okta');
175
- });
176
- it('should document JWKS-based JWT validation', () => {
177
- const template = getReadmeTemplate(projectName, { withOAuth: true });
178
- expect(template).toContain('JWT');
179
- expect(template).toContain('.well-known/jwks.json');
180
- });
181
- it('should document where auth info surfaces to handlers', () => {
182
- const template = getReadmeTemplate(projectName, { withOAuth: true });
183
- expect(template).toContain('ctx.http.authInfo');
184
- });
185
- it('should include auth.ts in project structure when OAuth enabled', () => {
186
- const template = getReadmeTemplate(projectName, { withOAuth: true });
187
- expect(template).toContain('auth.ts');
188
- });
189
- it('should NOT include OAuth section when disabled', () => {
190
- const template = getReadmeTemplate(projectName, { withOAuth: false });
191
- expect(template).not.toContain('## OAuth Authentication');
192
- });
193
- it('should NOT include OAuth section by default', () => {
194
- const template = getReadmeTemplate(projectName);
195
- expect(template).not.toContain('## OAuth Authentication');
196
- });
197
- });
198
- });
@@ -1 +0,0 @@
1
- export {};
File without changes
File without changes
File without changes
File without changes