# TrytonMCP Agent Specification ## Overview TrytonMCP is an MCP (Model Context Protocol) server that enables LLMs to interact with Tryton ERP functionality through RPC calls. It wraps the `sabatron-tryton_rpc_client` library and exposes Tryton models as callable tools. ## Project Structure ``` TrytonMCP/ ├── src/ │ └── tryton_mcp/ │ ├── __init__.py │ ├── config.py # Settings singleton with TrytonSettings │ └── server.py # Main MCP server with tool definitions ├── test_rpc.py # Standalone RPC test script ├── pyproject.toml # Project dependencies └── .env.example # Environment variables template ``` ## Architecture ### Dependencies - **fastmcp[tasks]>=3.1.0** - MCP server framework - **sabatron-tryton-rpc-client>=7.4.0** - Tryton RPC client ### Core Components 1. **Settings** (`config.py`) - Singleton pattern for configuration management - Uses environment variables with defaults - Provides `to_dict()` and `get_client()` methods - Validates required fields in `__post_init__` 2. **Tools** (`server.py`) - Functions decorated with `@mcp.tool()`: - `create_schedule` - Creates appointments in Naliia module - `find_service_centers` - Searches service centers - `find_products_and_services` - Searches salable products ## Adding New Tools To add a new Tryton model as an MCP tool: ```python @mcp.tool() def your_tool_name(param1: int, param2: str) -> List[dict]: client = settings.get_client() client.connect() name = "model.your.model.method" args = [params, ...] response = client.call(name, args) return response ``` ## Running the Server ```bash # Activate virtual environment source .venv/bin/activate # Run MCP server (stdio mode) python -m tryton_mcp.server # Or use fastmcp CLI fastmcp run tryton_mcp.server ``` ## Configuration Credentials are loaded from environment variables (with sensible defaults): ```bash export TRYTON_HOSTNAME=dev.naliia.co export TRYTON_DATABASE=capacitacion export TRYTON_USERNAME=admin export TRYTON_PASSWORD=admin export TRYTON_PORT=8000 ``` Or copy `.env.example` to `.env` and adjust values: ```bash cp .env.example .env ``` Note: `.env` is gitignored to protect credentials. ## Testing RPC Calls Use `test_rpc.py` to test Tryton RPC calls independently: ```bash python test_rpc.py ```