Skip to main content
Mirobody follows a “Tools First” philosophy. You write standard Python code, and the system automatically converts it into MCP (Model Context Protocol) tools for AI agents.

🔍 Tool Discovery

Tool directories are configured by MCP_TOOL_DIRS in config.{env}.yaml. The defaults:
  1. Built-in tools: mirobody/agent/tools/ (this directory) — the whole shipped tool surface: terminology (② Translate), health records, genetics.
Place your own tools in your own directory and add it to MCP_TOOL_DIRS — the list is ordinary config, so a deployment can extend it without touching the package:
Or ship them as a package. A distribution that declares a 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

  1. File Location: Must be a .py file inside a configured tool directory.
  2. Ignored Files: Files starting with _ (e.g., _utils.py) are ignored.
  3. 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.

  1. 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)

  1. Docstrings (Required)

Docstrings are parsed to provide descriptions to the AI. We recommend the standard format:

  1. 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 as my_tools/calculator.py:

Advanced Service Class

Save this as my_tools/stocks.py:

🧩 Reference

For the core implementation details of how tools are parsed, refer to: mirobody/mcp/tool.py