This project installs the Model Context Protocol Server (MCP), which provides configured REST APIs as context for Large Language Models (LLMs). It enables LLMs to interact with REST APIs and perform API calls using prompts. Currently, it supports HTTP API calls (GET
, PUT
, POST
, PATCH
).
Install the package:
shell
pip install openapi_mcp_server
Create a .env
file in the project folder with the minimum required values for OPENAPI_SPEC_PATH
and API_BASE_URL
. A sample .env
file is available here.
Test the server:
shell
uv run openapi_mcp_server
To configure the MCP server for Claud Desktop, use the following JSON structure:
{
"mcpServers": {
"openapi_mcp_server": {
"command": "uv",
"args": ["run", "openapi_mcp_server"],
"env": {
"DEBUG": "1",
"API_BASE_URL": "https://petstore.swagger.io/v2",
"OPENAPI_SPEC_PATH": "https://petstore.swagger.io/v2/swagger.json",
"API_HEADERS": "Accept:application/json",
"API_WHITE_LIST": "addPet,updatePet,findPetsByStatus"
}
}
}
}
DEBUG
: Enable debug logging (optional, default is False
).OPENAPI_SPEC_PATH
: Path to the OpenAPI document (required).API_BASE_URL
: Base URL for API requests (required).API_HEADERS
: Headers to include in API requests (optional).API_WHITE_LIST
: Whitelisted operation IDs in list format (optional).API_BLACK_LIST
: Blacklisted operation IDs in list format (optional).HTTP_PROXY
: HTTP proxy details (optional).HTTPS_PROXY
: HTTPS proxy details (optional).NO_PROXY
: No proxy details (optional).Contributions are welcome! Feel free to submit a Pull Request.
This project is licensed under the MIT License.
mkdir -m777 openapi_mcp_server
cd openapi_mcp_server
uv init
uv add mcp[cli] pydantic python-dotenv requests
uv add --dev twine setuptools
uv sync
uv run openapi_mcp_server
uv build
pip install --force-reinstall --no-deps .\dist\openapi_mcp_server-*fileversion*.whl
export TWINE_USERNAME="rahgadda"
export TWINE_USERNAME="<<API Key>>"
uv run twine upload --verbose dist/*