home / mcp / openai api mcp server

OpenAI API MCP Server

Provides an MCP interface to the OpenAI API specification, enabling clients to query model context and capabilities.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "ag2-mcp-servers-openai-api": {
      "command": "python",
      "args": [
        "mcp_server/main.py",
        "stdio"
      ],
      "env": {
        "CONFIG": "A JSON string containing the configuration",
        "SECURITY": "Environment variables for security parameters (e.g., API keys)",
        "CONFIG_PATH": "Path to a JSON configuration file such as mcp_server/mcp_config.json"
      }
    }
  }
}

You run an MCP (Model Context Protocol) Server to expose a model’s context and actions over a standard, interoperable transport. This server hosts the OpenAI API specification via MCP so clients can interact with it in a consistent, programmable way. It’s useful when you want a local or controlled MCP endpoint that mirrors the OpenAI API surface for integration, testing, or experimentation.

How to use

Start the MCP server in stdio mode and connect your MCP client to its standard input/output channel. The server is designed to be invoked locally and communicates with clients through the chosen transport, enabling structured request/response flows and streaming where supported.

How to install

Prerequisites: Python 3.9+ and a working Python toolchain (pip and uv if you plan to run via uv). Then follow these concrete steps to set up and run the server.

# Step 1: Clone the repository
git clone <repository-url>
cd mcp-server

# Step 2: Install dependencies (development mode)
pip install -e ".[dev]"

# Optional alternative using uv
uv pip install --editable ".[dev]"

Additional sections

Running the server is done with a Python command that starts the MCP server in stdio mode. You can also configure environment variables to control the server’s behavior.

Environment variables you may use (descriptions and example values shown):

CONFIG_PATH=/path/to/mcp_config.json
CONFIG={"transport": "stdio"}
SECURITY=API_KEY

Available tools

ruff

Linting and formatting tool used to ensure code quality and consistency.

mypy

Static type checker that verifies type hints across the codebase.

pytest

Testing framework used to run unit and integration tests.

static-analysis

Script-based static analysis including bandit and semgrep to detect security and quality issues.

pre-commit

Pre-commit hooks configured to run on each commit to enforce standards.