From c1d31620511e75f2ed5e9fdda3ee9a51145578b1 Mon Sep 17 00:00:00 2001 From: aserrador Date: Sat, 7 Mar 2026 23:07:02 -0500 Subject: [PATCH] docs: add AGENTS.md specification for developers --- AGENTS.md | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..6eb71bd --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,86 @@ +# 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: + +```python +@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 + +```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 + +Edit `TRYTON_CREDENTIALS` in `server.py:12-17` to change connection settings: + +```python +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: + +```bash +python test_rpc.py +```