Skip to main content
Glama
tuskermanshu

Swagger MCP Server

by tuskermanshu

template-get

Retrieve specific template content by providing the template ID from the Swagger MCP Server, which parses Swagger/OpenAPI documents to generate TypeScript types and API client code.

Instructions

Get specific template content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesTemplate ID

Implementation Reference

  • Registration of the "template-get" MCP tool, including input schema (id: string) and handler that delegates to getTemplate method.
    // 注册获取单个模板工具 server.tool( TEMPLATE_GET_TOOL_NAME, TEMPLATE_GET_TOOL_DESCRIPTION, { id: z.string().describe('Template ID'), }, async (params) => { return await this.getTemplate(params); } );
  • Main handler function for "template-get" tool: fetches template by ID using TemplateManager, handles errors, and returns JSON-formatted response in MCP content format.
    private async getTemplate(params: { id: string }): Promise<any> { try { const template = this.templateManager.getTemplate(params.id); if (!template) { return { content: [ { type: 'text' as const, text: JSON.stringify({ success: false, error: `Template not found with ID: ${params.id}` }, null, 2) } ] }; } return { content: [ { type: 'text' as const, text: JSON.stringify({ success: true, template }, null, 2) } ] }; } catch (error) { console.error('[TemplateManagerTool] 获取模板失败:', error); return { content: [ { type: 'text' as const, text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : String(error) }, null, 2) } ] }; }
  • Underlying helper method in TemplateManager that finds and returns the template by ID from loaded built-in and custom templates.
    getTemplate(id: string): Template | undefined { return this.getAllTemplates().find(template => template.id === id); }
  • Constants defining the tool name and description used in registration.
    const TEMPLATE_GET_TOOL_NAME = 'template-get'; const TEMPLATE_GET_TOOL_DESCRIPTION = 'Get specific template content';

Other Tools

Related Tools

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/tuskermanshu/swagger-mcp-server'

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