validate_webhook
Verify webhook connectivity by sending a test message to Discord, Slack, or both services, ensuring proper setup and functionality for notifications.
Instructions
Test webhook connectivity by sending a test message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | No | ||
| service | No |
Implementation Reference
- src/index.ts:59-120 (handler)Handler function that executes the validate_webhook tool: detects services, sends test messages via Discord/Slack webhooks, collects results, and returns formatted response.async (args) => { const testMessage = args.message || "notify_me_mcp connectivity test"; try { const targetServices = detectService(args.service); const config = getConfig(); const results: ServiceResult[] = []; for (const service of targetServices) { try { let result; if (service === "discord") { const payload = buildDiscordPayload({ message: testMessage }); result = await sendDiscord(config.discordWebhookUrl!, payload); } else { const payload = buildSlackPayload({ message: testMessage }); result = await sendSlack(config.slackWebhookUrl!, payload); } results.push({ service, success: result.success, httpCode: result.httpCode, timestamp: result.timestamp }); } catch (error) { results.push({ service, success: false, error: error instanceof Error ? error.message : "Unknown error" }); } } const overall = results.some(r => r.success); const response: SendResult = { success: overall, overall, results }; return { content: [ { type: "text", text: JSON.stringify(response, null, 2) } ] }; } catch (error) { const errorMsg = error instanceof Error ? error.message : "Unknown error"; return { content: [ { type: "text", text: JSON.stringify({ error: errorMsg }, null, 2) } ] }; } }
- src/index.ts:52-121 (registration)Registration of the validate_webhook tool using McpServer.tool method, including description, input schema, and handler reference.server.tool( "validate_webhook", "Test webhook connectivity by sending a test message", { service: z.enum(["discord", "slack", "both"]).optional(), message: z.string().optional(), }, async (args) => { const testMessage = args.message || "notify_me_mcp connectivity test"; try { const targetServices = detectService(args.service); const config = getConfig(); const results: ServiceResult[] = []; for (const service of targetServices) { try { let result; if (service === "discord") { const payload = buildDiscordPayload({ message: testMessage }); result = await sendDiscord(config.discordWebhookUrl!, payload); } else { const payload = buildSlackPayload({ message: testMessage }); result = await sendSlack(config.slackWebhookUrl!, payload); } results.push({ service, success: result.success, httpCode: result.httpCode, timestamp: result.timestamp }); } catch (error) { results.push({ service, success: false, error: error instanceof Error ? error.message : "Unknown error" }); } } const overall = results.some(r => r.success); const response: SendResult = { success: overall, overall, results }; return { content: [ { type: "text", text: JSON.stringify(response, null, 2) } ] }; } catch (error) { const errorMsg = error instanceof Error ? error.message : "Unknown error"; return { content: [ { type: "text", text: JSON.stringify({ error: errorMsg }, null, 2) } ] }; } } );
- src/types.ts:58-61 (schema)Zod schema definition for validate_webhook tool inputs, matching the inline schema used in registration.export const ValidateWebhookSchema = z.object({ service: ServiceSchema.optional(), message: z.string().optional(), });
- src/index.ts:56-58 (schema)Inline input schema for validate_webhook tool provided during registration.service: z.enum(["discord", "slack", "both"]).optional(), message: z.string().optional(), },