@agentailor/create-mcp-server 0.10.0 → 0.12.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 (53) hide show
  1. package/README.md +8 -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 +21 -28
  6. package/dist/skills.d.ts +9 -0
  7. package/dist/skills.js +9 -0
  8. package/dist/templates/common/agents.md.js +60 -3
  9. package/dist/templates/common/agents.md.test.js +28 -0
  10. package/dist/templates/common/package.json.js +13 -12
  11. package/dist/templates/common/skill-readme.d.ts +8 -0
  12. package/dist/templates/common/skill-readme.js +35 -0
  13. package/dist/templates/common/skill-readme.test.js +25 -0
  14. package/dist/templates/common/types.d.ts +6 -1
  15. package/dist/templates/sdk/{stateless → http}/index.d.ts +2 -1
  16. package/dist/templates/sdk/{stateless → http}/index.js +2 -1
  17. package/dist/templates/sdk/{stateless → http}/readme.js +9 -13
  18. package/dist/templates/sdk/{stateless → http}/server-test.js +59 -3
  19. package/dist/templates/sdk/{stateless → http}/store.js +5 -0
  20. package/dist/templates/sdk/{stateless → http}/templates.test.js +119 -1
  21. package/dist/templates/sdk/{stateless → http}/tools.js +135 -1
  22. package/dist/templates/sdk/stdio/index.d.ts +6 -6
  23. package/dist/templates/sdk/stdio/index.js +6 -6
  24. package/dist/templates/sdk/stdio/readme.js +9 -13
  25. package/dist/templates/sdk/stdio/server.d.ts +1 -1
  26. package/dist/templates/sdk/stdio/server.js +2 -2
  27. package/dist/templates/sdk/stdio/templates.test.js +2 -2
  28. package/package.json +1 -1
  29. package/dist/templates/sdk/stateful/index.d.ts +0 -11
  30. package/dist/templates/sdk/stateful/index.js +0 -12
  31. package/dist/templates/sdk/stateful/readme.d.ts +0 -1
  32. package/dist/templates/sdk/stateful/readme.js +0 -3
  33. package/dist/templates/sdk/stateful/server.d.ts +0 -1
  34. package/dist/templates/sdk/stateful/server.js +0 -2
  35. package/dist/templates/sdk/stateful/templates.test.js +0 -198
  36. /package/dist/templates/{sdk/stateful/auth.test.d.ts → common/skill-readme.test.d.ts} +0 -0
  37. /package/dist/templates/sdk/{stateful → http}/auth.d.ts +0 -0
  38. /package/dist/templates/sdk/{stateful → http}/auth.js +0 -0
  39. /package/dist/templates/sdk/{stateful/templates.test.d.ts → http/auth.test.d.ts} +0 -0
  40. /package/dist/templates/sdk/{stateful → http}/auth.test.js +0 -0
  41. /package/dist/templates/sdk/{stateless → http}/prompts.d.ts +0 -0
  42. /package/dist/templates/sdk/{stateless → http}/prompts.js +0 -0
  43. /package/dist/templates/sdk/{stateless → http}/readme.d.ts +0 -0
  44. /package/dist/templates/sdk/{stateless → http}/resources.d.ts +0 -0
  45. /package/dist/templates/sdk/{stateless → http}/resources.js +0 -0
  46. /package/dist/templates/sdk/{stateless → http}/server-test.d.ts +0 -0
  47. /package/dist/templates/sdk/{stateless → http}/server.d.ts +0 -0
  48. /package/dist/templates/sdk/{stateless → http}/server.js +0 -0
  49. /package/dist/templates/sdk/{stateless → http}/store-test.d.ts +0 -0
  50. /package/dist/templates/sdk/{stateless → http}/store-test.js +0 -0
  51. /package/dist/templates/sdk/{stateless → http}/store.d.ts +0 -0
  52. /package/dist/templates/sdk/{stateless → http}/templates.test.d.ts +0 -0
  53. /package/dist/templates/sdk/{stateless → http}/tools.d.ts +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
 
@@ -139,6 +139,12 @@ to the protocol over stdio).
139
139
  - `npm test` — run the test suite
140
140
  - `npm run inspect` — open MCP Inspector (update URL in `package.json` if needed)
141
141
 
142
+ ## Examples
143
+
144
+ Complete servers built with the CLI, each runnable on its own:
145
+
146
+ - [notes-oauth-keycloak](examples/notes-oauth-keycloak/): `--oauth` end to end, with a local Keycloak (realm already set up) via Docker Compose and notes kept per user.
147
+
142
148
  ## Learning Resources
143
149
 
144
150
  | Guide | Description |
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.12.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' },
@@ -26,15 +17,29 @@ export const packageManagerCommands = {
26
17
  };
27
18
  export async function generateProject(config) {
28
19
  const { projectName, packageManager, transport, withOAuth, withGitInit, withSkills } = config;
20
+ const projectPath = join(process.cwd(), projectName);
21
+ const srcPath = join(projectPath, 'src');
22
+ // Create directories
23
+ await mkdir(srcPath, { recursive: true });
24
+ // The skill is vendored, so this is a file copy. It never fails the scaffold:
25
+ // the project is complete without it. It runs before the templates so the
26
+ // README and AGENTS.md describe what is actually on disk — a project without
27
+ // the skill must not point at a directory that does not exist.
28
+ let skillCopied = false;
29
+ if (withSkills) {
30
+ const result = await copySkill(projectPath);
31
+ skillCopied = result.copied;
32
+ if (!result.copied) {
33
+ console.log(`\n Could not add the tool-design skill (${result.reason}).`);
34
+ console.log(` To add it by hand: ${SKILLS_INSTALL_HINT}`);
35
+ }
36
+ }
29
37
  const templateOptions = {
30
38
  withOAuth: transport === 'http' ? withOAuth : false,
31
39
  packageManager,
32
40
  transport,
41
+ withSkills: skillCopied,
33
42
  };
34
- const projectPath = join(process.cwd(), projectName);
35
- const srcPath = join(projectPath, 'src');
36
- // Create directories
37
- await mkdir(srcPath, { recursive: true });
38
43
  // Build list of files to write
39
44
  const filesToWrite = [];
40
45
  if (transport === 'stdio') {
@@ -42,10 +47,9 @@ export async function generateProject(config) {
42
47
  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
48
  }
44
49
  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)));
50
+ 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
51
  if (withOAuth) {
48
- filesToWrite.push(writeFile(join(srcPath, 'auth.ts'), templates.getAuthTemplate()));
52
+ filesToWrite.push(writeFile(join(srcPath, 'auth.ts'), getSdkAuthTemplate()));
49
53
  }
50
54
  }
51
55
  // server.ts only composes these; they are identical on both transports.
@@ -69,17 +73,6 @@ export async function generateProject(config) {
69
73
  console.log('\n Could not initialize git repository (is git installed?)');
70
74
  }
71
75
  }
72
- // The skill is vendored, so this is a file copy. It never fails the scaffold:
73
- // the project is complete without it.
74
- let skillCopied = false;
75
- if (withSkills) {
76
- const result = await copySkill(projectPath);
77
- skillCopied = result.copied;
78
- if (!result.copied) {
79
- console.log(`\n Could not add the tool-design skill (${result.reason}).`);
80
- console.log(` To add it by hand: ${SKILLS_INSTALL_HINT}`);
81
- }
82
- }
83
76
  const commands = packageManagerCommands[packageManager];
84
77
  console.log(`\nCreated ${projectName} with MCP SDK (${transport}) at ${projectPath}`);
85
78
  console.log(`\nNext steps:`);
package/dist/skills.d.ts CHANGED
@@ -23,6 +23,15 @@ export declare const SKILLS_UPDATE_COMMAND = "npx skills update -p -y";
23
23
  * tool-specific directory.
24
24
  */
25
25
  export declare const SKILLS_INSTALL_HINT = "npx skills add agentailor/skills --skill tool-design -a universal";
26
+ /** Where the skill lives upstream, for projects scaffolded without it. */
27
+ export declare const SKILL_URL = "https://github.com/agentailor/skills/tree/main/tool-design";
28
+ /**
29
+ * Offered to projects scaffolded with `--no-skills`.
30
+ *
31
+ * No `-a universal` here: whoever opted out of the vendored copy gets to pick
32
+ * which agent the skills CLI installs for.
33
+ */
34
+ export declare const SKILLS_ADD_COMMAND = "npx skills add agentailor/skills --skill tool-design";
26
35
  export interface SkillCopyResult {
27
36
  copied: boolean;
28
37
  /** Present on failure; suitable for a one-line notice. */
package/dist/skills.js CHANGED
@@ -27,6 +27,15 @@ export const SKILLS_UPDATE_COMMAND = 'npx skills update -p -y';
27
27
  * tool-specific directory.
28
28
  */
29
29
  export const SKILLS_INSTALL_HINT = `npx skills add ${SKILL_REPO} --skill ${SKILL_NAME} -a universal`;
30
+ /** Where the skill lives upstream, for projects scaffolded without it. */
31
+ export const SKILL_URL = `https://github.com/${SKILL_REPO}/tree/main/${SKILL_NAME}`;
32
+ /**
33
+ * Offered to projects scaffolded with `--no-skills`.
34
+ *
35
+ * No `-a universal` here: whoever opted out of the vendored copy gets to pick
36
+ * which agent the skills CLI installs for.
37
+ */
38
+ export const SKILLS_ADD_COMMAND = `npx skills add ${SKILL_REPO} --skill ${SKILL_NAME}`;
30
39
  /**
31
40
  * The vendored skill, copied verbatim from `agentailor/skills`.
32
41
  *
@@ -1,4 +1,4 @@
1
- import { SKILLS_UPDATE_COMMAND, SKILLS_INSTALL_HINT, SKILLS_DIR } from '../../skills.js';
1
+ import { SKILLS_UPDATE_COMMAND, SKILLS_INSTALL_HINT, SKILLS_DIR, SKILLS_ADD_COMMAND, SKILL_URL, } from '../../skills.js';
2
2
  /**
3
3
  * AGENTS.md for the generated project.
4
4
  *
@@ -10,6 +10,7 @@ export function getAgentsMdTemplate(projectName, options) {
10
10
  const transport = options?.transport ?? 'http';
11
11
  const withOAuth = options?.withOAuth ?? false;
12
12
  const packageManager = options?.packageManager ?? 'npm';
13
+ const withSkills = options?.withSkills ?? true;
13
14
  const isStdio = transport === 'stdio';
14
15
  const run = {
15
16
  npm: { build: 'npm run build', test: 'npm test', dev: 'npm run dev' },
@@ -72,6 +73,50 @@ server misconfiguration and belongs in the 500 bucket.
72
73
  line, not inside it.
73
74
  `
74
75
  : '';
76
+ const elicitationSection = `
77
+ ## Asking the user before acting
78
+
79
+ Elicitation lets a tool pause and ask the user a question through the client,
80
+ then finish with their answer. Reach for it when:
81
+
82
+ - **The action is consequential** — deleting, sending, paying, sharing data.
83
+ Confirm before acting, rather than trusting that the agent asked.
84
+ - **A required input is missing** and only the user knows it, such as which of
85
+ two accounts to use.
86
+
87
+ Do not use it for anything the agent could pass as a parameter, and **never to
88
+ collect passwords, API keys, tokens or other secrets** — the spec forbids it.
89
+ Credentials belong in an OAuth flow or in configuration.
90
+
91
+ On protocol \`2026-07-28\` the tool does not send a request mid-call. It returns
92
+ \`inputRequired({ inputRequests: { ... } })\`, the client asks the user, and the
93
+ tool is called again with the answers in \`ctx.mcpReq.inputResponses\`. Read them
94
+ with \`inputResponse()\` for the action and \`acceptedContent(..., schema)\` for
95
+ validated content. A handler written this way also serves 2025-era clients${isStdio ? '' : ' where the connection allows it'}.
96
+
97
+ Three rules keep it honest:
98
+
99
+ - **Check the capability first.** Returning \`inputRequired\` to a client that did
100
+ not declare \`elicitation\` fails the whole call. A \`2026-07-28\` client sends
101
+ its capabilities with every request (\`ctx.mcpReq.envelope\`, under
102
+ \`CLIENT_CAPABILITIES_META_KEY\`); a 2025-era client declared them once
103
+ (\`server.server.getClientCapabilities()\`). Read the first, fall back to the
104
+ second, and when neither has \`elicitation\`, return a result that says the
105
+ user could not be asked.${isStdio
106
+ ? ''
107
+ : `
108
+ Over HTTP this is also how 2025-era clients look: each request gets a fresh
109
+ server, so there is no connection left to carry the question.`}
110
+ - **Give every outcome its own result.** Accept, decline and cancel are three
111
+ different answers. Anything short of an explicit yes must say nothing happened
112
+ and why — never a result that reads like success.
113
+ - **Treat the answer as input, not proof.** It arrives from the client like any
114
+ parameter. Validate it, and do not rely on elicitation alone where a real
115
+ authorization check belongs.
116
+
117
+ Keep forms to one or two fields. For a choice, use \`oneOf\` entries with
118
+ \`const\` and \`title\`, so clients show readable labels such as "Delete it".
119
+ `;
75
120
  const testingSection = `
76
121
  ## Adding a tool means adding a test
77
122
 
@@ -139,7 +184,8 @@ Whichever shape you land on, keep two things: \`server.ts\` stays a composition
139
184
  root, and domain logic stays free of MCP imports so it remains testable on its
140
185
  own.
141
186
  `;
142
- const skillSection = `
187
+ const skillSection = withSkills
188
+ ? `
143
189
  ## The tool-design skill
144
190
 
145
191
  \`${SKILLS_DIR}/skills/tool-design/SKILL.md\` is the long form of the guidance above,
@@ -159,6 +205,17 @@ That is yours to run, not something this project does for you. If the directory
159
205
  is missing entirely, add it with \`${SKILLS_INSTALL_HINT}\`.
160
206
 
161
207
  Commit \`${SKILLS_DIR}/\` so everyone working on this project gets the same copy.
208
+ `
209
+ : `
210
+ ## The tool-design skill
211
+
212
+ The guidance above is the short form of Agentailor's
213
+ [tool-design](${SKILL_URL}) skill, which has the long form with worked
214
+ examples. It is not installed in this project. To add it:
215
+
216
+ \`\`\`bash
217
+ ${SKILLS_ADD_COMMAND}
218
+ \`\`\`
162
219
  `;
163
220
  const conventions = `
164
221
  ## Conventions worth keeping
@@ -190,7 +247,7 @@ code.
190
247
  ## Layout
191
248
 
192
249
  ${layout}
193
- ${perRequestSection}${stdioSection}${toolDesignSection}${testingSection}${skillSection}${oauthSection}${conventions}
250
+ ${perRequestSection}${stdioSection}${toolDesignSection}${elicitationSection}${testingSection}${skillSection}${oauthSection}${conventions}
194
251
  ## Commands
195
252
 
196
253
  \`\`\`bash
@@ -16,6 +16,7 @@ describe('getAgentsMdTemplate', () => {
16
16
  expect(template).not.toContain('list_notes');
17
17
  expect(template).not.toContain('get_note');
18
18
  expect(template).not.toContain('create_note');
19
+ expect(template).not.toContain('delete_note');
19
20
  expect(template).not.toContain('summarize-notes');
20
21
  }
21
22
  });
@@ -44,6 +45,23 @@ describe('getAgentsMdTemplate', () => {
44
45
  expect(template).toContain('isError');
45
46
  expect(template).toContain('Document every parameter');
46
47
  });
48
+ it('should cover elicitation for every transport', () => {
49
+ for (const options of [sdkHttp, sdkStdio]) {
50
+ const template = getAgentsMdTemplate(projectName, options);
51
+ expect(template).toContain('## Asking the user before acting');
52
+ expect(template).toContain('inputRequired');
53
+ expect(template).toContain('Check the capability first');
54
+ // The spec forbids eliciting credentials; the rule must survive edits.
55
+ expect(template).toContain('collect passwords, API keys, tokens or other secrets');
56
+ }
57
+ });
58
+ // Only HTTP serves 2025-era clients without a connection to carry the
59
+ // question, so only HTTP should warn about it.
60
+ it('should explain the HTTP-only 2025 limitation only for HTTP', () => {
61
+ const marker = 'no connection left to carry the question';
62
+ expect(getAgentsMdTemplate(projectName, sdkHttp)).toContain(marker);
63
+ expect(getAgentsMdTemplate(projectName, sdkStdio)).not.toContain(marker);
64
+ });
47
65
  it('should say how to organize tools as they grow', () => {
48
66
  const template = getAgentsMdTemplate(projectName, sdkHttp);
49
67
  expect(template).toContain('Organizing tools as they grow');
@@ -115,6 +133,16 @@ describe('getAgentsMdTemplate', () => {
115
133
  const template = getAgentsMdTemplate(projectName, sdkHttp);
116
134
  expect(template).toContain('Commit `.agents/`');
117
135
  });
136
+ // With --no-skills there is no .agents/ to point at; send the reader upstream.
137
+ it('should link upstream and give the install command when the skill is absent', () => {
138
+ for (const options of [sdkHttp, sdkStdio]) {
139
+ const template = getAgentsMdTemplate(projectName, { ...options, withSkills: false });
140
+ expect(template).not.toContain('.agents/');
141
+ expect(template).not.toContain('npx skills update');
142
+ expect(template).toContain('https://github.com/agentailor/skills/tree/main/tool-design');
143
+ expect(template).toContain('npx skills add agentailor/skills --skill tool-design');
144
+ }
145
+ });
118
146
  // The copy is vendored, so updating is the user's choice, not automatic.
119
147
  it("should frame the update as the reader's choice", () => {
120
148
  const template = getAgentsMdTemplate(projectName, sdkHttp);
@@ -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
  };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The README's "Tool design skill" section, shared by every transport.
3
+ *
4
+ * Branches on whether the skill is actually in the project: pointing at
5
+ * `.agents/skills/tool-design/` in a project scaffolded with `--no-skills` sends
6
+ * the reader to a directory that does not exist.
7
+ */
8
+ export declare function getSkillReadmeSection(withSkills: boolean): string;
@@ -0,0 +1,35 @@
1
+ import { SKILLS_ADD_COMMAND, SKILLS_DIR, SKILLS_UPDATE_COMMAND, SKILL_URL } from '../../skills.js';
2
+ /**
3
+ * The README's "Tool design skill" section, shared by every transport.
4
+ *
5
+ * Branches on whether the skill is actually in the project: pointing at
6
+ * `.agents/skills/tool-design/` in a project scaffolded with `--no-skills` sends
7
+ * the reader to a directory that does not exist.
8
+ */
9
+ export function getSkillReadmeSection(withSkills) {
10
+ if (!withSkills) {
11
+ return `## Tool design skill
12
+
13
+ Agentailor's [tool-design](${SKILL_URL}) skill gives a coding agent working here
14
+ detailed guidance on designing MCP tools. It is not installed in this project.
15
+ To add it:
16
+
17
+ \`\`\`bash
18
+ ${SKILLS_ADD_COMMAND}
19
+ \`\`\`
20
+ `;
21
+ }
22
+ return `## Tool design skill
23
+
24
+ Agentailor's [tool-design](${SKILL_URL}) skill is
25
+ included at \`${SKILLS_DIR}/skills/tool-design/\`, so a coding agent working here has
26
+ the guidance on hand. Commit it so the whole team gets the same copy.
27
+
28
+ It is the version that shipped with the scaffolding CLI. To check for a newer
29
+ one — your call, not automatic:
30
+
31
+ \`\`\`bash
32
+ ${SKILLS_UPDATE_COMMAND}
33
+ \`\`\`
34
+ `;
35
+ }
@@ -0,0 +1,25 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { getSkillReadmeSection } from './skill-readme.js';
3
+ import { getReadmeTemplate as getHttpReadme } from '../sdk/http/index.js';
4
+ import { getReadmeTemplate as getStdioReadme } from '../sdk/stdio/index.js';
5
+ describe('getSkillReadmeSection', () => {
6
+ it('should point at the installed skill and how to update it', () => {
7
+ const section = getSkillReadmeSection(true);
8
+ expect(section).toContain('.agents/skills/tool-design/');
9
+ expect(section).toContain('npx skills update -p -y');
10
+ });
11
+ // A --no-skills project has no .agents/; send the reader upstream instead.
12
+ it('should link upstream and give the install command when the skill is absent', () => {
13
+ const section = getSkillReadmeSection(false);
14
+ expect(section).not.toContain('.agents/');
15
+ expect(section).not.toContain('npx skills update');
16
+ expect(section).toContain('https://github.com/agentailor/skills/tree/main/tool-design');
17
+ expect(section).toContain('npx skills add agentailor/skills --skill tool-design');
18
+ });
19
+ it('should follow withSkills in both transport READMEs', () => {
20
+ for (const getReadme of [getHttpReadme, getStdioReadme]) {
21
+ expect(getReadme('p')).toContain('.agents/skills/tool-design/');
22
+ expect(getReadme('p', { withSkills: false })).not.toContain('.agents/');
23
+ }
24
+ });
25
+ });
@@ -5,9 +5,14 @@ export type TransportType = 'http' | 'stdio';
5
5
  */
6
6
  export interface BaseTemplateOptions {
7
7
  packageManager?: PackageManager;
8
+ /**
9
+ * Whether the tool-design skill is present in the project. Defaults to true.
10
+ * The generator sets it from the copy's actual outcome, not just the flag.
11
+ */
12
+ withSkills?: boolean;
8
13
  }
9
14
  /**
10
- * Template options for SDK templates (stateless and stateful)
15
+ * Template options for SDK templates (http and stdio)
11
16
  */
12
17
  export interface SdkTemplateOptions extends BaseTemplateOptions {
13
18
  withOAuth?: boolean;