editar_cliente
Update client details such as name, CPF, and additional info by providing the client ID. Modify existing client records in the database.
Instructions
Edita os dados básicos de um cliente já existente pelo ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id_cliente | Yes | ||
| nome | No | ||
| cpf | No | ||
| info | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- server.py:20-24 (handler)The tool handler for 'editar_cliente'. It accepts id_cliente (int), and optional nome, cpf, info parameters. Filters out None values and delegates to database.atualizar_registro.
@mcp.tool() def editar_cliente(id_cliente: int, nome: str = None, cpf: str = None, info: str = None) -> str: """Edita os dados básicos de um cliente já existente pelo ID.""" dados = {k: v for k, v in {"nome": nome, "cpf": cpf, "info": info}.items() if v is not None} return database.atualizar_registro("clientes", id_cliente, **dados) - server.py:20-20 (registration)The @mcp.tool() decorator registers 'editar_cliente' as an MCP tool on the FastMCP server instance.
@mcp.tool() - database.py:28-37 (helper)The helper function 'atualizar_registro' that performs the actual SQL UPDATE operation on the database. Called by the editar_cliente handler.
def atualizar_registro(tabela, registro_id, **kwargs): conn = sqlite3.connect(DB_NAME) cursor = conn.cursor() set_clause = ', '.join([f"{k} = ?" for k in kwargs.keys()]) sql = f"UPDATE {tabela} SET {set_clause} WHERE id = ?" cursor.execute(sql, list(kwargs.values()) + [registro_id]) conn.commit() conn.close() return f" {tabela.capitalize()} ID {registro_id} atualizado!"