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
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:
- '_*'
175 changes: 175 additions & 0 deletions .github/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
---
# Jekyll front matter to enable Liquid templating
---

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>MCP TypeScript SDK - API Documentation</title>
<meta http-equiv="refresh" content="1; url={{ site.data.latest_version }}/" />
<link rel="canonical" href="{{ site.data.latest_version }}/" />
<style>
* {
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 2rem;
line-height: 1.6;
color: #333;
}
h1 {
color: #1a1a1a;
border-bottom: 2px solid #eee;
padding-bottom: 0.5rem;
}
h2 {
color: #444;
margin-top: 2rem;
}
a {
color: #0066cc;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.redirect-notice {
background: #f0f7ff;
border: 1px solid #cce0ff;
border-radius: 6px;
padding: 1rem;
margin-bottom: 2rem;
}
.versions-table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
}
.versions-table th,
.versions-table td {
text-align: left;
padding: 0.75rem;
border-bottom: 1px solid #eee;
}
.versions-table th {
background: #f5f5f5;
font-weight: 600;
}
.package-versions {
display: none;
background: #fafafa;
border-radius: 6px;
padding: 1rem;
margin-top: 1rem;
}
.package-versions.loaded {
display: block;
}
.package-list {
list-style: none;
padding: 0;
margin: 0;
}
.package-list li {
padding: 0.25rem 0;
font-family: monospace;
font-size: 0.9rem;
}
.package-name {
color: #666;
}
.package-version {
color: #0066cc;
font-weight: 500;
}
@media (prefers-color-scheme: dark) {
body {
background: #1a1a1a;
color: #e0e0e0;
}
h1 {
color: #fff;
border-bottom-color: #333;
}
h2 {
color: #ccc;
}
a {
color: #66b3ff;
}
.redirect-notice {
background: #1a2a3a;
border-color: #2a4a6a;
}
.versions-table th {
background: #2a2a2a;
}
.versions-table td,
.versions-table th {
border-bottom-color: #333;
}
.package-versions {
background: #2a2a2a;
}
.package-name {
color: #999;
}
}
</style>
</head>
<body>
<h1>MCP TypeScript SDK</h1>

<div class="redirect-notice">
<p>Redirecting to <a href="{{ site.data.latest_version }}/">latest documentation ({{ site.data.latest_version }})</a>...</p>
</div>

<h2>Package Versions</h2>
<div id="package-versions" class="package-versions">
<p>Loading package versions...</p>
</div>

<h2>All Documentation Versions</h2>
<p>Select a version to view its API documentation:</p>
<ul id="versions-list">
<li><a href="{{ site.data.latest_version }}/">{{ site.data.latest_version }}</a> (latest)</li>
</ul>

<script>
// Redirect to latest version
setTimeout(function() {
window.location.href = '{{ site.data.latest_version }}/';
}, 1000);

// Load and display package versions from versions.json
fetch('{{ site.data.latest_version }}/versions.json')
.then(function(response) {
if (!response.ok) throw new Error('versions.json not found');
return response.json();
})
.then(function(data) {
var container = document.getElementById('package-versions');
var html = '<p>Packages included in the latest documentation:</p><ul class="package-list">';

for (var pkg in data.packages) {
html += '<li><span class="package-name">' + pkg + '</span>: <span class="package-version">' + data.packages[pkg] + '</span></li>';
}

html += '</ul>';
html += '<p style="font-size: 0.85rem; color: #666; margin-top: 1rem;">Generated from tag: ' + data.generated_from_tag + '</p>';

container.innerHTML = html;
container.classList.add('loaded');
})
.catch(function(err) {
// versions.json may not exist for older docs
document.getElementById('package-versions').style.display = 'none';
});
</script>
</body>
</html>
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,42 @@ jobs:
- run: pnpm publish --provenance --access public ${{ steps.npm-tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# Generates API documentation for GitHub Pages on any release
# Supports both simple tags (v1.2.3) and package-scoped tags (@scope/[email protected])
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 and tags

- 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 @@ -132,6 +132,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
Loading
Loading