OpenAI MCP Server について
AI アシスタントから OpenAI API を利用する MCP サーバーです。テキスト生成、画像生成、モデル一覧の取得、生成設定の指定に対応します。
主な機能
- 01OpenAI モデルでのチャット生成
- 02利用可能なモデルの一覧取得
- 03生成パラメーターの設定
- 04gpt-image-1 による画像生成
活用シーン
- 01コーディングエージェントの出力を ChatGPT で確認
- 02プロンプトから画像を生成
- 03タスクに応じた OpenAI モデルの選択
MCP 対応
MCP クライアントに chat_completion、list_models、generate_image ツールを提供し、OpenAI API へのリクエストを仲介します。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
OpenAI MCP Server
A Model Context Protocol (MCP) server that enables AI assistants to interact with OpenAI's ChatGPT API.
Features
- Chat Completion: Generate text using OpenAI's latest language models (GPT-4.1, GPT-4.1-mini, GPT-4.1-nano, GPT-4o, o1, o1-pro, o3, o4-mini)
- List Models: Retrieve available OpenAI models
- Configurable Parameters: Control temperature, max tokens, and other generation settings
Prerequisites
- Node.js 18 or higher
- OpenAI API key
Installation
# Clone the repository
git clone https://github.com/akiojin/openai-mcp-server.git
cd openai-mcp-server
# Install dependencies
npm install
# Build the project
npm run build
Configuration
- Create a
.envfile in the project root:
cp .env.example .env
- Add your OpenAI API key to the
.envfile:
OPENAI_API_KEY=your_api_key_here
Usage
使用例
このMCPサーバーは、Claude CodeなどのAIアシスタントから呼び出して使用することを想定しています:
- 出力結果の検証: Claude Codeの出力結果をChatGPTに検証させることができます
- 画像生成: Claude Codeでは直接画像生成ができませんが、このMCPサーバー経由でChatGPTのgpt-image-1モデルを使用した画像生成が可能です
- 異なるモデルの活用: 用途に応じて様々なOpenAIモデル(GPT-4.1、o1、o3など)を使い分けることができます
As an MCP Server
Add the server to your MCP client configuration:
{
"servers": {
"openai": {
"command": "node",
"args": ["path/to/openai-mcp-server/dist/index.js"]
}
}
}
Available Tools
chat_completion
Generate text using ChatGPT.
Parameters:
model(string, optional): Model to use (default: "gpt-4.1")messages(array, required): Chat history with role and contenttemperature(number, optional): Sampling temperature 0-2 (default: 0.7)- Note: GPT-5 models only support temperature=1
max_tokens(number, optional): Maximum tokens to generate- For GPT-4 models: defaults to 1000
- For GPT-5 models: optional - if not specified, model automatically allocates necessary tokens
reasoning_effort(string, optional): GPT-5 only - Controls reasoning depthminimal: Fast responses, no reasoning tokenslow: Light reasoningmedium: Standard reasoning (default)high: Deep reasoning for complex analysis
verbosity(string, optional): GPT-5 only - Response length (low/medium/high)
list_models
List all available OpenAI models.
generate_image
Generate images using gpt-image-1 model. Returns file paths for generated images saved in temporary directory.
Parameters:
prompt(string, required): Text description of the desired image(s). Maximum 1000 characters.model(string, optional): Model to use (default: "gpt-image-1")n(number, optional): Number of images to generate 1-10 (default: 1)size(string, optional): Size of images - "1024x1024", "1024x1536", "1536x1024", or "auto" (default: "1024x1024")quality(string, optional): Quality - "low", "medium", "high", or "auto" (default: "auto")background(string, optional): Background type - "opaque" or "transparent" (default: "opaque")
Note: Generated images are saved as temporary files to minimize token usage. The response includes file paths instead of base64 data.
Example:
{
"prompt": "A beautiful sunset over mountains",
"size": "1024x1024",
"quality": "high",
"background": "opaque"
}
Development
# Run in development mode with hot reload
npm run dev
# Build for production
npm run build
# Watch mode for development
npm run watch
Project Structure
openai-mcp-server/
├── src/
│ └── index.ts # Main server implementation
├── dist/ # Compiled JavaScript (generated)
├── .env # Environment variables (create from .env.example)
├── .env.example # Example environment configuration
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # This file
License
MIT License - see LICENSE file for details
Release Process
This project uses semantic-release for automated versioning and publishing.
Commit Message Format
Follow Conventional Commits format:
<type>(<scope>): <description>
[optional body]
[optional footer(s)]
Commit Types
feat:new feature (minor version bump)fix:bug fix (patch version bump)BREAKING CHANGE:breaking change (major version bump)docs:documentation changes (patch version bump)style:formatting changes (patch version bump)refactor:code refactoring (patch version bump)test:adding tests (patch version bump)chore:maintenance tasks (patch version bump)
Examples
# New feature (0.1.0 → 0.2.0)
feat: add streaming support for chat completion
# Bug fix (0.1.0 → 0.1.1)
fix: handle connection timeout properly
# Breaking change (0.1.0 → 1.0.0)
feat: redesign API interface
BREAKING CHANGE: The chat_completion tool now requires a different parameter structure
Helper Scripts
# Interactive commit with commitizen
npm run commit
# Test release without publishing
npm run release:dry-run
# Manual release (usually handled by CI)
npm run release
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Follow conventional commit format for your commits
- Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
サポート
問題の報告や機能のリクエストには、GitHub の課題トラッカーをご利用ください。
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。