OpenAI MCP server

Integrates with OpenAI's API to enable direct querying of various language models, supporting efficient text generation and question answering tasks.
Back to servers
Provider
Pierre Brunelle
Release date
Feb 21, 2025
Language
Python
Stats
2 stars

This MCP server enables direct communication with OpenAI models through Claude using the MCP protocol. It supports o3-mini and gpt-4o-mini models, allowing you to query OpenAI directly from within Claude's interface.

Installation

Prerequisites

  • Python 3.10 or higher
  • OpenAI API key
  • Claude Desktop application

Setting Up the Server

  1. Clone the repository and install:
git clone https://github.com/thadius83/mcp-server-openai
cd mcp-server-openai

# Install the package
pip install .
  1. Configure MCP Settings:

Modify your Claude Desktop MCP settings configuration file:

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

Add the following to your existing configuration:

{
  "mcpServers": {
    "github.com/thadius83/mcp-server-openai": {
      "command": "python",
      "args": [
        "-m",
        "src.mcp_server_openai.server",
        "--openai-api-key",
        "your-openai-api-key"
      ],
      "env": {
        "PYTHONPATH": "/path/to/mcp-server-openai"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}
  1. Insert your OpenAI API key in the configuration where it says "your-openai-api-key".

  2. Set the correct PYTHONPATH to point to the full path of your cloned repository.

  3. Restart Claude after saving the configuration changes.

Using the MCP Server

Basic Usage

Once installed, you can query OpenAI models directly from Claude using the ask-openai tool:

<use_mcp_tool>
<server_name>github.com/thadius83/mcp-server-openai</server_name>
<tool_name>ask-openai</tool_name>
<arguments>
{
  "query": "What's the difference between Lists and Tuples in Python?",
  "model": "o3-mini"
}
</arguments>
</use_mcp_tool>

Model Options

The server supports two OpenAI models:

  • o3-mini (default): Optimized for concise, efficient responses
  • gpt-4o-mini: Provides more detailed and comprehensive answers

You can specify which model to use in your query:

{
  "query": "Explain quantum computing in simple terms",
  "model": "gpt-4o-mini"
}

If you omit the model parameter, it defaults to o3-mini.

Troubleshooting

Common Issues

  1. Server Not Connecting:

    • Verify your OpenAI API key is valid
    • Check that PYTHONPATH in your configuration points to the correct directory
    • Ensure Python 3.10+ is installed
  2. Invalid Configuration:

    • Make sure the server name is exactly github.com/thadius83/mcp-server-openai
    • Confirm your JSON configuration syntax is correct
  3. No Response from Server:

    • Check your internet connection
    • Verify your OpenAI account has sufficient API credits
    • Try restarting Claude and the MCP server

Verifying Installation

To test if the server is working correctly, try a simple query:

<use_mcp_tool>
<server_name>github.com/thadius83/mcp-server-openai</server_name>
<tool_name>ask-openai</tool_name>
<arguments>
{
  "query": "Hello, are you working correctly?"
}
</arguments>
</use_mcp_tool>

If properly configured, you should receive a response from the OpenAI model.

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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