The entry point that bootstraps the Prisma AIRS MCP server, configuring Express HTTP server with MCP protocol handlers.
Core Purpose
- Initializes monitoring (via instrument.ts import)
- Creates Express server with middleware
- Sets up MCP protocol endpoints
- Establishes HTTP and SSE routes
- Handles graceful error management
Key Components
Server Creation
const createServer = (): void => {
const config = getConfig();
const logger = getLogger();
const app = express();
// Core middleware
app.use(cors());
app.use(express.json({ limit: '10mb' }));
// MCP transport layer
const transport = new HttpServerTransport({
server: new Server({ name: config.mcp.serverName }),
logger,
});
}
Route Structure
GET /
- Welcome messageGET /health
- Health checkGET /ready
- Readiness probePOST /
- Main MCP message endpointGET /sse
- Server-sent events for streaming
Error Flow
Request → Middleware → Routes → Handlers
↓ (on error)
Sentry Handler → Custom Error Handler → Error Response
Integration Points
- Configuration: Loads from
config/index.ts
- Monitoring: Uses
utils/monitoring.ts
for error tracking - Transport:
HttpServerTransport
handles MCP protocol - Logging: Structured logging via
utils/logger.ts
Application Lifecycle
- Import instrument.ts - Must be first for Sentry
- Load configuration - Environment and defaults
- Setup middleware - CORS, JSON parsing, monitoring
- Define routes - Health checks and MCP endpoints
- Start server - Listen on configured port
Key Patterns
- Singleton server instance
- Graceful error handling with monitoring
- Health/readiness probes for container orchestration
- SSE support for real-time communication
Related Modules
- Instrument - Monitoring initialization
- HTTP Transport - Request handling
- Configuration - App settings