Skip to main content
Glama

generate_request_template

Create path, query, and body templates for ACOMO API requests using operationId. Simplifies API interaction by generating structured request formats for backend services.

Instructions

operationIdからpath/query/body雛形を生成

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationIdYes

Implementation Reference

  • The handler function for the 'generate_request_template' tool. It fetches the operation schemas using getOperationSchemas and generates the request template using buildRequestTemplate, then returns it as JSON text content.
    async ({ operationId }: { operationId: string }) => { const schemas = await getOperationSchemas(operationId); if (!schemas) return { content: [ { type: "text", text: `Unknown operationId: ${operationId}` }, ], isError: true, }; const tmpl = buildRequestTemplate(schemas); return { content: [ { type: "text", text: JSON.stringify(tmpl, null, 2) }, ], }; }
  • The input schema definition for the tool, specifying 'operationId' as a required string using Zod validation.
    { title: "Generate API request template", description: "operationIdからpath/query/body雛形を生成", inputSchema: { operationId: z.string() }, },
  • src/server.ts:114-137 (registration)
    The registration of the 'generate_request_template' tool with the MCP server, including title, description, input schema, and handler function.
    server.registerTool( "generate_request_template", { title: "Generate API request template", description: "operationIdからpath/query/body雛形を生成", inputSchema: { operationId: z.string() }, }, async ({ operationId }: { operationId: string }) => { const schemas = await getOperationSchemas(operationId); if (!schemas) return { content: [ { type: "text", text: `Unknown operationId: ${operationId}` }, ], isError: true, }; const tmpl = buildRequestTemplate(schemas); return { content: [ { type: "text", text: JSON.stringify(tmpl, null, 2) }, ], }; } );
  • Core helper function that builds the request template object from operation schemas, extracting path/query params and generating body skeleton.
    export function buildRequestTemplate(opSchemas: { operationId: string; method: string; path: string; parameters: any[]; requestBody?: any; }) { const pathParams: Record<string, string> = {}; const query: Record<string, any> = {}; for (const p of opSchemas.parameters ?? []) { if (p.in === 'path') pathParams[p.name] = `<${p.name}>`; if (p.in === 'query') query[p.name] = `<${p.name}>`; } const body = opSchemas.requestBody ? buildBodySkeleton(opSchemas.requestBody) : undefined; return { operationId: opSchemas.operationId, method: opSchemas.method, path: opSchemas.path, pathParams, query: Object.keys(query).length ? query : undefined, body, }; }
  • Helper function that retrieves detailed schemas for parameters, requestBody, and responses for a given operationId, used by the tool handler.
    export async function getOperationSchemas(operationId: string): Promise<{ operationId: string; method: string; path: string; parameters: any[]; // path/query/header requestBody?: any; // schema if available responses?: Record<string, any>; // status -> schema/desc } | null> { const found = await findOperationById(operationId); if (!found) return null; const op = found.raw || {}; const parameters = op.parameters ?? []; let requestBody: any | undefined; if (op.requestBody?.content) { // prefer application/json const json = op.requestBody.content['application/json'] || Object.values(op.requestBody.content)[0]; requestBody = json?.schema ?? json; } const responses: Record<string, any> = {}; if (op.responses) { for (const [code, res] of Object.entries(op.responses)) { const content = (res as any)?.content; const json = content?.['application/json'] || (content && Object.values(content)[0]); responses[code] = json?.schema ?? (res as any)?.description ?? res; } } return { operationId, method: found.method, path: found.path, parameters, requestBody, responses, }; }

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/progress-all/acomo-mcp-server'

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