manage_webhooks
Control Tailscale webhooks to manage event notifications. Perform operations like listing, creating, deleting, or testing webhooks to configure automated alerts and monitoring.
Instructions
Manage Tailscale webhooks for event notifications
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| config | No | Webhook configuration for create operation | |
| operation | Yes | Webhook operation to perform | |
| webhookId | No | Webhook ID for delete/test operations |
Implementation Reference
- src/tools/admin-tools.ts:338-436 (handler)The handler function implementing the logic for managing Tailscale webhooks. Supports operations: list, create, delete, test using the Tailscale API.async function manageWebhooks( args: z.infer<typeof WebhookSchema>, context: ToolContext, ): Promise<CallToolResult> { try { logger.debug("Managing webhooks:", args); switch (args.operation) { case "list": { const result = await context.api.listWebhooks(); if (!result.success) { return returnToolError(result.error); } const webhooks = result.data?.webhooks || []; if (webhooks.length === 0) { return returnToolSuccess("No webhooks configured"); } const webhookList = webhooks .map((webhook, index: number) => { return `**Webhook ${index + 1}** - ID: ${webhook.id} - URL: ${webhook.endpointUrl} - Events: ${webhook.events?.join(", ") || "None"} - Description: ${webhook.description || "No description"} - Created: ${webhook.createdAt}`; }) .join("\n\n"); return returnToolSuccess( `Found ${webhooks.length} webhooks:\n\n${webhookList}`, ); } case "create": { if (!args.config) { return returnToolError( "Webhook configuration is required for create operation", ); } const result = await context.api.createWebhook(args.config); if (!result.success) { return returnToolError(result.error); } return returnToolSuccess( `Webhook created successfully: - ID: ${result.data?.id} - URL: ${result.data?.endpointUrl} - Events: ${result.data?.events?.join(", ")}`, ); } case "delete": { if (!args.webhookId) { return returnToolError("Webhook ID is required for delete operation"); } const result = await context.api.deleteWebhook(args.webhookId); if (!result.success) { return returnToolError(result.error); } return returnToolSuccess( `Webhook ${args.webhookId} deleted successfully`, ); } case "test": { if (!args.webhookId) { return returnToolError("Webhook ID is required for test operation"); } const result = await context.api.testWebhook(args.webhookId); if (!result.success) { return returnToolError(result.error); } return returnToolSuccess( `Webhook test successful. Response: ${JSON.stringify( result.data, null, 2, )}`, ); } default: return returnToolError( "Invalid webhook operation. Use: list, create, delete, or test", ); } } catch (error) { logger.error("Error managing webhooks:", error); return returnToolError(error); } }
- src/tools/admin-tools.ts:42-59 (schema)Zod input schema for the manage_webhooks tool defining parameters for different operations.const WebhookSchema = z.object({ operation: z .enum(["list", "create", "delete", "test"]) .describe("Webhook operation to perform"), webhookId: z .string() .optional() .describe("Webhook ID for delete/test operations"), config: z .object({ endpointUrl: z.string(), description: z.string().optional(), events: z.array(z.string()), secret: z.string().optional(), }) .optional() .describe("Webhook configuration for create operation"), });
- src/tools/admin-tools.ts:570-575 (registration)Tool registration in the adminTools module, specifying name, description, input schema, and handler function.{ name: "manage_webhooks", description: "Manage Tailscale webhooks for event notifications", inputSchema: WebhookSchema, handler: manageWebhooks, },