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.
Install the required dependencies:
pip install "mcp[cli]" httpx python-dotenv
Set your OpenAI API key using one of these methods:
# 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"
Create a .env
file in the project directory:
OPENAI_API_KEY=your_openai_api_key_here
Start the MCP server with:
python main.py
Once your server is running, you can connect it to Claude for Desktop by configuring it in the Claude Desktop config file.
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}
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"
.env
fileTo 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.
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.
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"
]
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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