Discovery
discovery
PlainTool
Bases: Protocol
Structural protocol for plain dispatcher tools (callable, no execute).
Source code in packages/axm-mcp/src/axm_mcp/discovery.py
ToolLike
Bases: Protocol
Minimal protocol for AXMTool-compatible objects.
Source code in packages/axm-mcp/src/axm_mcp/discovery.py
| Python | |
|---|---|
name
property
Tool name used for MCP registration.
ToolResultLike
Bases: Protocol
Structural protocol matching axm.tools.base.ToolResult.
Declared locally to keep axm_mcp.discovery free of axm.*
imports — axm-mcp is a pure discovery shell (enforced by
test_mcp_decoupled.py).
Source code in packages/axm-mcp/src/axm_mcp/discovery.py
discover_tools()
Discover and instantiate all AXMTool entry points.
Supports both AXMTool subclasses (instantiated) and plain
dispatcher functions (used as-is).
Tools can be excluded via the AXM_DISABLE_TOOLS environment
variable — a comma-separated list of tool names or glob patterns
(e.g. bib_*,ticket_*,ast_dead_code).
Returns:
| Type | Description |
|---|---|
dict[str, ToolEntry]
|
Dict mapping tool name → tool instance or callable. |
Source code in packages/axm-mcp/src/axm_mcp/discovery.py
is_disabled(name, patterns)
Check if a tool name matches any disable pattern.
Supports exact names (ast_dead_code) and glob patterns
(bib_*, ticket_*).
Source code in packages/axm-mcp/src/axm_mcp/discovery.py
register_list_tools(mcp, tools, extra_tools)
Register the list_tools meta-tool.
Source code in packages/axm-mcp/src/axm_mcp/discovery.py
register_one(mcp, name, tool, *, override_module=None)
Register a single tool, capturing in closure.
Supports both AXMTool instances (with .execute()) and plain
dispatcher functions. Sets the typed signature on the wrapper
before handing it to mcp.tool(), so FastMCP generates the
correct JSON-Schema for the tool's parameters.
For dispatcher functions (action + **kwargs), introspects
sub-functions to build a union of all their typed parameters.
When an AXMTool returns a successful ToolResult whose
text attribute is a string, the wrapper short-circuits and returns
the raw string instead of the flattened dict. FastMCP converts this to
a TextContent response, letting the LLM see pre-rendered markdown
rather than JSON. A failing ToolResult (success=False) never
short-circuits: it is flattened so the structural failure signal
(success=False + error) reaches the caller. Any exception
raised by execute() (or by a plain dispatcher) is caught and
returned as the flattened AXM error shape — it never propagates to
FastMCP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mcp
|
FastMCP
|
FastMCP server instance. |
required |
name
|
str
|
Tool name for MCP registration. |
required |
tool
|
ToolEntry
|
Tool instance or plain function. |
required |
override_module
|
ModuleType | None
|
For testing — module to search for |
None
|
Source code in packages/axm-mcp/src/axm_mcp/discovery.py
register_tools(mcp, tools)
Register discovered tools as MCP tool callables.
Each tool becomes a callable tool_name(**kwargs) -> dict
that delegates to tool.execute(**kwargs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mcp
|
FastMCP
|
FastMCP server instance. |
required |
tools
|
dict[str, ToolEntry]
|
Dict from discover_tools(). |
required |