Skip to main content
Glama
admin.ts1.29 kB
import { Router } from "express"; import { Services } from "../services/services.js"; import express from "express"; import { loggableError } from "@mcpx/toolkit-core/logging"; import { Logger } from "winston"; export function buildAdminRouter( authGuard: express.RequestHandler, services: Services, logger: Logger, ): Router { const router = Router(); // TODO: extract `Sessions` service and use reload here & in webserver router.post("/reload", authGuard, async (_req, res) => { try { logger.info("Reloading target servers"); await services.targetClients.initialize(); logger.debug( "Current clientsByService (global)", Object.fromEntries(services.targetClients.clientsByService.entries()), ); // Close all existing sessions so they can reconnect and get the updated tools await services.sessions.shutdown(); logger.info("All sessions closed"); res .status(200) .send( "Target server configuration reloaded (clients will be lazy-loaded per session)", ); } catch (e) { const error = loggableError(e); logger.error("Error reloading target servers", error); res.status(500).send("Error connecting to target servers"); } }); return router; }

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/TheLunarCompany/lunar'

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