发现优秀的 MCP 服务器

通过 MCP 服务器扩展您的代理能力,拥有 12,252 个能力。

搜索1,246
MCP 学习项目⚡

MCP 学习项目⚡

个人学习MCP (Gèrén xuéxí MCP) - This translates to "Personal study of MCP."

Math Agent with Microsoft Word and Gmail Integration

Math Agent with Microsoft Word and Gmail Integration

用于数学代理的 MCP 服务器,集成 Microsoft Word 和 Gmail

🌐 Welcome to Fetch-MCP Repository 🌟

🌐 Welcome to Fetch-MCP Repository 🌟

一个用于获取 URL / Youtube 视频文字稿的 MCP 服务器。

ts-mcp-server

ts-mcp-server

gomcptest: Proof of Concept for MCP with Custom Host

gomcptest: Proof of Concept for MCP with Custom Host

一个概念验证,展示了一个自定义构建的宿主,该宿主实现了与 OpenAI 兼容的 API,并集成了 Google Vertex AI、函数调用以及与 MCP 服务器的交互。

OpenWeather MCP Server

OpenWeather MCP Server

天气预报 MCP 服务器,用于天气预报。

Yahoo Finance MCP Server

Yahoo Finance MCP Server

这是一个模型上下文协议(MCP)服务器,它提供来自雅虎财经的全面金融数据。它允许您检索关于股票的详细信息,包括历史价格、公司信息、财务报表、期权数据和市场新闻。

Exchange Rate MCP Server

Exchange Rate MCP Server

提供访问挪威银行 API 汇率数据的玩具 MCP 服务器。

mcp-changtianML

mcp-changtianML

MCP 服务器访问 ChangtianML

MCP Gateway

MCP Gateway

一个基于插件的网关,用于协调其他MCP(微控制平面),并允许开发者在此基础上构建企业级代理。

🧠 DeepSeek R1 Reasoning Executor

🧠 DeepSeek R1 Reasoning Executor

一个强大的MCP服务器,通过集成DeepSeek R1的尖端推理引擎来增强Claude的能力。

Binance MCP Server

Binance MCP Server

镜子 (jìng zi)

XACHE - Crypto Trader Website

XACHE - Crypto Trader Website

鹅雁 AI 与 MCP 服务器

mcp-server-myweight

mcp-server-myweight

LeetCode MCP (Model Context Protocol)

LeetCode MCP (Model Context Protocol)

Okay, I understand. You want to use an MCP (presumably referring to a "Minecraft Protocol" server, though the connection to LeetCode is unclear) to generate LeetCode notes. This is a bit of an unusual request, and I need to make some assumptions to provide a helpful translation. Here's the breakdown and possible interpretations, along with translations: **Understanding the Request (and Assumptions):** * **"MCP Server":** I'm assuming you're *not* actually talking about a Minecraft server. It's more likely you're using "MCP" as shorthand for some kind of **"Machine Comprehension Program"** or a similar AI-powered system. This makes more sense in the context of generating notes. If you *are* talking about a Minecraft server, please clarify how you intend to use it for LeetCode notes! * **"Generate Leetcode Notes":** You want to automatically create notes, summaries, or explanations for LeetCode problems. This could involve: * Summarizing problem statements. * Generating code solutions (in various languages). * Explaining the logic behind solutions. * Creating test cases. * Providing time and space complexity analysis. **Possible Scenarios and Translations:** Based on the assumption that "MCP Server" refers to an AI-powered system, here are a few ways to phrase your request in Chinese, depending on the specific nuance you want to convey: **Scenario 1: General Request (Using an AI system to create LeetCode notes):** * **Chinese:** 使用机器学习系统生成 LeetCode 笔记 (Shǐyòng jīqì xuéxí xìtǒng shēngchéng LeetCode bǐjì) * **Literal Translation:** Use a machine learning system to generate LeetCode notes. * **Explanation:** This is a broad and general translation. It assumes the "MCP Server" is a machine learning system. **Scenario 2: More Specific (Using a server-based AI to generate LeetCode notes):** * **Chinese:** 使用服务器端的 AI 系统生成 LeetCode 笔记 (Shǐyòng fúwùqì duān de AI xìtǒng shēngchéng LeetCode bǐjì) * **Literal Translation:** Use a server-side AI system to generate LeetCode notes. * **Explanation:** This emphasizes that the AI is running on a server. **Scenario 3: Focusing on Automation (Automated generation of LeetCode notes):** * **Chinese:** 自动化生成 LeetCode 笔记 (Zìdòng huà shēngchéng LeetCode bǐjì) * **Literal Translation:** Automatically generate LeetCode notes. * **Explanation:** This focuses on the automated aspect, without explicitly mentioning the AI system. It implies that some system is doing the generation. **Scenario 4: If you *really* meant Minecraft (highly unlikely, but just in case):** * **Chinese:** 使用 Minecraft 服务器生成 LeetCode 笔记 (Shǐyòng Minecraft fúwùqì shēngchéng LeetCode bǐjì) * **Literal Translation:** Use a Minecraft server to generate LeetCode notes. * **Explanation:** This is the literal translation if you meant a Minecraft server. It's highly improbable that this is what you meant, as the connection is unclear. You would need to explain *how* you intend to use a Minecraft server for this. Perhaps you're thinking of using command blocks or a mod to create a visual representation of algorithms? **Key Vocabulary:** * **LeetCode:** LeetCode (No translation needed, it's a proper noun) * **笔记 (bǐjì):** Notes * **生成 (shēngchéng):** To generate, to produce * **机器学习 (jīqì xuéxí):** Machine learning * **人工智能 (réngōng zhìnéng) / AI:** Artificial intelligence / AI * **服务器 (fúwùqì):** Server * **自动化 (zìdòng huà):** Automation, automated **To get a more accurate translation, please provide more context:** * **What is the "MCP Server" you are referring to?** Is it a specific software, a type of AI, or something else? * **What kind of notes do you want to generate?** Summaries, code solutions, explanations, test cases, etc.? * **What is the purpose of generating these notes?** Studying, sharing, etc.? The more information you give me, the better I can tailor the translation to your specific needs.

insights-mcp-server

insights-mcp-server

红帽 Insights MCP 服务器 POC (Hóngmào Insights MCP fúwùqì POC) This translates to: * **红帽 (Hóngmào):** Red Hat * **Insights:** Insights (The English word is often used directly in Chinese in technical contexts) * **MCP:** MCP (The English abbreviation is often used directly in Chinese in technical contexts) * **服务器 (fúwùqì):** Server * **POC:** POC (Proof of Concept - The English abbreviation is often used directly in Chinese in technical contexts) Therefore, a more natural translation, especially in a technical setting, might be: **红帽 Insights MCP 服务器概念验证 (Hóngmào Insights MCP fúwùqì gàiniàn yànzhèng)** Where: * **概念验证 (gàiniàn yànzhèng):** Concept Validation (This is a more formal translation of "Proof of Concept") While the first translation is perfectly understandable, the second one is more precise and commonly used in formal documentation. Choose the one that best suits your audience and the context.

MCP Neo4j Knowledge Graph Memory Server

MCP Neo4j Knowledge Graph Memory Server

Weather MCP Server

Weather MCP Server

mcp-edge-search

mcp-edge-search

一个模型上下文协议(Model Context Protocol,MCP)服务器,为像 Claude Desktop 这样的 MCP 客户端提供网络搜索功能。

天气 MCP 服务器

天气 MCP 服务器

这是一个基于 FastMCP 构建的天气查询 MCP 服务器。 (This translates to: "This is a weather query MCP server built on FastMCP.")

NYT MCP Server

NYT MCP Server

一个消息集中协议 (MCP) 服务器,它为纽约时报 API 提供一个统一、简单的接口。该服务器通过一个单一的端点简化了与多个 NYT API 的交互。

mcp_server

mcp_server

Okay, I understand. You want me to describe how to implement a "weather MCP server" that can be called by a client IDE like Cursor. Here's a breakdown of the concept, implementation considerations, and a simplified example (using Python and a basic HTTP API) to illustrate the core ideas. **What is an MCP Server (in this context)?** In this scenario, "MCP" likely refers to a *Microservice Communication Protocol* or a similar concept. It means you're building a small, independent service (the weather server) that provides weather information and communicates with other applications (like the Cursor IDE) using a defined protocol. In practice, this often translates to a RESTful API over HTTP. **Key Components** 1. **Weather Data Source:** * This is where your server gets the actual weather information. You'll likely use a third-party weather API (e.g., OpenWeatherMap, AccuWeather, WeatherAPI.com). These APIs typically require you to sign up for an account and obtain an API key. * Consider caching the weather data to reduce the number of API calls and improve response times. 2. **Server-Side Implementation (e.g., Python with Flask/FastAPI):** * This is the core of your weather server. It handles incoming requests, fetches weather data from the data source, and formats the response. * **Framework Choice:** * **Flask:** A lightweight and flexible framework, good for simple APIs. * **FastAPI:** A modern, high-performance framework with automatic data validation and API documentation (using OpenAPI/Swagger). Generally preferred for new projects. * **API Endpoints:** You'll define endpoints like: * `/weather?city={city_name}`: Returns weather information for a specific city. * `/weather?zip={zip_code}`: Returns weather information for a specific zip code. * `/forecast?city={city_name}`: Returns a weather forecast for a specific city. 3. **Client-Side Integration (in Cursor IDE):** * The Cursor IDE (or any other client) will need to make HTTP requests to your weather server's API endpoints. * This might involve writing code within Cursor (e.g., using JavaScript or Python within a Cursor extension) to: * Get user input (e.g., the city name). * Construct the API request URL. * Send the request to the weather server. * Parse the JSON response from the server. * Display the weather information in the Cursor IDE. **Implementation Steps (Simplified Example with Python and Flask)** **1. Set up your environment:** ```bash # Create a project directory mkdir weather_server cd weather_server # Create a virtual environment (recommended) python3 -m venv venv source venv/bin/activate # On Linux/macOS # venv\Scripts\activate # On Windows # Install Flask and requests (for making HTTP requests to the weather API) pip install Flask requests ``` **2. `weather_server.py` (Flask Server):** ```python from flask import Flask, request, jsonify import requests import os app = Flask(__name__) # Replace with your actual OpenWeatherMap API key API_KEY = os.environ.get("OPENWEATHERMAP_API_KEY") or "YOUR_OPENWEATHERMAP_API_KEY" # Get from environment variable or hardcode (not recommended for production) BASE_URL = "https://api.openweathermap.org/data/2.5/weather" def get_weather_data(city): """Fetches weather data from OpenWeatherMap.""" params = { "q": city, "appid": API_KEY, "units": "metric", # Use Celsius } try: response = requests.get(BASE_URL, params=params) response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx) data = response.json() return data except requests.exceptions.RequestException as e: print(f"Error fetching weather data: {e}") return None @app.route("/weather") def weather(): """API endpoint to get weather by city.""" city = request.args.get("city") if not city: return jsonify({"error": "City parameter is required"}), 400 weather_data = get_weather_data(city) if weather_data: # Extract relevant information temperature = weather_data["main"]["temp"] description = weather_data["weather"][0]["description"] humidity = weather_data["main"]["humidity"] wind_speed = weather_data["wind"]["speed"] return jsonify({ "city": city, "temperature": temperature, "description": description, "humidity": humidity, "wind_speed": wind_speed }) else: return jsonify({"error": "Could not retrieve weather data for that city"}), 500 if __name__ == "__main__": app.run(debug=True) # Don't use debug=True in production! ``` **3. Running the Server:** ```bash # Set your OpenWeatherMap API key (replace with your actual key) export OPENWEATHERMAP_API_KEY="YOUR_OPENWEATHERMAP_API_KEY" # Linux/macOS # set OPENWEATHERMAP_API_KEY="YOUR_OPENWEATHERMAP_API_KEY" # Windows # Run the Flask server python weather_server.py ``` **4. Example Client-Side Code (Conceptual - in Cursor IDE):** This is a *very* simplified example of how you *might* integrate this into Cursor. The exact implementation will depend on Cursor's extension API and how you want to display the information. This assumes you can execute JavaScript or Python code within Cursor. ```javascript // Example JavaScript code (Conceptual - adapt to Cursor's API) async function getWeather(city) { const apiUrl = `http://127.0.0.1:5000/weather?city=${city}`; // Replace with your server's address try { const response = await fetch(apiUrl); const data = await response.json(); if (response.ok) { // Display the weather information in the Cursor IDE console.log(`Weather in ${data.city}:`); console.log(`Temperature: ${data.temperature}°C`); console.log(`Description: ${data.description}`); console.log(`Humidity: ${data.humidity}%`); console.log(`Wind Speed: ${data.wind_speed} m/s`); // You'd need to use Cursor's API to actually display this in the editor or a panel. // For example, Cursor might have a function like: // cursor.showInformationMessage(`Weather in ${data.city}: ...`); } else { console.error(`Error: ${data.error}`); // Display an error message in Cursor } } catch (error) { console.error("Error fetching weather:", error); // Display a network error in Cursor } } // Example usage: const cityName = "London"; // Or get the city from user input in Cursor getWeather(cityName); ``` **Explanation and Improvements** * **Error Handling:** The code includes basic error handling (checking for API errors, missing city parameter). Robust error handling is crucial for production. * **API Key Security:** *Never* hardcode your API key directly in the code, especially if you're sharing it. Use environment variables (as shown) or a configuration file. * **Asynchronous Operations:** Use `async/await` (as in the JavaScript example) to avoid blocking the UI thread while waiting for the API response. * **Data Validation:** Use a library like `marshmallow` (in Python) or a similar validation library in your chosen language to validate the data received from the weather API. This helps prevent unexpected errors. * **Caching:** Implement caching to store frequently accessed weather data. This reduces the load on the weather API and improves response times. You could use a simple in-memory cache (for small-scale deployments) or a more robust caching solution like Redis or Memcached. * **Rate Limiting:** Be aware of the rate limits imposed by the weather API you're using. Implement rate limiting in your server to avoid exceeding the limits and getting your API key blocked. * **Logging:** Use a logging library (e.g., `logging` in Python) to log important events, errors, and debugging information. * **API Documentation:** Use a tool like Swagger (with FastAPI) to automatically generate API documentation. This makes it easier for other developers to use your weather server. * **Deployment:** Consider deploying your weather server to a cloud platform like AWS, Google Cloud, or Azure. **Chinese Translation of Key Concepts** * **Weather MCP Server:** 天气 MCP 服务器 (Tiānqì MCP fúwùqì) * **Microservice Communication Protocol:** 微服务通信协议 (Wēi fúwù tōngxìn xiéyì) * **API Endpoint:** API 端点 (API duāndiǎn) * **RESTful API:** RESTful API (RESTful API) (The term is often used directly in Chinese as well) * **API Key:** API 密钥 (API mìyào) * **Data Source:** 数据源 (shùjù yuán) * **Caching:** 缓存 (huǎncún) * **Rate Limiting:** 速率限制 (sùlǜ xiànzhì) * **Error Handling:** 错误处理 (cuòwù chǔlǐ) * **Environment Variable:** 环境变量 (huánjìng biànliàng) **Important Considerations for Cursor Integration** * **Cursor's Extension API:** The most important thing is to understand Cursor's extension API. How can you create extensions, access the editor, display information, and get user input? Refer to Cursor's official documentation for this. * **Security:** Be very careful about security when integrating with an IDE. Avoid storing sensitive information (like API keys) directly in the extension code. Use secure storage mechanisms provided by the IDE or the operating system. * **User Experience:** Design the integration to be as seamless and intuitive as possible for the user. Consider how the weather information will be displayed (e.g., in a tooltip, a panel, or directly in the editor). This detailed explanation and example should give you a solid foundation for building your weather MCP server and integrating it with Cursor. Remember to adapt the code and concepts to your specific needs and the capabilities of the Cursor IDE. Good luck!

Awesome MCP Servers

Awesome MCP Servers

模型上下文协议 (MCP) 服务器的综合集合

Structured Thinking

Structured Thinking

一个统一的 MCP 服务器,用于结构化思维工具,包括模板思维和验证思维。 (Alternatively, depending on the specific context and target audience, you could also say:) 一个整合的 MCP 服务器,提供结构化思维工具,例如模板思维和验证思维。

Time-MCP

Time-MCP

For the time and date, an MCP (Minecraft Protocol) server doesn't directly provide that information. The Minecraft protocol focuses on game-related data. However, here are a few ways you could get the time and date in relation to a Minecraft server: * **Server-Side Mod/Plugin:** The most common and reliable way. You would need a server-side mod or plugin (like for Bukkit, Spigot, Paper, Fabric, or Forge) that exposes the server's current time and date. This mod/plugin could then: * Display the time/date in the server console. * Send the time/date to players in-game (e.g., via chat message, scoreboard, or a custom GUI). * Expose the time/date via an API that other programs can query. * **External Script/Program:** You could write a script (e.g., in Python, Java, etc.) that runs on the same machine as the Minecraft server. This script would: 1. Get the current system time and date from the operating system. 2. Potentially interact with the Minecraft server (if needed) to display the time/date in-game (using `rcon` or a similar method). This is less common because it requires more setup. * **In-Game Clock (Minecraft Feature):** Minecraft itself has a day/night cycle. While not a real-world clock, players can use the in-game clock to estimate the time. You could potentially use commands or mods to display the in-game time in a more readable format. **In summary, you'll need a server-side mod/plugin or an external script to get the actual time and date in relation to your Minecraft server.** The MCP itself doesn't handle this. Here's the translation to Chinese: 对于时间和日期,MCP(Minecraft 协议)服务器不直接提供这些信息。 Minecraft 协议专注于与游戏相关的数据。 但是,以下是一些您可以获取与 Minecraft 服务器相关的时间和日期的方法: * **服务器端模组/插件:** 这是最常见和最可靠的方法。 您需要一个服务器端模组或插件(例如 Bukkit、Spigot、Paper、Fabric 或 Forge),该模组或插件公开服务器的当前时间和日期。 然后,此模组/插件可以: * 在服务器控制台中显示时间/日期。 * 在游戏中将时间/日期发送给玩家(例如,通过聊天消息、记分牌或自定义 GUI)。 * 通过其他程序可以查询的 API 公开时间/日期。 * **外部脚本/程序:** 您可以编写一个脚本(例如,使用 Python、Java 等),该脚本与 Minecraft 服务器在同一台机器上运行。 该脚本将: 1. 从操作系统获取当前的系统时间和日期。 2. (如果需要)可能与 Minecraft 服务器交互,以在游戏中显示时间/日期(使用 `rcon` 或类似方法)。 这不太常见,因为它需要更多设置。 * **游戏内时钟(Minecraft 功能):** Minecraft 本身具有昼夜循环。 虽然不是真实世界的时钟,但玩家可以使用游戏内时钟来估计时间。 您可以潜在地使用命令或模组以更易读的格式显示游戏内时间。 **总而言之,您需要一个服务器端模组/插件或外部脚本来获取与您的 Minecraft 服务器相关的实际时间和日期。** MCP 本身不处理此问题。

Weather MCP Server

Weather MCP Server

Okay, here's an example of a simple weather MCP (Minecraft Protocol) server in Python. This is a very basic example and doesn't implement the full Minecraft protocol. It focuses on sending a custom packet to a client that's expecting weather information. **Important Considerations:** * **MCP (Minecraft Protocol) Complexity:** The actual Minecraft protocol is quite complex. This example simplifies things significantly. A real-world server would need to handle authentication, world data, player movement, and much more. * **Client-Side Mod:** This server *requires* a client-side mod (or a modified client) that knows how to interpret the custom weather packet this server sends. The standard Minecraft client won't understand it. * **Python Libraries:** This example uses the `socket` library for basic network communication and `struct` for packing data into binary format. ```python import socket import struct import time # Configuration HOST = '127.0.0.1' # Listen on localhost PORT = 25565 # Use a port (not the default Minecraft port unless you know what you're doing) WEATHER_UPDATE_INTERVAL = 5 # Seconds between weather updates def create_weather_packet(temperature, humidity, rain): """ Creates a custom weather packet. Args: temperature: Temperature value (float). humidity: Humidity value (float). rain: Rain intensity (float, 0.0 - 1.0). Returns: A bytes object representing the weather packet. """ packet_id = 0x01 # Custom packet ID (must match client-side mod) # Pack the data into a binary format packet_data = struct.pack('!bff', temperature, humidity, rain) # ! = network byte order, b = byte (packet ID), f = float # Prepend the packet ID packet = struct.pack('!b', packet_id) + packet_data # Prepend the packet length packet_length = len(packet) packet = struct.pack('!i', packet_length) + packet return packet def main(): """ Main server loop. """ 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(1) # Listen for one connection print(f"Weather MCP Server listening on {HOST}:{PORT}") conn, addr = server_socket.accept() print(f"Client connected from {addr}") try: while True: # Simulate weather data (replace with real data source) temperature = 25.5 + (time.time() % 10) - 5 # Temperature between 20.5 and 30.5 humidity = 0.6 + (time.time() % 5) / 10 # Humidity between 0.6 and 1.1 rain = 0.0 if temperature > 28 else (time.time() % 3) / 3 # Rain if temp is below 28 weather_packet = create_weather_packet(temperature, humidity, rain) try: conn.sendall(weather_packet) print(f"Sent weather update: Temp={temperature:.1f}, Humidity={humidity:.2f}, Rain={rain:.2f}") except BrokenPipeError: print("Client disconnected.") break # Exit the loop if the client disconnects time.sleep(WEATHER_UPDATE_INTERVAL) except KeyboardInterrupt: print("Server shutting down.") finally: conn.close() server_socket.close() if __name__ == "__main__": main() ``` **Explanation:** 1. **Imports:** Imports necessary libraries (`socket`, `struct`, `time`). 2. **Configuration:** Sets the host, port, and weather update interval. *Change the port if you're running a real Minecraft server on the default port (25565).* 3. **`create_weather_packet()`:** * Takes temperature, humidity, and rain intensity as input. * `packet_id = 0x01`: This is a *crucial* part. This is a custom packet ID. Your client-side mod *must* be programmed to recognize this ID and know how to interpret the data that follows. If the client doesn't know about this ID, it will likely crash or ignore the packet. * `struct.pack('!bff', ...)`: This packs the data into a binary format. * `!`: Specifies network byte order (big-endian), which is standard for network communication. * `b`: Represents a single byte (for the packet ID). * `f`: Represents a float (for temperature, humidity, and rain). * The packet length is prepended to the packet. This is important for the client to know how many bytes to read. 4. **`main()`:** * Creates a socket, binds it to the host and port, and listens for connections. * `server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)`: This allows you to quickly restart the server without waiting for the port to be released. * Accepts a connection from a client. * Enters a `while True` loop to continuously send weather updates. * **Simulates Weather Data:** The example generates random weather data. In a real application, you would get this data from a weather API or some other source. * `conn.sendall(weather_packet)`: Sends the weather packet to the client. * `time.sleep(WEATHER_UPDATE_INTERVAL)`: Waits before sending the next update. * Handles `BrokenPipeError`: This exception is raised if the client disconnects. * Handles `KeyboardInterrupt`: Allows you to gracefully shut down the server with Ctrl+C. * Closes the connection and the socket in the `finally` block. **How to Use:** 1. **Client-Side Mod:** You *must* create a client-side mod (using Forge, Fabric, or another modding framework) that: * Connects to this server on the specified host and port. * Listens for packets with the packet ID `0x01`. * Unpacks the data from the packet (using `struct.unpack('!bff', data)`) to get the temperature, humidity, and rain values. * Displays the weather information in the game or uses it to affect the game world. 2. **Run the Server:** Save the Python code as a `.py` file (e.g., `weather_server.py`) and run it from your terminal: `python weather_server.py` 3. **Run Minecraft with the Mod:** Start Minecraft with your client-side mod installed. The mod should connect to the server and start receiving weather updates. **Example Client-Side Mod (Conceptual - Forge, Simplified):** ```java // (This is a very simplified example - you'll need to adapt it to your modding framework) import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import java.net.Socket; import java.io.DataInputStream; import java.nio.ByteBuffer; @Mod(modid = "weather_mod", name = "Weather Mod", version = "1.0") public class WeatherMod { private static final String SERVER_HOST = "127.0.0.1"; private static final int SERVER_PORT = 25565; private static Socket socket; private static DataInputStream in; private float temperature = 0.0f; private float humidity = 0.0f; private float rain = 0.0f; @Mod.EventHandler public void init(FMLInitializationEvent event) { new Thread(() -> { try { socket = new Socket(SERVER_HOST, SERVER_PORT); in = new DataInputStream(socket.getInputStream()); while (true) { // Read packet length int packetLength = in.readInt(); // Read packet ID byte packetId = in.readByte(); if (packetId == 0x01) { // Read the rest of the packet data byte[] data = new byte[packetLength - 1]; in.readFully(data); ByteBuffer buffer = ByteBuffer.wrap(data); buffer.order(java.nio.ByteOrder.BIG_ENDIAN); // Network byte order temperature = buffer.getFloat(); humidity = buffer.getFloat(); rain = buffer.getFloat(); System.out.println("Received weather: Temp=" + temperature + ", Humidity=" + humidity + ", Rain=" + rain); // Update game world (e.g., change sky color, add rain particles) // This part requires more Forge-specific code } } } catch (Exception e) { e.printStackTrace(); } }).start(); } // Getter methods to access weather data from other parts of your mod public float getTemperature() { return temperature; } public float getHumidity() { return humidity; } public float getRain() { return rain; } } ``` **Important Notes about the Client Mod:** * **Threading:** The client mod uses a separate thread to connect to the server and receive data. This prevents the main game thread from blocking. * **Error Handling:** The client mod needs proper error handling (e.g., handling connection errors, invalid packet data). * **Forge/Fabric Specifics:** The example uses some basic Forge annotations. You'll need to adapt it to the specific modding framework you're using. The code to update the game world (e.g., changing sky color, adding rain particles) will be very framework-specific. * **Byte Order:** Make sure the client uses the same byte order (`java.nio.ByteOrder.BIG_ENDIAN`) as the server when unpacking the data. * **Packet Length:** The client reads the packet length first to know how many bytes to read for the rest of the packet. **Chinese Translation (Simplified):** ```chinese # 这是一个用 Python 编写的简单天气 MCP (Minecraft 协议) 服务器的例子。 # 重要注意事项: # * MCP (Minecraft 协议) 非常复杂。 这个例子大大简化了。 # * 这个服务器需要一个客户端模组(或修改过的客户端),它知道如何解释这个服务器发送的自定义天气数据包。 # * 这个例子使用 socket 库进行基本的网络通信,并使用 struct 库将数据打包成二进制格式。 import socket import struct import time # 配置 HOST = '127.0.0.1' # 监听本地主机 PORT = 25565 # 使用一个端口(除非你知道自己在做什么,否则不要使用默认的 Minecraft 端口) WEATHER_UPDATE_INTERVAL = 5 # 天气更新之间的秒数 def create_weather_packet(temperature, humidity, rain): """ 创建一个自定义天气数据包。 参数: temperature: 温度值 (浮点数)。 humidity: 湿度值 (浮点数)。 rain: 降雨强度 (浮点数, 0.0 - 1.0)。 返回值: 表示天气数据包的字节对象。 """ packet_id = 0x01 # 自定义数据包 ID(必须与客户端模组匹配) # 将数据打包成二进制格式 packet_data = struct.pack('!bff', temperature, humidity, rain) # ! = 网络字节顺序,b = 字节 (数据包 ID),f = 浮点数 # 在前面加上数据包 ID packet = struct.pack('!b', packet_id) + packet_data # 在前面加上数据包长度 packet_length = len(packet) packet = struct.pack('!i', packet_length) + packet return packet 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((HOST, PORT)) server_socket.listen(1) # 监听一个连接 print(f"天气 MCP 服务器监听在 {HOST}:{PORT}") conn, addr = server_socket.accept() print(f"客户端从 {addr} 连接") try: while True: # 模拟天气数据(用真实数据源替换) temperature = 25.5 + (time.time() % 10) - 5 # 温度在 20.5 和 30.5 之间 humidity = 0.6 + (time.time() % 5) / 10 # 湿度在 0.6 和 1.1 之间 rain = 0.0 if temperature > 28 else (time.time() % 3) / 3 # 如果温度低于 28,则下雨 weather_packet = create_weather_packet(temperature, humidity, rain) try: conn.sendall(weather_packet) print(f"发送天气更新:温度={temperature:.1f}, 湿度={humidity:.2f}, 降雨={rain:.2f}") except BrokenPipeError: print("客户端断开连接。") break # 如果客户端断开连接,则退出循环 time.sleep(WEATHER_UPDATE_INTERVAL) except KeyboardInterrupt: print("服务器正在关闭。") finally: conn.close() server_socket.close() if __name__ == "__main__": main() ``` **Key Takeaways:** * This is a *very* simplified example. A real Minecraft server is much more complex. * The client-side mod is essential. Without it, the standard Minecraft client will not understand the custom weather packets. * Pay close attention to packet IDs, data packing/unpacking, and byte order. * Use threading in your client mod to avoid blocking the main game thread. * Handle errors gracefully. This should give you a good starting point. Good luck!

Malaysia Prayer Time for Claude Desktop

Malaysia Prayer Time for Claude Desktop

马来西亚祈祷时间数据的模型上下文协议 (MCP) 服务器

Mcp Akshare

Mcp Akshare

AKShare 是一个基于 Python 的金融数据接口库,旨在提供一套工具,用于采集、清洗和存储股票、期货、期权、基金、外汇、债券、指数、加密货币等金融产品的基本面数据、实时和历史行情数据以及衍生数据。它主要用于学术研究目的。

🧠 MCP PID Wallet Verifier

🧠 MCP PID Wallet Verifier

一个轻量级且对 AI 友好的 MCP 服务器,允许任何 AI 代理或 MCP 兼容的助手通过 OIDC4VP 发起和验证 PID(个人身份数据)凭证展示。

Thirdweb Mcp

Thirdweb Mcp