python-docs-mcp-server 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_server_python_docs/server.py +54 -2
- {python_docs_mcp_server-0.1.2.dist-info → python_docs_mcp_server-0.1.3.dist-info}/METADATA +1 -1
- {python_docs_mcp_server-0.1.2.dist-info → python_docs_mcp_server-0.1.3.dist-info}/RECORD +6 -6
- {python_docs_mcp_server-0.1.2.dist-info → python_docs_mcp_server-0.1.3.dist-info}/WHEEL +0 -0
- {python_docs_mcp_server-0.1.2.dist-info → python_docs_mcp_server-0.1.3.dist-info}/entry_points.txt +0 -0
- {python_docs_mcp_server-0.1.2.dist-info → python_docs_mcp_server-0.1.3.dist-info}/licenses/LICENSE +0 -0
mcp_server_python_docs/server.py
CHANGED
|
@@ -9,7 +9,9 @@ from __future__ import annotations
|
|
|
9
9
|
import asyncio
|
|
10
10
|
import importlib.resources
|
|
11
11
|
import logging
|
|
12
|
+
import os
|
|
12
13
|
import sqlite3
|
|
14
|
+
import subprocess
|
|
13
15
|
import sys
|
|
14
16
|
import traceback
|
|
15
17
|
from collections.abc import AsyncIterator
|
|
@@ -61,6 +63,55 @@ def _assert_fts5(conn: sqlite3.Connection) -> None:
|
|
|
61
63
|
assert_fts5_available(conn)
|
|
62
64
|
|
|
63
65
|
|
|
66
|
+
def _auto_build_symbol_index(index_path) -> bool:
|
|
67
|
+
"""Build a small symbol-only index when the server starts without one.
|
|
68
|
+
|
|
69
|
+
This keeps hosted scanners/directories such as Glama from failing MCP
|
|
70
|
+
introspection on a fresh container while preserving the documented full
|
|
71
|
+
corpus command for normal users. Set PYTHON_DOCS_MCP_DISABLE_AUTO_INDEX=1
|
|
72
|
+
to require an explicitly prebuilt index.
|
|
73
|
+
"""
|
|
74
|
+
if os.environ.get("PYTHON_DOCS_MCP_DISABLE_AUTO_INDEX") == "1":
|
|
75
|
+
return False
|
|
76
|
+
|
|
77
|
+
versions = os.environ.get("PYTHON_DOCS_MCP_AUTO_INDEX_VERSIONS", "3.13")
|
|
78
|
+
logger.warning(
|
|
79
|
+
"No index found at %s; auto-building symbol-only Python docs index for %s",
|
|
80
|
+
index_path,
|
|
81
|
+
versions,
|
|
82
|
+
)
|
|
83
|
+
try:
|
|
84
|
+
result = subprocess.run(
|
|
85
|
+
[
|
|
86
|
+
sys.executable,
|
|
87
|
+
"-m",
|
|
88
|
+
"mcp_server_python_docs",
|
|
89
|
+
"build-index",
|
|
90
|
+
"--versions",
|
|
91
|
+
versions,
|
|
92
|
+
"--skip-content",
|
|
93
|
+
],
|
|
94
|
+
check=False,
|
|
95
|
+
capture_output=True,
|
|
96
|
+
text=True,
|
|
97
|
+
timeout=180,
|
|
98
|
+
)
|
|
99
|
+
except (OSError, subprocess.TimeoutExpired) as e:
|
|
100
|
+
logger.error("Auto index build failed to start or timed out: %s", e)
|
|
101
|
+
return False
|
|
102
|
+
|
|
103
|
+
if result.returncode != 0:
|
|
104
|
+
logger.error(
|
|
105
|
+
"Auto index build failed with exit code %s:\n%s",
|
|
106
|
+
result.returncode,
|
|
107
|
+
(result.stderr or result.stdout)[-4000:],
|
|
108
|
+
)
|
|
109
|
+
return False
|
|
110
|
+
|
|
111
|
+
logger.info("Auto index build complete at %s", index_path)
|
|
112
|
+
return index_path.exists()
|
|
113
|
+
|
|
114
|
+
|
|
64
115
|
@asynccontextmanager
|
|
65
116
|
async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
|
|
66
117
|
"""Manage application lifecycle with typed context (SRVR-01).
|
|
@@ -72,8 +123,9 @@ async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
|
|
|
72
123
|
cache_dir = get_cache_dir()
|
|
73
124
|
index_path = get_index_path()
|
|
74
125
|
|
|
75
|
-
# Fail fast on missing index
|
|
76
|
-
|
|
126
|
+
# Fail fast on missing index unless a small symbol-only auto-index succeeds
|
|
127
|
+
# (SRVR-10 plus hosted-directory scanner compatibility).
|
|
128
|
+
if not index_path.exists() and not _auto_build_symbol_index(index_path):
|
|
77
129
|
from mcp_server_python_docs.ingestion.cpython_versions import (
|
|
78
130
|
SUPPORTED_DOC_VERSIONS_CSV,
|
|
79
131
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-docs-mcp-server
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: A read-only, version-aware MCP retrieval server over Python standard library documentation
|
|
5
5
|
Author-email: Aymen Hammouda <hammouda.aymen@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -6,7 +6,7 @@ mcp_server_python_docs/diagnostics.py,sha256=FyC6QDFLvozARpYuMnaKfJwaN6BCzVycME_
|
|
|
6
6
|
mcp_server_python_docs/errors.py,sha256=XTOm1raJfxS2adaOPZdwj0SuhpMAXAdjBsF2-zTv_1E,827
|
|
7
7
|
mcp_server_python_docs/models.py,sha256=jtC1TEAOZHBDEfFf8uqsSzC5FKmY06zRrHWzw3HSmsg,6966
|
|
8
8
|
mcp_server_python_docs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
mcp_server_python_docs/server.py,sha256
|
|
9
|
+
mcp_server_python_docs/server.py,sha256=z1FwWz6ivJVbvN4CYugCKABYTY2Bg_QCuBqZRjdxAVk,13835
|
|
10
10
|
mcp_server_python_docs/data/synonyms.yaml,sha256=LgJxamZ9QT6Pykva7M1uM8juSd9ybHuv3vUOKrUFMg4,10696
|
|
11
11
|
mcp_server_python_docs/ingestion/__init__.py,sha256=Yd7Jk7hD7XG3eoBVQpYiG94EwJGfI3qXxVCpA8JszYg,66
|
|
12
12
|
mcp_server_python_docs/ingestion/cpython_versions.py,sha256=mEhjuT7q8Bo1aZ-zj6PSqmbq2Bz64g4xj50ttqA4QUU,977
|
|
@@ -29,8 +29,8 @@ mcp_server_python_docs/services/version_resolution.py,sha256=rULBoqq97t0ZfSWSy-e
|
|
|
29
29
|
mcp_server_python_docs/storage/__init__.py,sha256=YNeNr7FW9Vgvo79oXgKXE3eGP0WwWDqRgTZ7lg7MFW4,62
|
|
30
30
|
mcp_server_python_docs/storage/db.py,sha256=Lys8HN3IvgmNpr_qyocUQghcZnwHf2lz9eq_BFmwi54,5634
|
|
31
31
|
mcp_server_python_docs/storage/schema.sql,sha256=4cXPktPQSLfbjkSjirpf0dA2CphlO9UCIKUxnLiIm_g,5637
|
|
32
|
-
python_docs_mcp_server-0.1.
|
|
33
|
-
python_docs_mcp_server-0.1.
|
|
34
|
-
python_docs_mcp_server-0.1.
|
|
35
|
-
python_docs_mcp_server-0.1.
|
|
36
|
-
python_docs_mcp_server-0.1.
|
|
32
|
+
python_docs_mcp_server-0.1.3.dist-info/METADATA,sha256=9p96MUOdzeXdbZ8xAbRGVHL_sVKpXpVzZgmTJT-9gfU,16977
|
|
33
|
+
python_docs_mcp_server-0.1.3.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
34
|
+
python_docs_mcp_server-0.1.3.dist-info/entry_points.txt,sha256=-1arbtjZhF5mtnJNAh_90UBr1f4AqJxT3Tmfy9p7NMI,142
|
|
35
|
+
python_docs_mcp_server-0.1.3.dist-info/licenses/LICENSE,sha256=-AHGWRwcvoeP4bkY1W2ok_qaI1Mg0Zx2qYgR1k-3CHY,1071
|
|
36
|
+
python_docs_mcp_server-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
{python_docs_mcp_server-0.1.2.dist-info → python_docs_mcp_server-0.1.3.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{python_docs_mcp_server-0.1.2.dist-info → python_docs_mcp_server-0.1.3.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|