Skip to main content
Glama
collect-config.tool.ts1.62 kB
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import { ZodRawShape } from "zod"; import { SmitheryClient } from "../client/smithery.client.js"; import { ITool } from "../interfaces/tool.js"; import { zodType } from "../interfaces/zod.type.js"; import { ToolResponseGenerator } from "./util/tool-response.generator.js"; export class CollectConfigTool implements ITool { private readonly smitheryClient = new SmitheryClient(); private readonly responseGenerator = new ToolResponseGenerator(); name: string = "collect_config"; description: string = "Collect the config to be used for connection to mcp server"; parameters: ZodRawShape = { qualifiedName: zodType.qualifiedName.describe( "The qualified name of the config to collect" ), }; fn: (params: ZodRawShape) => Promise<CallToolResult> = async (params) => { const qualifiedName = params.qualifiedName.toString(); const foundServer = await this.smitheryClient.getServerDetailOrNull( qualifiedName ); if (!foundServer) { return this.responseGenerator.textResponse("Server not found"); } if (foundServer.connections.length === 0) { return this.responseGenerator.textResponse("No connections found"); } const config = foundServer.connections[0].configSchema; const response = Object.entries(config.properties).map( ([key, property]) => ({ configKey: key, isRequired: config.required.includes(key), description: property.description, }) ); return this.responseGenerator.textResponse(JSON.stringify(response)); }; }

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/bbangjooo/mcp-installer'

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