loading…
Search for a command to run...
loading…
An MCP server demonstrating OAuth 2.0 authentication with Keycard's Security Token Service, providing tools for displaying the Keycard logo and retrieving authe
An MCP server demonstrating OAuth 2.0 authentication with Keycard's Security Token Service, providing tools for displaying the Keycard logo and retrieving authenticated user information.
A production-ready MCP server demonstrating OAuth 2.0 authentication with Keycard's Security Token Service (STS). This project showcases best practices for building secure, type-safe, and modular MCP servers with enterprise-grade observability.
TypeScript Node.js MCP Protocol OAuth 2.0
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ Cursor │───▶│ MCP Server │───▶│ Keycard STS │
│ IDE │ │ (localhost: │ │ │
│ │ │ 8888) │ │ │
└─────────────┘ └──────────────┘ └─────────────┘
│ │ │
OAuth Flow JWT Validation Token Issuance
git clone https://github.com/keycardai/hello-mcp-server.git
cd hello-mcp-server
npm install
Create a .env file:
# Required: Your Keycard STS issuer URL
KEYCARD_STS_ISSUER_URL=https://your-zone-id.keycard.cloud
# Optional: Server configuration
PORT=8888
HOST=localhost
💡 Finding your Zone ID:
j434uokph8th1ia1npxiaykh7p)your-zone-id in your STS URLNote: Use the zone ID, not the zone name or label.
# Development mode with auto-reload
npm run dev
# Production mode
npm run build && npm start
You should see:
🚀 Keycard Hello MCP Server started!
🔗 MCP Endpoint: http://localhost:8888/mcp
🔐 STS Issuer: https://your-zone-id.keycard.cloud
🛠️ Available Tools: keycard-logo, whoami
Add to your Cursor MCP settings:
{
"mcpServers": {
"keycard-hello-mcp": {
"url": "http://localhost:8888/mcp"
}
}
}
keycard-logo, whoamikeycard-logoDisplays the official Keycard ASCII art logo.
whoamiProvides detailed information about the authenticated user including:
| Variable | Description | Default | Required |
|---|---|---|---|
KEYCARD_STS_ISSUER_URL |
Keycard STS issuer URL (single-tenant mode) | - | ✅* |
ISSUER_BASE_DOMAIN |
Base domain for STS (multi-tenant mode) | - | ✅* |
MCP_BASE_DOMAIN |
Base domain for MCP server (multi-tenant mode) | - | ✅* |
PORT |
Server port | 8888 |
|
HOST |
Server host | localhost |
|
LOG_LEVEL |
Logging level | INFO |
|
ENABLE_OTEL |
Enable OpenTelemetry | true |
|
OTEL_SERVICE_NAME |
Service name for telemetry | hello-mcp-server |
|
OTEL_ENVIRONMENT |
Environment for telemetry | development |
*Either KEYCARD_STS_ISSUER_URL (single-tenant) OR ISSUER_BASE_DOMAIN + MCP_BASE_DOMAIN (multi-tenant) is required.
For multi-tenant deployments (serving multiple organizations/zones), use these environment variables instead:
# Multi-tenant mode
ISSUER_BASE_DOMAIN=keycard.cloud
MCP_BASE_DOMAIN=mcp.example.com
# Other configuration
PORT=8888
ENABLE_OTEL=true
This enables dynamic issuer discovery based on subdomain routing, allowing one deployment to serve multiple Keycard zones.
The server includes comprehensive observability features:
/healthIn development, logs are formatted for console readability. In production, logs are sent to configured OTLP endpoints.
src/
├── config.ts # Configuration management
├── index.ts # Application entry point
├── server.ts # Express server setup
├── middleware/ # Express middlewares
│ ├── auth.ts # Authentication middleware
│ └── logging.ts # Request logging and tracing
├── observability/ # Telemetry and logging
│ ├── logger.ts # Structured logger
│ └── telemetry.ts # OpenTelemetry setup
├── tools/ # MCP tools
│ ├── index.ts # Tool registration
│ ├── logo.ts # Keycard logo tool
│ └── whoami.ts # User information tool
└── types/ # Type definitions
├── auth.ts # Authentication types
└── index.ts # Exported types
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run integration tests
npm run test:integration
# Watch mode for development
npm run test:watch
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format
# Check all (lint + format)
npm run check
# Fix all issues
npm run check:fix
npm run devhttp://localhost:8888/mcpThe server provides a health check endpoint at /health:
curl http://localhost:8888/health
Response:
{
"status": "healthy",
"timestamp": "2024-01-01T00:00:00.000Z",
"service": "hello-mcp-server",
"version": "1.0.0"
}
Apache-2.0 License - see LICENSE file for details.
Выполни в терминале:
claude mcp add keycard-hello-mcp-server -- npx Безопасность
Низкий рискАвтоматическая эвристика по публичным данным — не гарантия безопасности.