Skip to main content
Glama
heartbeat.ts1.01 kB
import { BroadcastableStdioServerTransport } from './stdio-transport.js' const HEARTBEAT_INTERVAL = 30000 // 30 seconds export class HeartbeatManager { private transports: Set<BroadcastableStdioServerTransport> = new Set() private intervalId: NodeJS.Timeout | null = null public add(transport: BroadcastableStdioServerTransport) { this.transports.add(transport) this.start() } public remove(transport: BroadcastableStdioServerTransport) { this.transports.delete(transport) if (this.transports.size === 0) { this.stop() } } private start() { if (this.intervalId === null) { this.intervalId = setInterval(() => this.sendHeartbeat(), HEARTBEAT_INTERVAL) } } private stop() { if (this.intervalId !== null) { clearInterval(this.intervalId) this.intervalId = null } } private sendHeartbeat() { for (const transport of this.transports) { transport.sendNotification({ method: '$/heartbeat', }) } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PixdataOrg/coderide-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server