docs

@Tool

@Tool registers a Python function as an agent-callable tool, extracting the name, description, and parameter schema automatically from the function name, docstring, and type annotations.

Basic usage

Use @Tool bare — the function name becomes the tool name, the docstring becomes the description:

Python
from ninetrix import Tool

@Tool
def search_products(query: str, limit: int = 20) -> list[dict]:
    """Search the product catalog by keyword.

    Args:
        query: Full-text search query.
        limit: Maximum products to return.
    """
    ...

Overriding name or description

Pass name= or description= when you want to decouple the tool name from the function name, or write a richer description than the docstring:

Python
@Tool(name="send_internal_notification", description="Send a message to Slack or PagerDuty.")
def notify(channel: str, message: str) -> bool:
    ...

Docstring parameter descriptions

The SDK parses Google-style Args: sections and injects per-parameter descriptions into the JSON Schema. This is what the LLM sees when deciding how to call your tool — write it clearly.

Python
@Tool
def send_email(to: str, subject: str, body: str, cc: list[str] | None = None) -> bool:
    """Send a transactional email.

    Args:
        to: Recipient email address.
        subject: Email subject line (under 80 chars).
        body: Plain-text email body.
        cc: Optional list of CC addresses.
    """
    ...

The function stays a normal callable

@Tool returns the original function unchanged — it just registers metadata on the side. You can call your tools in tests exactly as you would any Python function:

Python
# Works fine — no mocking, no wrapping
result = search_products("laptop", limit=5)
assert isinstance(result, list)

Inspecting the generated schema

After importing your tool file, you can inspect what schema was generated:

Python
from ninetrix import _registry
import tools.db_tools  # triggers registration

td = _registry.get("query_customers")
print(td.to_anthropic_schema())
# {
#   "name": "query_customers",
#   "description": "Execute a read-only SQL query...",
#   "input_schema": { "type": "object", "properties": {...}, "required": ["sql"] }
# }

print(td.to_openai_schema())
# { "type": "function", "function": { "name": ..., "parameters": {...} } }
On this page