JJsilvera1/OpenAI-WebSearch-MCP
If you are the rightful owner of OpenAI-WebSearch-MCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The OpenAI Web Search MCP Server is a Model Context Protocol server that enables real-time web search capabilities using OpenAI's `gpt-4o-mini-search-preview` model, providing automatic citations and location-aware results.
OpenAI Web Search MCP Server
A Model Context Protocol (MCP) server that provides real-time web search capabilities using OpenAI's gpt-4o-mini-search-preview
model. This server enables Claude Code, Claude Desktop, and other MCP clients to perform current web searches with automatic citations and location-aware results.
Features
- š Real-time web search using OpenAI's latest search-enabled model
- š Automatic citations with source URLs and titles
- š Location-aware searches with country/city/region support
- ā” Configurable search context (low/medium/high) for speed vs depth
- š Secure API key handling through environment variables
- šÆ Domain-specific searches for current information, pricing, availability checks
Installation
Prerequisites
- Python 3.8 or higher
- OpenAI API key with access to
gpt-4o-mini-search-preview
model
Quick Install
# Clone the repository
git clone https://github.com/your-username/openai-websearch-mcp.git
cd openai-websearch-mcp
# Install dependencies
pip install -r requirements.txt
# Set your OpenAI API key
export OPENAI_API_KEY="your-openai-api-key-here"
Using pip (when published)
pip install openai-websearch-mcp
Configuration
Claude Desktop
Add to your Claude Desktop configuration file (~/.claude/claude.json
):
{
"mcpServers": {
"openai-web-search": {
"command": "python",
"args": ["/path/to/openai-websearch-mcp/server.py"],
"env": {
"OPENAI_API_KEY": "your-openai-api-key-here"
}
}
}
}
Claude Code
Add to your Claude Code configuration (~/.claude/claude.json
):
{
"projects": {
"*": {
"mcpServers": {
"openai-web-search": {
"command": "python",
"args": ["/path/to/openai-websearch-mcp/server.py"],
"env": {
"OPENAI_API_KEY": "your-openai-api-key-here"
}
}
},
"allowedTools": [
"mcp__openai_web_search__openai_web_search"
]
}
}
}
Other MCP Clients
The server follows the standard MCP protocol and can be used with any MCP-compatible client by configuring it to run the server.py
script with the appropriate environment variables.
Usage
Basic Search
Once configured, you can use the web search functionality through your MCP client:
Search for "current Bitcoin price"
Location-Aware Search
Search for "best restaurants" with location "New York", "NY", "US"
Context Control
- Low context: Fastest searches for quick answers
- Medium context: Balanced speed and comprehensiveness (default)
- High context: Most comprehensive results for complex queries
Tool Parameters
The openai_web_search
tool accepts the following parameters:
Parameter | Type | Required | Description |
---|---|---|---|
query | string | Yes | The search query or question |
context_size | string | No | "low", "medium", or "high" (default: "medium") |
country | string | No | Two-letter ISO country code (e.g., "US", "GB") |
city | string | No | City name for location-based search |
region | string | No | Region/state for location-based search |
Examples
Current Information
- "What's the current weather in London?"
- "Latest news about OpenAI"
- "Bitcoin price today"
Domain Research
- "Check domain availability for example.com"
- "Domain registration pricing"
Market Research
- "Current stock price for AAPL"
- "AWS pricing for EC2 instances"
- "iPhone 15 availability"
Location-Specific
- "Best coffee shops in Seattle" (with city: "Seattle", region: "WA", country: "US")
- "Current time in Tokyo" (with city: "Tokyo", country: "JP")
Response Format
The server returns search results with:
- Main Content: Comprehensive answer to your query
- Sources: Automatic citations with clickable links
- Metadata: Search context and model information
Example response:
The current Bitcoin price is $67,234.52 USD, up 2.3% in the last 24 hours...
š Sources:
1. [CoinGecko - Bitcoin Price](https://www.coingecko.com/en/coins/bitcoin)
2. [CoinMarketCap - BTC](https://coinmarketcap.com/currencies/bitcoin/)
Development
Running Tests
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/
# Run with coverage
pytest tests/ --cov=server
Code Formatting
# Format code
black server.py
# Check linting
flake8 server.py
# Type checking
mypy server.py
Testing the Server
You can test the server directly:
# Set your API key
export OPENAI_API_KEY="your-api-key"
# Test the server
python server.py
Troubleshooting
Common Issues
-
"OPENAI_API_KEY environment variable not set"
- Ensure your OpenAI API key is properly set in the environment
- Verify the key has access to
gpt-4o-mini-search-preview
model
-
"Server timeout" or connection issues
- Check your internet connection
- Verify OpenAI API status
- Try reducing context_size to "low" for faster responses
-
"Tool not found" in Claude
- Ensure the MCP server is properly configured in your client
- Verify the tool name is correctly added to allowedTools
- Restart your MCP client after configuration changes
-
Unicode/encoding errors on Windows
- This is a display issue and doesn't affect functionality
- The search results are still accurate
Debug Mode
Enable debug logging by setting:
export PYTHONPATH="."
export OPENAI_LOG=debug
python server.py
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the file for details.
Acknowledgments
- Built on the Model Context Protocol
- Powered by OpenAI's search-enabled models
- Designed for seamless integration with Claude Code and Claude Desktop
Support
- š Bug Reports: GitHub Issues
- š¬ Discussions: GitHub Discussions
- š Documentation: See the
docs/
directory for detailed guides
Note: This is an independent project and is not officially affiliated with OpenAI or Anthropic.