Discover Awesome MCP Servers

Extend your agent with 26,962 capabilities via MCP servers.

All26,962
claude_mcp

claude_mcp

Okay, here are a few different ways to implement "MCP servers" (assuming you mean servers that handle Minecraft Protocol) in Python, along with explanations and considerations: **Understanding the Context: What is an "MCP Server" in this case?** Before diving into code, let's clarify what you mean by "MCP server." There are a few possibilities: 1. **A Full Minecraft Server Implementation:** This is the most complex. You'd be essentially re-creating a Minecraft server from scratch in Python, handling all the game logic, world generation, player interactions, etc. This is a *huge* undertaking. It's rarely done in Python due to performance limitations. You'd be better off using Java (the language Minecraft is written in) for this. 2. **A Proxy Server:** This sits between a Minecraft client and a real Minecraft server. It intercepts and modifies packets, allowing you to do things like: * Add custom commands. * Implement anti-cheat measures. * Modify game mechanics. * Log player activity. * Implement custom authentication. 3. **A Simple Server for Testing/Experimentation:** This might be a minimal server that only handles basic connection and authentication, perhaps for testing a client or experimenting with the Minecraft protocol. It wouldn't implement any real game logic. 4. **A Server for a Custom Minecraft-Like Game:** You might be building your own game that uses a similar protocol to Minecraft, but with different rules and content. **Examples (with increasing complexity):** **1. Minimal "Hello World" Server (for basic connection):** This example demonstrates the very basic handshake and status response. It's *not* a functional Minecraft server. It's just enough to get a client to connect and see a status message. ```python import socket import struct import json def handle_handshake(sock): # Read the handshake packet length = read_varint(sock) packet_id = read_varint(sock) if packet_id != 0x00: print("Unexpected packet ID in handshake:", packet_id) return protocol_version = read_varint(sock) server_address = read_string(sock) server_port = struct.unpack('>H', sock.recv(2))[0] # Unpack as big-endian unsigned short next_state = read_varint(sock) print(f"Handshake: Protocol {protocol_version}, Address {server_address}:{server_port}, Next State {next_state}") return next_state def handle_status_request(sock): # Read the status request packet (should be empty) length = read_varint(sock) packet_id = read_varint(sock) if packet_id != 0x00: print("Unexpected packet ID in status request:", packet_id) return # Craft a status response status = { "version": { "name": "My Python Server", "protocol": 757 # Example protocol version (Minecraft 1.17.1) }, "players": { "max": 20, "online": 0, "sample": [] }, "description": { "text": "A simple Python Minecraft server." } } status_json = json.dumps(status) status_bytes = status_json.encode('utf-8') status_packet = write_varint(0x00) + write_string(status_json) status_packet_length = write_varint(len(status_packet)) sock.send(status_packet_length + status_packet) # Handle ping request (optional) length = read_varint(sock) packet_id = read_varint(sock) if packet_id == 0x01: payload = sock.recv(8) # Ping payload is 8 bytes ping_response = write_varint(0x01) + payload ping_response_length = write_varint(len(ping_response)) sock.send(ping_response_length + ping_response) def read_varint(sock): result = 0 shift = 0 while True: byte = sock.recv(1)[0] result |= (byte & 0x7F) << shift shift += 7 if not (byte & 0x80): break return result def read_string(sock): length = read_varint(sock) return sock.recv(length).decode('utf-8') def write_varint(value): output = bytearray() while True: byte = value & 0x7F value >>= 7 if value != 0: byte |= 0x80 output.append(byte) if value == 0: break return bytes(output) def write_string(string): encoded = string.encode('utf-8') return write_varint(len(encoded)) + encoded def handle_client(sock, address): print(f"Accepted connection from {address}") try: next_state = handle_handshake(sock) if next_state == 1: # Status handle_status_request(sock) elif next_state == 2: # Login print("Login requested, but not implemented.") # In a real server, you'd handle login here. pass else: print("Unknown next state:", next_state) except Exception as e: print(f"Error handling client: {e}") finally: sock.close() print(f"Connection with {address} closed.") def main(): host = 'localhost' port = 25565 server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # Allow address reuse server_socket.bind((host, port)) server_socket.listen(5) print(f"Listening on {host}:{port}") try: while True: client_socket, client_address = server_socket.accept() handle_client(client_socket, client_address) except KeyboardInterrupt: print("Shutting down server...") finally: server_socket.close() if __name__ == "__main__": main() ``` Key improvements and explanations: * **VarInt Handling:** Minecraft uses a variable-length integer encoding (VarInt) for packet lengths and other data. The `read_varint` and `write_varint` functions correctly handle this. This is *essential* for Minecraft protocol communication. * **String Handling:** The `read_string` and `write_string` functions handle reading and writing UTF-8 encoded strings, which are also used in the protocol. * **Status Response:** The `handle_status_request` function now creates a valid JSON status response that a Minecraft client can understand. It includes the server version, player count, and a description. You can customize this. * **Handshake Handling:** The `handle_handshake` function reads the initial handshake packet and determines the next state (status or login). * **Error Handling:** Includes a `try...except...finally` block to handle potential errors during client communication and ensure the socket is closed properly. * **Socket Options:** `server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)` allows you to quickly restart the server without waiting for the socket to time out. * **Comments:** Added more comments to explain the code. * **Ping Handling (Optional):** The `handle_status_request` function now includes basic handling of the ping request (packet ID 0x01). This allows the client to measure the server's latency. * **Big-Endian Port:** The server port is read as a big-endian unsigned short using `struct.unpack('>H', sock.recv(2))[0]`. This is important because the Minecraft protocol uses big-endian byte order for multi-byte values. **How to Run:** 1. Save the code as a Python file (e.g., `minecraft_server.py`). 2. Run it from your terminal: `python minecraft_server.py` 3. In your Minecraft client, add a new server with the address `localhost` and port `25565`. 4. You should see the server in your server list with the status message "A simple Python Minecraft server." **Important Notes:** * **This is *not* a playable Minecraft server.** It only handles the initial handshake and status request. You can't join and play. * **Protocol Version:** The `protocol` field in the status response must match the Minecraft version you're using. The example uses 757 (Minecraft 1.17.1). You can find a list of protocol versions here: [https://wiki.vg/Protocol_version_numbers](https://wiki.vg/Protocol_version_numbers) * **Error Handling:** The error handling is basic. A real server would need much more robust error handling. * **Security:** This example has *no* security. Do not expose it to the internet without proper security measures. **2. Proxy Server (Conceptual Outline):** Building a proxy server is significantly more complex. Here's a conceptual outline and some code snippets to get you started: ```python import socket import threading # Configuration LISTEN_HOST = 'localhost' LISTEN_PORT = 25565 REMOTE_HOST = 'your_real_minecraft_server_ip' # Replace with your real server IP REMOTE_PORT = 25565 def handle_client(client_socket, client_address): try: # Connect to the remote server remote_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) remote_socket.connect((REMOTE_HOST, REMOTE_PORT)) # Create threads to forward traffic in both directions client_to_remote_thread = threading.Thread(target=forward_data, args=(client_socket, remote_socket)) remote_to_client_thread = threading.Thread(target=forward_data, args=(remote_socket, client_socket)) client_to_remote_thread.start() remote_to_client_thread.start() client_to_remote_thread.join() remote_to_client_thread.join() except Exception as e: print(f"Error handling client: {e}") finally: if client_socket: client_socket.close() if remote_socket: remote_socket.close() print(f"Connection with {client_address} closed.") def forward_data(source, destination): try: while True: data = source.recv(4096) # Adjust buffer size as needed if not data: break # Here you can inspect and modify the data (packets) # Example: print(f"Received data: {data}") destination.sendall(data) except Exception as e: print(f"Error forwarding data: {e}") def main(): server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server_socket.bind((LISTEN_HOST, LISTEN_PORT)) server_socket.listen(5) print(f"Proxy server listening on {LISTEN_HOST}:{LISTEN_PORT}, forwarding to {REMOTE_HOST}:{REMOTE_PORT}") try: while True: client_socket, client_address = server_socket.accept() client_thread = threading.Thread(target=handle_client, args=(client_socket, client_address)) client_thread.start() except KeyboardInterrupt: print("Shutting down proxy server...") finally: server_socket.close() if __name__ == "__main__": main() ``` Key points about the proxy server: * **Threading:** Uses threads to handle multiple client connections concurrently and to forward data in both directions (client to server and server to client). * **Data Forwarding:** The `forward_data` function is the core of the proxy. It receives data from one socket and sends it to the other. This is where you would add your packet inspection and modification logic. * **Packet Inspection/Modification:** The `forward_data` function includes a comment indicating where you would add code to inspect and modify the Minecraft packets. This is the most complex part. You'll need to: * Understand the Minecraft protocol (see the wiki.vg link above). * Parse the packets to identify their type and content. * Modify the packets as needed. * Reassemble the packets and send them on. * **Configuration:** The `LISTEN_HOST`, `LISTEN_PORT`, `REMOTE_HOST`, and `REMOTE_PORT` variables allow you to configure the proxy server's listening address and the address of the real Minecraft server. **To make this a *useful* proxy server, you would need to:** 1. **Implement Packet Parsing:** Use the `read_varint`, `read_string`, and other functions from the first example to parse the Minecraft packets. 2. **Identify Packet Types:** Use the packet ID to determine the type of packet. 3. **Implement Your Logic:** Add code to modify specific packets based on your desired functionality (e.g., custom commands, anti-cheat, etc.). 4. **Handle Encryption:** Minecraft uses encryption after the initial handshake. You'll need to handle this if you want to inspect encrypted packets. This is very complex. **3. Using Libraries (Advanced):** There are some Python libraries that can help with Minecraft protocol handling, but they are often incomplete or outdated. Here are a few: * **`mcstatus`:** This library is primarily for querying the status of Minecraft servers. It can be useful for getting server information, but it doesn't provide full server implementation capabilities. `pip install mcstatus` * **`nbt`:** For reading and writing NBT data, the format Minecraft uses for storing world data, player data, and other game information. `pip install nbt` * **`pymclevel` (Legacy):** This library was used for editing Minecraft worlds, but it's largely outdated and not actively maintained. **Why Python is Not Ideal for Full Minecraft Servers:** * **Performance:** Python is an interpreted language, which makes it significantly slower than compiled languages like Java or C++. A full Minecraft server requires very high performance to handle many players and complex game logic. * **Garbage Collection:** Python's garbage collection can introduce pauses that can cause lag in a real-time game environment. * **Ecosystem:** The Minecraft server ecosystem is heavily based on Java. There are many mature Java libraries and tools available for server development. **In summary:** * For simple experimentation or querying server status, Python can be useful. * For building a proxy server, Python is *possible*, but requires a significant amount of work to implement the Minecraft protocol correctly. * For building a full Minecraft server, Java is the much better choice. Choose the approach that best suits your needs and level of experience. Be prepared for a significant learning curve if you attempt to implement a proxy server or a custom Minecraft-like game. Good luck!

AWorld

AWorld

汎用的なマルチエージェント支援を簡単に構築、評価、実行できます。

ZZZHDW_mcp Server Kusto

ZZZHDW_mcp Server Kusto

鏡 (Kagami)

MCP Montano Server

MCP Montano Server

TypeScript で構築されたサーバープロジェクトで、Cursor IDE と MCP (Model Control Protocol) サーバーとして統合でき、開発機能を強化できます。

SSH MCP Server

SSH MCP Server

WebSocket MCP

WebSocket MCP

カスタム WebSocket トランスポート層を持つ Model Context Protocol (MCP) サーバーおよびクライアント。

NearbySearch MCP Server

NearbySearch MCP Server

IPベースの位置情報検出による、近隣の場所検索のためのMCPサーバー。

PowerPlatform MCP

PowerPlatform MCP

PowerPlatform/Dataverse のエンティティとレコードへのインテリジェントなアクセスを提供するモデルコンテキストプロトコル (MCP) サーバー。このツールは、コンテキストに応じた支援、エンティティの探索、およびメタデータへのアクセスを提供します。

Bio-Agents MCP

Bio-Agents MCP

タンパク質構造データバンク (Protein Data Bank)、ChemBL、その他のライフサイエンスデータ用の MCP サーバー (開発中)。ローカルテスト用の Ollama クライアント付き。

Mcp Servers

Mcp Servers

OracleDB MCP Server

OracleDB MCP Server

LLMが自然言語プロンプトを使用してSQL文を生成し、結果を取得できるように、データベースのテーブル/カラムをコンテキストとして提供することで、LLMがOracle Databaseと対話できるようにするモデルコンテキストプロトコルサーバー。

Hackage Documentation MCP

Hackage Documentation MCP

Claude がドキュメントを簡単に取得できるようにするための MCP サーバー

YouTube MCP Server

YouTube MCP Server

AI言語モデルが標準化されたインターフェースを介してYouTubeコンテンツとやり取りできるようにし、動画情報、トランスクリプト、チャンネル分析、トレンド分析を取得するためのツールを提供します。

Cheqd MCP Toolkit

Cheqd MCP Toolkit

cheqd 分散型アイデンティティのためのモデルコンテキストプロトコル (MCP) ツールキット

Awesome Claude MCP Servers 🤖

Awesome Claude MCP Servers 🤖

Claude AIアシスタントに最適化された、厳選されたモデルコンテキストプロトコル(MCP)サーバーのリスト。

MySQL MCP Server

MySQL MCP Server

AIエージェントがMySQLデータベースと対話し、SQLクエリを実行し、シンプルなインターフェースを通じてデータベースコンテンツを管理できる強力なサーバー。

Juhe News MCP Server

Juhe News MCP Server

大規模言語モデルが、おすすめ、国内、テクノロジー、スポーツニュースなど、様々なカテゴリーの最新トレンドニュースの見出しや詳細なコンテンツにアクセスできるようにする、モデルコンテキストプロトコルサーバー。

YouTube MCP Server

YouTube MCP Server

Claudeや他のAIアシスタントがYouTube APIと連携し、動画やチャンネルの検索、詳細情報の取得を可能にするMCPサーバー。

Wikimedia MCP Server

Wikimedia MCP Server

Wikimedia APIとやり取りするためのMCPサーバーです。Wikipediaやその他のWikimediaプロジェクトのコンテンツにプログラムでアクセスできます。

QRCode_MCP

QRCode_MCP

カスタマイズ可能なQRコードを生成するMCPサーバー。サイズ、色、誤り訂正、マージン設定などのオプションがあります。

MCP Server-Client Example

MCP Server-Client Example

A Pokedex web app!

A Pokedex web app!

ポケモン図鑑ウェブアプリ

Tiny MCP Server (Rust)

Tiny MCP Server (Rust)

Rust で実装された Machine Communication Protocol (MCP)

MCP Server - JavaScript SDK

MCP Server - JavaScript SDK

Model Context Protocol 用のカスタマイズされたサーバーを作成するための非公式 JavaScript SDK。プロンプト、リソース、およびツールを定義して、調整されたインタラクションを可能にします。

Pica Mcp Server

Pica Mcp Server

A Model Context Protocol Server for Pica, built in TypeScript

mcp-server-jupyter

mcp-server-jupyter

Jupyter Notebook および JupyterLab 用の MCP サーバー

MCP Server for Data Exploration

MCP Server for Data Exploration

鏡 (Kagami)

Template project to build MCP server using SpringBoot

Template project to build MCP server using SpringBoot

Soccer MCP Server

Soccer MCP Server

鏡 (Kagami)

MCP Cases

MCP Cases

MCP Casesは、MCPサーバーの動作を様々な自動化処理に対してどのように指定するかを可能にするフォーマットです。