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);
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Get' implies a read operation, it doesn't specify whether this is a safe, idempotent call, what authentication might be required, or how results are structured (e.g., pagination, sorting). For a tool with three parameters and no output schema, this leaves significant behavioral aspects undocumented.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it immediately scannable. Every word serves a clear function, and there's no redundancy or fluff, exemplifying optimal conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (3 parameters, no output schema, and no annotations), the description is insufficiently complete. It doesn't address what the output looks like (e.g., list format, fields), how to handle multiple templates, or error conditions. With siblings involving template operations, more context is needed to ensure proper integration and usage in workflows.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no parameter-specific information beyond what's already in the schema, which has 100% coverage with clear descriptions and enums. This meets the baseline of 3 since the schema adequately documents all parameters. However, the description doesn't explain how parameters interact (e.g., that 'framework' only applies to certain 'type' values) or provide usage examples, missing opportunities to enhance understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('available code generation template list'), making the purpose immediately understandable. It distinguishes itself from siblings like template-delete, template-get, and template-save by focusing on listing rather than modifying or retrieving individual templates. However, it doesn't explicitly differentiate from other list-like operations among siblings, keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like template-get (for individual templates) and generate-* tools (for code generation), there's no indication of appropriate contexts, prerequisites, or exclusions. This lack of usage context leaves the agent to infer relationships, which could lead to incorrect tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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