Skip to main content
Glama
tuskermanshu

Swagger MCP Server

by tuskermanshu

template-list

Retrieve available code generation templates for Swagger/OpenAPI documents, filtering by template type and framework to generate TypeScript types and API client code.

Instructions

Get available code generation template list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNoTemplate type filter
frameworkNoFramework type filter (only for API client and config file templates)
includeContentNoWhether to include template content

Implementation Reference

  • Core implementation of the template-list tool handler. Filters and lists templates by type and framework, optionally includes content, returns JSON response.
    private async listTemplates(params: { type?: string; framework?: string; includeContent?: boolean; }): Promise<any> { try { let templates: Template[] = []; // 根据类型过滤 if (params.type && params.type !== 'all') { const templateType = params.type as TemplateType; templates = this.templateManager.getTemplatesByType(templateType); // 根据框架类型进一步过滤 if (params.framework && (templateType === TemplateType.API_CLIENT || templateType === TemplateType.CONFIG_FILE)) { const frameworkType = params.framework as FrameworkType; templates = templates.filter(template => template.framework === frameworkType); } } else { templates = this.templateManager.getAllTemplates(); // 根据框架类型过滤 if (params.framework) { const frameworkType = params.framework as FrameworkType; templates = templates.filter(template => template.framework === frameworkType); } } // 处理返回结果 const result = templates.map(template => { const { content, ...rest } = template; // 如果不需要包含内容,则省略 if (!params.includeContent) { return rest; } return template; }); return { content: [ { type: 'text' as const, text: JSON.stringify({ success: true, templates: result }, 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) } ] }; } }
  • Input schema using Zod for the template-list tool, defining optional parameters for filtering templates.
    { type: z.enum(['all', 'api-client', 'typescript-types', 'config-file']).optional().describe('Template type filter'), framework: z.enum(['axios', 'fetch', 'react-query', 'swr', 'angular', 'vue']).optional().describe('Framework type filter (only for API client and config file templates)'), includeContent: z.boolean().optional().describe('Whether to include template content') },
  • Registration of the 'template-list' tool on the MCP server, specifying name, description, input schema, and handler function.
    server.tool( TEMPLATE_LIST_TOOL_NAME, TEMPLATE_LIST_TOOL_DESCRIPTION, { type: z.enum(['all', 'api-client', 'typescript-types', 'config-file']).optional().describe('Template type filter'), framework: z.enum(['axios', 'fetch', 'react-query', 'swr', 'angular', 'vue']).optional().describe('Framework type filter (only for API client and config file templates)'), includeContent: z.boolean().optional().describe('Whether to include template content') }, async (params) => { return await this.listTemplates(params); } );

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