Skip to main content
Glama

1MCP Server

versionsHandler.ts1.8 kB
import { createRegistryClient } from '@src/domains/registry/mcpRegistryClient.js'; import { RegistryOptions, ServerVersionsResponse, VersionsCommandArgs } from '@src/domains/registry/types.js'; import logger from '@src/logger/logger.js'; import { withErrorHandling } from '@src/utils/core/errorHandling.js'; // Singleton instances let registryClient: ReturnType<typeof createRegistryClient> | null = null; let currentRegistryConfig: RegistryOptions | undefined = undefined; /** * Get or create registry client instance */ function getRegistryClient(registryOptions?: RegistryOptions) { // Recreate client if config changed if (!registryClient || JSON.stringify(currentRegistryConfig) !== JSON.stringify(registryOptions)) { if (registryClient) { registryClient.destroy(); } registryClient = createRegistryClient(registryOptions); currentRegistryConfig = registryOptions; } return registryClient; } /** * Handle list_mcp_server_versions tool calls */ export async function handleListMCPServerVersions( args: VersionsCommandArgs, registryOptions?: RegistryOptions, ): Promise<ServerVersionsResponse> { const handler = withErrorHandling(async () => { logger.debug('Processing list_mcp_server_versions request', args); const client = getRegistryClient(registryOptions); // Get server versions const versions = await client.getServerVersions(args.serverId); logger.debug(`Successfully fetched ${versions.versions.length} versions for: ${args.serverId}`); return versions; }, `Failed to list versions for MCP server: ${args.serverId}`); return await handler(); } /** * Cleanup resources */ export function cleanupVersionsHandler(): void { if (registryClient) { registryClient.destroy(); registryClient = null; } }

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/1mcp-app/agent'

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