Skip to content

Commit 7703df1

Browse files
authored
Expand site-absolute spec links in generated docstrings to full URLs (#2885)
1 parent 65be5a7 commit 7703df1

2 files changed

Lines changed: 61 additions & 56 deletions

File tree

scripts/gen_surface_types.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
Runs `datamodel-code-generator` over each `schema/PINNED.json` entry and
44
writes the result to `src/mcp/types/v<version>/__init__.py` with only the
55
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]`.
89
"""
910

1011
from __future__ import annotations
@@ -198,6 +199,10 @@ def build(entry: dict[str, str]) -> str:
198199
# Codegen appends `| None` to forward refs of nullable models, which is a
199200
# runtime TypeError on a string ref and redundant since `JSONValue` includes None.
200201
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/")
201206
source = allow_open_class_extras(source, OPEN_CLASSES[version])
202207
if epilogue := EPILOGUES.get(version, ""):
203208
# Insert before the trailing model_rebuild() block: pyright's evaluation

0 commit comments

Comments
 (0)