GPT-MCP Bridge

GPT-MCP Bridge

Enables Claude and other MCP-compatible tools to communicate with OpenAI's GPT models (GPT-5, GPT-5-mini, o3) with conversation history and session management. Features advanced controls like reasoning effort settings, token tracking, and parallel conversation sessions for efficient AI workflows.

Category
访问服务器

README

GPT-MCP Bridge

A Model Context Protocol (MCP) server that enables Claude Code and other MCP-compatible tools to communicate with OpenAI's GPT models, featuring conversation history, session management, and advanced controls.

Features

🎯 Core Capabilities

  • Conversation History - Maintain context across multiple interactions
  • Session Management - Create, manage, and track parallel conversation sessions
  • Multi-Model Support - GPT-5, GPT-5-mini, and o3 models
  • Advanced Controls - Reasoning effort and verbosity parameters
  • Token Tracking - Monitor usage per session for cost management
  • Error Handling - Robust error recovery and session validation

💡 Key Benefits

  • 70% Token Savings - Reuse context without repeating information
  • Parallel Workflows - Handle multiple independent tasks simultaneously
  • Adaptive Responses - Control response length with verbosity settings
  • Smart Model Routing - Choose optimal model for each task

Installation

  1. Clone the repository
git clone https://github.com/yourusername/gpt-mcp.git
cd gpt-mcp
  1. Install dependencies
npm install
  1. Configure environment
cp .env.example .env
# Edit .env and add your OpenAI API key
  1. Build the project
npm run build

Usage

Running the Server

Development mode:

npm run dev

Production mode:

npm start

MCP Tools

1. askGPT

Send prompts to GPT models with optional conversation context.

Parameters:

  • model (required): "gpt-5" | "gpt-5-mini" | "o3"
  • prompt (required): Your question or request
  • reasoning_effort (optional): "minimal" | "low" | "medium" | "high"
  • verbosity (optional): "low" | "medium" | "high"
  • session_id (optional): Session ID for conversation context

Example:

{
  "model": "gpt-5",
  "prompt": "Explain async/await",
  "reasoning_effort": "medium",
  "verbosity": "low",
  "session_id": "abc-123"
}

2. createSession

Create a new conversation session for maintaining context.

Parameters:

  • system_prompt (optional): System message to set context

Returns: Session ID for use in subsequent calls

3. clearSession

Clear a conversation session and its history.

Parameters:

  • session_id (required): Session to clear

4. listSessions

List all active conversation sessions.

Returns: Array of session information including ID, creation time, message count, and token usage

5. getSessionInfo

Get detailed information about a specific session.

Parameters:

  • session_id (required): Session to query

Configuration

Environment Variables

  • OPENAI_API_KEY - Your OpenAI API key (required)

Session Limits

  • Max tokens per session: 100,000
  • Max messages per session: 100
  • Session expiry: 24 hours
  • Auto-cleanup of expired sessions

Example Workflows

Multi-Step Debugging

// Create a session for debugging
session_id = createSession("Help debug React component")

// Step 1: Present the problem
askGPT({
  model: "gpt-5",
  prompt: "My component re-renders on every keystroke",
  session_id: session_id
})

// Step 2: Ask follow-up (context maintained)
askGPT({
  model: "gpt-5",
  prompt: "How do I fix this?",
  session_id: session_id
})

Parallel Tasks

// Create separate sessions for different tasks
bugSession = createSession("Fixing memory leak")
featureSession = createSession("Adding authentication")

// Work on both independently
askGPT({ model: "gpt-5", prompt: "...", session_id: bugSession })
askGPT({ model: "gpt-5-mini", prompt: "...", session_id: featureSession })

Model Selection Guide

GPT-5

  • Best for: Complex tasks, code generation, detailed analysis
  • Reasoning levels: minimal, low, medium, high
  • Use when: Quality is priority over speed

GPT-5-mini

  • Best for: Simple queries, quick responses, cost optimization
  • Reasoning levels: minimal, low, medium, high
  • Use when: Speed and cost are priorities

o3

  • Best for: Logic puzzles, mathematical reasoning, complex problem-solving
  • Reasoning levels: Not applicable (always maximum)
  • Use when: Deep reasoning is required

Architecture

gpt-mcp/
├── src/
│   ├── index.ts              # MCP server setup
│   ├── services/
│   │   ├── openai.ts         # OpenAI API integration
│   │   └── session-manager.ts # Session management
│   ├── tools/
│   │   ├── askGPT.ts         # Main GPT interface
│   │   └── session-tools.ts  # Session management tools
│   └── types/
│       └── index.ts          # TypeScript interfaces

Development

Building

npm run build

Type Checking

npx tsc --noEmit

Project Structure

  • ES Modules - Uses .js extensions in imports
  • Strict TypeScript - Full type safety
  • MCP SDK - Built on official MCP TypeScript SDK

Requirements

  • Node.js >= 18
  • OpenAI API key
  • MCP-compatible client (Claude Code, etc.)

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please use the GitHub issue tracker.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选