generate_ai_tool
Generate AI agent tool code from Postman collections to integrate APIs with frameworks like OpenAI, LangChain, or Anthropic.
Instructions
Generate code for an AI agent tool using a Postman collection and request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collectionId | Yes | The Public API Network collection ID | |
| requestId | Yes | The public request ID | |
| language | Yes | Programming language to use | |
| agentFramework | Yes | AI agent framework to use |
Implementation Reference
- src/index.ts:109-149 (handler)The handler function that executes the generate_ai_tool logic: validates input parameters, makes a POST request to Postman API endpoint '/postbot/generations/tool', and returns the generated tool code or error.private async handleGenerateTool(args: any): Promise<any> { if (!args?.collectionId || !args?.requestId || !args?.language || !args?.agentFramework) { throw new McpError( ErrorCode.InvalidParams, 'Missing required parameters: collectionId, requestId, language, agentFramework' ); } try { const response = await this.axiosInstance.post('/postbot/generations/tool', { collectionId: args.collectionId, requestId: args.requestId, config: { language: args.language, agentFramework: args.agentFramework, }, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { if (axios.isAxiosError(error)) { return { content: [ { type: 'text', text: `Error generating tool: ${error.response?.data?.error || error.message}`, }, ], isError: true, }; } throw error; } }
- src/index.ts:65-92 (registration)Registration of the generate_ai_tool in the ListTools response, including name, description, and input schema.{ name: 'generate_ai_tool', description: 'Generate code for an AI agent tool using a Postman collection and request', inputSchema: { type: 'object', properties: { collectionId: { type: 'string', description: 'The Public API Network collection ID', }, requestId: { type: 'string', description: 'The public request ID', }, language: { type: 'string', enum: ['javascript', 'typescript'], description: 'Programming language to use', }, agentFramework: { type: 'string', enum: ['openai', 'mistral', 'gemini', 'anthropic', 'langchain', 'autogen'], description: 'AI agent framework to use', }, }, required: ['collectionId', 'requestId', 'language', 'agentFramework'], }, },
- src/index.ts:98-99 (registration)Dispatch in the CallToolRequest handler switch statement that routes to the generate_ai_tool handler.case 'generate_ai_tool': return this.handleGenerateTool(request.params.arguments);
- src/index.ts:68-91 (schema)Input schema definition for the generate_ai_tool tool parameters.inputSchema: { type: 'object', properties: { collectionId: { type: 'string', description: 'The Public API Network collection ID', }, requestId: { type: 'string', description: 'The public request ID', }, language: { type: 'string', enum: ['javascript', 'typescript'], description: 'Programming language to use', }, agentFramework: { type: 'string', enum: ['openai', 'mistral', 'gemini', 'anthropic', 'langchain', 'autogen'], description: 'AI agent framework to use', }, }, required: ['collectionId', 'requestId', 'language', 'agentFramework'], },
- src/index.ts:12-19 (helper)TypeScript interface defining the structure for GenerateToolConfig, matching the tool's input and API request body.interface GenerateToolConfig { collectionId: string; requestId: string; config: { language: 'javascript' | 'typescript'; agentFramework: 'openai' | 'mistral' | 'gemini' | 'anthropic' | 'langchain' | 'autogen'; }; }