Skip to content

Commit ff06828

Browse files
authored
docs: update v1 references to link to hosted V1 API docs (#1584)
1 parent 3eec8b6 commit ff06828

9 files changed

Lines changed: 237 additions & 15 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- v1.x
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: deploy-docs
12+
cancel-in-progress: true
13+
14+
jobs:
15+
deploy-docs:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
pages: write
21+
id-token: write
22+
23+
environment:
24+
name: github-pages
25+
url: ${{ steps.deployment.outputs.page_url }}
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Install pnpm
31+
uses: pnpm/action-setup@v4
32+
with:
33+
run_install: false
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: 24
37+
cache: pnpm
38+
cache-dependency-path: pnpm-lock.yaml
39+
40+
- name: Generate multi-version docs
41+
run: bash scripts/generate-multidoc.sh tmp/docs-combined
42+
43+
- name: Configure Pages
44+
uses: actions/configure-pages@v5
45+
46+
- name: Upload Pages artifact
47+
uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: tmp/docs-combined
50+
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4

.github/workflows/main.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ jobs:
109109
env:
110110
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
111111

112-
# Generates API documentation and deploys to GitHub Pages on any release
112+
# Generates API documentation (V1 + V2) and deploys to GitHub Pages on any release
113113
deploy-docs:
114114
runs-on: ubuntu-latest
115115
if: github.event_name == 'release'
116116
needs: [publish]
117117

118118
permissions:
119+
contents: read
119120
pages: write
120121
id-token: write
121122

@@ -136,22 +137,16 @@ jobs:
136137
cache: pnpm
137138
cache-dependency-path: pnpm-lock.yaml
138139

139-
- name: Install dependencies
140-
run: pnpm install
141-
142-
- name: Build packages
143-
run: pnpm build:all
144-
145-
- name: Generate documentation
146-
run: pnpm docs
140+
- name: Generate multi-version docs
141+
run: bash scripts/generate-multidoc.sh tmp/docs-combined
147142

148143
- name: Configure Pages
149144
uses: actions/configure-pages@v5
150145

151146
- name: Upload Pages artifact
152147
uses: actions/upload-pages-artifact@v3
153148
with:
154-
path: tmp/docs
149+
path: tmp/docs-combined
155150

156151
- name: Deploy to GitHub Pages
157152
id: deployment

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,8 @@ dist/
138138
.idea/
139139
.cursor/
140140

141+
# Git worktrees for local doc generation
142+
.worktrees/
143+
141144
# Conformance test results
142145
results/

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
>
55
> We anticipate a stable v2 release in Q1 2026. Until then, **v1.x remains the recommended version** for production use. v1.x will continue to receive bug fixes and security updates for at least 6 months after v2 ships to give people time to upgrade.
66
>
7-
> For v1 documentation and code, see the [`v1.x` branch](https://github.com/modelcontextprotocol/typescript-sdk/tree/v1.x).
7+
> For v1 documentation, see the [V1 API docs](https://modelcontextprotocol.github.io/typescript-sdk/). For v2 API docs, see [`/v2/`](https://modelcontextprotocol.github.io/typescript-sdk/v2/).
88
99
![NPM Version](https://img.shields.io/npm/v/%40modelcontextprotocol%2Fserver) ![NPM Version](https://img.shields.io/npm/v/%40modelcontextprotocol%2Fclient) ![MIT licensed](https://img.shields.io/npm/l/%40modelcontextprotocol%2Fserver)
1010

@@ -136,10 +136,20 @@ Next steps:
136136
- [MCP Specification](https://spec.modelcontextprotocol.io)
137137
- [Example Servers](https://github.com/modelcontextprotocol/servers)
138138

139+
### Building docs locally
140+
141+
To generate the API reference documentation locally:
142+
143+
```bash
144+
pnpm docs # Generate V2 docs only (output: tmp/docs/)
145+
pnpm docs:multi # Generate combined V1 + V2 docs (output: tmp/docs-combined/)
146+
```
147+
148+
The `docs:multi` script checks out both the `v1.x` and `main` branches via git worktrees, builds each, and produces a combined site with V1 docs at the root and V2 docs under `/v2/`.
149+
139150
## v1 (legacy) documentation and fixes
140151

141-
If you are using the **v1** generation of the SDK, the **v1 documentation** (and any v1-specific fixes) live on the long-lived [`v1.x` branch](https://github.com/modelcontextprotocol/typescript-sdk/tree/v1.x). See:
142-
[`https://github.com/modelcontextprotocol/typescript-sdk/tree/v1.x`](https://github.com/modelcontextprotocol/typescript-sdk/tree/v1.x).
152+
If you are using the **v1** generation of the SDK, the **v1 API documentation** is available at [`https://modelcontextprotocol.github.io/typescript-sdk/`](https://modelcontextprotocol.github.io/typescript-sdk/). The v1 source code and any v1-specific fixes live on the long-lived [`v1.x` branch](https://github.com/modelcontextprotocol/typescript-sdk/tree/v1.x). V2 API docs are at [`/v2/`](https://modelcontextprotocol.github.io/typescript-sdk/v2/).
143153

144154
## Contributing
145155

docs/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ wanting to switch to `v2` and using SSE should migrate to Streamable HTTP.
8282

8383
### Where do v1 documentation and v1-specific fixes live?
8484

85-
The v1 generation of this SDK is maintained on the long-lived [`v1.x` branch](https://github.com/modelcontextprotocol/typescript-sdk/tree/v1.x). If you’re using v1, refer to that branch for documentation and any v1-specific fixes.
85+
The v1 API documentation is available at [`https://modelcontextprotocol.github.io/typescript-sdk/`](https://modelcontextprotocol.github.io/typescript-sdk/). The v1 source code and any v1-specific fixes live on the long-lived [`v1.x` branch](https://github.com/modelcontextprotocol/typescript-sdk/tree/v1.x). V2 API docs are at [`/v2/`](https://modelcontextprotocol.github.io/typescript-sdk/v2/).

docs/v2-banner.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
document.addEventListener("DOMContentLoaded", function () {
2+
var banner = document.createElement("div");
3+
banner.innerHTML =
4+
"This documents a <strong>pre-release</strong> version of the SDK. Expect breaking changes. For the stable SDK, see the <a href='/'>V1 docs</a>.";
5+
banner.style.cssText =
6+
"background:#fff3cd;color:#856404;border-bottom:1px solid #ffc107;padding:8px 16px;text-align:center;font-size:14px;";
7+
banner.querySelector("a").style.cssText = "color:#856404;text-decoration:underline;";
8+
document.body.insertBefore(banner, document.body.firstChild);
9+
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"sync:snippets": "tsx scripts/sync-snippets.ts",
2727
"examples:simple-server:w": "pnpm --filter @modelcontextprotocol/examples-server exec tsx --watch src/simpleStreamableHttp.ts --oauth",
2828
"docs": "typedoc",
29+
"docs:multi": "bash scripts/generate-multidoc.sh",
2930
"docs:check": "typedoc",
3031
"typecheck:all": "pnpm -r typecheck",
3132
"build:all": "pnpm -r build",

scripts/generate-multidoc.sh

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Generate combined V1 + V2 TypeDoc documentation.
4+
#
5+
# V1 docs (from the v1.x branch) are placed at the root.
6+
# V2 docs (from main) are placed under /v2/.
7+
#
8+
# This script can be run from any branch — it fetches both v1.x and main
9+
# via git worktrees.
10+
#
11+
# Usage:
12+
# scripts/generate-multidoc.sh [output-dir]
13+
#
14+
# Default output directory: tmp/docs-combined
15+
#
16+
set -euo pipefail
17+
18+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
20+
OUTPUT_DIR="${1:-$REPO_ROOT/tmp/docs-combined}"
21+
V1_WORKTREE="$REPO_ROOT/.worktrees/v1-docs"
22+
V2_WORKTREE="$REPO_ROOT/.worktrees/v2-docs"
23+
24+
cleanup() {
25+
echo "Cleaning up worktrees..."
26+
cd "$REPO_ROOT"
27+
git worktree remove --force "$V1_WORKTREE" 2>/dev/null || true
28+
git worktree remove --force "$V2_WORKTREE" 2>/dev/null || true
29+
}
30+
trap cleanup EXIT
31+
32+
rm -rf "$OUTPUT_DIR"
33+
mkdir -p "$OUTPUT_DIR"
34+
35+
# ---------------------------------------------------------------------------
36+
# Step 1: Generate V1 docs from v1.x branch
37+
# ---------------------------------------------------------------------------
38+
echo "=== Generating V1 docs ==="
39+
40+
git fetch origin v1.x
41+
42+
git worktree remove --force "$V1_WORKTREE" 2>/dev/null || true
43+
rm -rf "$V1_WORKTREE"
44+
git worktree add "$V1_WORKTREE" "origin/v1.x" --detach
45+
46+
cd "$V1_WORKTREE"
47+
npm install
48+
npm install --save-dev typedoc@^0.28.14
49+
50+
cat > typedoc.json << 'TYPEDOC_EOF'
51+
{
52+
"name": "MCP TypeScript SDK",
53+
"entryPoints": [
54+
"src/client/index.ts",
55+
"src/server/index.ts",
56+
"src/shared/protocol.ts",
57+
"src/shared/transport.ts",
58+
"src/types.ts",
59+
"src/inMemory.ts",
60+
"src/validation/index.ts",
61+
"src/experimental/index.ts"
62+
],
63+
"tsconfig": "tsconfig.json",
64+
"out": "tmp/docs",
65+
"exclude": [
66+
"**/*.test.ts",
67+
"**/__fixtures__/**",
68+
"**/__mocks__/**",
69+
"src/examples/**"
70+
],
71+
"projectDocuments": [
72+
"docs/server.md",
73+
"docs/client.md",
74+
"docs/capabilities.md",
75+
"docs/protocol.md",
76+
"docs/faq.md"
77+
],
78+
"navigationLinks": {
79+
"V2 Docs": "/v2/"
80+
},
81+
"headings": {
82+
"readme": false
83+
},
84+
"skipErrorChecking": true
85+
}
86+
TYPEDOC_EOF
87+
88+
# Rewrite relative .ts links to point to GitHub source instead of media downloads
89+
V1_GITHUB="https://github.com/modelcontextprotocol/typescript-sdk/blob/v1.x"
90+
sed -i "s|(src/examples/|(${V1_GITHUB}/src/examples/|g" README.md
91+
sed -i "s|(../src/examples/|(${V1_GITHUB}/src/examples/|g" docs/*.md
92+
93+
npx typedoc
94+
95+
cp -r "$V1_WORKTREE/tmp/docs/"* "$OUTPUT_DIR/"
96+
97+
# ---------------------------------------------------------------------------
98+
# Step 2: Generate V2 docs from main branch
99+
# ---------------------------------------------------------------------------
100+
echo "=== Generating V2 docs ==="
101+
102+
git fetch origin main
103+
104+
git worktree remove --force "$V2_WORKTREE" 2>/dev/null || true
105+
rm -rf "$V2_WORKTREE"
106+
git worktree add "$V2_WORKTREE" "origin/main" --detach
107+
108+
cd "$V2_WORKTREE"
109+
pnpm install
110+
pnpm -r --filter='./packages/**' build
111+
112+
# Write the V2 pre-release banner script
113+
cat > docs/v2-banner.js << 'BANNER_EOF'
114+
document.addEventListener("DOMContentLoaded", function () {
115+
var banner = document.createElement("div");
116+
banner.innerHTML =
117+
"This documents a <strong>pre-release</strong> version of the SDK. Expect breaking changes. For the stable SDK, see the <a href='/'>V1 docs</a>.";
118+
banner.style.cssText =
119+
"background:#fff3cd;color:#856404;border-bottom:1px solid #ffc107;padding:8px 16px;text-align:center;font-size:14px;";
120+
banner.querySelector("a").style.cssText = "color:#856404;text-decoration:underline;";
121+
document.body.insertBefore(banner, document.body.firstChild);
122+
123+
124+
});
125+
BANNER_EOF
126+
127+
# Patch the V2 typedoc config to add navigation links, base URL, and banner
128+
node -e "
129+
import fs from 'fs';
130+
const cfg = fs.readFileSync('typedoc.config.mjs', 'utf8');
131+
const patched = cfg.replace(
132+
/export default \{/,
133+
\"export default {\\n hostedBaseUrl: 'https://modelcontextprotocol.github.io/typescript-sdk/v2/',\\n customJs: 'docs/v2-banner.js',\"
134+
).replace(
135+
/navigation:/,
136+
\"navigationLinks: {\\n 'V1 Docs': '/',\\n },\\n navigation:\"
137+
);
138+
fs.writeFileSync('typedoc.config.mjs', patched);
139+
"
140+
141+
npx typedoc # outputs to tmp/docs/ per typedoc.config.mjs
142+
143+
mkdir -p "$OUTPUT_DIR/v2"
144+
cp -r "$V2_WORKTREE/tmp/docs/"* "$OUTPUT_DIR/v2/"
145+
146+
cd "$REPO_ROOT"
147+
echo "=== Combined docs generated at $OUTPUT_DIR ==="

typedoc.config.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ console.log(
2424

2525
/** @type {Partial<import("typedoc").TypeDocOptions>} */
2626
export default {
27-
name: 'MCP TypeScript SDK',
27+
name: 'MCP TypeScript SDK (V2)',
2828
entryPointStrategy: 'packages',
2929
entryPoints,
3030
packageOptions: {
@@ -33,13 +33,17 @@ export default {
3333
},
3434
highlightLanguages: [...OptionDefaults.highlightLanguages, 'powershell'],
3535
projectDocuments: ['docs/documents.md'],
36+
navigationLinks: {
37+
'V1 Docs': '/'
38+
},
3639
navigation: {
3740
compactFolders: true,
3841
includeFolders: false
3942
},
4043
headings: {
4144
readme: false
4245
},
46+
customJs: 'docs/v2-banner.js',
4347
treatWarningsAsErrors: true,
4448
out: 'tmp/docs/',
4549
};

0 commit comments

Comments
 (0)