openapi2mcptools
by 2013xile
An utility library for converting OpenAPI specifications to MCP tools. It helps to faster the development of MCP servers based on OPENAPI specifications.
Last updated: N/A
What is openapi2mcptools?
openapi2mcptools is a utility library that converts OpenAPI specifications into MCP (Model Context Protocol) tools. It simplifies and accelerates the development of MCP servers by leveraging existing OpenAPI definitions.
How to use openapi2mcptools?
The library provides a Converter
class that can load OpenAPI specifications and generate lists of tools and a tool caller function. You can then integrate these tools into an MCP server using the @modelcontextprotocol/sdk
library, handling tool listing and execution requests.
Key features of openapi2mcptools
OpenAPI to MCP conversion
Tool list generation
Tool execution handler
Customizable HTTP client
Supports baseURL configuration
Facilitates rapid MCP server development
Use cases of openapi2mcptools
Building MCP servers from existing OpenAPI specifications
Integrating OpenAPI-defined tools into MCP environments
Automating the creation of MCP tool interfaces
Developing custom MCP clients with specific HTTP configurations
Creating tool execution handlers based on OpenAPI definitions
FAQ from openapi2mcptools
What is OpenAPI?
What is OpenAPI?
OpenAPI is a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.
What is MCP?
What is MCP?
MCP stands for Model Context Protocol. It's a protocol used for communication between different components in a system.
Can I use a custom HTTP client?
Can I use a custom HTTP client?
Yes, you can provide a custom HTTP client with specific configurations like baseURL, headers, etc. The library expects the client to have a request
method that takes a RequestConfig
object and returns a Promise with a data
property.
How do I define the OpenAPI specifications?
How do I define the OpenAPI specifications?
The OpenAPI specifications are loaded into the Converter
instance. The example shows // specs
as a placeholder, you should replace this with your actual OpenAPI specification data.
What is the purpose of the toolCaller
?
What is the purpose of the toolCaller
?
The toolCaller
is a function generated by the Converter
that handles the execution of tools based on the OpenAPI specifications. It takes a request object and returns the result of the tool execution.