🔍 Tool Discovery
Tool directories are configured byMCP_TOOL_DIRS in config.{env}.yaml. The defaults:
- Built-in tools:
mirobody/agent/tools/(this directory) — the whole shipped tool surface: terminology (② Translate), health records, genetics.
MCP_TOOL_DIRS — the list is ordinary config, so a deployment can extend it without touching the package:
mirobody.tools
entry point pointing at a module of tool classes is loaded at boot the moment
it is pip installed — same registry, same schema generation, served over
/mcp and handed to the agent like the built-ins:
examples/mirobody_example_plugin/ is a complete example.
Discovery Rules
- File Location: Must be a
.pyfile inside a configured tool directory. - Ignored Files: Files starting with
_(e.g.,_utils.py) are ignored. - Eligible Code:
- Functions: Top-level functions are automatically registered.
- Classes: Must end with
Service(e.g.,FinanceService) to be registered.
Conditional Registration (_enabled)
A Service may define a static _enabled() -> bool; returning False skips the whole class (none of its methods register). Use it to gate optional integrations on config (e.g. an API key).
📝 Implementation Guide
Your Python code is the definition. No separate configuration or JSON schema is needed.
- Type Hints (Required)
Mirobody uses Python type hints (str, int, bool, float) to generate the tool’s input schema.
- Fundamental Types:
str,int,float,bool - Complex Types:
list[str],dict(parsed as generic object)
- Docstrings (Required)
Docstrings are parsed to provide descriptions to the AI. We recommend the standard format:
- Authentication & Context
If your tool needs user information (like a User ID from a JWT), add a user_info parameter.
- Injection: Mirobody automatically injects this value; the AI agent does not see or provide it.
- Structure:
{"user_id": "...", "success": True}.
💡 Examples
Basic Function Tool
Save this asmy_tools/calculator.py:
Advanced Service Class
Save this asmy_tools/stocks.py:
🧩 Reference
For the core implementation details of how tools are parsed, refer to:mirobody/mcp/tool.py