OpenAPI based MCP
Project description
OpenAPI MCP
OpenAPI based MCP that creates a FastMCP server from an OpenAPI specification.
Build and Install
This project uses uv for dependency management and requires Python 3.12 or higher.
Prerequisites
- Install Python 3.12 or higher
- Install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
Installation Steps
-
Clone the repository:
git clone <repository-url> cd openapimcp
-
Install the project in editable mode:
uv pip install -e .
This will:
- Install all required dependencies (
fastmcpandhttpx) - Create the
openapimcpcommand-line tool - Make the project available for development
- Install all required dependencies (
-
Verify the installation:
openapimcp --help
Alternative: Using uvx
You can also run the tool directly without installation using uvx:
uvx openapimcp
This is particularly useful for the example configurations in the examples directory.
Usage
The openapimcp command-line tool creates a FastMCP server from an OpenAPI specification. The tool is configured using environment variables.
Configuration
The following environment variables are available for configuration:
API_BASE_URL: The base URL of the API.OPENAPI_SPEC_URL: The URL of the OpenAPI specification.SERVER_NAME: The name of the MCP server.BEARER_TOKEN: The bearer token for authentication.USERNAME: The username for basic authentication.PASSWORD: The password for basic authentication.
Running the server
To run the server, you can use the openapimcp script, which is created during the installation. You need to set the environment variables before running the script.
For example:
export API_BASE_URL="http://localhost:3000/v1"
export OPENAPI_SPEC_URL="http://localhost/local/openapi/gal-inq.json"
export SERVER_NAME="Galicia Inquiries API"
openapimcp
Examples
The examples directory contains several example configurations that can be used to run the server. These examples are in the form of JSON files that define the environment variables for different services.
For example, to run the gal-mock example, you can use the environment variables defined in examples/gal-mock/gal-inq.json.
{
"mcpServers": {
"galInq": {
"command": "uvx",
"args": [
"openapimcp"
],
"env": {
"SERVER_NAME": "Galicia Inquiries API",
"OPENAPI_SPEC_URL": "http://localhost/local/openapi/gal-inq.json",
"API_BASE_URL": "http://localhost:3000/v1"
}
}
}
}
This configuration can be used with a tool that consumes mcpServers definitions to start the MCP server with the specified environment.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geaimcpopenapi-1.0.0.tar.gz.
File metadata
- Download URL: geaimcpopenapi-1.0.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
340ef6bfa664316632dcc00fb60c30c08ff02564c065e330abff0077c4593b73
|
|
| MD5 |
48356104f0a4b173fd91c60d602fb20e
|
|
| BLAKE2b-256 |
7b0a506d35ae803f9ab3690732b8e772ef9b71e95f797515cff622444c0d8ae1
|
File details
Details for the file geaimcpopenapi-1.0.0-py3-none-any.whl.
File metadata
- Download URL: geaimcpopenapi-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9aa4e2e0fe41c9244e487c7b182100d830350e6e32b24afff23201627746dcce
|
|
| MD5 |
d3486a7646fd0c5e6d9cef141edee6e8
|
|
| BLAKE2b-256 |
6b7c28eb65b1ac1ca87247a76e45a5cc819332435f1b208fab610dac13c0ec10
|