Files
NaliiaBotMCP/AGENTS.md

2.1 KiB

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
│   └── server.py          # Main MCP server with tool definitions
├── test_rpc.py            # Standalone RPC test script
└── pyproject.toml         # Project dependencies

Architecture

Dependencies

  • fastmcp[tasks]>=3.1.0 - MCP server framework
  • sabatron-tryton-rpc-client>=7.4.0 - Tryton RPC client

Core Components

  1. Client Connection (server.py:45-47, 59-61, 73-75)

    • Creates a new Client instance for each tool call
    • Credentials are hardcoded in TRYTON_CREDENTIALS dict
  2. Tools - Functions decorated with @mcp.tool():

    • create_schedule (line 32-54) - Creates appointments in Naliia module
    • find_service_centers (line 57-69) - Searches service centers
    • find_products_and_services (line 71-83) - Searches salable products
  3. Context (server.py:20-24) - Dataclass for managing client state (currently unused)

Adding New Tools

To add a new Tryton model as an MCP tool:

@mcp.tool()
def your_tool_name(param1: int, param2: str) -> List[dict]:
    client = Client(**TRYTON_CREDENTIALS)
    client.connect()
    
    name = "model.your.model.method"
    args = [params, ...]
    response = client.call(name, args)
    
    return response

Running the Server

# 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

Edit TRYTON_CREDENTIALS in server.py:12-17 to change connection settings:

TRYTON_CREDENTIALS = {
    "hostname": 'dev.naliia.co',
    "database": 'capacitacion',
    "username": 'admin',
    "password": 'admin' 
}

Testing RPC Calls

Use test_rpc.py to test Tryton RPC calls independently:

python test_rpc.py