Skip to content
Open
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
5 changes: 5 additions & 0 deletions .github/pages/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
title: '@modelcontextprotocol/sdk'

# Include generated files and directories which may start with underscores
include:
- '_*'
19 changes: 19 additions & 0 deletions .github/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
# Empty Jekyll front matter to enable Liquid templating (see {{ ... }} below)
---

<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Redirecting to latest documentation...</title>
<meta http-equiv="refresh" content="0; url={{ site.data.latest_version }}/" />
<link rel="canonical" href="{{ site.data.latest_version }}/" />
</head>
<body>
<p>Redirecting to <a href="{{ site.data.latest_version }}/">latest documentation</a>...</p>
<script>
window.location.href = '{{ site.data.latest_version }}/';
</script>
</body>
</html>
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,40 @@ jobs:
- run: pnpm publish --provenance --access public ${{ steps.npm-tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-gh-pages:
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs: [publish]

permissions:
contents: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: Install dependencies
run: pnpm install

- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Generate documentation
run: ./scripts/generate-gh-pages.sh ${{ github.ref_name }}

- name: Push to gh-pages
run: git push origin gh-pages
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Next steps:
- [docs/capabilities.md](docs/capabilities.md) – sampling, elicitation (form and URL), and experimental task-based execution.
- [docs/faq.md](docs/faq.md) – environment and troubleshooting FAQs (including Node.js Web Crypto support).
- External references:
- [SDK API documentation](https://modelcontextprotocol.github.io/typescript-sdk/)
- [Model Context Protocol documentation](https://modelcontextprotocol.io)
- [MCP Specification](https://spec.modelcontextprotocol.io)
- [Example Servers](https://github.com/modelcontextprotocol/servers)
Expand Down
18 changes: 11 additions & 7 deletions docs/capabilities.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
---
title: Capabilities
---

## Sampling

MCP servers can request LLM completions from connected clients that support the sampling capability. This lets your tools offload summarisation or generation to the client’s model.

For a runnable server that combines tools, logging and tasks, see:

- [`toolWithSampleServer.ts`](../examples/server/src/toolWithSampleServer.ts)
- [`toolWithSampleServer.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/toolWithSampleServer.ts)

In practice you will:

Expand All @@ -22,8 +26,8 @@ Form elicitation lets a tool ask the user for additional, **non‑sensitive** in

Runnable example:

- Server: [`elicitationFormExample.ts`](../examples/server/src/elicitationFormExample.ts)
- Client‑side handling: [`simpleStreamableHttp.ts`](../examples/client/src/simpleStreamableHttp.ts)
- Server: [`elicitationFormExample.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/elicitationFormExample.ts)
- Client‑side handling: [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleStreamableHttp.ts)

The `simpleStreamableHttp` server also includes a `collect-user-info` tool that demonstrates how to drive elicitation from a tool and handle the response.

Expand All @@ -33,8 +37,8 @@ URL elicitation is designed for sensitive data and secure web‑based flows (e.g

Runnable example:

- Server: [`elicitationUrlExample.ts`](../examples/server/src/elicitationUrlExample.ts)
- Client: [`elicitationUrlExample.ts`](../examples/client/src/elicitationUrlExample.ts)
- Server: [`elicitationUrlExample.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/elicitationUrlExample.ts)
- Client: [`elicitationUrlExample.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/elicitationUrlExample.ts)

Key points:

Expand Down Expand Up @@ -62,7 +66,7 @@ On the server you will:

For a runnable example that uses the in-memory store shipped with the SDK, see:

- [`toolWithSampleServer.ts`](../examples/server/src/toolWithSampleServer.ts)
- [`toolWithSampleServer.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/toolWithSampleServer.ts)
- `packages/core/src/experimental/tasks/stores/in-memory.ts`

### Client-side usage
Expand All @@ -74,7 +78,7 @@ On the client, you use:

The interactive client in:

- [`simpleStreamableHttp.ts`](../examples/client/src/simpleStreamableHttp.ts)
- [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleStreamableHttp.ts)

includes commands to demonstrate calling tools that support tasks and handling their lifecycle.

Expand Down
26 changes: 15 additions & 11 deletions docs/client.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Client
---

## Client overview

The SDK provides a high-level `Client` class that connects to MCP servers over different transports:
Expand All @@ -8,11 +12,11 @@ The SDK provides a high-level `Client` class that connects to MCP servers over d

Runnable client examples live under:

- [`simpleStreamableHttp.ts`](../examples/client/src/simpleStreamableHttp.ts)
- [`streamableHttpWithSseFallbackClient.ts`](../examples/client/src/streamableHttpWithSseFallbackClient.ts)
- [`ssePollingClient.ts`](../examples/client/src/ssePollingClient.ts)
- [`multipleClientsParallel.ts`](../examples/client/src/multipleClientsParallel.ts)
- [`parallelToolCallsClient.ts`](../examples/client/src/parallelToolCallsClient.ts)
- [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleStreamableHttp.ts)
- [`streamableHttpWithSseFallbackClient.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/streamableHttpWithSseFallbackClient.ts)
- [`ssePollingClient.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/ssePollingClient.ts)
- [`multipleClientsParallel.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/multipleClientsParallel.ts)
- [`parallelToolCallsClient.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/parallelToolCallsClient.ts)

## Connecting and basic operations

Expand All @@ -25,7 +29,7 @@ A typical flow:
- `listPrompts`, `getPrompt`
- `listResources`, `readResource`

See [`simpleStreamableHttp.ts`](../examples/client/src/simpleStreamableHttp.ts) for an interactive CLI client that exercises these methods and shows how to handle notifications, elicitation and tasks.
See [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleStreamableHttp.ts) for an interactive CLI client that exercises these methods and shows how to handle notifications, elicitation and tasks.

## Transports and backwards compatibility

Expand All @@ -36,7 +40,7 @@ To support both modern Streamable HTTP and legacy SSE servers, use a client that

Runnable example:

- [`streamableHttpWithSseFallbackClient.ts`](../examples/client/src/streamableHttpWithSseFallbackClient.ts)
- [`streamableHttpWithSseFallbackClient.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/streamableHttpWithSseFallbackClient.ts)

## OAuth client authentication helpers

Expand All @@ -48,10 +52,10 @@ For OAuth-secured MCP servers, the client `auth` module exposes:

Examples:

- [`simpleOAuthClient.ts`](../examples/client/src/simpleOAuthClient.ts)
- [`simpleOAuthClientProvider.ts`](../examples/client/src/simpleOAuthClientProvider.ts)
- [`simpleClientCredentials.ts`](../examples/client/src/simpleClientCredentials.ts)
- Server-side auth demo: [`demoInMemoryOAuthProvider.ts`](../examples/shared/src/demoInMemoryOAuthProvider.ts) (tests live under `examples/shared/test/demoInMemoryOAuthProvider.test.ts`)
- [`simpleOAuthClient.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleOAuthClient.ts)
- [`simpleOAuthClientProvider.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleOAuthClientProvider.ts)
- [`simpleClientCredentials.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleClientCredentials.ts)
- Server-side auth demo: [`demoInMemoryOAuthProvider.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/shared/src/demoInMemoryOAuthProvider.ts) (tests live under `examples/shared/test/demoInMemoryOAuthProvider.test.ts`)

These examples show how to:

Expand Down
15 changes: 15 additions & 0 deletions docs/documents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Documents
children:
- ./server.md
- ./client.md
- ./capabilities.md
- ./faq.md
---

# Documents

- [Server](./server.md) – building MCP servers, transports, tools/resources/prompts, and deployment patterns
- [Client](./client.md) – using the high-level client, transports, backwards compatibility, and OAuth helpers
- [Capabilities](./capabilities.md) – sampling, elicitation, and experimental task-based execution
- [FAQ](./faq.md) – frequently asked questions and troubleshooting
4 changes: 4 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: FAQ
---

## FAQ

<details>
Expand Down
46 changes: 25 additions & 21 deletions docs/server.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Server
---

## Server overview

This SDK lets you build MCP servers in TypeScript and connect them to different transports. For most use cases you will use `McpServer` from `@modelcontextprotocol/server` and choose one of:
Expand All @@ -8,11 +12,11 @@ This SDK lets you build MCP servers in TypeScript and connect them to different

For a complete, runnable example server, see:

- [`simpleStreamableHttp.ts`](../examples/server/src/simpleStreamableHttp.ts) – feature‑rich Streamable HTTP server
- [`jsonResponseStreamableHttp.ts`](../examples/server/src/jsonResponseStreamableHttp.ts) – Streamable HTTP with JSON response mode
- [`simpleStatelessStreamableHttp.ts`](../examples/server/src/simpleStatelessStreamableHttp.ts) – stateless Streamable HTTP server
- [`simpleSseServer.ts`](../examples/server/src/simpleSseServer.ts) – deprecated HTTP+SSE transport
- [`sseAndStreamableHttpCompatibleServer.ts`](../examples/server/src/sseAndStreamableHttpCompatibleServer.ts) – backwards‑compatible server for old and new clients
- [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts) – feature‑rich Streamable HTTP server
- [`jsonResponseStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/jsonResponseStreamableHttp.ts) – Streamable HTTP with JSON response mode
- [`simpleStatelessStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStatelessStreamableHttp.ts) – stateless Streamable HTTP server
- [`simpleSseServer.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleSseServer.ts) – deprecated HTTP+SSE transport
- [`sseAndStreamableHttpCompatibleServer.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/sseAndStreamableHttpCompatibleServer.ts) – backwards‑compatible server for old and new clients

## Transports

Expand All @@ -27,9 +31,9 @@ Streamable HTTP is the modern, fully featured transport. It supports:

Key examples:

- [`simpleStreamableHttp.ts`](../examples/server/src/simpleStreamableHttp.ts) – sessions, logging, tasks, elicitation, auth hooks
- [`jsonResponseStreamableHttp.ts`](../examples/server/src/jsonResponseStreamableHttp.ts) – `enableJsonResponse: true`, no SSE
- [`standaloneSseWithGetStreamableHttp.ts`](../examples/server/src/standaloneSseWithGetStreamableHttp.ts) – notifications with Streamable HTTP GET + SSE
- [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts) – sessions, logging, tasks, elicitation, auth hooks
- [`jsonResponseStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/jsonResponseStreamableHttp.ts) – `enableJsonResponse: true`, no SSE
- [`standaloneSseWithGetStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/standaloneSseWithGetStreamableHttp.ts) – notifications with Streamable HTTP GET + SSE

See the MCP spec for full transport details: `https://modelcontextprotocol.io/specification/2025-11-25/basic/transports`

Expand All @@ -42,24 +46,24 @@ Streamable HTTP can run:

Examples:

- Stateless Streamable HTTP: [`simpleStatelessStreamableHttp.ts`](../examples/server/src/simpleStatelessStreamableHttp.ts)
- Stateful with resumability: [`simpleStreamableHttp.ts`](../examples/server/src/simpleStreamableHttp.ts)
- Stateless Streamable HTTP: [`simpleStatelessStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStatelessStreamableHttp.ts)
- Stateful with resumability: [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts)

### Deprecated HTTP + SSE

The older HTTP+SSE transport (protocol version 2024‑11‑05) is supported only for backwards compatibility. New implementations should prefer Streamable HTTP.

Examples:

- Legacy SSE server: [`simpleSseServer.ts`](../examples/server/src/simpleSseServer.ts)
- Legacy SSE server: [`simpleSseServer.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleSseServer.ts)
- Backwards‑compatible server (Streamable HTTP + SSE):
[`sseAndStreamableHttpCompatibleServer.ts`](../examples/server/src/sseAndStreamableHttpCompatibleServer.ts)
[`sseAndStreamableHttpCompatibleServer.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/sseAndStreamableHttpCompatibleServer.ts)

## Running your server

For a minimal “getting started” experience:

1. Start from [`simpleStreamableHttp.ts`](../examples/server/src/simpleStreamableHttp.ts).
1. Start from [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts).
2. Remove features you do not need (tasks, advanced logging, OAuth, etc.).
3. Register your own tools, resources and prompts.

Expand Down Expand Up @@ -125,8 +129,8 @@ server.registerTool(

This snippet is illustrative only; for runnable servers that expose tools, see:

- [`simpleStreamableHttp.ts`](../examples/server/src/simpleStreamableHttp.ts)
- [`toolWithSampleServer.ts`](../examples/server/src/toolWithSampleServer.ts)
- [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts)
- [`toolWithSampleServer.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/toolWithSampleServer.ts)

#### ResourceLink outputs

Expand Down Expand Up @@ -157,7 +161,7 @@ server.registerResource(

Dynamic resources use `ResourceTemplate` and can support completions on path parameters. For full runnable examples of resources:

- [`simpleStreamableHttp.ts`](../examples/server/src/simpleStreamableHttp.ts)
- [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts)

### Prompts

Expand Down Expand Up @@ -189,13 +193,13 @@ server.registerPrompt(

For prompts integrated into a full server, see:

- [`simpleStreamableHttp.ts`](../examples/server/src/simpleStreamableHttp.ts)
- [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts)

### Completions

Both prompts and resources can support argument completions. On the client side, you use `client.complete()` with a reference to the prompt or resource and the partially‑typed argument.

See the MCP spec sections on prompts and resources for complete details, and [`simpleStreamableHttp.ts`](../examples/client/src/simpleStreamableHttp.ts) for client‑side usage patterns.
See the MCP spec sections on prompts and resources for complete details, and [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleStreamableHttp.ts) for client‑side usage patterns.

### Display names and metadata

Expand All @@ -207,15 +211,15 @@ Tools, resources and prompts support a `title` field for human‑readable names.

The SDK supports multi‑node deployments using Streamable HTTP. The high‑level patterns and diagrams live with the runnable server examples:

- [`examples/server/README.md`](../examples/server/README.md#multi-node-deployment-patterns)
- [`examples/server/README.md`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/README.md#multi-node-deployment-patterns)

## Backwards compatibility

To handle both modern and legacy clients:

- Run a backwards‑compatible server:
- [`sseAndStreamableHttpCompatibleServer.ts`](../examples/server/src/sseAndStreamableHttpCompatibleServer.ts)
- [`sseAndStreamableHttpCompatibleServer.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/sseAndStreamableHttpCompatibleServer.ts)
- Use a client that falls back from Streamable HTTP to SSE:
- [`streamableHttpWithSseFallbackClient.ts`](../examples/client/src/streamableHttpWithSseFallbackClient.ts)
- [`streamableHttpWithSseFallbackClient.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/streamableHttpWithSseFallbackClient.ts)

For the detailed protocol rules, see the “Backwards compatibility” section of the MCP spec.
Loading
Loading