I Built MCP Servers for 9 SaaS APIs — Here's What I Learned About the Pattern
I Built MCP Servers for 9 SaaS APIs — Here's What I Learned About the Pattern I've spent the last few weeks building MCP (Model Context Protocol) servers for various APIs — CoinGecko, Stripe, Jira, PostHog, Plausible, Etherscan, DeFiLlama, Jobber, and Resend. Nine servers, 68 tools, all published to npm and indexed on Glama. Along the way, I noticed the same architecture keeps working. If you're building an MCP server for your own API — or thinking about hiring someone to do it — here's the pattern. The Three-Layer Architecture Every MCP server I build has three layers: 1. Tool Definitions (the contract) Each API endpoint becomes an MCP tool with a typed input schema. I use Zod for validation — it catches bad inputs before they hit your API. { name : " send_email " , description : " Send a single email via Resend " , inputSchema : { from : z . string (). email (), to : z . union ([ z . string (). email (), z . array ( z . string (). email ())]), subject : z . string (). min ( 1 ), html : z . string (). optional (), text : z . string (). optional (), }, } The description matters more than you think. LLMs read these descriptions to decide which tool to call. A vague description like "send email" wastes tokens. A specific one like "Send a single transactional email via Resend API. Supports HTML and plain text. Returns message ID and delivery status." gets used correctly. 2. API Client (the plumbing) This layer handles auth, rate limiting, and error transformation. The key insight: don't leak HTTP errors to the LLM. Transform them into structured, actionable messages. // Bad: "Error: 429" // Good: "Rate limited by Resend API. Retry after 30 seconds. You've sent 100 emails in the last hour." 3. Output Formatter (the presentation) Raw JSON dumps are terrible for LLM consumption. Format responses as markdown tables, bullet points, or structured text. The LLM reads this output to decide what to do next — make it scannable. ## Email Sent Successfully - **Message ID:** abc123