@agentailor/create-mcp-server 0.9.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.
- package/README.md +13 -47
- package/dist/cli.d.ts +3 -4
- package/dist/cli.js +29 -16
- package/dist/cli.test.js +60 -67
- 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 +11 -39
- 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 +16 -29
- 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 +1 -12
- package/dist/templates/sdk/{stateless → http}/index.d.ts +2 -1
- package/dist/templates/sdk/{stateless → http}/index.js +2 -1
- package/dist/templates/sdk/{stateless → http}/templates.test.js +90 -1
- package/dist/templates/sdk/stdio/index.d.ts +6 -6
- package/dist/templates/sdk/stdio/index.js +6 -6
- package/dist/templates/sdk/stdio/server.d.ts +1 -1
- package/dist/templates/sdk/stdio/server.js +2 -2
- package/dist/templates/sdk/stdio/templates.test.js +2 -2
- package/package.json +1 -1
- package/dist/deprecations.d.ts +0 -7
- package/dist/deprecations.js +0 -17
- package/dist/deprecations.test.d.ts +0 -1
- package/dist/deprecations.test.js +0 -24
- 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.js +0 -66
- package/dist/templates/fastmcp/templates.test.js +0 -109
- package/dist/templates/sdk/stateful/index.d.ts +0 -11
- package/dist/templates/sdk/stateful/index.js +0 -12
- package/dist/templates/sdk/stateful/readme.d.ts +0 -1
- package/dist/templates/sdk/stateful/readme.js +0 -3
- package/dist/templates/sdk/stateful/server.d.ts +0 -1
- package/dist/templates/sdk/stateful/server.js +0 -2
- package/dist/templates/sdk/stateful/templates.test.d.ts +0 -1
- package/dist/templates/sdk/stateful/templates.test.js +0 -198
- package/dist/templates/sdk/stateless/server.d.ts +0 -1
- package/dist/templates/sdk/stateless/templates.test.d.ts +0 -1
- /package/dist/templates/sdk/{stateful → http}/auth.d.ts +0 -0
- /package/dist/templates/sdk/{stateful → http}/auth.js +0 -0
- /package/dist/templates/sdk/{stateful → http}/auth.test.d.ts +0 -0
- /package/dist/templates/sdk/{stateful → http}/auth.test.js +0 -0
- /package/dist/templates/sdk/{stateless → http}/prompts.d.ts +0 -0
- /package/dist/templates/sdk/{stateless → http}/prompts.js +0 -0
- /package/dist/templates/sdk/{stateless → http}/readme.d.ts +0 -0
- /package/dist/templates/sdk/{stateless → http}/readme.js +0 -0
- /package/dist/templates/sdk/{stateless → http}/resources.d.ts +0 -0
- /package/dist/templates/sdk/{stateless → http}/resources.js +0 -0
- /package/dist/templates/sdk/{stateless → http}/server-test.d.ts +0 -0
- /package/dist/templates/sdk/{stateless → http}/server-test.js +0 -0
- /package/dist/templates/{fastmcp → sdk/http}/server.d.ts +0 -0
- /package/dist/templates/sdk/{stateless → http}/server.js +0 -0
- /package/dist/templates/sdk/{stateless → http}/store-test.d.ts +0 -0
- /package/dist/templates/sdk/{stateless → http}/store-test.js +0 -0
- /package/dist/templates/sdk/{stateless → http}/store.d.ts +0 -0
- /package/dist/templates/sdk/{stateless → http}/store.js +0 -0
- /package/dist/templates/{fastmcp → sdk/http}/templates.test.d.ts +0 -0
- /package/dist/templates/sdk/{stateless → http}/tools.d.ts +0 -0
- /package/dist/templates/sdk/{stateless → http}/tools.js +0 -0
package/README.md
CHANGED
|
@@ -29,10 +29,10 @@ npx @agentailor/create-mcp-server --name=my-server
|
|
|
29
29
|
|--------|-------|---------|-------------|
|
|
30
30
|
| `--name` | `-n` | — | Project name (required in CLI mode) |
|
|
31
31
|
| `--package-manager` | `-p` | `npm` | Package manager: npm, pnpm, yarn |
|
|
32
|
-
| `--framework` | `-f` | `sdk` |
|
|
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` |
|
|
35
|
-
| `--oauth` | — | `false` | Enable OAuth (
|
|
34
|
+
| `--template` | `-t` | — | **Deprecated**, no effect; prints a warning and will be removed in a future release |
|
|
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 |
|
|
38
38
|
| `--help` | `-h` | — | Show help |
|
|
@@ -51,7 +51,6 @@ npx @agentailor/create-mcp-server --name=my-server --stdio
|
|
|
51
51
|
npx @agentailor/create-mcp-server \
|
|
52
52
|
--name=my-auth-server \
|
|
53
53
|
--package-manager=pnpm \
|
|
54
|
-
--framework=sdk \
|
|
55
54
|
--oauth
|
|
56
55
|
|
|
57
56
|
# Short flags
|
|
@@ -60,54 +59,22 @@ npx @agentailor/create-mcp-server -n my-server -p yarn --stdio
|
|
|
60
59
|
|
|
61
60
|
## Features
|
|
62
61
|
|
|
63
|
-
- **MCP SDK v2** —
|
|
64
|
-
- **Official MCP SDK** — FastMCP is still available but deprecated
|
|
62
|
+
- **MCP SDK v2** — projects serve protocol revision `2026-07-28` and still accept 2025-era clients
|
|
65
63
|
- **Two transport types** — HTTP (streamable) or stdio (for local clients)
|
|
66
64
|
- **Stateless by design** — the SDK handler builds a fresh server per request, so HTTP servers scale without sticky sessions
|
|
67
|
-
- **Optional OAuth** — OIDC-compliant authentication (
|
|
65
|
+
- **Optional OAuth** — OIDC-compliant authentication (HTTP only) ([setup guide](docs/oauth-setup.md))
|
|
68
66
|
- **Package manager choice** — npm, pnpm, or yarn
|
|
69
67
|
- **TypeScript ready** — ready to customize
|
|
70
68
|
- **Docker ready** — production Dockerfile included (HTTP transport)
|
|
71
69
|
- **MCP Inspector** — built-in debugging with `npm run inspect`
|
|
72
70
|
|
|
73
|
-
##
|
|
71
|
+
## Official MCP SDK
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|-----------|-------------|
|
|
77
|
-
| **Official MCP SDK** (default) | SDK v2, full control with Express.js, supports OAuth |
|
|
78
|
-
| **FastMCP** (deprecated) | Simpler API with less boilerplate (still on SDK v1) |
|
|
79
|
-
|
|
80
|
-
### Official MCP SDK
|
|
81
|
-
|
|
82
|
-
SDK projects are generated against the [MCP TypeScript SDK v2](https://ts.sdk.modelcontextprotocol.io/v2/) — the split `@modelcontextprotocol/server`, `@modelcontextprotocol/express`, and `@modelcontextprotocol/node` packages, rather than the v1 `@modelcontextprotocol/sdk` monolith.
|
|
73
|
+
Projects are generated against the [MCP TypeScript SDK v2](https://ts.sdk.modelcontextprotocol.io/v2/) — the split `@modelcontextprotocol/server`, `@modelcontextprotocol/express`, and `@modelcontextprotocol/node` packages, rather than the v1 `@modelcontextprotocol/sdk` monolith.
|
|
83
74
|
|
|
84
75
|
HTTP servers are built on `createMcpHandler`, which runs the server factory once per request. They serve protocol revision `2026-07-28` and also accept 2025-era clients. stdio servers use `serveStdio`, which negotiates the era per connection.
|
|
85
76
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
> **Deprecated:** FastMCP support will be removed in a future release. Generating a FastMCP project prints a warning. New projects should use the Official MCP SDK; if you need to keep scaffolding FastMCP projects after the removal, pin `npx @agentailor/create-mcp-server@0.9`.
|
|
89
|
-
|
|
90
|
-
[FastMCP](https://github.com/punkpeye/fastmcp) is a TypeScript framework built on top of the official MCP SDK that provides a simpler, more intuitive API for building MCP servers.
|
|
91
|
-
|
|
92
|
-
> **Note:** FastMCP has not migrated to SDK v2 — it still depends on `@modelcontextprotocol/sdk` v1 internally, so FastMCP projects speak the 2025-era protocol. Choose the Official MCP SDK if you need protocol revision `2026-07-28`.
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
import { FastMCP } from "fastmcp";
|
|
96
|
-
import { z } from "zod";
|
|
97
|
-
|
|
98
|
-
const server = new FastMCP({ name: "My Server", version: "1.0.0" });
|
|
99
|
-
|
|
100
|
-
server.addTool({
|
|
101
|
-
name: "add",
|
|
102
|
-
description: "Add two numbers",
|
|
103
|
-
parameters: z.object({ a: z.number(), b: z.number() }),
|
|
104
|
-
execute: async ({ a, b }) => String(a + b),
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
server.start({ transportType: "httpStream", httpStream: { port: 3000 } });
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Learn more: [FastMCP Documentation](https://github.com/punkpeye/fastmcp)
|
|
77
|
+
> **FastMCP was removed in 0.10.0.** It never moved to SDK v2, so FastMCP projects stayed on the 2025-era protocol and shipped without tests. To scaffold one anyway, pin the last release that supports it: `npx @agentailor/create-mcp-server@0.9 --framework=fastmcp`.
|
|
111
78
|
|
|
112
79
|
## Transport Types
|
|
113
80
|
|
|
@@ -115,7 +82,7 @@ Learn more: [FastMCP Documentation](https://github.com/punkpeye/fastmcp)
|
|
|
115
82
|
|---------|------------------------|-------|
|
|
116
83
|
| Use case | Remote access, cloud deployment | Local clients (Claude Desktop) |
|
|
117
84
|
| Protocol | HTTP | stdin/stdout |
|
|
118
|
-
| OAuth support | ✓
|
|
85
|
+
| OAuth support | ✓ | — |
|
|
119
86
|
| Docker deployment | ✓ | — |
|
|
120
87
|
| Port configuration | ✓ | — |
|
|
121
88
|
|
|
@@ -127,7 +94,7 @@ Learn more: [FastMCP Documentation](https://github.com/punkpeye/fastmcp)
|
|
|
127
94
|
|
|
128
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.
|
|
129
96
|
|
|
130
|
-
`--template` is
|
|
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).
|
|
131
98
|
|
|
132
99
|
## Generated Project
|
|
133
100
|
|
|
@@ -152,9 +119,9 @@ my-mcp-server/
|
|
|
152
119
|
└── README.md
|
|
153
120
|
```
|
|
154
121
|
|
|
155
|
-
|
|
122
|
+
Projects come with a worked example — a small notes server — and a test suite
|
|
156
123
|
that runs green immediately, so there is a working pattern to copy when you add
|
|
157
|
-
your own tools.
|
|
124
|
+
your own tools.
|
|
158
125
|
|
|
159
126
|
Projects also get Agentailor's [tool-design](https://github.com/agentailor/skills)
|
|
160
127
|
skill at `.agents/skills/`, so a coding agent working in the project has the
|
|
@@ -169,7 +136,7 @@ to the protocol over stdio).
|
|
|
169
136
|
|
|
170
137
|
**Scripts:**
|
|
171
138
|
- `npm run dev` — build and start the server
|
|
172
|
-
- `npm test` — run the test suite
|
|
139
|
+
- `npm test` — run the test suite
|
|
173
140
|
- `npm run inspect` — open MCP Inspector (update URL in `package.json` if needed)
|
|
174
141
|
|
|
175
142
|
## Learning Resources
|
|
@@ -178,7 +145,6 @@ to the protocol over stdio).
|
|
|
178
145
|
|-------|-------------|
|
|
179
146
|
| [Create Your First MCP Server in 5 Minutes](https://blog.agentailor.com/posts/create-your-first-mcp-server-in-5-minutes?utm_source=github&utm_medium=readme&utm_campaign=create-mcp-server) | Build your first production-ready MCP server. A complete beginner guide to scaffolding a Fetch MCP server with TypeScript. |
|
|
180
147
|
| [Securing MCP Servers with Keycloak](https://blog.agentailor.com/posts/oauth-for-mcp-servers-practical-guide-keycloak?utm_source=github&utm_medium=readme&utm_campaign=create-mcp-server) | Learn how to secure your MCP servers with OAuth authentication using Keycloak. |
|
|
181
|
-
| [Getting Started with FastMCP](https://blog.agentailor.com/posts/getting-started-with-fastmcp?utm_source=github&utm_medium=readme&utm_campaign=create-mcp-server) | Build MCP servers faster with FastMCP — the TypeScript framework inspired by Python's most popular MCP library. |
|
|
182
148
|
| [OAuth for MCP Clients (Next.js + LangGraph.js)](https://blog.agentailor.com/posts/mcp-client-oauth-nextjs-langgraph?utm_source=github&utm_medium=readme&utm_campaign=create-mcp-server) | Implement OAuth authentication in your MCP client using Next.js and the MCP SDK. |
|
|
183
149
|
|
|
184
150
|
## Need help building MCP servers or agent infrastructure?
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import type { PackageManager,
|
|
2
|
-
export type TemplateType = 'stateless' | 'stateful';
|
|
1
|
+
import type { PackageManager, TransportType } from './templates/common/types.js';
|
|
3
2
|
export interface CLIOptions {
|
|
4
3
|
name: string;
|
|
5
4
|
packageManager: PackageManager;
|
|
6
|
-
framework: Framework;
|
|
7
5
|
transport: TransportType;
|
|
8
|
-
template: TemplateType;
|
|
9
6
|
oauth: boolean;
|
|
10
7
|
git: boolean;
|
|
11
8
|
skills: boolean;
|
|
@@ -14,4 +11,6 @@ export interface ParseResult {
|
|
|
14
11
|
mode: 'interactive' | 'cli';
|
|
15
12
|
options?: CLIOptions;
|
|
16
13
|
}
|
|
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,6 +1,14 @@
|
|
|
1
1
|
import { Command, Option, InvalidArgumentError } from 'commander';
|
|
2
2
|
const NAME_REGEX = /^[a-z0-9-_]+$/i;
|
|
3
|
-
const VERSION = '0.
|
|
3
|
+
const VERSION = '0.11.0';
|
|
4
|
+
export const FASTMCP_REMOVED_MESSAGE = [
|
|
5
|
+
'FastMCP support was removed in 0.10.0. New projects use the Official MCP SDK;',
|
|
6
|
+
'drop --framework, or pass --framework=sdk.',
|
|
7
|
+
'To scaffold a FastMCP project, pin the last release that supports it:',
|
|
8
|
+
' npx @agentailor/create-mcp-server@0.9 --framework=fastmcp',
|
|
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.';
|
|
4
12
|
function validateName(value) {
|
|
5
13
|
if (!NAME_REGEX.test(value)) {
|
|
6
14
|
throw new InvalidArgumentError('Project name can only contain letters, numbers, hyphens, and underscores');
|
|
@@ -17,12 +25,16 @@ export function parseArguments() {
|
|
|
17
25
|
.addOption(new Option('-p, --package-manager <manager>', 'Package manager')
|
|
18
26
|
.choices(['npm', 'pnpm', 'yarn'])
|
|
19
27
|
.default('npm'))
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
.addOption(new Option('-
|
|
28
|
+
// Only one framework remains. The flag is still parsed so existing
|
|
29
|
+
// `--framework=sdk` invocations keep working, and so `fastmcp` gets a
|
|
30
|
+
// removal message instead of Commander's generic invalid-choice error.
|
|
31
|
+
.addOption(new Option('-f, --framework <framework>', 'Framework (sdk only; accepted for compatibility)').default('sdk'))
|
|
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')
|
|
24
36
|
.choices(['stateless', 'stateful'])
|
|
25
|
-
.
|
|
37
|
+
.hideHelp())
|
|
26
38
|
.option('--stdio', 'Use stdio transport instead of HTTP', false)
|
|
27
39
|
.option('--oauth', 'Enable OAuth authentication (sdk HTTP only)', false)
|
|
28
40
|
.option('--no-git', 'Skip git repository initialization')
|
|
@@ -36,6 +48,15 @@ export function parseArguments() {
|
|
|
36
48
|
if (!hasExplicitArgs) {
|
|
37
49
|
return { mode: 'interactive' };
|
|
38
50
|
}
|
|
51
|
+
// Checked before --name, so a FastMCP user sees why rather than a missing-name error.
|
|
52
|
+
if (opts.framework === 'fastmcp') {
|
|
53
|
+
console.error(`\nError: ${FASTMCP_REMOVED_MESSAGE}\n`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
if (opts.framework !== 'sdk') {
|
|
57
|
+
console.error(`\nError: unknown --framework "${opts.framework}". The only framework is sdk.\n`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
39
60
|
// CLI mode - validate required args
|
|
40
61
|
if (!opts.name) {
|
|
41
62
|
console.error('\nError: --name is required when using CLI arguments\n');
|
|
@@ -48,23 +69,15 @@ export function parseArguments() {
|
|
|
48
69
|
console.error('\nError: --stdio cannot be combined with --oauth\n');
|
|
49
70
|
process.exit(1);
|
|
50
71
|
}
|
|
51
|
-
if (opts.
|
|
52
|
-
console.
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
// Validate OAuth constraint
|
|
56
|
-
if (opts.oauth && opts.framework !== 'sdk') {
|
|
57
|
-
console.error('\nError: --oauth is only valid with --framework=sdk\n');
|
|
58
|
-
process.exit(1);
|
|
72
|
+
if (opts.template !== undefined) {
|
|
73
|
+
console.warn(`\nWarning: ${TEMPLATE_DEPRECATED_MESSAGE}\n`);
|
|
59
74
|
}
|
|
60
75
|
return {
|
|
61
76
|
mode: 'cli',
|
|
62
77
|
options: {
|
|
63
78
|
name: opts.name,
|
|
64
79
|
packageManager: opts.packageManager,
|
|
65
|
-
framework: opts.framework,
|
|
66
80
|
transport: (opts.stdio ? 'stdio' : 'http'),
|
|
67
|
-
template: opts.template,
|
|
68
81
|
oauth: opts.oauth,
|
|
69
82
|
git: opts.git, // Commander handles --no-git -> git: false
|
|
70
83
|
skills: opts.skills, // Commander handles --no-skills -> skills: false
|
package/dist/cli.test.js
CHANGED
|
@@ -31,9 +31,7 @@ describe('CLI argument parsing', () => {
|
|
|
31
31
|
const { parseArguments } = await import('./cli.js');
|
|
32
32
|
const result = parseArguments();
|
|
33
33
|
expect(result.options?.packageManager).toBe('npm');
|
|
34
|
-
expect(result.options?.framework).toBe('sdk');
|
|
35
34
|
expect(result.options?.transport).toBe('http');
|
|
36
|
-
expect(result.options?.template).toBe('stateless');
|
|
37
35
|
expect(result.options?.oauth).toBe(false);
|
|
38
36
|
expect(result.options?.git).toBe(true);
|
|
39
37
|
});
|
|
@@ -43,8 +41,7 @@ describe('CLI argument parsing', () => {
|
|
|
43
41
|
'create-mcp-server',
|
|
44
42
|
'--name=test-project',
|
|
45
43
|
'--package-manager=pnpm',
|
|
46
|
-
'--framework=
|
|
47
|
-
'--template=stateful',
|
|
44
|
+
'--framework=sdk',
|
|
48
45
|
'--no-git',
|
|
49
46
|
];
|
|
50
47
|
const { parseArguments } = await import('./cli.js');
|
|
@@ -52,58 +49,52 @@ describe('CLI argument parsing', () => {
|
|
|
52
49
|
expect(result.options).toEqual({
|
|
53
50
|
name: 'test-project',
|
|
54
51
|
packageManager: 'pnpm',
|
|
55
|
-
framework: 'fastmcp',
|
|
56
52
|
transport: 'http',
|
|
57
|
-
template: 'stateful',
|
|
58
53
|
oauth: false,
|
|
59
54
|
git: false,
|
|
60
55
|
skills: true,
|
|
61
56
|
});
|
|
62
57
|
});
|
|
63
58
|
it('parses short flags correctly', async () => {
|
|
64
|
-
process.argv = [
|
|
65
|
-
'node',
|
|
66
|
-
'create-mcp-server',
|
|
67
|
-
'-n',
|
|
68
|
-
'my-project',
|
|
69
|
-
'-p',
|
|
70
|
-
'yarn',
|
|
71
|
-
'-f',
|
|
72
|
-
'sdk',
|
|
73
|
-
'-t',
|
|
74
|
-
'stateful',
|
|
75
|
-
];
|
|
59
|
+
process.argv = ['node', 'create-mcp-server', '-n', 'my-project', '-p', 'yarn', '-f', 'sdk'];
|
|
76
60
|
const { parseArguments } = await import('./cli.js');
|
|
77
61
|
const result = parseArguments();
|
|
78
62
|
expect(result.options?.name).toBe('my-project');
|
|
79
63
|
expect(result.options?.packageManager).toBe('yarn');
|
|
80
|
-
expect(result.options?.framework).toBe('sdk');
|
|
81
|
-
expect(result.options?.template).toBe('stateful');
|
|
82
64
|
});
|
|
83
|
-
it('parses oauth flag
|
|
84
|
-
process.argv = [
|
|
85
|
-
'node',
|
|
86
|
-
'create-mcp-server',
|
|
87
|
-
'--name=my-auth-server',
|
|
88
|
-
'--framework=sdk',
|
|
89
|
-
'--template=stateful',
|
|
90
|
-
'--oauth',
|
|
91
|
-
];
|
|
65
|
+
it('parses the oauth flag', async () => {
|
|
66
|
+
process.argv = ['node', 'create-mcp-server', '--name=my-auth-server', '--oauth'];
|
|
92
67
|
const { parseArguments } = await import('./cli.js');
|
|
93
68
|
const result = parseArguments();
|
|
94
69
|
expect(result.options?.oauth).toBe(true);
|
|
95
|
-
expect(result.options?.framework).toBe('sdk');
|
|
96
|
-
expect(result.options?.template).toBe('stateful');
|
|
97
70
|
});
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
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');
|
|
103
76
|
const result = parseArguments();
|
|
104
|
-
expect(result.
|
|
105
|
-
expect(result.options?.
|
|
106
|
-
expect(
|
|
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();
|
|
107
98
|
});
|
|
108
99
|
it('exits with error when --name is missing in CLI mode', async () => {
|
|
109
100
|
process.argv = ['node', 'create-mcp-server', '--package-manager=npm'];
|
|
@@ -119,8 +110,10 @@ describe('CLI argument parsing', () => {
|
|
|
119
110
|
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('--name is required when using CLI arguments'));
|
|
120
111
|
consoleError.mockRestore();
|
|
121
112
|
});
|
|
122
|
-
|
|
123
|
-
|
|
113
|
+
// FastMCP was removed in 0.10.0. The flag value must explain that and say how
|
|
114
|
+
// to get the old behaviour, not fall through to a generic error.
|
|
115
|
+
it('exits with a removal message for --framework=fastmcp', async () => {
|
|
116
|
+
process.argv = ['node', 'create-mcp-server', '--name=test', '--framework=fastmcp'];
|
|
124
117
|
let exitCode;
|
|
125
118
|
process.exit = vi.fn((code) => {
|
|
126
119
|
exitCode = code;
|
|
@@ -130,7 +123,8 @@ describe('CLI argument parsing', () => {
|
|
|
130
123
|
const { parseArguments } = await import('./cli.js');
|
|
131
124
|
expect(() => parseArguments()).toThrow('process.exit called');
|
|
132
125
|
expect(exitCode).toBe(1);
|
|
133
|
-
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('
|
|
126
|
+
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('FastMCP support was removed in 0.10.0'));
|
|
127
|
+
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('@agentailor/create-mcp-server@0.9 --framework=fastmcp'));
|
|
134
128
|
consoleError.mockRestore();
|
|
135
129
|
});
|
|
136
130
|
it('exits with error for invalid project name', async () => {
|
|
@@ -163,29 +157,21 @@ describe('CLI argument parsing', () => {
|
|
|
163
157
|
expect(result.options?.transport).toBe('stdio');
|
|
164
158
|
expect(result.options?.oauth).toBe(false);
|
|
165
159
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
'
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
// Checked before --name, so the user learns FastMCP is gone rather than
|
|
161
|
+
// fixing --name first and only then hitting the removal.
|
|
162
|
+
it('reports the FastMCP removal even when --name is missing', async () => {
|
|
163
|
+
process.argv = ['node', 'create-mcp-server', '-f', 'fastmcp'];
|
|
164
|
+
process.exit = vi.fn(() => {
|
|
165
|
+
throw new Error('process.exit called');
|
|
166
|
+
});
|
|
167
|
+
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
174
168
|
const { parseArguments } = await import('./cli.js');
|
|
175
|
-
|
|
176
|
-
expect(
|
|
177
|
-
|
|
169
|
+
expect(() => parseArguments()).toThrow('process.exit called');
|
|
170
|
+
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('FastMCP support was removed'));
|
|
171
|
+
consoleError.mockRestore();
|
|
178
172
|
});
|
|
179
|
-
it('exits with error
|
|
180
|
-
process.argv = [
|
|
181
|
-
'node',
|
|
182
|
-
'create-mcp-server',
|
|
183
|
-
'--name=test',
|
|
184
|
-
'--stdio',
|
|
185
|
-
'--oauth',
|
|
186
|
-
'--framework=sdk',
|
|
187
|
-
'--template=stateful',
|
|
188
|
-
];
|
|
173
|
+
it('exits with error for an unknown --framework', async () => {
|
|
174
|
+
process.argv = ['node', 'create-mcp-server', '--name=test', '--framework=nope'];
|
|
189
175
|
let exitCode;
|
|
190
176
|
process.exit = vi.fn((code) => {
|
|
191
177
|
exitCode = code;
|
|
@@ -195,11 +181,18 @@ describe('CLI argument parsing', () => {
|
|
|
195
181
|
const { parseArguments } = await import('./cli.js');
|
|
196
182
|
expect(() => parseArguments()).toThrow('process.exit called');
|
|
197
183
|
expect(exitCode).toBe(1);
|
|
198
|
-
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('
|
|
184
|
+
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('unknown --framework'));
|
|
199
185
|
consoleError.mockRestore();
|
|
200
186
|
});
|
|
201
|
-
it('exits with error when --stdio combined with --
|
|
202
|
-
process.argv = [
|
|
187
|
+
it('exits with error when --stdio combined with --oauth', async () => {
|
|
188
|
+
process.argv = [
|
|
189
|
+
'node',
|
|
190
|
+
'create-mcp-server',
|
|
191
|
+
'--name=test',
|
|
192
|
+
'--stdio',
|
|
193
|
+
'--oauth',
|
|
194
|
+
'--framework=sdk',
|
|
195
|
+
];
|
|
203
196
|
let exitCode;
|
|
204
197
|
process.exit = vi.fn((code) => {
|
|
205
198
|
exitCode = code;
|
|
@@ -209,7 +202,7 @@ describe('CLI argument parsing', () => {
|
|
|
209
202
|
const { parseArguments } = await import('./cli.js');
|
|
210
203
|
expect(() => parseArguments()).toThrow('process.exit called');
|
|
211
204
|
expect(exitCode).toBe(1);
|
|
212
|
-
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('--
|
|
205
|
+
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('--stdio cannot be combined with --oauth'));
|
|
213
206
|
consoleError.mockRestore();
|
|
214
207
|
});
|
|
215
208
|
it('installs the tool-design skill by default', async () => {
|
package/dist/index.js
CHANGED
|
@@ -12,9 +12,7 @@ async function main() {
|
|
|
12
12
|
await generateProject({
|
|
13
13
|
projectName: options.name,
|
|
14
14
|
packageManager: options.packageManager,
|
|
15
|
-
framework: options.framework,
|
|
16
15
|
transport: options.transport,
|
|
17
|
-
templateType: options.template,
|
|
18
16
|
withOAuth: options.oauth,
|
|
19
17
|
withGitInit: options.git,
|
|
20
18
|
withSkills: options.skills,
|
package/dist/interactive.js
CHANGED
|
@@ -37,26 +37,6 @@ export async function runInteractiveMode() {
|
|
|
37
37
|
initial: 0,
|
|
38
38
|
}, { onCancel });
|
|
39
39
|
const packageManager = packageManagerResponse.packageManager || 'npm';
|
|
40
|
-
// Framework selection
|
|
41
|
-
const frameworkResponse = await prompts({
|
|
42
|
-
type: 'select',
|
|
43
|
-
name: 'framework',
|
|
44
|
-
message: 'Framework:',
|
|
45
|
-
choices: [
|
|
46
|
-
{
|
|
47
|
-
title: 'Official MCP SDK',
|
|
48
|
-
value: 'sdk',
|
|
49
|
-
description: 'Full control with Express.js',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
title: 'FastMCP (deprecated)',
|
|
53
|
-
value: 'fastmcp',
|
|
54
|
-
description: 'Stays on SDK v1, no tests; will be removed in a future release',
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
initial: 0,
|
|
58
|
-
}, { onCancel });
|
|
59
|
-
const framework = frameworkResponse.framework || 'sdk';
|
|
60
40
|
// Transport selection
|
|
61
41
|
const transportResponse = await prompts({
|
|
62
42
|
type: 'select',
|
|
@@ -77,34 +57,9 @@ export async function runInteractiveMode() {
|
|
|
77
57
|
initial: 0,
|
|
78
58
|
}, { onCancel });
|
|
79
59
|
const transport = transportResponse.transport || 'http';
|
|
80
|
-
// Only asked for FastMCP HTTP, where it maps to a real `stateless` config
|
|
81
|
-
// flag. SDK projects generate the same server either way, so asking would be
|
|
82
|
-
// a meaningless choice.
|
|
83
|
-
let templateType = 'stateless';
|
|
84
|
-
if (transport === 'http' && framework === 'fastmcp') {
|
|
85
|
-
const templateTypeResponse = await prompts({
|
|
86
|
-
type: 'select',
|
|
87
|
-
name: 'templateType',
|
|
88
|
-
message: 'Server mode:',
|
|
89
|
-
choices: [
|
|
90
|
-
{
|
|
91
|
-
title: 'Stateless',
|
|
92
|
-
value: 'stateless',
|
|
93
|
-
description: 'No session state between requests',
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
title: 'Stateful',
|
|
97
|
-
value: 'stateful',
|
|
98
|
-
description: 'Session-based server with SSE support',
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
initial: 0,
|
|
102
|
-
}, { onCancel });
|
|
103
|
-
templateType = templateTypeResponse.templateType || 'stateless';
|
|
104
|
-
}
|
|
105
60
|
// OAuth prompt - available for any SDK HTTP project
|
|
106
61
|
let withOAuth = false;
|
|
107
|
-
if (transport === 'http'
|
|
62
|
+
if (transport === 'http') {
|
|
108
63
|
const oauthResponse = await prompts({
|
|
109
64
|
type: 'confirm',
|
|
110
65
|
name: 'withOAuth',
|
|
@@ -131,9 +86,7 @@ export async function runInteractiveMode() {
|
|
|
131
86
|
await generateProject({
|
|
132
87
|
projectName,
|
|
133
88
|
packageManager,
|
|
134
|
-
framework,
|
|
135
89
|
transport,
|
|
136
|
-
templateType,
|
|
137
90
|
withOAuth,
|
|
138
91
|
withGitInit,
|
|
139
92
|
withSkills,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { TemplateType } from './cli.js';
|
|
1
|
+
import type { PackageManager, TransportType } from './templates/common/types.js';
|
|
3
2
|
export declare const packageManagerCommands: Record<PackageManager, {
|
|
4
3
|
install: string;
|
|
5
4
|
dev: string;
|
|
@@ -7,9 +6,7 @@ export declare const packageManagerCommands: Record<PackageManager, {
|
|
|
7
6
|
export interface ProjectConfig {
|
|
8
7
|
projectName: string;
|
|
9
8
|
packageManager: PackageManager;
|
|
10
|
-
framework: Framework;
|
|
11
9
|
transport: TransportType;
|
|
12
|
-
templateType: TemplateType;
|
|
13
10
|
withOAuth: boolean;
|
|
14
11
|
withGitInit: boolean;
|
|
15
12
|
withSkills: boolean;
|
|
@@ -6,40 +6,20 @@ import { getTsconfigTemplate } from './templates/common/tsconfig.json.js';
|
|
|
6
6
|
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
|
-
import { warnIfDeprecated } from './deprecations.js';
|
|
10
9
|
import { copySkill, SKILLS_UPDATE_COMMAND, SKILLS_INSTALL_HINT, SKILLS_DIR } from './skills.js';
|
|
11
|
-
import { getServerTemplate as
|
|
12
|
-
import { getAuthTemplate as getSdkAuthTemplate } from './templates/sdk/stateful/index.js';
|
|
13
|
-
import { getServerTemplate as getFastMCPServerTemplate, getIndexTemplate as getFastMCPIndexTemplate, getReadmeTemplate as getFastMCPReadmeTemplate, } from './templates/fastmcp/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';
|
|
14
11
|
import { getServerTemplate as getSdkStdioServerTemplate, getIndexTemplate as getSdkStdioIndexTemplate, getReadmeTemplate as getSdkStdioReadmeTemplate, } from './templates/sdk/stdio/index.js';
|
|
15
12
|
import { getDockerfileTemplate, getDockerignoreTemplate } from './templates/deployment/index.js';
|
|
16
|
-
// Auth is keyed off `withOAuth`, never off the template type - see
|
|
17
|
-
// "Why stateless and stateful are identical" in AGENTS.md.
|
|
18
|
-
const sdkHttpTemplateFunctions = {
|
|
19
|
-
getServerTemplate: getSdkStatelessServerTemplate,
|
|
20
|
-
getIndexTemplate: getSdkStatelessIndexTemplate,
|
|
21
|
-
getReadmeTemplate: getSdkStatelessReadmeTemplate,
|
|
22
|
-
getAuthTemplate: getSdkAuthTemplate,
|
|
23
|
-
};
|
|
24
|
-
const fastmcpTemplateFunctions = {
|
|
25
|
-
getServerTemplate: getFastMCPServerTemplate,
|
|
26
|
-
getIndexTemplate: getFastMCPIndexTemplate,
|
|
27
|
-
getReadmeTemplate: getFastMCPReadmeTemplate,
|
|
28
|
-
};
|
|
29
13
|
export const packageManagerCommands = {
|
|
30
14
|
npm: { install: 'npm install', dev: 'npm run dev' },
|
|
31
15
|
pnpm: { install: 'pnpm install', dev: 'pnpm dev' },
|
|
32
16
|
yarn: { install: 'yarn', dev: 'yarn dev' },
|
|
33
17
|
};
|
|
34
18
|
export async function generateProject(config) {
|
|
35
|
-
const { projectName, packageManager,
|
|
36
|
-
// Here rather than in either entry point, so CLI and interactive runs both warn.
|
|
37
|
-
warnIfDeprecated(framework);
|
|
19
|
+
const { projectName, packageManager, transport, withOAuth, withGitInit, withSkills } = config;
|
|
38
20
|
const templateOptions = {
|
|
39
21
|
withOAuth: transport === 'http' ? withOAuth : false,
|
|
40
22
|
packageManager,
|
|
41
|
-
framework,
|
|
42
|
-
stateless: transport === 'stdio' ? true : templateType === 'stateless',
|
|
43
23
|
transport,
|
|
44
24
|
};
|
|
45
25
|
const projectPath = join(process.cwd(), projectName);
|
|
@@ -48,29 +28,22 @@ export async function generateProject(config) {
|
|
|
48
28
|
await mkdir(srcPath, { recursive: true });
|
|
49
29
|
// Build list of files to write
|
|
50
30
|
const filesToWrite = [];
|
|
51
|
-
if (
|
|
52
|
-
// FastMCP templates
|
|
53
|
-
filesToWrite.push(writeFile(join(srcPath, 'server.ts'), fastmcpTemplateFunctions.getServerTemplate(projectName)), writeFile(join(srcPath, 'index.ts'), fastmcpTemplateFunctions.getIndexTemplate(templateOptions)), writeFile(join(projectPath, 'README.md'), fastmcpTemplateFunctions.getReadmeTemplate(projectName, templateOptions)));
|
|
54
|
-
}
|
|
55
|
-
else if (transport === 'stdio') {
|
|
31
|
+
if (transport === 'stdio') {
|
|
56
32
|
// SDK stdio templates
|
|
57
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)));
|
|
58
34
|
}
|
|
59
35
|
else {
|
|
60
|
-
|
|
61
|
-
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)));
|
|
62
37
|
if (withOAuth) {
|
|
63
|
-
filesToWrite.push(writeFile(join(srcPath, 'auth.ts'),
|
|
38
|
+
filesToWrite.push(writeFile(join(srcPath, 'auth.ts'), getSdkAuthTemplate()));
|
|
64
39
|
}
|
|
65
40
|
}
|
|
66
|
-
// server.ts only composes these; they are identical on both
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
writeFile(join(srcPath, 'notes-store.test.ts'), getSdkStoreTestTemplate()), writeFile(join(srcPath, 'server.test.ts'), getSdkServerTestTemplate()));
|
|
71
|
-
}
|
|
41
|
+
// server.ts only composes these; they are identical on both transports.
|
|
42
|
+
filesToWrite.push(writeFile(join(srcPath, 'tools.ts'), getSdkToolsTemplate()), writeFile(join(srcPath, 'prompts.ts'), getSdkPromptsTemplate()), writeFile(join(srcPath, 'resources.ts'), getSdkResourcesTemplate()), writeFile(join(srcPath, 'notes-store.ts'), getSdkStoreTemplate()),
|
|
43
|
+
// Two layers: the store in isolation, and the payload an agent reads.
|
|
44
|
+
writeFile(join(srcPath, 'notes-store.test.ts'), getSdkStoreTestTemplate()), writeFile(join(srcPath, 'server.test.ts'), getSdkServerTestTemplate()));
|
|
72
45
|
// Common files for all templates
|
|
73
|
-
filesToWrite.push(writeFile(join(projectPath, 'package.json'), getPackageJsonTemplate(projectName, templateOptions)), writeFile(join(projectPath, 'tsconfig.json'), getTsconfigTemplate(
|
|
46
|
+
filesToWrite.push(writeFile(join(projectPath, 'package.json'), getPackageJsonTemplate(projectName, templateOptions)), writeFile(join(projectPath, 'tsconfig.json'), getTsconfigTemplate()), writeFile(join(projectPath, '.gitignore'), getGitignoreTemplate()), writeFile(join(projectPath, '.env.example'), getEnvExampleTemplate(templateOptions)), writeFile(join(projectPath, 'AGENTS.md'), getAgentsMdTemplate(projectName, templateOptions)));
|
|
74
47
|
// Deployment files for HTTP transport only (stdio servers are not HTTP services)
|
|
75
48
|
if (transport === 'http') {
|
|
76
49
|
filesToWrite.push(writeFile(join(projectPath, 'Dockerfile'), getDockerfileTemplate(templateOptions)), writeFile(join(projectPath, '.dockerignore'), getDockerignoreTemplate()));
|
|
@@ -98,8 +71,7 @@ export async function generateProject(config) {
|
|
|
98
71
|
}
|
|
99
72
|
}
|
|
100
73
|
const commands = packageManagerCommands[packageManager];
|
|
101
|
-
|
|
102
|
-
console.log(`\nCreated ${projectName} with ${frameworkName} (${transport}) at ${projectPath}`);
|
|
74
|
+
console.log(`\nCreated ${projectName} with MCP SDK (${transport}) at ${projectPath}`);
|
|
103
75
|
console.log(`\nNext steps:`);
|
|
104
76
|
console.log(` cd ${projectName}`);
|
|
105
77
|
console.log(` ${commands.install}`);
|