home / mcp / mcp server template mcp server
Dual-transport MCP server with OAuth foundations, SQLite caching, and observability for practical model-context integrations.
Configuration
View docs{
"mcpServers": {
"cameronsjo-mcp-server-template": {
"url": "https://placeholder.example/mcp",
"headers": {
"MCP_SERVER_HOST": "127.0.0.1",
"MCP_SERVER_NAME": "mcp-server-template",
"MCP_SERVER_PORT": "3000",
"MCP_SERVER_DB_PATH": ".data/cache.db",
"MCP_SERVER_TIMEOUT": "30000",
"MCP_SERVER_VERSION": "0.1.0",
"MCP_SERVER_CACHE_TTL": "3600",
"MCP_SERVER_LOG_LEVEL": "info",
"MCP_SERVER_TRANSPORT": "stdio",
"MCP_SERVER_SENTRY_DSN": "https://[email protected]/xxx",
"MCP_SERVER_CACHE_ENABLED": "true"
}
}
}
}You can run a production-ready MCP server using TypeScript with dual transport (stdio for local Claude Desktop workflows and HTTP for cloud deployments), built-in caching, observability, and strong type safety. This guide walks you through practical usage, a clear install flow, and essential configuration and security notes so you can start serving MCP clients quickly and safely.
You run the MCP server locally during development with the standard development flow, then start a production build for deployment. Your MCP server accepts client requests, serves server-sent events for real-time updates, and supports JSON-RPC interactions via the MCP protocol. When using Claude Desktop, you can connect through the stdio transport by invoking the local runtime, while cloud deployments connect via HTTP with proper transport configuration. You also enable observability, safe data handling, and rate limiting to ensure reliable, secure operation.
# Clone and install
git clone <this-repo> my-mcp-server
cd my-mcp-server
npm install
# Development mode (hot reload)
npm run dev
# Build and run
npm run build
npm start
# Test with MCP Inspector
npm run inspectorTo run in stdio mode (local development and Claude Desktop integration), use the command shown in the example configuration: node with the script path to the built bundle, e.g. /path/to/dist/index.js. In Claude Desktop, register the MCP server with the following configuration snippet.
- You can switch to HTTP transport for cloud deployment by starting with MCP_SERVER_TRANSPORT=http npm start. The server exposes endpoints for health checks, metadata discovery, OAuth foundations, and the MCP JSON-RPC stream over HTTP.
A registered tool example with a Zod-based input schema and a handler that returns structured results.