MCP OpenAI扩展
用于OpenAI的扩展模型上下文协议(MCP)服务器,支持GPT-5系列,包括专门的Codex模型。
特性
- ✅ GPT-5家族支持(GPT-5、GPT-5.1、GPT-5.2,聊天最新/专业/迷你/纳米/codex变体)
- ✅ GPT-4o和o1系列支持
- ✅ 响应API支持 用于Codex模型(
*codex*) - ✅ 自动选择API端点(针对codex的响应API,针对其他人的聊天完成)
- ✅ 适用于Claude Desktop、Claude Code和任何兼容MCP的客户端
支持的型号
GPT-5系列
gpt-5-codex- 专门用于代码和设计审查 (默认情况下,使用Responses API)gpt-5.3-codexgpt-5.3-codex-sparkgpt-5.2-chat-latestgpt-5.2-progpt-5.2gpt-5.2-codexgpt-5.1-chat-latestgpt-5.1-codexgpt-5.1-codex-minigpt-5.1-codex-maxgpt-5.1gpt-5-chat-latestcodex-mini-latestgpt-5-progpt-5gpt-5-minigpt-5-nano
注:较新的Codex模型ID在API请求中工作之前可能需要帐户级访问权限。
GPT-4系列
gpt-4o-GPT-4 Omnigpt-4o-mini-较小的GPT-4o
o1系列
o1-推理模型o1-preview-推理模型预览o1-mini-较小的推理模型
安装
NPM(推荐)
npm install -g @kent013/mcp-openai-extended通过npx(GitHub)
npx github:kent013/mcp-openai-extended本地开发
git clone https://github.com/kent013/mcp-openai-extended.git
cd mcp-openai-extended
npm install
npm run build配置
⚠️ 安全警告
切勿将您的API密钥提交给版本控制!
- 保持你的
OPENAI_API_KEY在环境变量或安全配置文件中 - 将包含API密钥的配置文件添加到
.gitignore - 如果您意外提交了API密钥, 立即撤销 在https://platform.openai.com/api-keys
- 定期旋转API键
克劳德桌面/克劳德代码
添加到您的 .mcp.json 或 claude_desktop_config.json:
{
"mcpServers": {
"openai": {
"command": "npx",
"args": ["-y", "@kent013/mcp-openai-extended"],
"env": {
"OPENAI_API_KEY": "your-openai-api-key-here"
}
}
}
}本地开发
{
"mcpServers": {
"openai": {
"command": "node",
"args": ["/path/to/mcp-openai-extended/dist/index.js"],
"env": {
"OPENAI_API_KEY": "your-openai-api-key-here"
}
}
}
}用法
服务器提供了一个工具: openai_chat
默认型号为 gpt-5-codex (自动使用响应API)。
示例:使用GPT-5.2 Codex进行设计审查(默认)
{
"name": "openai_chat",
"arguments": {
"messages": [
{
"role": "system",
"content": "You are an experienced system architect."
},
{
"role": "user",
"content": "Review this code:\n\n```php\n$user = User::find($id);\nMail::to($user->email)->send(new TestMail());\n```"
}
]
// model defaults to "gpt-5-codex"
}
}示例:GPT-5聊天最新的一般推理
{
"name": "openai_chat",
"arguments": {
"messages": [
{
"role": "user",
"content": "Explain quantum computing in simple terms"
}
],
"model": "gpt-5-chat-latest"
}
}API终点
此服务器自动选择适当的OpenAI API终结点:
- 响应API (
/v1/responses):适用于Codex型号(*codex*) - 聊天完成API (
/v1/chat/completions):适用于所有其他型号(gpt-4o、gpt-5-chat-latest等)
环境变量
OPENAI_API_KEY(必需):您的OpenAI API密钥
获取API密钥
- 访问https://platform.openai.com/api-keys
- 创建新的API密钥
- 安全存放- 永远不要将其共享或提交给版本控制
- 设置适当的使用限制,以防止意外收费
最佳实践
- 使用特定于环境的API密钥(开发、阶段、生产)
- 在您的OpenAI帐户中启用使用警报
- 定期审查API的使用情况和旋转键
- 使用OpenAI的API密钥限制功能来限制密钥权限
发展
# Install dependencies
npm install
# Build
npm run build
# Run locally
node dist/index.js贡献
欢迎投稿!请随时提交拉取请求。
许可证
麻省理工学院
学分
基于 mcp openai 通过mzxrai。
扩展以支持GPT-5系列和专用型号。
