Skip to main content
Glama
tuskermanshu

Swagger MCP Server

by tuskermanshu

template-get

Retrieve specific template content by ID to generate TypeScript types and API client code from Swagger/OpenAPI documents.

Instructions

Get specific template content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesTemplate ID

Implementation Reference

  • The main handler function for the 'template-get' tool. It fetches the template by ID using TemplateManager and returns a standardized JSON response with success/error status.
    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)
            }
          ]
        };
      }
    }
  • Registers the 'template-get' tool with the MCP server, including name, description, input schema, and handler reference.
    // 注册获取单个模板工具
    server.tool(
      TEMPLATE_GET_TOOL_NAME,
      TEMPLATE_GET_TOOL_DESCRIPTION,
      {
        id: z.string().describe('Template ID'),
      },
      async (params) => {
        return await this.getTemplate(params);
      }
    );
  • Zod input schema defining the required 'id' parameter as a string.
    {
      id: z.string().describe('Template 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';
  • Underlying helper method in TemplateManager that finds and returns a template by ID from loaded templates.
    getTemplate(id: string): Template | undefined {
      return this.getAllTemplates().find(template => template.id === id);
    }
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. It states 'Get' which implies a read operation, but doesn't disclose behavioral traits such as error handling (e.g., what happens if the ID is invalid), authentication needs, rate limits, or return format. This leaves significant gaps for a tool with no annotation coverage.

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 extremely concise with just three words, front-loaded with the key action and resource. There is zero waste or redundancy, making it efficient and easy to parse, though it may be overly brief for clarity.

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 has no annotations, no output schema, and a simple input schema, the description is incomplete. It doesn't cover what 'template content' entails (e.g., structure, format), error cases, or usage context, leaving the agent with insufficient information for reliable invocation.

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 schema description coverage is 100%, with the parameter 'id' documented as 'Template ID' in the schema. The description adds no additional meaning beyond this, as it doesn't explain the ID format, source, or constraints. With high schema coverage, the baseline is 3, and the description doesn't compensate with extra details.

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

Purpose3/5

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

The description 'Get specific template content' clearly states the action (get) and resource (template content), but it's vague about what 'specific' means and doesn't differentiate from sibling tools like template-list. It's better than a tautology but lacks precision about scope or format.

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?

No guidance is provided on when to use this tool versus alternatives like template-list or template-save. The description implies retrieval of a single template but doesn't specify prerequisites, such as needing an existing template ID, or exclusions, like not being for creating or listing templates.

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