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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Template ID |
Implementation Reference
- src/tools/template-manager-tool.ts:57-67 (registration)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); }
- src/tools/template-manager-tool.ts:13-14 (registration)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';