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.
Model Context Protocol (MCP) Server Architecture
Architecture of Model Context Protocol TypeScript servers bridging LLM clients (Claude Desktop, Cursor, Antigravity) over Stdio/SSE transports to execute typed tools and access contextual resources.
Model Context Protocol (MCP) TypeScript Server Template Pack Configurator
Marketing Analytics & Ads Governance — Model Context Protocol (MCP) Server
TypeScript Model Context Protocol (MCP) server exposing GAQL query execution and unit economics calculation tools to Claude and AI agents.
1 Input Parameters & Assumptions
| Parameter | Value | Context & Provenance |
|---|---|---|
| Server Identifier | marketing-analytics-mcp Server Name | Unique MCP server identifier |
| Server Version | 1.0.0 SemVer | Initial production release specification |
| Transport Layer | Standard I/O (stdio) Transport | Process-level stdio communication compatible with Claude Desktop and Antigravity |
| Exposed Tools | 2 Registered Tools Tools | GAQL query execution & POAS unit-economics calculation |
2 Explicit Mathematical Formula
Protocol Framing: JSON-RPC 2.0 over standard I/O (stdio transport)
Registered Tool 1: query_google_ads_gaql (parameters: query [string, required], accountId [string, required])
Registered Tool 2: calculate_poas_unit_economics (parameters: aov [number, required], cpa [number, required], cogsPercentage [number, required])
Input Validation: Strict JSON Schema parameter enforcement before handler dispatch
Config Export: claude_desktop_config.json snippet3 Computed Output Metrics
| Computed Metric | Result | Interpretation & Threshold |
|---|---|---|
| Registered Tool Count | 2 Tools Tools | Exposes GAQL querying and unit-economics calculation to LLMs |
| Protocol Standard | Model Context Protocol Standard | Native JSON-RPC 2.0 stdio framing compatible with Claude Desktop, Cursor, and Antigravity |
| Type Safety Guarantee | 100% Zod / TS Schema | Strict parameter typing prevents ill-formed tool call invocations |
Model Context Protocol (MCP) TypeScript Server Template Pack — Scope & Limitations
Explicit operational boundaries and constraints defining target use cases and out-of-scope scenarios.
Built For (Target Use Cases)
- Scaffolding a TypeScript Model Context Protocol server manifest and boilerplate from named tools.
- Documenting tool names, parameters, and required fields for stdio or SSE transport.
- Producing a starting claude_desktop_config.json snippet for local MCP server registration.
Not Built For (Limitations & Out-of-Scope)
- Working tool implementations; generated handlers are stubs returning placeholder text, not real logic.
- SSE transport code; the generated server always wires StdioServerTransport regardless of the selected transport.
- Authentication, rate limiting, or deployment configuration for the generated server.
Operational Assumptions & Defaults
- PRESET_TOOLKITS.marketing_analytics and similar presets define example tool sets, not required ones.
- Tool parameter types map directly to JSON Schema without additional runtime validation.
- Generated code targets the @modelcontextprotocol/sdk stdio and SSE transport APIs as documented.
Model Context Protocol (MCP) Server & Tool Pack Builder
MCP SDK & Claude DesktopBuild custom Model Context Protocol (MCP) servers with typed tool definitions, parameter schemas, and instant exports for `@modelcontextprotocol/sdk` TypeScript boilerplate and `claude_desktop_config.json`.
MCP Server Properties
Generated MCP Artifacts
{
"name": "marketing-analytics-mcp",
"version": "1.0.0",
"transport": "stdio",
"tools": [
{
"name": "query_google_ads_gaql",
"description": "Executes a Google Ads Query Language (GAQL) query and returns campaign performance metrics.",
"inputSchema": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "GAQL query string"
},
"accountId": {
"type": "string",
"description": "Google Ads CID"
}
},
"required": [
"query",
"accountId"
]
}
},
{
"name": "calculate_poas_unit_economics",
"description": "Computes net contribution margin and break-even ROAS for an e-commerce brand.",
"inputSchema": {
"type": "object",
"properties": {
"aov": {
"type": "number",
"description": "Average order value"
},
"cpa": {
"type": "number",
"description": "Cost per acquisition"
},
"cogsPercentage": {
"type": "number",
"description": "COGS %"
}
},
"required": [
"aov",
"cpa",
"cogsPercentage"
]
}
}
]
}Deploy MCP Server to Claude Desktop / Antigravity
Download the generated MCP server package (`index.ts`, `package.json`, `tsconfig.json`), compile with `npm run build`, and add to your `claude_desktop_config.json`.
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
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);MCP Server Inspector & Tool Execution QA
Debug and test your MCP server tools using the official MCP Inspector before connecting to production clients.
Pre-Production Verification Checklist
Run npx @modelcontextprotocol/inspector node dist/index.js and verify all tools appear in UI.
Pass invalid types to tool arguments and confirm clean error payloads are returned.
Confirm Claude Desktop displays the hammer icon and successfully executes registered tools.
Terminal Diagnostic & Debug Commands
Opens local web interface on port 5173 to test tool calls and resource reads.
npx @modelcontextprotocol/inspector node dist/index.jsFailure Remediation & Troubleshooting
Cause: Server process wrote non-JSON debug logs to stdout, corrupting the Stdio transport.
Fix: Always use console.error() instead of console.log() for debugging in Stdio MCP servers.
How to cite and attribute this tool
MIT LicenceThis resource is free, open and un-gated under the MIT Open Source Licence. You are encouraged to use, integrate and cite it with attribution:
@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 Media, Empire Amplify}
}Changelog & Version History
v1.0.0Initial release of TypeScript MCP server template with Stdio and SSE support.
Strategic Takeaway & Operational Guidelines
The Model Context Protocol allows language models to interact securely with private data sources and APIs. This template exposes structured GAQL queries and unit economics models as verifiable tools.