OpenAI MCP MCP server

Provides a high-performance bridge between OpenAI and Anthropic models with prompt templating, response streaming, and efficient caching for applications requiring customizable LLM access.
Back to servers
Setup instructions
Provider
Arthur Colle
Release date
Mar 08, 2025
Language
Python
Stats
33 stars

This Python-based MCP server provides a powerful natural language interface for software development tasks with support for multiple LLM providers including OpenAI and Anthropic. It offers real-time visualization, cost management, and Model Context Protocol integration for an enhanced coding experience.

Installation

First, clone the repository and install the required dependencies:

pip install -r requirements.txt

Create a .env file with your API keys:

# Choose one or more providers
OPENAI_API_KEY=your_openai_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here

# Optional model selection
OPENAI_MODEL=gpt-4o
ANTHROPIC_MODEL=claude-3-opus-20240229

Using the CLI

Run the CLI with the default provider:

python claude.py chat

Specify a provider and model:

python claude.py chat --provider openai --model gpt-4o

Set a budget limit to manage costs:

python claude.py chat --budget 5.00

Running as an MCP Server

Start the Model Context Protocol server:

python claude.py serve

For development mode with the MCP Inspector:

python claude.py serve --dev

Configure the host and port:

python claude.py serve --host 0.0.0.0 --port 8000

Specify additional dependencies:

python claude.py serve --dependencies pandas numpy

Load environment variables from a file:

python claude.py serve --env-file .env

Using the MCP Client

Connect to an MCP server using the built-in client:

python claude.py mcp-client path/to/server.py

Specify a specific model:

python claude.py mcp-client path/to/server.py --model claude-3-5-sonnet-20241022

Try the included example server:

# In terminal 1 - start the server
python examples/echo_server.py

# In terminal 2 - connect with the client
python claude.py mcp-client examples/echo_server.py

Multi-Agent Mode

Launch a multi-agent client with synchronized agents:

python claude.py mcp-multi-agent path/to/server.py

Use a custom agent configuration:

python claude.py mcp-multi-agent path/to/server.py --config examples/agents_config.json

Available Tools

The system includes several powerful tools:

  • View: Read files with optional line limits
  • Edit: Modify files with precise text replacement
  • Replace: Create or overwrite files
  • GlobTool: Find files by pattern matching
  • GrepTool: Search file contents using regex
  • LS: List directory contents
  • Bash: Execute shell commands

Chat Commands

While in the chat interface, you can use these commands:

  • /help: Show available commands
  • /compact: Compress conversation history to save tokens
  • /version: Show version information
  • /providers: List available LLM providers
  • /cost: Show cost and usage information
  • /budget [amount]: Set a budget limit
  • /quit, /exit: Exit the application

Using with Claude Desktop

To use with Claude Desktop:

  1. Start the MCP server:

    python claude.py serve
    
  2. Open the configuration page:

    http://localhost:8000
    
  3. Follow the instructions to configure Claude Desktop with the provided JSON configuration.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "openai-mcp" '{"command":"python","args":["claude.py","serve"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "openai-mcp": {
            "command": "python",
            "args": [
                "claude.py",
                "serve"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "openai-mcp": {
            "command": "python",
            "args": [
                "claude.py",
                "serve"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later