Unichat MCP Server in Python Overview Unichat is a simple chat server that allows multiple clients to connect and communicate with each other. This implementation is done using Python's socket programming. Requirements - Python 3.x - Basic knowledge of socket programming Installation Make sure you have Python installed on your machine. You can download it from [python.org](https://www.python.org/downloads/). Code ```python import socket import threading Server settings HOST = '127.0.0.1' Localhost PORT = 12345 Port to listen on List to keep track of connected clients clients = [] def handle_client(client_socket, addr): print(f"Connection from {addr} has been established!") clients.append(client_socket) while True: try: message = client_socket.recv(1024).decode('utf-8') if message: print(f"Received message: {message}") broadcast(message, client_socket) else: break except: break print(f"Connection from {addr} has been closed.") clients.remove(client_socket) client_socket.close() def broadcast(message, client_socket): for client in clients: if client != client_socket: client.send(message.encode('utf-8')) def start_server(): server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind((HOST, PORT)) server_socket.listen() print(f"Server is listening on {HOST}:{PORT}") while True: client_socket, addr = server_socket.accept() thread = threading.Thread(target=handle_client, args=(client_socket, addr)) thread.start() if __name__ == "__main__": start_server() ``` How to Run 1. Save the code in a file named `unichat_server.py`. 2. Open a terminal and navigate to the directory where the file is saved. 3. Run the server using the command: ``` python unichat_server.py ``` Connecting Clients You can create a simple client using the following code: ```python import socket HOST = '127.0.0.1' Server address PORT = 12345 Server port client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect((HOST, PORT)) while True: message = input("Enter message: ") client_socket.send(message.encode('utf-8')) ``` Conclusion This is a basic implementation of a chat server in Python. You can enhance it by adding features like user authentication, message history, or a graphical user interface.
Overview
What is Unichat MCP Server?
Unichat MCP Server is an innovative solution designed to facilitate real-time communication across various platforms. This server acts as a middleware, enabling seamless messaging and data exchange between different applications and services. With its robust architecture, Unichat MCP Server ensures high availability and scalability, making it an ideal choice for developers looking to integrate chat functionalities into their applications.
Features of Unichat MCP Server
- Real-Time Messaging: Supports instant messaging capabilities, allowing users to send and receive messages in real-time.
- Cross-Platform Compatibility: Works across multiple platforms, ensuring that users can communicate regardless of the device or operating system.
- Scalability: Built to handle a large number of concurrent users, making it suitable for both small and large applications.
- Security: Implements advanced security measures to protect user data and ensure secure communication.
- Customizable: Offers flexibility for developers to customize features according to their application needs.
- User Management: Provides tools for managing user accounts, including authentication and authorization features.
How to Set Up Unichat MCP Server
- Installation: Begin by downloading the Unichat MCP Server package from the official repository. Follow the installation instructions provided in the documentation.
- Configuration: Configure the server settings according to your requirements. This includes setting up database connections, defining user roles, and customizing messaging protocols.
- Integration: Integrate the server with your application using the provided APIs. Ensure that your application can communicate with the server for sending and receiving messages.
- Testing: Conduct thorough testing to ensure that all features are functioning as expected. Check for real-time messaging capabilities and user management functionalities.
- Deployment: Once testing is complete, deploy the server to your production environment. Monitor the server performance and make adjustments as necessary.
Frequently Asked Questions
Q1: What programming languages are supported by Unichat MCP Server?
A1: Unichat MCP Server is designed to be language-agnostic, allowing integration with various programming languages through its API.
Q2: Is there a limit to the number of users that can connect to the server?
A2: No, Unichat MCP Server is built to scale and can handle a large number of concurrent users without performance degradation.
Q3: How does Unichat MCP Server ensure data security?
A3: The server employs encryption protocols and secure authentication methods to protect user data and ensure secure communication.
Q4: Can I customize the features of Unichat MCP Server?
A4: Yes, the server is highly customizable, allowing developers to modify features and functionalities to suit their specific application needs.
Q5: Where can I find support for Unichat MCP Server?
A5: Support can be found through the official documentation, community forums, and GitHub repository where you can report issues or ask questions.
Details
Unichat MCP Server in Python
Also available in TypeScript
<h4 align="center"> <a href="https://mseep.ai/app/amidabuddha-unichat-mcp-server"> <img src="https://mseep.net/pr/amidabuddha-unichat-mcp-server-badge.png" alt="MseeP.ai Security Assessment Badge" /> </a> </h4> <h4 align="center"> <a href="https://github.com/amidabuddha/unichat-mcp-server/blob/main/LICENSE.md"> <img src="https://img.shields.io/github/license/amidabuddha/unichat-mcp-server" alt="Released under the MIT license." /> </a> <a href="https://smithery.ai/server/unichat-mcp-server"> <img src="https://smithery.ai/badge/unichat-mcp-server" alt="Smithery Server Installations" /> </a> </h4> <h4 align="center"> <a href="https://mcphub.com/mcp-servers/amidabuddha/unichat-mcp-server"> <img src="https://img.mcphub.com/_next/image?url=%2Flogo-dark.png&w=48&q=75" alt="Hosted at MCPHub" /> </a> </h4>Send requests to OpenAI, MistralAI, Anthropic, xAI, Google AI, DeepSeek, Alibaba, Inception using MCP protocol via tool or predefined prompts. Vendor API key required
Tools
The server implements one tool:
unichat
: Send a request to unichat- Takes "messages" as required string arguments
- Returns a response
Prompts
code_review
- Review code for best practices, potential issues, and improvements
- Arguments:
code
(string, required): The code to review"
document_code
- Generate documentation for code including docstrings and comments
- Arguments:
code
(string, required): The code to comment"
explain_code
- Explain how a piece of code works in detail
- Arguments:
code
(string, required): The code to explain"
code_rework
- Apply requested changes to the provided code
- Arguments:
changes
(string, optional): The changes to apply"code
(string, required): The code to rework"
Quickstart
Install
Claude Desktop
On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
Supported Models:
A list of currently supported models to be used as
"SELECTED_UNICHAT_MODEL"
may be found here. Please make sure to add the relevant vendor API key as"YOUR_UNICHAT_API_KEY"
Example:
"env": {
"UNICHAT_MODEL": "gpt-4o-mini",
"UNICHAT_API_KEY": "YOUR_OPENAI_API_KEY"
}
Development/Unpublished Servers Configuration
"mcpServers": {
"unichat-mcp-server": {
"command": "uv",
"args": [
"--directory",
"{{your source code local directory}}/unichat-mcp-server",
"run",
"unichat-mcp-server"
],
"env": {
"UNICHAT_MODEL": "SELECTED_UNICHAT_MODEL",
"UNICHAT_API_KEY": "YOUR_UNICHAT_API_KEY"
}
}
}
Published Servers Configuration
"mcpServers": {
"unichat-mcp-server": {
"command": "uvx",
"args": [
"unichat-mcp-server"
],
"env": {
"UNICHAT_MODEL": "SELECTED_UNICHAT_MODEL",
"UNICHAT_API_KEY": "YOUR_UNICHAT_API_KEY"
}
}
}
Installing via Smithery
To install Unichat for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install unichat-mcp-server --client claude
Development
Building and Publishing
To prepare the package for distribution:
- Remove older builds:
rm -rf dist
- Sync dependencies and update lockfile:
uv sync
- Build package distributions:
uv build
This will create source and wheel distributions in the dist/
directory.
- Publish to PyPI:
uv publish --token {{YOUR_PYPI_API_TOKEN}}
Debugging
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.
You can launch the MCP Inspector via npm
with this command:
npx @modelcontextprotocol/inspector uv --directory {{your source code local directory}}/unichat-mcp-server run unichat-mcp-server
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
Server Config
{
"mcpServers": {
"unichat-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--amidabuddha--unichat-mcp-server--unichat-mcp-server",
"unichat-mcp-server"
],
"env": {
"UNICHAT_MODEL": "unichat-model",
"UNICHAT_API_KEY": "unichat-api-key"
}
}
}
}