Skip to content

Conversation

@jonathanhefner
Copy link
Member

@jonathanhefner jonathanhefner commented Nov 13, 2025

This adds automated generation and deployment of versioned API documentation using TypeDoc and GitHub Pages. Documentation will be generated and published when a new release is created.

Changes

  1. Documentation generation script (see scripts/generate-gh-pages.sh)

    Generates TypeDoc documentation for a specific version tag and commits it to the gh-pages branch. The script uses git worktrees to isolate the documentation generation process from the main workspace.

    Documentation for each release is stored in a versioned directory (e.g., v1.2.3/) on the gh-pages branch. The script:

    • Parses semantic versions from tag names, ignoring arbitrary prefixes (e.g., tags 1.2.3, v1.2.3, and release-1.2.3 all create v1.2.3/)
    • Creates the gh-pages branch as an orphan branch if it doesn't exist
    • Generates new doc pages while preserving existing versioned directories
    • Generates _data/latest_version.yml for Jekyll template
    • Determines the latest version via semantic version sorting
    • For the latest version only, copies static Jekyll template files from .github/pages/ to the gh-pages root
  2. Jekyll template files (see .github/pages/ directory)

    • .github/pages/_config.yml - Jekyll configuration
    • .github/pages/index.html - Landing page that redirects to the latest version based on the generated _data/latest_version.yml
  3. GitHub Actions workflow (see .github/workflows/main.yml)

    Added a publish-gh-pages job that runs after the publish job on release events. This ensures documentation is generated and published only after the npm package is successfully published. The job invokes the generation script with the release tag name and pushes the updated gh-pages branch.

  4. CI validation (see package.json)

    Updated the check script to include TypeDoc validation with --emit none. This ensures TypeDoc can successfully parse the codebase (without generating output), catching documentation issues early in CI.

  5. Documentation link (see README.md)

    Added a link to the published API documentation in the Documentation section of the README.

TypeDoc Configuration

TypeDoc is configured via typedoc.json:

  • Uses the src directory as the entry point with the expand strategy
  • Explicitly excludes test files, mocks, examples, and integration tests

Documentation URL

Documentation will be available at:
https://modelcontextprotocol.github.io/typescript-sdk/

Versioned API documentation will be available at:

Co-Authored-By: Claude noreply@anthropic.com


You can see a preview of the documentation at: https://jonathanhefner.github.io/mcp-typescript-sdk/.

Note that the page automatically redirects to the latest version (in the preview, dummy v99.0.1), but it is fully customizable — see .github/pages/index.html — and can be more sophisticated in the future.

Eventually, I intend to link to the page from the modelcontextprotocol.io SDKs page. And, ultimately, I think it would be nice have something like sdks.modelcontextprotocol.io such that https://sdks.modelcontextprotocol.io/typescript-sdk/ resolves to https://modelcontextprotocol.github.io/typescript-sdk/.

If desired, I can also submit a PR for the gh-pages branch that backfills docs for old tags.

@jonathanhefner jonathanhefner requested a review from a team as a code owner November 13, 2025 19:19
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 13, 2025

Open in StackBlitz

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/sdk@1109

commit: 63bf877

@jonathanhefner jonathanhefner force-pushed the generate-api-docs branch 12 times, most recently from a79839c to 80f17f4 Compare November 16, 2025 20:59
@mattzcarey
Copy link
Contributor

Hey, thanks for your contribution. This is a great idea but I think these docs should live in the [official docs](https://modelcontextprotocol.io/] under its own section. It probably needs some syncing with that repo more than creating a deployment here.

@jonathanhefner
Copy link
Member Author

@mattzcarey I intend to link to the docs from the SDKs page. Ultimately, I think it would be nice have something like sdks.modelcontextprotocol.io such that https://sdks.modelcontextprotocol.io/typescript-sdk/ resolves to https://modelcontextprotocol.github.io/typescript-sdk/.

However, I strongly feel that the docs files themselves should live in each individual SDK's repo. That way, (1) the docs will be naturally kept in sync with the SDK, and (2) generation of versioned API docs will be tied to an SDK's release via GitHub Actions.

@jonathanhefner jonathanhefner force-pushed the generate-api-docs branch 2 times, most recently from 94a7781 to 5023e06 Compare November 21, 2025 18:25
@jonathanhefner jonathanhefner marked this pull request as draft November 27, 2025 04:28
@jonathanhefner jonathanhefner marked this pull request as ready for review November 27, 2025 20:59
@jonathanhefner jonathanhefner force-pushed the generate-api-docs branch 2 times, most recently from fab0d31 to e66c540 Compare December 3, 2025 16:43
@felixweinberger felixweinberger added P0 Broken core functionality, security issues, critical missing feature v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes ready for work Enough information for someone to start working on documentation Improvements or additions to documentation enhancement Request for a new feature that's not currently supported labels Dec 8, 2025
Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jonathanhefner thanks for kicking this off!

I think having a documentation page specifically for the TypeScript SDK is good and GH Pages seems like the right way to host this imo.

Looking at the current version of the documentation though this looks like mostly generated docs based on DocStrings / Types. Is the idea for this to be a skeleton that we then fill in with actual guides and How-Tos for doing stuff or is the intention just to be a type reference? I'm not sure if the type reference adds a ton of value over just having the source code on github directly and inspecting the source?

Comparing for example the direction the Python SDK docs are going in which is more of a nicely rendered and navigable guide on how to actually use the SDK: https://modelcontextprotocol.github.io/python-sdk/

Do we need all the generated type docs or should we stick to something closer to what Python is doing?

@felixweinberger felixweinberger added P1 Significant bug affecting many users, highly requested feature and removed P0 Broken core functionality, security issues, critical missing feature labels Dec 15, 2025
@jonathanhefner
Copy link
Member Author

Is the idea for this to be a skeleton that we then fill in with actual guides and How-Tos for doing stuff or is the intention just to be a type reference?

There are two possible approaches I had in mind:

  1. Include the guides in the generated TypeDoc output via the projectDocuments setting.
  2. Create a full-fledged GH Pages site and put the generated TypeDoc documentation at api/.

When I first submitted this PR, there were no other documents, so I tried to allow for either possibility. (See this comment in the script for Option 2.)

Since #1197, there are now some guides in docs/, so I have pushed a commit to include them in the TypeDoc output per Option 1. For example: https://jonathanhefner.github.io/mcp-typescript-sdk/v99.0.1/documents/Server.html.

At the moment, I lean toward staying with Option 1. If we have more sophisticated needs for structure and styling, we can switch to Option 2.

@felixweinberger
Copy link
Contributor

felixweinberger commented Dec 16, 2025

Is the idea for this to be a skeleton that we then fill in with actual guides and How-Tos for doing stuff or is the intention just to be a type reference?

There are two possible approaches I had in mind:

  1. Include the guides in the generated TypeDoc output via the projectDocuments setting.
  2. Create a full-fledged GH Pages site and put the generated TypeDoc documentation at api/.

When I first submitted this PR, there were no other documents, so I tried to allow for either possibility. (See this comment in the script for Option 2.)

Since #1197, there are now some guides in docs/, so I have pushed a commit to include them in the TypeDoc output per Option 1. For example: https://jonathanhefner.github.io/mcp-typescript-sdk/v99.0.1/documents/Server.html.

At the moment, I lean toward staying with Option 1. If we have more sophisticated needs for structure and styling, we can switch to Option 2.

Yeah I think this is heading more in the direction I was thinking: https://jonathanhefner.github.io/mcp-typescript-sdk/v99.0.1/documents/Server.html

However, I do feel like the navigation might be a little bit confusing / overwhelming? Looking at the side bar:

CleanShot 2025-12-16 at 15 03 14@2x

There's a mix of low level API references that mirror the code structure and more classic tutorial-style guides. By virtue of the code structure for example we're elevating inMemory to a top level thing people might end up clicking on and browsing, but in practice we expect basically nobody to use it given it's not an official transport. It's probably a sign to move that file elsewhere, but more generally wondering if we can move the purely generated code into a visually separate section somehow?

Even just having:

docs
   - Client
   - Server
   - Capabilities
   - FAQ
   
API reference
   - client
   - server
   - inMemory
   - ...

Would be quite helpful potentially to separate the generated class and type docs from the actually written prose and guides?

jonathanhefner and others added 2 commits December 16, 2025 10:13
This adds automated generation and deployment of versioned API
documentation using TypeDoc and GitHub Pages. Documentation will be
generated and published when a new release is created.

Changes
-------

1. **Documentation generation script** (see `scripts/generate-gh-pages.sh`)

    Generates TypeDoc documentation for a specific version tag and
    commits it to the gh-pages branch. The script uses git worktrees to
    isolate the documentation generation process from the main workspace.

    Documentation for each release is stored in a versioned directory
    (e.g., `v1.2.3/`) on the gh-pages branch. The script:

    - Parses semantic versions from tag names, ignoring arbitrary prefixes
      (e.g., tags `1.2.3`, `v1.2.3`, and `release-1.2.3` all create `v1.2.3/`)
    - Creates the gh-pages branch as an orphan branch if it doesn't exist
    - Generates new doc pages while preserving existing versioned directories
    - Generates `_data/latest_version.yml` for Jekyll template
    - Determines the latest version via semantic version sorting
    - For the latest version only, copies static Jekyll template files
      from `.github/pages/` to the gh-pages root

2. **Jekyll template files** (see `.github/pages/` directory)

    - `.github/pages/_config.yml` - Jekyll configuration
    - `.github/pages/index.html` - Landing page that redirects to the
      latest version based on the generated `_data/latest_version.yml`

3. **GitHub Actions workflow** (see `.github/workflows/main.yml`)

    Added a `publish-gh-pages` job that runs after the `publish` job on
    release events. This ensures documentation is generated and
    published only after the npm package is successfully published. The
    job invokes the generation script with the release tag name and
    pushes the updated gh-pages branch.

4. **CI validation** (see `package.json`)

    Updated the `check` script to include TypeDoc validation with
    `--emit none`. This ensures TypeDoc can successfully parse the
    codebase (without generating output), catching documentation issues
    early in CI.

5. **Documentation link** (see `README.md`)

    Added a link to the published API documentation in the Documentation
    section of the README.

TypeDoc Configuration
---------------------

TypeDoc is configured via `typedoc.json`:

- Uses the `src` directory as the entry point with the `expand` strategy
- Explicitly excludes test files, mocks, examples, and integration tests

Documentation URL
-----------------

Documentation will be available at:
https://modelcontextprotocol.github.io/typescript-sdk/

Versioned API documentation will be available at:
- https://modelcontextprotocol.github.io/typescript-sdk/ (redirects to latest)
- https://modelcontextprotocol.github.io/typescript-sdk/v1.2.3/ (specific versions)

Co-Authored-By: Claude <noreply@anthropic.com>

latest version
- Add `projectDocuments` option to `typedoc.json` to include `docs/*.md`
- Prefix `docs/*.md` filenames with indexes to control sidebar ordering
- Convert relative links to absolute GitHub URLs so they work in the
  generated documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sonarqubecloud
Copy link

@jonathanhefner
Copy link
Member Author

@felixweinberger Good point. How does this look:

nav

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement Request for a new feature that's not currently supported P1 Significant bug affecting many users, highly requested feature ready for work Enough information for someone to start working on v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants