openapi-mcp

openapi-mcp is a tool that quickly transforms OpenAPI 3.x specifications into a robust MCP tool server. It validates the API specification, generates MCP tools for each operation, and provides structured, machine-readable output through stdio or HTTP. This facilitates seamless integration with AI agents.

GitHub Stars

68

User Rating

Not Rated

Favorites

0

Views

61

Forks

14

Issues

0

Installation
Difficulty
Intermediate
Estimated Time
10-20 minutes
Requirements
Go: 1.21 or higher

Installation

Installation

Prerequisites

Please specify required software and versions:
Go: 1.21 or higher

Installation Steps

1. Clone Repository

bash
git clone https://github.com/jedisct1/openapi-mcp.git
cd openapi-mcp

2. Install Dependencies

bash
go mod tidy

3. Build the Server

bash
go build

4. Start the Server

bash
./openapi-mcp --spec path/to/openapi.yaml

Troubleshooting

Common Issues

Issue: Server won't start Solution: Check Go version and reinstall dependencies. Issue: OpenAPI specification is incorrect Solution: Review the YAML/JSON file to ensure it is in the correct format.

Configuration

Configuration

Basic Configuration

No specific configuration is required to start the MCP server, but you need to specify the path to the OpenAPI specification file.

Configuration Example

Specifying OpenAPI Specification File

bash
./openapi-mcp --spec path/to/openapi.yaml

Environment Variables

Set the following environment variables as needed:
bash
export MCP_SERVER_PORT=3000

Advanced Configuration

Security Settings

Store API keys in environment variables or secure configuration files.
Set appropriate file access permissions.

Examples

Examples

Basic Usage

Here are basic usage examples for the MCP server:

Starting the MCP Server

bash
./openapi-mcp --spec path/to/openapi.yaml

Programmatic Usage

go
package main

import (
	"fmt"
	"github.com/jedisct1/openapi-mcp/pkg/openapi2mcp"
)

func main() {
	result, err := openapi2mcp.CallTool("toolName", map[string]interface{}{
		"parameter1": "value1",
		"parameter2": "value2",
	})
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(result)
}

Use Cases

Transforming API specifications into MCP tools for seamless integration with AI agents, enhancing the development process.
Validating OpenAPI specifications to detect and fix errors early.
Using HTTP server mode to allow external applications to call the API.
Utilizing as a CLI tool to automate API operations from scripts.