|
3 | 3 | Runs `datamodel-code-generator` over each `schema/PINNED.json` entry and |
4 | 4 | writes the result to `src/mcp/types/v<version>/__init__.py` with only the |
5 | 5 | fixes the raw output needs: a small JSON pre-patch for the known |
6 | | -`number`-as-`integer` schema.json defect, a header, and per-version |
7 | | -epilogue aliases. Run with `uv run --frozen --group codegen python scripts/gen_surface_types.py [--check]`. |
| 6 | +`number`-as-`integer` schema.json defect, a header, full URLs for the spec's |
| 7 | +site-absolute doc links, and per-version epilogue aliases. Run with |
| 8 | +`uv run --frozen --group codegen python scripts/gen_surface_types.py [--check]`. |
8 | 9 | """ |
9 | 10 |
|
10 | 11 | from __future__ import annotations |
@@ -198,6 +199,10 @@ def build(entry: dict[str, str]) -> str: |
198 | 199 | # Codegen appends `| None` to forward refs of nullable models, which is a |
199 | 200 | # runtime TypeError on a string ref and redundant since `JSONValue` includes None. |
200 | 201 | source = source.replace('"JSONValue" | None', '"JSONValue"') |
| 202 | + # Schema descriptions link to spec-site pages with site-absolute paths; expand |
| 203 | + # them to full URLs so they resolve from the rendered API docs and pass the |
| 204 | + # strict mkdocs link validation. |
| 205 | + source = source.replace("](/", "](https://modelcontextprotocol.io/") |
201 | 206 | source = allow_open_class_extras(source, OPEN_CLASSES[version]) |
202 | 207 | if epilogue := EPILOGUES.get(version, ""): |
203 | 208 | # Insert before the trailing model_rebuild() block: pyright's evaluation |
|
0 commit comments