UNPKG

@callzero/mcp

Version:

MCP server for CallZero AI phone call automation

63 lines (62 loc) 2.12 kB
import { SearchMemoriesInputSchema } from "../schemas.js"; export function createSearchMemoriesTool(client) { return { name: "search_memories", description: "Search stored memories by query, category, or related phone number to retrieve context for calls.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query to find relevant memories", }, category: { type: "string", enum: ["contact", "task", "preference", "general"], description: "Filter by memory category", }, relatedPhone: { type: "string", pattern: "^\\+1[2-9]\\d{9}$", description: "Filter by related phone number (E.164 format)", }, limit: { type: "number", minimum: 1, maximum: 50, description: "Maximum number of results to return (default: 10)", }, }, required: ["query"], }, }; } export async function handleSearchMemories(client, args) { try { // Validate input const validatedInput = SearchMemoriesInputSchema.parse(args); // Call HTTP API const result = await client.searchMemories(validatedInput); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ { type: "text", text: JSON.stringify({ error: `Failed to search memories: ${errorMessage}`, }, null, 2), }, ], }; } }