MCP Hello World
A minimal reference implementation of an MCP server that responds with "Hello, World" via Streamable HTTP. Serves as a baseline for integration testing and MCP client development with production-ready features including health checks, metrics, and containerized deployment.
README
MCP Hello World
A minimal MCP (Model Context Protocol) server that responds with "Hello, World" via Streamable HTTP. This project serves as a reference implementation and integration testing baseline for MCP client development.
Features
- Streamable HTTP MCP endpoint at
/mcpthat returns "Hello, World" - Health check endpoint at
/healthzfor monitoring - Prometheus metrics at
/metricsfor observability - Production-ready with proper error handling, logging, and security
- TypeScript codebase with comprehensive test coverage
- Docker support for containerized deployment
- Cloud Run ready for serverless deployment
Quick Start
Prerequisites
- Node.js 20+
- npm or yarn
Local Development
-
Install dependencies
npm install -
Start development server
npm run dev -
Test the endpoints
# Health check curl http://localhost:8080/healthz # Metrics curl http://localhost:8080/metrics # MCP endpoint (POST request) curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"initialize","id":1}'
Using with MCP Inspector
The primary use case is connecting via MCP Inspector for integration testing:
-
Deploy or run locally (see deployment options below)
-
Open MCP Inspector in your browser
-
Connect to your MCP server
- Local development:
http://localhost:8080/mcp - Cloud Run:
https://your-service-url.run.app/mcp
- Local development:
-
Verify connection
- You should see "Hello, World" message
- Connection status should show as connected
- Response time should be < 300ms (excluding cold starts)
API Endpoints
POST /mcp - MCP Streamable HTTP
Main MCP endpoint that implements the Streamable HTTP protocol.
Request:
{
"jsonrpc": "2.0",
"method": "initialize",
"id": 1
}
Response: Server-Sent Events stream
data: {"jsonrpc":"2.0","id":1,"result":{"message":"Hello, World","timestamp":"2025-08-28T...","server":"mcp-hello-world","version":"0.1.0"}}
Headers:
Content-Type: text/event-streamCache-Control: no-storeAccess-Control-Allow-Origin: *
GET /healthz - Health Check
Returns server health status and uptime.
Response:
{
"status": "ok",
"uptime_s": 120,
"timestamp": "2025-08-28T...",
"version": "0.1.0"
}
GET /metrics - Prometheus Metrics
Returns metrics in Prometheus text exposition format.
Key Metrics:
mcp_hello_world_http_requests_total- HTTP request countermcp_hello_world_handshake_total- MCP handshake countermcp_hello_world_handshake_duration_seconds- MCP handshake latencymcp_hello_world_uptime_seconds- Server uptimemcp_hello_world_cold_start_total- Cold start counter (Cloud Run)
Development
Scripts
# Development with hot reload
npm run dev
# Build for production
npm run build
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Lint code
npm run lint
# Type check
npm run typecheck
# Docker build
npm run docker:build
# Docker run
npm run docker:run
Testing
The project has comprehensive test coverage with 38 tests covering:
- Core MCP functionality - handshake, response format, error handling
- HTTP endpoints - health checks, metrics, CORS
- Error scenarios - malformed requests, method validation
- Metrics collection - counters, histograms, gauges
- Logging - structured logs, request IDs
Run tests with coverage:
npm test
Code Quality
- ESLint for code linting with TypeScript rules
- Prettier for code formatting
- TypeScript with strict configuration
- Vitest for testing with coverage reporting
- Conventional Commits for commit messages
Deployment
Docker
-
Build the image
docker build -t mcp-hello-world . -
Run the container
docker run -p 8080:8080 mcp-hello-world
Google Cloud Platform (Automated)
This project uses GCP Cloud Build for automated CI/CD. Every push to the main branch triggers:
-
Automated Build Pipeline (via
cloudbuild.yaml):- Code quality checks (TypeScript, ESLint)
- Test execution with coverage
- Docker image build and push to Artifact Registry
- SBOM generation and security scanning
- Automatic deployment to Cloud Run
- Health checks and endpoint testing
-
Setup GCP Cloud Build Trigger:
# Enable required APIs gcloud services enable cloudbuild.googleapis.com gcloud services enable run.googleapis.com gcloud services enable artifactregistry.googleapis.com # Create Artifact Registry repository gcloud artifacts repositories create mcp-servers \ --repository-format=docker \ --location=us-central1 # Set up Cloud Build trigger (via Console or CLI) gcloud alpha builds triggers create github \ --repo-name=mcp-hello-world \ --repo-owner=MillCityAI \ --branch-pattern=^main$ \ --build-config=cloudbuild.yaml -
Manual Deployment (if needed):
gcloud builds submit --config cloudbuild.yaml -
Get the service URL:
gcloud run services describe mcp-hello-world \ --platform managed \ --region us-central1 \ --format 'value(status.url)'
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
PORT |
No | 8080 | Server port |
NODE_ENV |
No | development | Environment (development/production) |
LOG_LEVEL |
No | info/debug | Logging level |
REGION |
No | unknown | Deployment region |
BUILD_SHA |
No | dev | Build/commit SHA |
INSTANCE_ID |
No | local | Instance identifier |
Architecture
Technology Stack
- Runtime: Node.js 20 LTS
- Framework: Fastify (high performance HTTP server)
- Language: TypeScript with strict configuration
- Logging: Pino (structured JSON logging)
- Metrics: prom-client (Prometheus metrics)
- Testing: Vitest + @vitest/coverage-v8
- Container: Multi-stage Docker build with Alpine Linux
Security
- OWASP ASVS Level 1 compliance
- CORS properly configured for MCP Inspector
- Rate limiting (100 requests/minute)
- Security headers via Helmet
- Input validation and request size limits
- Secrets management via environment variables
- Non-root container execution
- Log sanitization (redacts auth headers)
Performance
- Target latency: p95 < 300ms (excluding cold starts)
- Cold start tracking for Cloud Run deployments
- Connection pooling and keep-alive
- Efficient JSON parsing and SSE streaming
- Graceful shutdown handling
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with tests
- Run the test suite (
npm test) - Run linting (
npm run lint) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
Apache-2.0 License - see the LICENSE file for details.
Related Projects
- Model Context Protocol - The MCP specification
- MCP Inspector - MCP client testing tool
- Fastify - Fast and low overhead web framework
Support
- Documentation: See the
/Documentationfolder for detailed specs - Issues: Report bugs via GitHub Issues
- Community: Join the MCP community discussions
🤖 Generated with Claude Code
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。