Sponsored by Deepsite.site

OpenAI MCP Server

Created By
marchampsona year ago
An mcp-openai-server for connecting via Claude or similar
Content

OpenAI MCP Server

A Model Context Protocol (MCP) server implementation for the OpenAI API. This server provides a standardized interface between Augment and OpenAI's language models using the official MCP SDK.

What is MCP?

The Model Context Protocol (MCP) is a standardized API specification that provides a unified way to interact with various large language models (LLMs). It allows applications like Augment to work with different LLM providers through a consistent interface.

MCP acts as a "universal adapter" for LLMs - it translates application requests into the specific format each LLM provider requires.

Features

  • 🔄 Uses the official MCP SDK for compatibility
  • Secure API key management
  • 📊 Support for chat completions
  • 📋 Model listing
  • 🧠 Embedding generation
  • ⚠️ Proper error handling and logging

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • OpenAI API key

Installation

  1. Clone this repository or copy the files to your project directory
  2. Install dependencies:
npm install
  1. Create a .env file based on the .env.example provided:
cp .env.example .env
  1. Add your OpenAI API key to the .env file:
OPENAI_API_KEY=your_openai_api_key_here

Running the Server

Start the server with:

npm start

For development with auto-restart on file changes:

npm run dev

Using with Augment

To use this MCP server with Augment, add the following to your Augment settings.json file:

"augment.advanced": {
    "mcpServers": [
        {
            "name": "openai-mcp",
            "command": "node",
            "args": ["/path/to/openai-mcp-server.js"],
            "env": {
                "OPENAI_API_KEY": "your_openai_api_key_here",
                "DEBUG": "true"
            }
        }
    ]
}

Replace /path/to/openai-mcp-server.js with the actual path to the server file on your system.

Available Tools

This MCP server provides the following tools to Augment:

1. List Models

Lists all available OpenAI models.

2. Chat Completion

Generates responses using OpenAI's chat completion API. Supports parameters like:

  • model: The model to use (e.g., gpt-3.5-turbo, gpt-4)
  • messages: Array of conversation messages
  • temperature: Controls randomness (0-1)
  • max_tokens: Maximum number of tokens to generate

3. Create Embedding

Generates embeddings for text using OpenAI's embedding API. Supports parameters like:

  • model: The model to use (e.g., text-embedding-ada-002)
  • input: The text to embed (string or array of strings)

Testing

A sample client is provided in client-example.js to test your MCP server. Run it with:

node client-example.js

Understanding the Code

The server consists of several key components:

  1. MCP SDK Integration: Uses the official MCP SDK for standardized communication
  2. Tool Handlers: Implements handlers for each supported tool
  3. OpenAI API Integration: Communicates with OpenAI's API
  4. Error Handling: Provides consistent error responses
  5. Logging: Logs operations for debugging

Potential Improvements

See mcp-server-improvement-suggestions.md for a list of potential improvements that could be made to this implementation.

License

MIT

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Amap Maps高德地图官方 MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
CursorThe AI Code Editor
WindsurfThe new purpose-built IDE to harness magic
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
DeepChatYour AI Partner on Desktop
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Serper MCP ServerA Serper MCP Server
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Playwright McpPlaywright MCP server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Tavily Mcp
ChatWiseThe second fastest AI chatbot™