#!/usr/bin/env node import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { loadConfig } from '../config.ts'; import { SessionKeepalive } from '../keepalive.ts'; import { SchulcloudClient } from '../schulcloud/client.ts'; import { createServer } from '../server.ts'; /** * stdio entry point — for running the server locally against Claude Code or * Claude Desktop. The remote deployment uses bin/http.ts instead. * * Nothing may be written to stdout here except MCP protocol frames. */ async function main(): Promise { const config = loadConfig(); const { server } = createServer(config); await server.connect(new StdioServerTransport()); // A desktop client left open overnight idles far past the instance's 2h // session timeout, so stdio needs the keepalive just as much as HTTP does. // It logs to stderr; stdout carries protocol frames only. if (config.keepaliveIntervalMs > 0) { new SessionKeepalive(new SchulcloudClient(config), config.keepaliveIntervalMs).start(); } console.error(`[schulcloud-mcp] stdio transport ready for ${config.baseUrl}`); } main().catch((error: unknown) => { console.error('[schulcloud-mcp] fatal:', error); process.exit(1); });