Skip to content

Commit a43b791

Browse files
committed
fix(docs[ext]): Restrict tool label registration to tool sections only
why: _register_tool_labels iterated every section in every document, registering non-tool headings (e.g. "Inspect", "Act") in the StandardDomain. This risked label collisions with other extensions. what: - Replace fallback to title_node.astext() with continue - Only register sections whose title starts with a nodes.literal child (the pattern used by fastmcp-tool directive output)
1 parent 6074aba commit a43b791

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

docs/_ext/fastmcp_autodoc.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,16 +814,18 @@ def _register_tool_labels(app: Sphinx, doctree: nodes.document) -> None:
814814
continue
815815
section_id = section["ids"][0]
816816
if section.children and isinstance(section[0], nodes.title):
817-
# Extract just the tool name from the first literal child,
818-
# ignoring the safety badge that follows it.
817+
# Only register sections whose title starts with a literal
818+
# (tool sections generated by fastmcp-tool have nodes.literal
819+
# as the first title child). Non-tool sections (e.g. "Inspect",
820+
# "Act") don't need site-wide labels.
819821
title_node = section[0]
820822
tool_name = ""
821823
for child in title_node.children:
822824
if isinstance(child, nodes.literal):
823825
tool_name = child.astext()
824826
break
825827
if not tool_name:
826-
tool_name = title_node.astext()
828+
continue
827829
domain.anonlabels[section_id] = (docname, section_id)
828830
domain.labels[section_id] = (docname, section_id, tool_name)
829831

0 commit comments

Comments
 (0)