Skip to content

Commit f3cec5f

Browse files
committed
fix(docs[ext]): Log warnings when tool module collection fails
why: _collect_tools silently swallowed all exceptions with bare except/pass, hiding import errors and causing missing tools in docs without any warning. Contradicts the project's fail-closed philosophy. what: - Add logging import and module-level logger - Replace except/pass with logger.warning including exc_info
1 parent 82d177b commit f3cec5f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

docs/_ext/fastmcp_autodoc.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import importlib
2727
import inspect
28+
import logging
2829
import re
2930
import typing as t
3031
from dataclasses import dataclass
@@ -38,6 +39,8 @@
3839
from sphinx.domains.std import StandardDomain
3940
from sphinx.util.typing import ExtensionMetadata
4041

42+
logger = logging.getLogger(__name__)
43+
4144
# ---------------------------------------------------------------------------
4245
# Constants
4346
# ---------------------------------------------------------------------------
@@ -529,7 +532,11 @@ def _collect_tools(app: Sphinx) -> None:
529532
if hasattr(mod, "register"):
530533
mod.register(collector)
531534
except Exception:
532-
pass # Module not importable during docs build
535+
logger.warning(
536+
"fastmcp_autodoc: failed to load tool module %s",
537+
mod_name,
538+
exc_info=True,
539+
)
533540

534541
app.env.fastmcp_tools = {tool.name: tool for tool in collector.tools} # type: ignore[attr-defined]
535542

0 commit comments

Comments
 (0)