Skip to main content
Glama

OpenAI Universal Model MCP

OpenAI Platform 的通用模型 MCP + Agent Skills 專案。 以動態探索為核心,讓 Codex、Claude Desktop、Cursor、VS Code 及其他 MCP Host 可以使用同一個 MCP Server 呼叫帳號有權限使用的 OpenAI API 模型。

專案版本:0.1.2 · 文件與能力登錄檔核對日期:2026-11-08

設計目標

  1. 不硬編碼可用模型清單:每次透過 GET /v1/models 取得目前 API Key 可見的模型。

  2. 能力與端點分離:Models API 不會提供完整能力規格,因此以官方文件建立能力登錄檔,未知模型一律標示 unknown,不猜測。

  3. 依任務選擇 API:Responses、Chat Completions、Images、Audio、Embeddings、Moderation、Realtime、GPT-Live 各自使用正確端點。

  4. 尊重帳號權限:模型可見不等於所有端點都可用;實際呼叫由 API 權限驗證。

  5. 安全預設:API Key 只從環境變數或本機 .env 讀取;不接受工具參數傳入 Key;產生檔案限制在 artifact 目錄;進階 REST 工具採 endpoint allowlist。

  6. Agent-first / Human-friendly:MCP tools 供代理呼叫,Skills 提供選型規則,人類可以用 PowerShell 和 MCP Inspector 驗證。

Related MCP server: Bay Run

功能總覽

Area

MCP tools

API surface

Discovery

openai_list_models, openai_get_model, openai_inspect_model

/v1/models

Routing

openai_recommend_model

Live model list + capability registry

File input

openai_upload_file (explicit confirmation required)

/v1/files

Text / reasoning / vision

openai_create_response

/v1/responses

Chat/audio-compatible models

openai_create_chat_completion

/v1/chat/completions

Image generation

openai_generate_image

/v1/images/generations

Image editing

openai_edit_image

/v1/images/edits

File transcription

openai_transcribe_audio

/v1/audio/transcriptions

Speech generation

openai_generate_speech

/v1/audio/speech

Embeddings

openai_create_embeddings

/v1/embeddings

Moderation

openai_moderate_content

/v1/moderations

Realtime

openai_create_realtime_client_secret

/v1/realtime/client_secrets

Realtime translation

openai_create_realtime_translation_secret

/v1/realtime/translations/client_secrets

GPT-Live

openai_create_live_session

/v1/live/sessions

Advanced

openai_safe_api_request

Allowlisted inference endpoints only

Diagnostics

openai_health_check

/v1/models

The server also exposes the openai://model-capabilities resource and choose_openai_model prompt.

1. Requirements

  • Windows 10/11, macOS, or Linux

  • Python 3.11+

  • uv package manager (recommended)

  • An OpenAI Platform project API key with the required model permissions and billing configured

This is an API integration, not a bridge to ChatGPT's consumer model selector. ChatGPT product access does not automatically make every ChatGPT model available through the API; the official catalog explicitly separates ChatGPT-only models from API-recommended models. API usage is subject to the Platform project, endpoint permissions, rate limits, and API billing. Eligible ChatGPT Pro and Business subscriptions may claim separate API credits by linking an eligible subscription to an API organization; those credits do not expand ChatGPT or signed-in Codex usage limits.

2. Install on Windows (PowerShell)

Unzip the project, open PowerShell in the project directory, then run:

Set-ExecutionPolicy -Scope Process Bypass
.\scripts\install.ps1

The installer runs uv sync --extra dev and creates .env from .env.example if needed.

Edit .env:

notepad .env

Set your key:

OPENAI_API_KEY=sk-proj-REPLACE_WITH_YOUR_KEY
OPENAI_TIMEOUT_SECONDS=180
OPENAI_ARTIFACT_DIR=artifacts

Do not put a real key in Git, screenshots, prompts, or MCP tool arguments.

3. Verify API access

.\scripts\test.ps1
.\scripts\run.ps1

For an interactive tool test (requires Node.js/npx for MCP Inspector):

uv run mcp dev src/openai_universal_model_mcp/server.py --with-editable .

Call openai_health_check, then openai_list_models. Use openai_inspect_model before selecting a model for a non-standard endpoint.

4. Connect to Codex

Copy the example from examples/codex-config.toml into your Codex config.toml, and replace the project directory with the actual absolute path.

Example:

[mcp_servers.openai_universal_models]
command = "uv"
args = [
  "--directory",
  "D:\\AI\\openai-universal-model-mcp",
  "run",
  "python",
  "-m",
  "openai_universal_model_mcp.server"
]
# Codex does not forward arbitrary environment variables to MCP servers.
# Needed only when the key is in the OS environment instead of .env.
env_vars = ["OPENAI_API_KEY"]

The recommended launch command is uv run python -m openai_universal_model_mcp.server. This avoids package-relative imports failing when a server file is loaded as a standalone script.

Restart Codex after editing the MCP configuration. The MCP process reads the .env file in the project root; a key already set in the process environment takes precedence.

5. Connect to Claude Code / Claude Desktop / Cursor / VS Code

Claude Code (user scope, available in every project):

claude mcp add --scope user openai-universal-models -- uv --directory D:/path/to/openai-universal-model-mcp run python -m openai_universal_model_mcp.server
claude mcp list

For the other hosts, see:

  • examples/claude-desktop-config.json

  • examples/cursor-mcp.json

Replace the example path with the absolute project path. Host configuration formats can vary by version; keep the command and arguments aligned with the host's current MCP documentation.

6. Agent usage examples

Find all visible models

Call openai_list_models with include_shutdown=false.

Select a reasoning model

Call openai_recommend_model(task="reasoning", budget_preference="balanced").
Then call openai_inspect_model with the recommended model ID.

Use a model directly

Call openai_create_response:
- model: gpt-6.1-sol
- input_text: Explain Rust ownership with a small example.
- reasoning_effort: medium
- max_output_tokens: 1200

Generate an image

Call openai_generate_image:
- model: gpt-image-2.6-sunburst
- prompt: A cinematic photorealistic miniature greenhouse at dawn.
- size: auto
- quality: high
- output_format: png

The generated file is written to artifacts/ by default. GPT Image 2.6 supports complexity controls, SVG output, and animated GIF output. For a 16-frame GIF at 120 ms per frame, set output_format=gif, frame_count=16, frame_duration_ms=120, and optionally complexity=high. The Image API accepts GIF output for generation and edits; SVG is generation-only and requires n=1.

Call openai_generate_image:
- model: gpt-image-2.6-sunburst
- prompt: A seamless looping cinematic chibi character animation, fixed camera, consistent character and background.
- output_format: gif
- frame_count: 16
- frame_duration_ms: 120
- complexity: high

Use a local PDF or image as model input

First call openai_upload_file with confirm_upload=true only after the user explicitly authorizes sending the file to OpenAI Platform. Then reference the returned file_id in openai_create_response using the appropriate input_file or input_image item.

Analyze an image with a general model

Use openai_create_response with input_json containing a Responses API message whose content includes input_text and input_image. Supply a supported HTTPS image URL, a data: URL, or a previously uploaded file ID. For example:

[
  {
    "role": "user",
    "content": [
      {"type": "input_text", "text": "Describe this image."},
      {"type": "input_image", "image_url": "https://example.com/image.jpg", "detail": "high"}
    ]
  }
]

Transcribe audio

Call openai_transcribe_audio:
- file_path: D:\\recordings\\meeting.wav
- model: gpt-transcribe
- response_format: json

Create embeddings

Call openai_create_embeddings:
- model: text-embedding-3-small
- input_text: The source text to embed.
- include_vectors: false

7. Skills

Skills are in skills/. They are written in English for consistent agent execution and include Traditional Chinese trigger phrases so Chinese-language users can invoke them naturally.

  • openai-platform-universal: main routing and operating policy

  • openai-model-discovery: dynamic catalog and lifecycle checks

  • openai-model-routing: task-to-model and endpoint selection

  • openai-image-generation: image creation and editing

  • openai-audio-realtime: transcription, speech, Realtime, GPT-Live

  • openai-embeddings-safety: embeddings and moderation

  • openai-api-extension: safe extension policy for new endpoints

Use AGENTS.md as the project-level instruction file for coding agents. To install the bundled skills into a Codex-style skills directory, run .\scripts\install-skills.ps1 or pass an explicit -TargetPath for another agent runtime.

8. Important compatibility boundaries

  • /v1/models returns model identifiers and basic fields; it does not return full modalities, context windows, pricing, or endpoint compatibility.

  • A model being listed does not guarantee the current project can use every endpoint or feature.

  • shutdown_date is checked before recommending a model. A listed model with a past shutdown date is excluded from recommendations by default.

  • Unknown model IDs remain discoverable but are marked with unknown capability metadata. Do not infer endpoint compatibility from the name alone.

  • Realtime and GPT-Live are persistent media sessions. MCP tools create an ephemeral client secret or return an SDP answer; the application must establish and maintain the actual WebRTC/WebSocket audio stream.

  • Speech generation models and endpoint support can change. Pass a currently supported model ID and verify it against the current official audio docs.

  • The safe REST tool allows only a fixed set of inference endpoints and model discovery. It does not expose destructive, organization-admin, billing, or arbitrary URL access.

9. Tests and quality gates

uv run pytest
uv run ruff check .
uv run python -m compileall src

Unit tests cover registry status, recommendation filtering, model ID validation, endpoint allowlisting, and output path containment. Live API tests are intentionally opt-in because they can incur charges.

10. Official references

The model catalog and API docs change over time. Treat the following official documentation as the source of truth:


Project status: Initial implementation package. Live model access, organization approvals, and endpoint compatibility must be verified with the user's own API key. No API calls are made during installation or unit tests.

Available Tools

18 tools
openai_create_chat_completionC

Call Chat Completions for models or audio workflows that require that API surface.

Inputs: model (required), messages_json (required), audio_json, temperature, +4 more. Returns: object

openai_create_embeddingsB

Create text embeddings. Vector values are omitted by default to keep MCP responses compact.

Inputs: model (required), dimensions, input_json, input_text, +1 more. Returns: object

openai_create_live_sessionC

Create a GPT-Live WebRTC session from an SDP offer and return the SDP answer.

Inputs: sdp_offer (required), model, session_json, safety_identifier. Returns: object

openai_create_realtime_client_secretC

Create a short-lived Realtime client secret. The main API key is never returned.

Inputs: model, session_json, session_type, safety_identifier, +1 more. Returns: object

openai_create_realtime_translation_secretC

Create a short-lived client secret for the Realtime Translation API.

Inputs: session_json (required), safety_identifier, expires_in_seconds. Returns: object

openai_create_responseC

Call the Responses API for text, reasoning, image input, tools, or structured output.

Inputs: model (required), store, input_json, input_text, +10 more. Returns: object

openai_edit_imageC

Edit one local image with a GPT Image model. An optional alpha mask may be supplied.

Inputs: model (required), prompt (required), image_path (required), size, +10 more. Returns: object

openai_generate_imageC

Generate images with GPT Image 2.x; supports 2.6 complexity and GIF frame controls.

Inputs: model (required), prompt (required), n, size, +10 more. Returns: object

openai_generate_speechC

Generate speech audio and save it locally. Supply a model supported by the current speech endpoint.

Inputs: model (required), input_text (required), speed, voice, +3 more. Returns: object

openai_get_modelC

Retrieve one model record from GET /v1/models/{model_id}.

Inputs: model_id (required). Returns: object

openai_health_checkA

Check local configuration and connectivity to the OpenAI Platform API.

Inputs: no named parameters. Returns: object

openai_inspect_modelB

Inspect live API visibility plus locally documented capabilities and compatible endpoints.

Inputs: model_id (required). Returns: object

openai_list_modelsB

List model IDs visible to this API key. Filter shutdown models unless explicitly requested.

Inputs: limit, query, include_shutdown. Returns: object

openai_moderate_contentC

Classify text or supported image inputs with the Moderations API.

Inputs: model, input_json, input_text. Returns: object

openai_recommend_modelB

Recommend an available model for a supported task using the live model list and curated priorities.

Inputs: task (required), budget_preference. Returns: object

openai_safe_api_requestC

Advanced JSON REST call restricted to approved model and inference endpoints; no destructive methods.

Inputs: path (required), method (required), body_json, query_json. Returns: object

openai_transcribe_audioC

Transcribe a local audio/video file using the Audio Transcriptions API.

Inputs: file_path (required), model, prompt, language, +1 more. Returns: object

openai_upload_fileB

Upload a local file to OpenAI Files for Responses input. Requires explicit confirm_upload=true.

Inputs: file_path (required), confirm_upload. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 18 tools

    Disambiguation4/5

    Most tools map to clearly distinct resources/actions (image generate vs edit, transcribe vs speech, moderation vs embeddings). There is mild overlap between openai_inspect_model, openai_get_model, openai_list_models, and openai_recommend_model, and between openai_create_response, openai_create_chat_completion, and openai_safe_api_request, but descriptions do enough to separate them. The three realtime secret/session tools are close cousins but still distinguishable by intent.

    Naming Consistency4/5

    All names share the openai_ prefix and overwhelmingly follow verb_noun (create_response, generate_image, transcribe_audio, list_models). A few deviate in form—openai_health_check and openai_safe_api_request read as noun/adjective phrases rather than verb_noun—but the pattern remains predictable overall.

    Tool Count4/5

    18 tools is on the heavier side, but the server spans models, files, responses, chat, images, audio, embeddings, moderation, and realtime, so each tool covers a genuinely different API surface. Only the model-introspection group (inspect/get/list/recommend) feels slightly padded.

    Completeness3/5

    Core inference surfaces are well covered, but file handling is a dead end: openai_upload_file has no list, retrieve, or delete counterpart. Broader OpenAI lifecycle areas such as batches, fine-tuning, and vector stores/assistants are absent, so agents hitting those needs will fall back to safe_api_request or fail.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      C
      quality
      Not graded
      maintenance
      Enables interaction with OpenAI-compatible APIs (like Ollama) through MCP tools. Provides access to chat completions, model listings, and embeddings generation from local or remote OpenAI-style endpoints.
      3
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables agents to discover, evaluate, and serve task-specialist models (embeddings, reranking, classification, extraction) with OpenAI-compatible endpoints and MCP tools for routing, embedding, reranking, and extraction.
      -