listar_tudo
Lists all customers and products currently stored in the system.
Instructions
Lista todos os clientes e produtos cadastrados.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- server.py:116-122 (handler)The tool handler function for 'listar_tudo'. It queries all clientes and produtos from the database and returns a formatted string listing them.
def listar_tudo() -> str: """Lista todos os clientes e produtos cadastrados.""" c = database.buscar_registros("clientes") p = database.buscar_registros("produtos") res = "--- CLIENTES ---\n" + "\n".join([f"{x[0]}: {x[1]} (CPF: {x[2]})" for x in c]) res += "\n\n--- PRODUTOS ---\n" + "\n".join([f"{y[0]}: {y[1]} - R${y[2]}" for y in p]) return res - server.py:115-115 (registration)The @mcp.tool() decorator that registers 'listar_tudo' as an MCP tool.
@mcp.tool() - database.py:47-56 (helper)The database helper function 'buscar_registros' used by listar_tudo to fetch all records from a table.
def buscar_registros(tabela, campo_filtro=None, valor_filtro=None): conn = sqlite3.connect(DB_NAME) cursor = conn.cursor() if campo_filtro: cursor.execute(f"SELECT * FROM {tabela} WHERE {campo_filtro} LIKE ?", (f"%{valor_filtro}%",)) else: cursor.execute(f"SELECT * FROM {tabela}") rows = cursor.fetchall() conn.close() return rows