@@ -66,6 +66,10 @@ def _consume_saved_stdout_fd() -> int:
6666# === Now safe to import everything else ===
6767import click # noqa: E402
6868
69+ from mcp_server_python_docs .ingestion .cpython_versions import ( # noqa: E402
70+ SUPPORTED_DOC_VERSIONS_CSV ,
71+ )
72+
6973
7074@click .group (invoke_without_command = True )
7175@click .option ("--version" , "show_version" , is_flag = True , help = "Show version and exit." )
@@ -105,7 +109,7 @@ def serve() -> None:
105109@click .option (
106110 "--versions" ,
107111 required = True ,
108- help = "Comma-separated Python versions (e.g., 3.12,3.13 )" ,
112+ help = f "Comma-separated Python versions (e.g., { SUPPORTED_DOC_VERSIONS_CSV } )" ,
109113)
110114@click .option (
111115 "--skip-content" ,
@@ -120,6 +124,9 @@ def build_index(versions: str, skip_content: bool) -> None:
120124 import venv
121125 from pathlib import Path
122126
127+ from mcp_server_python_docs .ingestion .cpython_versions import (
128+ CPYTHON_DOCS_BUILD_CONFIG ,
129+ )
123130 from mcp_server_python_docs .ingestion .inventory import ingest_inventory
124131 from mcp_server_python_docs .ingestion .publish import (
125132 _version_sort_key ,
@@ -128,6 +135,7 @@ def build_index(versions: str, skip_content: bool) -> None:
128135 publish_index ,
129136 )
130137 from mcp_server_python_docs .ingestion .sphinx_json import (
138+ build_sphinx_bootstrap_requirements ,
131139 build_sphinx_json_command ,
132140 ingest_sphinx_json_dir ,
133141 make_sphinx_json_env ,
@@ -142,15 +150,12 @@ def build_index(versions: str, skip_content: bool) -> None:
142150 get_readwrite_connection ,
143151 )
144152
145- # Version tag mapping: CPython git tag and Sphinx constraints (INGR-C-02)
146- VERSION_CONFIG : dict [str , dict [str , str ]] = {
147- "3.12" : {"tag" : "v3.12.13" , "sphinx_pin" : "sphinx~=8.2.0" },
148- "3.13" : {"tag" : "v3.13.12" , "sphinx_pin" : "sphinx<9.0.0" },
149- }
150-
151153 version_list = parse_expected_versions (versions )
152154 if not version_list :
153- logger .error ("No valid versions specified. Example: --versions 3.13" )
155+ logger .error (
156+ "No valid versions specified. Example: --versions %s" ,
157+ SUPPORTED_DOC_VERSIONS_CSV ,
158+ )
154159 raise SystemExit (1 )
155160
156161 # Validate version format before sorting (CR-03, WR-04)
@@ -188,7 +193,7 @@ def build_index(versions: str, skip_content: bool) -> None:
188193 continue
189194
190195 # === Content ingestion (INGR-C-01 through INGR-C-03) ===
191- config = VERSION_CONFIG .get (version )
196+ config = CPYTHON_DOCS_BUILD_CONFIG .get (version )
192197 if not config :
193198 logger .warning (
194199 "No CPython build config for %s, skipping content ingestion" ,
@@ -226,9 +231,22 @@ def build_index(versions: str, skip_content: bool) -> None:
226231 )
227232 pip_path = os .path .join (scripts_dir , "pip" )
228233
229- # Install Sphinx with the version pin for this CPython branch
234+ # Install Sphinx with the version pin for this CPython branch.
235+ bootstrap_requirements = build_sphinx_bootstrap_requirements (
236+ config ["sphinx_pin" ]
237+ )
238+ if len (bootstrap_requirements ) > 1 :
239+ logger .info (
240+ "Installing Sphinx bootstrap packages for Python %s: %s" ,
241+ version ,
242+ ", " .join (bootstrap_requirements [:- 1 ]),
243+ )
230244 subprocess .run (
231- [pip_path , "install" , config ["sphinx_pin" ]],
245+ [
246+ pip_path ,
247+ "install" ,
248+ * bootstrap_requirements ,
249+ ],
232250 check = True ,
233251 capture_output = True ,
234252 text = True ,
@@ -381,7 +399,10 @@ def validate_corpus(db_path: str | None) -> None:
381399
382400 if not target .exists ():
383401 logger .error ("Index not found at %s" , target )
384- logger .error ("Run: mcp-server-python-docs build-index --versions 3.13" )
402+ logger .error (
403+ "Run: mcp-server-python-docs build-index --versions %s" ,
404+ SUPPORTED_DOC_VERSIONS_CSV ,
405+ )
385406 raise SystemExit (1 )
386407
387408 logger .info ("Validating corpus at %s" , target )
@@ -506,7 +527,8 @@ def doctor() -> None:
506527 index_detail = str (index_path )
507528 if not index_exists :
508529 index_detail += (
509- " (not found -- run: mcp-server-python-docs build-index --versions 3.13)"
530+ f" (not found -- run: mcp-server-python-docs build-index --versions "
531+ f"{ SUPPORTED_DOC_VERSIONS_CSV } )"
510532 )
511533 else :
512534 size_mb = index_path .stat ().st_size / (1024 * 1024 )
0 commit comments