MCP ExplorerExplorer

Any Chat Completions

@pyropromptson 12 days ago
125 MIT
FreeCommunity
AI Systems
#Claude#OpenAI#API#Chat Completion
Interact with any OpenAI SDK Compatible Chat Completions API like OpenAI, Perplexity, Groq, xAI and many more.

Overview

What is Any Chat Completions

The Any Chat Completions MCP Server is a TypeScript-based implementation that allows integration with various AI chat providers via a common protocol. It facilitates the connection to any API compatible with OpenAI’s chat completion service, thereby enabling users to leverage different models and chat environments seamlessly.

Use cases

This server is suitable for users wanting to utilize multiple AI chat models in a single interface, such as Claude Desktop or LibreChat. It allows users to connect to various providers, enhancing their capabilities for tasks like conversational agents, virtual assistants, and chatbots across different platforms.

How to use

To integrate the MCP server, users can define their configurations in the Claude Desktop settings or various compatible applications. They can specify commands, arguments, and environment variables for different chat providers. This setup can involve installing dependencies, building the server, and launching it using specified commands and configuration files.

Key features

Key features of the MCP Server include compatibility with multiple AI providers, the ability to handle multiple configurations, easy integration with desktop applications, and support for real-time chat interactions with various models. Additionally, it offers a debugging tool for troubleshooting communication between the server and clients.

Where to use

The MCP server can be used in environments like Claude Desktop, which allows users to access various AI models conveniently. It can also be implemented in other applications like LibreChat, enabling developers and end-users to create more interactive and versatile chat experiences.

Content

any-chat-completions-mcp MCP Server

Integrate Claude with Any OpenAI SDK Compatible Chat Completion API - OpenAI, Perplexity, Groq, xAI, PyroPrompts and more.

This implements the Model Context Protocol Server. Learn more: https://modelcontextprotocol.io

This is a TypeScript-based MCP server that implements an implementation into any OpenAI SDK Compatible Chat Completions API.

It has one tool, chat which relays a question to a configured AI Chat Provider.

smithery badge

Development

Install dependencies:

npm install

Build the server:

npm run build

For development with auto-rebuild:

npm run watch

Installation

To add OpenAI to Claude Desktop, add the server config:

On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json

On Windows: %APPDATA%/Claude/claude_desktop_config.json

You can use it via npx in your Claude Desktop configuration like this:

{
  "mcpServers": {
    "chat-openai": {
      "command": "npx",
      "args": [
        "@pyroprompts/any-chat-completions-mcp"
      ],
      "env": {
        "AI_CHAT_KEY": "OPENAI_KEY",
        "AI_CHAT_NAME": "OpenAI",
        "AI_CHAT_MODEL": "gpt-4o",
        "AI_CHAT_BASE_URL": "https://api.openai.com/v1"
      }
    }
  }
}

Or, if you clone the repo, you can build and use in your Claude Desktop configuration like this:

{
  "mcpServers": {
    "chat-openai": {
      "command": "node",
      "args": [
        "/path/to/any-chat-completions-mcp/build/index.js"
      ],
      "env": {
        "AI_CHAT_KEY": "OPENAI_KEY",
        "AI_CHAT_NAME": "OpenAI",
        "AI_CHAT_MODEL": "gpt-4o",
        "AI_CHAT_BASE_URL": "https://api.openai.com/v1"
      }
    }
  }
}

You can add multiple providers by referencing the same MCP server multiple times, but with different env arguments:

{
  "mcpServers": {
    "chat-pyroprompts": {
      "command": "node",
      "args": [
        "/path/to/any-chat-completions-mcp/build/index.js"
      ],
      "env": {
        "AI_CHAT_KEY": "PYROPROMPTS_KEY",
        "AI_CHAT_NAME": "PyroPrompts",
        "AI_CHAT_MODEL": "ash",
        "AI_CHAT_BASE_URL": "https://api.pyroprompts.com/openaiv1"
      }
    },
    "chat-perplexity": {
      "command": "node",
      "args": [
        "/path/to/any-chat-completions-mcp/build/index.js"
      ],
      "env": {
        "AI_CHAT_KEY": "PERPLEXITY_KEY",
        "AI_CHAT_NAME": "Perplexity",
        "AI_CHAT_MODEL": "sonar",
        "AI_CHAT_BASE_URL": "https://api.perplexity.ai"
      }
    },
    "chat-openai": {
      "command": "node",
      "args": [
        "/path/to/any-chat-completions-mcp/build/index.js"
      ],
      "env": {
        "AI_CHAT_KEY": "OPENAI_KEY",
        "AI_CHAT_NAME": "OpenAI",
        "AI_CHAT_MODEL": "gpt-4o",
        "AI_CHAT_BASE_URL": "https://api.openai.com/v1"
      }
    }
  }
}

With these three, you’ll see a tool for each in the Claude Desktop Home:

Claude Desktop Home with Chat Tools

And then you can chat with other LLMs and it shows in chat like this:

Claude Chat with OpenAI

Or, configure in LibreChat like:

  chat-perplexity:
    type: stdio
    command: npx
    args:
      - -y
      - @pyroprompts/any-chat-completions-mcp
    env:
      AI_CHAT_KEY: "pplx-012345679"
      AI_CHAT_NAME: Perplexity
      AI_CHAT_MODEL: sonar
      AI_CHAT_BASE_URL: "https://api.perplexity.ai"
      PATH: '/usr/local/bin:/usr/bin:/bin'

And it shows in LibreChat:

LibreChat with Perplexity Chat

Installing via Smithery

To install Any OpenAI Compatible API Integrations for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install any-chat-completions-mcp-server --client claude

Debugging

Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:

npm run inspector

The Inspector will provide a URL to access debugging tools in your browser.

Acknowledgements

Tools

chat-with-${AI_CHAT_NAME_CLEAN}
Text chat with ${AI_CHAT_NAME}

Comments