Skip to main content
Glama

1MCP Server

showHandler.ts1.71 kB
import { createRegistryClient } from '@src/domains/registry/mcpRegistryClient.js'; import { RegistryOptions, RegistryServer, ShowCommandArgs } 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 show_mcp_server tool calls */ export async function handleShowMCPServer( args: ShowCommandArgs, registryOptions?: RegistryOptions, ): Promise<RegistryServer> { const handler = withErrorHandling(async () => { logger.debug('Processing show_mcp_server request', args); const client = getRegistryClient(registryOptions); // Get server details const server = await client.getServerById(args.serverId, args.version); logger.debug(`Successfully fetched server details for: ${args.serverId}`); return server; }, `Failed to show MCP server: ${args.serverId}`); return await handler(); } /** * Cleanup resources */ export function cleanupShowHandler(): 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