Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning " AI Answers

How to use openapi-mcp-server conversion API programmatically?

2025-08-28 1.4 K

Developers can programmatically integrate the functionality of openapi-mcp-server with the following main steps:

  1. Import Module: Introducing Converters in Node.js Projects
    import { OpenAPIToMCPConverter } from 'openapi-mcp-server' ;
  2. Converting API Formats: Create an instance of the converter and convert to the desired format
    const converter = new OpenAPIToMCPConverter(openApiSpec); // openApiSpec is OpenAPI JSON data
    const openAiTools = await converter.convertToOpenAITools(); // convert to OpenAI format
    const mcpTools = converter.convertToMCPTools(); // convert to MCP format
  3. Executing API Calls: Using HttpClient for specific operations
    import { HttpClient } from 'openapi-mcp-server' ;
    const httpClient = new HttpClient({ baseUrl: 'https://api.example.com' }, openApiSpec);
    const response = await httpClient.executeOperation(mcpTools.openApiLookup['getPetById'], { petId: 123 });

This approach is particularly suitable for scenarios where APIs need to be integrated into existing projects or automated workflows, where developers have the flexibility to programmatically control the transformation process and use the transformed API resources.

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

Top

en_USEnglish