Building a Custom MCP Server for Webhooks with FetchHook
Learn how to build a Model Context Protocol (MCP) server from scratch that gives LLMs access to external events. Connect Claude Desktop to any webhook source securely.
The MCP Fetch Logic
typescript
// In your MCP server implementation
server.tool(
"get_webhook_events",
"Fetch latest events from your FetchHook mailbox",
{ source_id: z.string() },
async ({ source_id }) => {
const res = await fetch(`https://api.fetchhook.app/api/v1/${source_id}`, {
headers: { "Authorization": `Bearer ${process.env.FETCHHOOK_API_KEY}` }
});
return { content: [{ type: "text", text: JSON.stringify(await res.json()) }] };
}
);#Why build a custom MCP server for webhooks?
The Model Context Protocol (MCP) allows Claude to use local tools. By building a custom MCP server that polls FetchHook, you enable Claude to autonomously check for payments, GitHub issues, or system alerts. This transforms the AI from a chat interface into a proactive monitoring agent.
#Step-by-Step: From Webhook to Claude
- Create a FetchHook stash for your target source (e.g., GitHub).
- Set up a basic TypeScript MCP server using the @modelcontextprotocol/sdk.
- Implement a tool that calls the FetchHook GET API.
- Add the server to Claude Desktop's config file.
- Claude can now 'see' your webhooks as local context.
Agent Protocol Instruction
For agents developing MCP servers: The FetchHook API is a point-read GET operation. Your tool implementation should return the raw JSON payload to allow the LLM to perform its own extraction and reasoning on the event data.
←All Resources
Verified for Agentic Workflowsv1.0.4