refactor: add Settings singleton pattern for config management
This commit is contained in:
71
src/tryton_mcp/server.py
Normal file
71
src/tryton_mcp/server.py
Normal file
@@ -0,0 +1,71 @@
|
||||
"""
|
||||
MCP Server for Naliia Module
|
||||
"""
|
||||
|
||||
from sabatron_tryton_rpc_client.client import Client
|
||||
from fastmcp import FastMCP
|
||||
from typing import List
|
||||
import datetime
|
||||
|
||||
from tryton_mcp.config import settings
|
||||
|
||||
|
||||
mcp = FastMCP("Tryton MCP Server")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def create_schedule(
|
||||
professional: int, description: str, customer: int, date: str, service_center: int
|
||||
) -> List[int]:
|
||||
|
||||
example_schedule = [
|
||||
{
|
||||
"professional": 6,
|
||||
"description": description,
|
||||
"customer": 4,
|
||||
"date": datetime.datetime.fromisoformat(date),
|
||||
"service_center": 11,
|
||||
}
|
||||
]
|
||||
|
||||
client = Client(**settings.to_dict())
|
||||
|
||||
client.connect()
|
||||
name = "model.naliia.schedule.create"
|
||||
args = [example_schedule, {}]
|
||||
response = client.call(name, args)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def find_service_centers():
|
||||
client = Client(**settings.to_dict())
|
||||
|
||||
client.connect()
|
||||
|
||||
name = "model.naliia.service_center.search_read"
|
||||
args = [[[]], 0, None, None, ["name", "address.street"], {}]
|
||||
response = client.call(name, args)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def find_products_and_services():
|
||||
client = Client(**settings.to_dict())
|
||||
|
||||
client.connect()
|
||||
|
||||
name = "model.product.product.search_read"
|
||||
args = [
|
||||
[["active", "=", True], ["salable", "=", True]],
|
||||
0,
|
||||
None,
|
||||
None,
|
||||
["name", "list_price", "description"],
|
||||
{"company": 1},
|
||||
]
|
||||
response = client.call(name, args)
|
||||
|
||||
return response
|
||||
Reference in New Issue
Block a user