Unichat MCP server

Interact with multiple LLM chat APIs through a unified interface.
Back to servers
Provider
amidabuddha
Release date
Nov 30, 2024
Language
Python
Package
Stats
3.0K downloads
36 stars

The Unichat MCP Server allows you to send requests to various AI providers such as OpenAI, MistralAI, Anthropic, xAI, Google AI, DeepSeek, Alibaba, and Inception using the Model Context Protocol (MCP). It provides a unified interface for interacting with different AI models through predefined prompts or a general-purpose tool.

Installation

Claude Desktop Integration

To integrate Unichat MCP Server with Claude Desktop, you need to modify the Claude Desktop configuration file located at:

  • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json

Add the server configuration with your selected model and API key:

For Published Servers

"mcpServers": {
  "unichat-mcp-server": {
    "command": "uvx",
    "args": [
      "unichat-mcp-server"
    ],
    "env": {
      "UNICHAT_MODEL": "gpt-4o-mini",
      "UNICHAT_API_KEY": "YOUR_OPENAI_API_KEY"
    }
  }
}

For Development/Unpublished Servers

"mcpServers": {
  "unichat-mcp-server": {
    "command": "uv",
    "args": [
      "--directory",
      "/path/to/your/unichat-mcp-server",
      "run",
      "unichat-mcp-server"
    ],
    "env": {
      "UNICHAT_MODEL": "gpt-4o-mini",
      "UNICHAT_API_KEY": "YOUR_OPENAI_API_KEY"
    }
  }
}

Automated Installation via Smithery

For automatic installation, you can use Smithery:

npx -y @smithery/cli install unichat-mcp-server --client claude

Usage

Using the Unichat Tool

The server implements a general-purpose tool called unichat that can send requests to any supported AI provider.

The tool takes a required messages argument and returns a response. Here's an example of how to use it:

unichat(messages="Your prompt or message here")

Using Predefined Prompts

The server also provides several predefined prompts for common code-related tasks:

Code Review

Use this prompt to review code for best practices, potential issues, and improvements:

code_review(code="function example() { console.log('Hello world'); }")

Document Code

Generate documentation for code including docstrings and comments:

document_code(code="def add(a, b): return a + b")

Explain Code

Get a detailed explanation of how a piece of code works:

explain_code(code="import pandas as pd\ndf = pd.read_csv('data.csv')\nresult = df.groupby('category').sum()")

Code Rework

Apply specific changes to the provided code:

code_rework(
  code="function greet(name) { return 'Hello ' + name; }",
  changes="Convert to ES6 arrow function with template literals"
)

Supported Models

To specify which AI model to use, set the UNICHAT_MODEL environment variable. You can find a list of supported models in the Unichat models.py file.

Remember to provide the corresponding API key for the vendor you're using in the UNICHAT_API_KEY environment variable.

Debugging

If you encounter issues, you can use the MCP Inspector for debugging:

npx @modelcontextprotocol/inspector uv --directory /path/to/your/unichat-mcp-server run unichat-mcp-server

The Inspector will provide a URL that you can open in your browser to help with debugging.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later