OpenAI MCP Server

OpenAI MCP Server

Enables advanced OpenAI GPT model integration with Claude through 5 specialized tools including GPT-5 reasoning, token optimization, context management, batch processing, and model comparison. Features intelligent fallback mechanisms and task-specific system prompts for enhanced AI capabilities.

Category
访问服务器

README

OpenAI MCP Server

Advanced OpenAI GPT-5 MCP Server with multiple tools, intelligent reasoning, and comprehensive AI utilities for Claude Code integration.

✨ Features

🎯 Multiple AI Tools

  • 5 Specialized Tools: From basic GPT calling to advanced batch processing
  • Modular Architecture: Each tool is independently developed and maintained
  • Extensible Framework: Easy to add new tools and capabilities

🧠 Advanced AI Capabilities

  • GPT-5 by Default: Latest reasoning model with intelligent fallback to GPT-4o
  • Advanced Reasoning: Support for reasoning_effort and verbosity parameters
  • Hybrid Intelligence: GPT-5 reasoning + GPT-4o content generation
  • Task-Specific Optimization: Specialized system prompts for different domains

🚀 Professional Features

  • Token Analysis & Optimization: Analyze and optimize text for token efficiency
  • Context Window Management: Smart context optimization with multiple strategies
  • Batch Processing: Process multiple prompts in parallel with concurrency control
  • Model Management: List and compare available OpenAI models

🔧 Technical Excellence

  • stdio Transport: No ports needed, simple integration
  • Claude Context Integration: Leverages Claude session context
  • NPX Ready: Install and run with npx
  • TypeScript: Full type safety and modern JavaScript features
  • Error Handling: Comprehensive error handling and fallback mechanisms

Quick Start

Installation

# Global install
npm install -g openai-mcp-server

# Or use npx (no installation needed)
npx openai-mcp-server

Setup

  1. Get your OpenAI API key from https://platform.openai.com/api-keys

  2. Set environment variable:

export OPENAI_API_KEY="your-api-key-here"
  1. Add to Claude Code:
claude mcp add --transport stdio openai-gpt5 \\
  "OPENAI_API_KEY=your-key-here npx openai-mcp-server"

Available Tools

The server provides 5 specialized tools:

1. call_gpt5 - Enhanced GPT Model Calling

Call OpenAI GPT models with optimized system prompts and advanced reasoning.

Key Parameters:

  • prompt (string, required): Your question or request
  • taskType (enum, required): analysis, generation, reasoning, coding
  • domain (string, optional): Specific domain like "security", "performance", "architecture"
  • reasoningEffort (enum, optional): GPT-5 reasoning depth - "minimal", "low", "medium", "high"
  • verbosity (enum, optional): GPT-5 response detail level - "low", "medium", "high"
  • model (string, optional): Override model ("gpt-5", "gpt-4o", "gpt-4")

2. list_models - Model Information

List available OpenAI models with capabilities and metadata.

Parameters:

  • includeDetails (boolean, optional): Include detailed model information

3. analyze_token_usage - Token Optimization

Analyze text for token usage and get optimization suggestions.

Parameters:

  • text (string, required): Text to analyze
  • model (string, optional): Model for token counting
  • includeOptimization (boolean, optional): Include optimization suggestions

Features:

  • Token count estimation
  • Text composition analysis
  • Cost calculation
  • Optimization recommendations

4. optimize_context_window - Context Management

Optimize long context for efficient token usage while preserving important information.

Parameters:

  • context (string, required): Context text to optimize
  • maxTokens (number, required): Maximum tokens for optimized context
  • preservationStrategy (enum, optional): Strategy for preserving context
    • important_first: Preserve sentences with keywords and importance indicators
    • recent_first: Preserve recent content with keyword protection
    • semantic: Preserve semantically similar content
    • balanced: Balance importance and recency (default)
  • preserveKeywords (array, optional): Keywords to preserve

Use Cases:

  • Large document summarization
  • Chat history optimization
  • Context window management

5. process_batch_prompts - Batch Processing

Process multiple prompts efficiently with parallel execution support.

Parameters:

  • prompts (array, required): Array of prompts to process
  • taskType (enum, optional): Task type for system prompt optimization
  • parallel (boolean, optional): Process prompts in parallel (default: true)
  • maxConcurrency (number, optional): Maximum concurrent requests (1-10, default: 5)
  • model (string, optional): Model to use for all prompts

Features:

  • Parallel processing with concurrency control
  • Automatic retry and error handling
  • Performance metrics and cost estimation
  • Progress tracking

Usage Examples

# Basic GPT-5 call with reasoning
claude mcp call openai-gpt5 call_gpt5 '{
  "prompt": "Analyze this code for security vulnerabilities",
  "taskType": "analysis", 
  "domain": "security",
  "reasoningEffort": "high"
}'

# Token analysis
claude mcp call openai-gpt5 analyze_token_usage '{
  "text": "Your text here...",
  "includeOptimization": true
}'

# Batch processing
claude mcp call openai-gpt5 process_batch_prompts '{
  "prompts": ["Question 1", "Question 2", "Question 3"],
  "parallel": true,
  "maxConcurrency": 3
}'

# Context optimization
claude mcp call openai-gpt5 optimize_context_window '{
  "context": "Very long text...",
  "maxTokens": 1000,
  "preservationStrategy": "important_first",
  "preserveKeywords": ["key", "important"]
}'

Environment Variables

Create a .env file or set environment variables:

# Required
OPENAI_API_KEY=your_openai_api_key_here

# Optional  
OPENAI_MODEL=gpt-5                    # Default model (gpt-5, gpt-4o, gpt-4)
OPENAI_BASE_URL=https://api.openai.com/v1  # Custom API endpoint
DEBUG=false                           # Enable debug logging

Development

# Clone and install
git clone <repository>
cd openai-mcp-server
npm install

# Build
npm run build

# Development with auto-reload
npm run dev

# Test
npm test

Integration with Claude Code

Once configured, Claude can automatically use this comprehensive MCP server to:

🎯 Core AI Capabilities

  1. Enhanced Analysis: Deep code analysis with GPT-5 reasoning capabilities
  2. Alternative Perspectives: Get different AI viewpoints on complex problems
  3. Creative Problem Solving: Leverage GPT's creativity for brainstorming and innovation
  4. Specialized Domain Expertise: Task-specific optimized prompts for security, performance, architecture

🚀 Advanced Features

  1. Token Optimization: Analyze and optimize prompts for cost-effectiveness
  2. Context Management: Handle large documents and conversations efficiently
  3. Batch Operations: Process multiple requests simultaneously for productivity
  4. Model Selection: Choose optimal models based on task requirements

💡 Smart Integration

Claude will intelligently decide when and which tools to use based on:

  • Task complexity and type
  • Content length and optimization needs
  • Batch processing opportunities
  • Resource and cost considerations

🔧 Professional Workflows

  • Development: Code analysis, review, and optimization
  • Content: Large document processing and summarization
  • Research: Multi-query analysis and comparison
  • Optimization: Token usage and cost management

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选