@callzero/mcp
Version:
MCP server for CallZero AI phone call automation
47 lines (46 loc) • 1.41 kB
JavaScript
import { CancelCallInputSchema } from "../schemas.js";
export function createCancelCallTool(client) {
return {
name: "cancel_call",
description: "Cancel a scheduled call before it starts. Only works for calls that haven't started yet.",
inputSchema: {
type: "object",
properties: {
callId: {
type: "string",
description: "ID of the scheduled call to cancel",
},
},
required: ["callId"],
},
};
}
export async function handleCancelCall(client, args) {
try {
// Validate input
const validatedInput = CancelCallInputSchema.parse(args);
// Call HTTP API
const result = await client.cancelCall(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 cancel call: ${errorMessage}`,
}, null, 2),
},
],
};
}
}