Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 47 additions & 19 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@ create-mcp-server/
│ ├── index.ts # CLI entry point
│ └── templates/
│ ├── common/ # Shared template files
│ │ ├── package.json.ts # package.json template
│ │ ├── package.json.ts # package.json template (framework-aware)
│ │ ├── tsconfig.json.ts # tsconfig.json template
│ │ ├── gitignore.ts # .gitignore template
│ │ ├── env.example.ts # .env.example template
│ │ └── templates.test.ts # Tests for common templates
│ ├── streamable-http/ # Stateless streamable HTTP template
│ │ ├── server.ts # MCP server definition template
│ │ ├── index.ts # Barrel export + getIndexTemplate
│ │ ├── readme.ts # README.md template
│ │ └── templates.test.ts # Tests for stateless template
│ └── stateful-streamable-http/ # Stateful streamable HTTP template
│ ├── server.ts # Re-exports from streamable-http
│ ├── sdk/ # Official MCP SDK templates
│ │ ├── stateless/ # Stateless HTTP template
│ │ │ ├── server.ts # MCP server definition template
│ │ │ ├── index.ts # Barrel export + getIndexTemplate
│ │ │ ├── readme.ts # README.md template
│ │ │ └── templates.test.ts
│ │ └── stateful/ # Stateful HTTP template with OAuth option
│ │ ├── server.ts # Re-exports from stateless
│ │ ├── index.ts # Barrel export + getIndexTemplate
│ │ ├── readme.ts # README.md template
│ │ ├── auth.ts # OAuth authentication template
│ │ ├── auth.test.ts # Tests for auth template
│ │ └── templates.test.ts
│ └── fastmcp/ # FastMCP templates
│ ├── server.ts # FastMCP server definition template
│ ├── index.ts # Barrel export + getIndexTemplate
│ ├── readme.ts # README.md template
│ ├── auth.ts # OAuth authentication template
│ └── templates.test.ts # Tests for stateful template
│ └── templates.test.ts
├── dist/ # Compiled output (generated)
├── docs/
│ └── oauth-setup.md # OAuth setup guide for various providers
Expand Down Expand Up @@ -66,11 +73,23 @@ npm run format:check
npm publish --access public
```

## Frameworks

### Official MCP SDK (default)

Uses the official `@modelcontextprotocol/sdk` package with Express.js for full control.

### FastMCP

Uses [FastMCP](https://github.com/punkpeye/fastmcp), a TypeScript framework built on top of the official SDK that provides a simpler, more intuitive API.

## Templates

### streamable-http (stateless, default)
### SDK Templates

#### sdk/stateless

A stateless streamable HTTP MCP server. Each request creates a new transport and server instance.
A stateless streamable HTTP MCP server using the official SDK. Each request creates a new transport and server instance.

Features:
- Express.js with `StreamableHTTPServerTransport`
Expand All @@ -81,9 +100,9 @@ Features:
- TypeScript configuration
- Environment variable support for PORT

### stateful-streamable-http
#### sdk/stateful

A stateful streamable HTTP MCP server with session management.
A stateful streamable HTTP MCP server with session management using the official SDK.

Features:
- Session tracking via `mcp-session-id` header
Expand All @@ -94,7 +113,7 @@ Features:
- Graceful shutdown with transport cleanup
- **Optional OAuth authentication** (enabled via CLI prompt)

#### OAuth Option
##### OAuth Option

When OAuth is enabled for the stateful template:
- Generates `src/auth.ts` with JWKS/JWT-based OAuth middleware
Expand All @@ -105,17 +124,26 @@ When OAuth is enabled for the stateful template:
- Server startup validation ensures OAuth provider is reachable
- See [docs/oauth-setup.md](docs/oauth-setup.md) for provider-specific setup instructions

Generated project structure (same for both templates, +auth.ts when OAuth enabled):
### FastMCP Templates

A single template that supports both stateless and stateful modes via the `stateless` configuration option. Uses the FastMCP framework for simpler server setup.

Features:
- Declarative tool/prompt/resource registration
- Built-in HTTP server (no Express setup required)
- Supports both stateless and stateful modes via config
- Example prompt, tool, and resource

Generated project structure (same for all templates, +auth.ts when OAuth enabled for SDK stateful):
```
{project-name}/
├── src/
│ ├── server.ts # MCP server with tools/prompts/resources
│ ├── index.ts # Express app and transport setup
│ └── auth.ts # OAuth middleware (only when OAuth enabled)
│ ├── index.ts # Server startup configuration
│ └── auth.ts # OAuth middleware (SDK stateful + OAuth only)
├── package.json
├── tsconfig.json
├── .gitignore
├── .env.example
└── README.md
```

42 changes: 36 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,54 @@ npx @agentailor/create-mcp-server

## Features

- **Two templates** — stateless or stateful with session management
- **Optional OAuth** — OIDC-compliant authentication ([setup guide](docs/oauth-setup.md))
- **Two frameworks** — Official MCP SDK or FastMCP
- **Two server modes** — stateless or stateful with session management
- **Optional OAuth** — OIDC-compliant authentication (SDK only) ([setup guide](docs/oauth-setup.md))
- **Package manager choice** — npm, pnpm, or yarn
- **TypeScript + Express.js** — ready to customize
- **TypeScript ready** — ready to customize
- **MCP Inspector** — built-in debugging with `npm run inspect`

## Templates
## Frameworks

| Framework | Description |
|-----------|-------------|
| **Official MCP SDK** (default) | Full control with Express.js, supports OAuth |
| **FastMCP** | Simpler API with less boilerplate |

### FastMCP

[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.

```typescript
import { FastMCP } from "fastmcp";
import { z } from "zod";

const server = new FastMCP({ name: "My Server", version: "1.0.0" });

server.addTool({
name: "add",
description: "Add two numbers",
parameters: z.object({ a: z.number(), b: z.number() }),
execute: async ({ a, b }) => String(a + b),
});

server.start({ transportType: "httpStream", httpStream: { port: 3000 } });
```

Learn more: [FastMCP Documentation](https://github.com/punkpeye/fastmcp)

## Server Modes

| Feature | Stateless (default) | Stateful |
|---------|---------------------|----------|
| Session management | — | ✓ |
| SSE support | — | ✓ |
| OAuth option | — | ✓ |
| OAuth option (SDK only) | — | ✓ |
| Endpoints | POST /mcp | POST, GET, DELETE /mcp |

**Stateless**: Simple HTTP server — each request creates a new transport instance.

**Stateful**: Session-based server with transport reuse, Server-Sent Events for real-time updates, and optional OAuth authentication.
**Stateful**: Session-based server with transport reuse, Server-Sent Events for real-time updates, and optional OAuth authentication (SDK only).

## Generated Project

Expand Down
Loading