Skip to content

Model Context Protocol (MCP) TypeScript Server Template Pack

Production template pack for building Model Context Protocol servers in TypeScript. Supports Stdio and SSE transports with schema validation.

By Gordon Geraghty·MIT Licence·Updated: 21 August 2026·ADVANCED·GitHub Mirror ↗

The Standard Interface for AI Tool Execution

The Model Context Protocol establishes an open standard for connecting AI models to external tools, databases, and APIs. This template pack provides clean error handling and schema validation for production deployments.

Implementation Code & Script

Standard MCP Stdio Server Templatemcp-server.tstypescript

Production MCP server with tool definitions, error boundaries, and input schemas.

import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';

const server = new Server(
  { name: 'marketing-analytics-mcp', version: '1.0.0' },
  { capabilities: { tools: {} } }
);

server.setRequestHandler(ListToolsRequestSchema, async () => ({
  tools: [
    {
      name: 'get_campaign_performance',
      description: 'Fetches spend, conversion, and CPA metrics for a given campaign.',
      inputSchema: {
        type: 'object',
        properties: {
          campaignId: { type: 'string', description: 'Google Ads or Meta campaign ID' },
          dateRange: { type: 'string', enum: ['LAST_7_DAYS', 'LAST_30_DAYS'] },
        },
        required: ['campaignId'],
      },
    },
  ],
}));

server.setRequestHandler(CallToolRequestSchema, async (request) => {
  if (request.params.name === 'get_campaign_performance') {
    const campaignId = String(request.params.arguments?.campaignId);
    return {
      content: [{ type: 'text', text: JSON.stringify({ campaignId, spend: 1250.00, conversions: 42, cpa: 29.76 }) }],
    };
  }
  throw new Error('Tool not found');
});

const transport = new StdioServerTransport();
await server.connect(transport);

How to cite and attribute this tool

MIT Licence

This resource is free, open and un-gated under the MIT Open Source Licence. You are encouraged to use, integrate and cite it with attribution:

Geraghty, G. (2026). Model Context Protocol (MCP) TypeScript Server Template Pack. Gordon Geraghty Resources Hub. https://gordongeraghty.com/resources/ai-engineering/mcp-server-template-pack
BibTeX Format
@misc{geraghty_mcp_server_template_pack,
  author = {Geraghty, Gordon},
  title = {Model Context Protocol (MCP) TypeScript Server Template Pack},
  year = {2026},
  url = {https://gordongeraghty.com/resources/ai-engineering/mcp-server-template-pack},
  note = {Head of Performance, Empire Amplify}
}

Changelog & Version History

  • v1.0.0Initial release of TypeScript MCP server template with Stdio and SSE support.