Loading repository data…
Loading repository data…
jdutton / repository
A simple MCP (Model Context Protocol) server built with TypeScript featuring dynamic tool discovery and comprehensive CI/CD testing
A production-ready MCP (Model Context Protocol) server built with TypeScript featuring both basic tools and advanced LLM-powered capabilities with type-safe provider and model selection and dual-mode operation (STDIO + Streamable HTTP with OAuth).
Create a production-ready MCP server in under 2 minutes:
npm create @mcp-typescript-simple@latest my-mcp-server
cd my-mcp-server
cp .env.example .env
npm run dev:stdio
What you get:
Adding API keys:
Edit .env to add your provider keys (all optional):
ANTHROPIC_API_KEY - Claude LLM toolsOPENAI_API_KEY - GPT LLM toolsGOOGLE_API_KEY - Gemini LLM toolsGOOGLE_CLIENT_ID/SECRET - Google OAuthGITHUB_CLIENT_ID/SECRET - GitHub OAuthMICROSOFT_CLIENT_ID/SECRET - Microsoft OAuthSee Getting Started Guide for full documentation.
This project provides a containerized MCP server with comprehensive CI/CD testing and multi-LLM support:
Note: LLM tools require API keys. The server gracefully runs with basic tools only if no API keys are configured.
Copy the example environment file and add your API keys:
cp .env.example .env
# Edit .env with your API keys
API Key Sources:
Tip: You can use any combination of providers. The server will automatically detect available APIs and enable corresponding tools.
# Install dependencies
npm install
# STDIO Mode (traditional MCP - recommended for development)
npm run dev:stdio
# Streamable HTTP Mode (for web development - no auth)
npm run dev:http
# Streamable HTTP Mode (with OAuth - requires Google credentials)
npm run dev:oauth
# Vercel Serverless Development (test as serverless functions)
npm run dev:vercel
# Build the project
npm run build
# Production STDIO mode
npm start
# Type checking
npm run typecheck
# Linting
npm run lint
# Unit tests with coverage
npm run test:unit
# Integration / CI suite
npm run test:integration
# Test dual-mode functionality
npm run test:dual-mode
# Observability features
npm run otel:start # Start Grafana OTEL-LGTM stack (requires Docker)
npm run otel:stop # Stop observability stack
npm run otel:logs # View observability stack logs
# API Documentation
npm run docs:validate # Validate OpenAPI specification
npm run docs:preview # Preview docs locally with Redocly
npm run docs:build # Build static Redoc HTML
npm run docs:bundle # Bundle OpenAPI spec to JSON
This project includes comprehensive OpenAPI 3.1 specification and interactive documentation. When running the server (development or production), access:
/docs - Beautiful read-focused documentation (Redoc)/api-docs - Interactive API testing with OAuth support (Swagger UI)/openapi.yaml - OpenAPI specification (YAML format)/openapi.json - OpenAPI specification (JSON format)Example: Start the server and visit http://localhost:3000/docs
npm run dev:http
# Open http://localhost:3000/docs in your browser
The documentation includes:
# Build production Docker image
npm run run:docker:build
# Run Docker container with multi-provider OAuth
npm run run:docker # Uses .env.oauth (supports Google, GitHub, Microsoft)
# Manual Docker commands
docker build -t mcp-typescript-simple:latest .
docker run --rm -p 3000:3000 --env-file .env.oauth mcp-typescript-simple:latest
For production-grade horizontal scaling with Redis session persistence:
# Start 3 MCP servers + Redis + Nginx load balancer
docker-compose --profile loadbalanced up -d
# Test the load-balanced deployment
curl http://localhost:8080/health
Features:
📘 Multi-Node Deployment Guide - Complete guide for horizontally scaled deployment with testing instructions
Test with increasing production-like fidelity:
Level 1: Development Mode (TypeScript via tsx)
npm run dev:oauth
Level 2: Docker Container
npm run run:docker:build
npm run run:docker:google
Level 3: Vercel Serverless Automatic deployment via GitHub Actions on PR merge to main.
src/
├── index.ts # Main MCP server implementation
├── auth/ # OAuth authentication system
├── config/ # Environment and configuration management
├── llm/ # Multi-LLM provider integration
├── observability/ # Structured logging and OpenTelemetry integration
├── server/ # HTTP and MCP server implementations
├── session/ # Session management
├── tools/ # MCP tool implementations
└── transport/ # Transport layer abstractions
api/ # Vercel serverless functions
├── mcp.ts # Main MCP protocol endpoint
├── health.ts # Health check and status
├── auth.ts # OAuth authentication endpoints
└── admin.ts # Administration and metrics
test/
├── unit/ # Unit tests (mirrors src/ structure)
├── integration/ # Integration tests
└── system/ # End-to-end system tests
tools/ # Manual development and testing utilities
├── interactive-client.ts # Interactive MCP client
├── remote-http-client.ts # Remote HTTP MCP client
├── test-oauth.ts # OAuth flow testing
└── manual/ # Manual testing scripts
docs/ # Deployment and architecture documentation
examples/ # Usage examples and demonstrations
.github/workflows/ # GitHub Actions CI/CD pipeline
build/ # Compiled TypeScript output
Dockerfile # Container configuration
vercel.json # Vercel deployment configuration
This project uses a comprehensive testing approach with multiple layers:
test/unit/)test/integration/)test/system/)End-to-end system tests validate the complete deployed application. See test/system/README.md for detailed documentation.
# Run against local development server
npm run test:system:local
# Run against Docker container
npm run test:system:docker
# Run against Vercel preview deployment
npm run test:system:preview
# Run against production deployment
npm run test:system:production
System tests cover:
Primary command for GitHub Actions and automated testing:
# Complete regression test suite - USE THIS FOR CI/CD
npm run test:ci
# Alternative: Full validation including build
npm run validate
The test:ci command runs:
Unit tests live under test/unit/ (mirroring src/** paths, e.g. test/unit/config/environment.test.ts) and feed npm run test:unit; integration suites live under test/integration/ and are exercised by npm run test:integration.
# Individual test commands
npm run test:mcp # MCP-specific functionality tests
npm run test:interactive # Interactive client testing
npm run typecheck # TypeScr