API Tester (OpenAI) MCP server

Integrates with OpenAI's APIs to provide tools for API testing, text generation, image creation, and HTTP request handling within applications.
Back to servers
Setup instructions
Provider
Vikrant Khedkar
Release date
Mar 03, 2025
Language
Python

This MCP server allows Claude to make API requests on your behalf, providing tools for testing various APIs, including a dedicated integration with OpenAI's APIs. You can use it to test HTTP requests, OpenAI's GPT models, and generate images with DALL-E without sharing your API keys directly in the chat.

Prerequisites

  • Python 3.10 or higher
  • MCP SDK 1.2.0 or higher

Installation

Install the required dependencies:

pip install "mcp[cli]" httpx python-dotenv

Configuration

Set your OpenAI API key using one of these methods:

Environment Variables

# On Windows (PowerShell)
$env:OPENAI_API_KEY = "your-api-key"

# On Windows (Command Prompt)
set OPENAI_API_KEY=your-api-key

# On macOS/Linux
export OPENAI_API_KEY="your-api-key"

Using a .env File (Recommended)

Create a .env file in the project directory:

OPENAI_API_KEY=your_openai_api_key_here

Running the Server

Start the MCP server with:

python main.py

Using with Claude

Once your server is running, you can connect it to Claude for Desktop by configuring it in the Claude Desktop config file.

Available Tools

General API Tools

  • get_request: Make GET requests to any URL
  • post_request: Make POST requests with JSON bodies
  • put_request: Make PUT requests with JSON bodies
  • delete_request: Make DELETE requests

OpenAI-Specific Tools

  • openai_chat_completion: Generate text using OpenAI's chat models
  • openai_image_generation: Generate images using DALL-E

Usage Examples

General API Testing

To fetch data from an API:

Use the get_request tool to fetch data from https://jsonplaceholder.typicode.com/posts/1

To send data to an API:

Use the post_request tool to send data to https://jsonplaceholder.typicode.com/posts with this JSON body: {"title": "Test Post", "body": "This is a test", "userId": 1}

Using OpenAI Tools

To generate text with GPT-4:

Use the openai_chat_completion tool with:
prompt: "Write a short poem about artificial intelligence"
system_message: "You are a helpful assistant that writes creative poetry"
model: "gpt-4"

To generate images with DALL-E:

Use the openai_image_generation tool with:
prompt: "A futuristic city with flying cars and tall glass buildings at sunset"
size: "1024x1024"

Security Considerations

  • Your OpenAI API key remains on your server and isn't exposed in the chat
  • API usage counts against your OpenAI quota and may incur charges
  • For production use, always set the API key as an environment variable or use a .env file

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 "api-tester-openai" '{"command":"python","args":["main.py"]}'

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": {
        "api-tester-openai": {
            "command": "python",
            "args": [
                "main.py"
            ]
        }
    }
}

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": {
        "api-tester-openai": {
            "command": "python",
            "args": [
                "main.py"
            ]
        }
    }
}

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