Skip to content

Commit 6f2c22a

Browse files
Generate schema reference page based on template (modelcontextprotocol#1085)
* Hide `@TJS-type` tag artifacts in `schema.mdx` Previously, `@TJS-type` tags were not recognized by TypeDoc because of the hyphen in their name. However, [TypeDoc v0.28.8][] supports such tags, allowing them to be listed in the `excludeTags` option. This commit upgrades TypeDoc to the latest version, and adds `@TJS-type` tags to the `excludeTags` configuration option, preventing their appearance in `schema.mdx`. [TypeDoc v0.28.8]: https://github.com/TypeStrong/typedoc/releases/tag/v0.28.8 * Prioritize RPC-related types in schema reference This changes the order of the schema reference page such that RPC-related types are listed first and common types are listed last. This also adds logic to ensure that, for a given RPC method, the relevant types are ordered as follows: `*Request` type, `*RequestParams` type, `*Result` type, `*Notification` type, `*NotificationParams` type, and then any other relevant types in alphabetical order. * Categorize more types in `schema.ts` This adds `@category` tags to more types in `schema.ts`. (The schema reference page uses these categories to organize types.) * Generate schema reference page based on template This commit modifies the TypeDoc plugin to generate the schema reference page based on a template `schema.mdx` file instead of based solely on the content of `schema.ts`. The template file uses placeholders to indicate where categories of types should be rendered. For example, the ``{/* @category `tools/call` */}`` placeholder will be replaced by the documentation for all types in the `` `tools/call` `` category. This change gives us more control over headings and category order, and allows us to easily add surrounding prose.
1 parent e79ae19 commit 6f2c22a

File tree

11 files changed

+1133
-588
lines changed

11 files changed

+1133
-588
lines changed

docs/specification/2025-06-18/schema.mdx

Lines changed: 239 additions & 207 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/specification/draft/schema.mdx

Lines changed: 252 additions & 229 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
"check:schema": "npm run check:schema:ts && npm run check:schema:json && npm run check:schema:md",
2626
"check:schema:ts": "tsc --noEmit && eslint schema/ && prettier --check \"schema/**/*.ts\"",
2727
"check:schema:json": "for f in schema/*/schema.ts; do typescript-json-schema --defaultNumberType integer --required --skipLibCheck \"$f\" \"*\" | cat | cmp \"${f%.ts}.json\" - || exit 1; done",
28-
"check:schema:md": "for f in docs/specification/*/schema.mdx; do typedoc --entryPoints \"schema/$(basename -- $(dirname -- \"$f\"))/schema.ts\" | cmp \"$f\" - || exit 1; done",
28+
"check:schema:md": "for f in schema/*/schema.mdx; do typedoc --entryPoints \"${f%.mdx}.ts\" --schemaPageTemplate \"$f\" | cmp docs/specification/$(basename -- $(dirname -- \"$f\"))/schema.mdx - || exit 1; done",
2929
"check:docs": "npm run check:docs:format && npm run check:docs:links",
3030
"check:docs:format": "prettier --check \"**/*.{md,mdx}\"",
3131
"check:docs:links": "cd docs && npx mint broken-links",
3232
"generate:schema": "npm run generate:schema:json && npm run generate:schema:md",
3333
"generate:schema:json": "for f in schema/*/schema.ts; do typescript-json-schema --defaultNumberType integer --required --skipLibCheck \"$f\" \"*\" -o \"${f%.ts}.json\"; done",
34-
"generate:schema:md": "for f in docs/specification/*/schema.mdx; do typedoc --entryPoints \"schema/$(basename -- $(dirname -- \"$f\"))/schema.ts\" > \"$f\"; done",
34+
"generate:schema:md": "for f in schema/*/schema.mdx; do typedoc --entryPoints \"${f%.mdx}.ts\" --schemaPageTemplate \"$f\" > docs/specification/$(basename -- $(dirname -- \"$f\"))/schema.mdx; done",
3535
"format": "prettier --write \"**/*.{md,mdx}\" --ignore \"docs/specification/*/schema.mdx\" ",
3636
"serve:docs": "cd docs && npx mint dev",
3737
"serve:blog": "cd blog && hugo serve"
@@ -45,7 +45,7 @@
4545
"glob": "^11.0.0",
4646
"prettier": "^3.6.2",
4747
"tsx": "^4.19.1",
48-
"typedoc": "^0.28.7",
48+
"typedoc": "^0.28.14",
4949
"typescript": "^5.6.2",
5050
"typescript-eslint": "^8.0.0",
5151
"typescript-json-schema": "^0.65.1"

schema/2025-06-18/schema.mdx

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: Schema Reference
3+
---
4+
5+
<div id="schema-reference" />
6+
7+
## JSON-RPC
8+
9+
{/* @category JSON-RPC */}
10+
11+
## Common Types
12+
13+
{/* @category Common Types */}
14+
15+
## Content
16+
17+
{/* @category Content */}
18+
19+
## `completion/complete`
20+
21+
{/* @category `completion/complete` */}
22+
23+
## `elicitation/create`
24+
25+
{/* @category `elicitation/create` */}
26+
27+
## `initialize`
28+
29+
{/* @category `initialize` */}
30+
31+
## `logging/setLevel`
32+
33+
{/* @category `logging/setLevel` */}
34+
35+
## `notifications/cancelled`
36+
37+
{/* @category `notifications/cancelled` */}
38+
39+
## `notifications/initialized`
40+
41+
{/* @category `notifications/initialized` */}
42+
43+
## `notifications/message`
44+
45+
{/* @category `notifications/message` */}
46+
47+
## `notifications/progress`
48+
49+
{/* @category `notifications/progress` */}
50+
51+
## `notifications/prompts/list_changed`
52+
53+
{/* @category `notifications/prompts/list_changed` */}
54+
55+
## `notifications/resources/list_changed`
56+
57+
{/* @category `notifications/resources/list_changed` */}
58+
59+
## `notifications/resources/updated`
60+
61+
{/* @category `notifications/resources/updated` */}
62+
63+
## `notifications/roots/list_changed`
64+
65+
{/* @category `notifications/roots/list_changed` */}
66+
67+
## `notifications/tools/list_changed`
68+
69+
{/* @category `notifications/tools/list_changed` */}
70+
71+
## `ping`
72+
73+
{/* @category `ping` */}
74+
75+
## `prompts/get`
76+
77+
{/* @category `prompts/get` */}
78+
79+
## `prompts/list`
80+
81+
{/* @category `prompts/list` */}
82+
83+
## `resources/list`
84+
85+
{/* @category `resources/list` */}
86+
87+
## `resources/read`
88+
89+
{/* @category `resources/read` */}
90+
91+
## `resources/subscribe`
92+
93+
{/* @category `resources/subscribe` */}
94+
95+
## `resources/templates/list`
96+
97+
{/* @category `resources/templates/list` */}
98+
99+
## `resources/unsubscribe`
100+
101+
{/* @category `resources/unsubscribe` */}
102+
103+
## `roots/list`
104+
105+
{/* @category `roots/list` */}
106+
107+
## `sampling/createMessage`
108+
109+
{/* @category `sampling/createMessage` */}
110+
111+
## `tools/call`
112+
113+
{/* @category `tools/call` */}
114+
115+
## `tools/list`
116+
117+
{/* @category `tools/list` */}

0 commit comments

Comments
 (0)