141 lines
7 KiB
TypeScript
141 lines
7 KiB
TypeScript
import { existsSync, readFileSync } from 'node:fs';
|
|
import { dirname, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
import { defineConfig, type DefaultTheme } from 'vitepress';
|
|
|
|
const docsDir = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
|
|
/**
|
|
* The API Reference sidebar is generated by `pnpm docs:api` (typedoc + typedoc-vitepress-theme)
|
|
* into docs/api/typedoc-sidebar.json. When it is missing (e.g. `docs:dev` before `docs:api`),
|
|
* fall back to an empty group with a hint instead of crashing.
|
|
*/
|
|
function apiSidebarItems(): DefaultTheme.SidebarItem[] {
|
|
const sidebarPath = resolve(docsDir, 'api/typedoc-sidebar.json');
|
|
if (!existsSync(sidebarPath)) {
|
|
console.warn(`[docs] ${sidebarPath} not found — run \`pnpm docs:api\` first to populate the API Reference section.`);
|
|
return [];
|
|
}
|
|
return JSON.parse(readFileSync(sidebarPath, 'utf8'));
|
|
}
|
|
|
|
export default defineConfig({
|
|
title: 'MCP TypeScript SDK',
|
|
description: 'The TypeScript SDK implementation of the Model Context Protocol specification.',
|
|
base: '/v2/',
|
|
srcExclude: ['v1/**', '_meta/**', 'behavior-surface-pins.md'],
|
|
sitemap: { hostname: 'https://ts.sdk.modelcontextprotocol.io/v2/' },
|
|
markdown: {
|
|
config(md) {
|
|
// Spec-generated JSDoc (packages/core-internal/src/types/spec.types.*.ts) carries
|
|
// site-root-relative links like /specification/draft/basic/index#meta that are meant
|
|
// to resolve on modelcontextprotocol.io. Rewrite them at render time so they work on
|
|
// this site (and so the dead-link check sees them as external).
|
|
const orig = md.renderer.rules.link_open ?? ((tokens, idx, options, _env, self) => self.renderToken(tokens, idx, options));
|
|
md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
|
|
const href = tokens[idx].attrGet('href');
|
|
if (href?.startsWith('/specification/')) {
|
|
tokens[idx].attrSet('href', `https://modelcontextprotocol.io${href}`);
|
|
}
|
|
return orig(tokens, idx, options, env, self);
|
|
};
|
|
}
|
|
},
|
|
themeConfig: {
|
|
nav: [
|
|
{ text: 'Get started', link: '/get-started/first-server', activeMatch: '^/get-started/' },
|
|
{ text: 'Servers', link: '/servers/tools', activeMatch: '^/(servers|serving)/' },
|
|
{ text: 'Clients', link: '/clients/connect', activeMatch: '^/clients/' },
|
|
{ text: 'Migration', link: '/migration/', activeMatch: '^/migration/' },
|
|
{ text: 'API Reference', link: '/api/', activeMatch: '^/api/' },
|
|
{ text: 'V1 Docs', link: 'https://ts.sdk.modelcontextprotocol.io/' }
|
|
],
|
|
sidebar: [
|
|
{
|
|
text: 'Get started',
|
|
items: [
|
|
{ text: 'Build a server', link: '/get-started/first-server' },
|
|
{ text: 'Plug into a real host', link: '/get-started/real-host' },
|
|
{ text: 'Build a client', link: '/get-started/first-client' },
|
|
{ text: 'Packages', link: '/get-started/packages' },
|
|
{ text: 'Examples', link: '/get-started/examples' }
|
|
]
|
|
},
|
|
{
|
|
text: 'Servers',
|
|
items: [
|
|
{ text: 'Tools', link: '/servers/tools' },
|
|
{ text: 'Resources', link: '/servers/resources' },
|
|
{ text: 'Prompts', link: '/servers/prompts' },
|
|
{ text: 'Completion', link: '/servers/completion' },
|
|
{ text: 'Logging, progress, cancellation', link: '/servers/logging-progress-cancellation' },
|
|
{ text: 'Elicitation', link: '/servers/elicitation' },
|
|
{ text: 'Sampling (sunset)', link: '/servers/sampling' },
|
|
{ text: 'Input required', link: '/servers/input-required' },
|
|
{ text: 'Notifications', link: '/servers/notifications' },
|
|
{ text: 'Errors', link: '/servers/errors' }
|
|
]
|
|
},
|
|
{
|
|
text: 'Serving',
|
|
items: [
|
|
{ text: 'stdio', link: '/serving/stdio' },
|
|
{ text: 'HTTP', link: '/serving/http' },
|
|
{ text: 'Express', link: '/serving/express' },
|
|
{ text: 'Hono', link: '/serving/hono' },
|
|
{ text: 'Fastify', link: '/serving/fastify' },
|
|
{ text: 'Web-standard runtimes', link: '/serving/web-standard' },
|
|
{ text: 'Sessions, state, scaling', link: '/serving/sessions-state-scaling' },
|
|
{ text: 'Authorization', link: '/serving/authorization' },
|
|
{ text: 'Legacy clients', link: '/serving/legacy-clients' }
|
|
]
|
|
},
|
|
{
|
|
text: 'Clients',
|
|
items: [
|
|
{ text: 'Connect', link: '/clients/connect' },
|
|
{ text: 'Calling', link: '/clients/calling' },
|
|
{ text: 'Handle server requests', link: '/clients/server-requests' },
|
|
{ text: 'Roots (sunset)', link: '/clients/roots' },
|
|
{ text: 'Subscriptions', link: '/clients/subscriptions' },
|
|
{ text: 'OAuth', link: '/clients/oauth' },
|
|
{ text: 'Machine auth', link: '/clients/machine-auth' },
|
|
{ text: 'Middleware', link: '/clients/middleware' },
|
|
{ text: 'Caching', link: '/clients/caching' }
|
|
]
|
|
},
|
|
{ text: 'Protocol versions', link: '/protocol-versions' },
|
|
{
|
|
text: 'Advanced',
|
|
collapsed: true,
|
|
items: [
|
|
{ text: 'Low-level server', link: '/advanced/low-level-server' },
|
|
{ text: 'Custom methods', link: '/advanced/custom-methods' },
|
|
{ text: 'Schema libraries', link: '/advanced/schema-libraries' },
|
|
{ text: 'Custom transports', link: '/advanced/custom-transports' },
|
|
{ text: 'Wire schemas', link: '/advanced/wire-schemas' },
|
|
{ text: 'Gateway', link: '/advanced/gateway' }
|
|
]
|
|
},
|
|
{ text: 'Testing', link: '/testing' },
|
|
{ text: 'Troubleshooting', link: '/troubleshooting' },
|
|
{
|
|
text: 'Migration',
|
|
items: [
|
|
{ text: 'Overview', link: '/migration/' },
|
|
{ text: 'Upgrade to v2', link: '/migration/upgrade-to-v2' },
|
|
{ text: '2026-07-28 protocol support', link: '/migration/support-2026-07-28' }
|
|
]
|
|
},
|
|
{
|
|
text: 'API Reference',
|
|
collapsed: true,
|
|
items: apiSidebarItems()
|
|
}
|
|
],
|
|
outline: { level: [2, 3] },
|
|
search: { provider: 'local' },
|
|
socialLinks: [{ icon: 'github', link: 'https://github.com/modelcontextprotocol/typescript-sdk' }]
|
|
}
|
|
});
|