Discover Awesome MCP Servers

Extend your agent with 15,726 capabilities via MCP servers.

All15,726
MCP Host Project

MCP Host Project

## Spring AI での MCP (Model Context Protocol) の Spring Boot アプリケーションへの統合 このドキュメントでは、Spring AI の MCP (Model Context Protocol) サポートを Spring Boot アプリケーションに統合する方法を、サーバーサイドとクライアントサイドの両方の実装をカバーして説明します。 **MCP (Model Context Protocol) とは?** MCP は、大規模言語モデル (LLM) との対話を標準化するためのプロトコルです。これにより、LLM にコンテキスト情報を提供し、より正確で関連性の高い応答を得ることができます。Spring AI は MCP をサポートしており、Spring Boot アプリケーションで LLM をより効果的に活用できます。 **前提条件** * Java 17 以上 * Maven または Gradle * Spring Boot 3.1 以上 * Spring AI 0.8.0 以上 * LLM API キー (例: OpenAI, Azure OpenAI) **1. プロジェクトのセットアップ** Spring Initializr (https://start.spring.io/) を使用して、必要な依存関係を含む Spring Boot プロジェクトを作成します。 以下の依存関係を含めることを推奨します。 * Spring Web * Spring AI * Lombok (オプション) **2. 依存関係の追加 (pom.xml)** ```xml <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.ai</groupId> <artifactId>spring-ai-spring-boot-starter</artifactId> <version>0.8.0</version> </dependency> <!-- 使用する LLM プロバイダーの依存関係を追加 (例: OpenAI) --> <dependency> <groupId>org.springframework.ai</groupId> <artifactId>spring-ai-openai</artifactId> <version>0.8.0</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> ``` **3. 設定 (application.properties または application.yml)** LLM プロバイダーの API キーとモデルを設定します。 ```properties spring.ai.openai.api-key=YOUR_OPENAI_API_KEY spring.ai.openai.model=gpt-3.5-turbo ``` または (application.yml): ```yaml spring: ai: openai: api-key: YOUR_OPENAI_API_KEY model: gpt-3.5-turbo ``` **4. サーバーサイドの実装 (MCP を使用して LLM にコンテキストを渡す)** ```java import org.springframework.ai.chat.ChatClient; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.prompt.PromptTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.Map; @RestController public class AiController { @Autowired private ChatClient chatClient; @GetMapping("/ai/generate") public String generate(@RequestParam("topic") String topic, @RequestParam("context") String context) { // プロンプトテンプレートを作成 String template = "以下のコンテキストに基づいて、{topic} について説明してください。\n\nコンテキスト: {context}"; PromptTemplate promptTemplate = new PromptTemplate(template); // コンテキストをマップに格納 Map<String, Object> model = Map.of("topic", topic, "context", context); // プロンプトを生成 String prompt = promptTemplate.render(model); // LLM にリクエストを送信 ChatResponse response = chatClient.call(prompt); // 応答を抽出 Generation generation = response.getResult(); return generation.getOutput().getContent(); } } ``` この例では、`@RequestParam` を使用してクライアントから `topic` と `context` を受け取ります。 `PromptTemplate` を使用して、コンテキストをプロンプトに組み込みます。 `ChatClient` は、生成されたプロンプトを LLM に送信し、応答を受け取ります。 **5. クライアントサイドの実装 (サーバーにコンテキストを送信)** クライアントサイドでは、サーバーに `topic` と `context` を含むリクエストを送信する必要があります。 以下は、JavaScript (fetch API) を使用した例です。 ```javascript async function generateText(topic, context) { const url = `/ai/generate?topic=${topic}&context=${context}`; try { const response = await fetch(url); const data = await response.text(); return data; } catch (error) { console.error("Error:", error); return "An error occurred."; } } // 使用例 const topic = "Spring AI"; const context = "Spring AI は、大規模言語モデル (LLM) を使用したアプリケーションを構築するためのフレームワークです。"; generateText(topic, context) .then(result => { console.log(result); }); ``` この例では、`generateText` 関数は、指定された `topic` と `context` を含む GET リクエストを `/ai/generate` エンドポイントに送信します。 サーバーからの応答はコンソールに記録されます。 **6. 実行とテスト** Spring Boot アプリケーションを実行し、ブラウザまたは API クライアント (例: Postman) を使用して `/ai/generate` エンドポイントにリクエストを送信します。 例: `http://localhost:8080/ai/generate?topic=Spring%20AI&context=Spring%20AI%E3%81%AF%E3%80%81%E5%A4%A7%E8%A6%8F%E6%A8%A1%E8%A8%80%E8%AA%9E%E3%83%A2%E3%83%87%E3%83%AB%20(LLM)%20%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%9F%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E6%A7%8B%E7%AF%89%E3%81%99%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AE%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%83%AF%E3%83%BC%E3%82%AF%E3%81%A7%E3%81%99%E3%80%82` **7. より高度な MCP の使用** Spring AI は、より高度な MCP の使用をサポートしています。例えば、`ChatRequest` オブジェクトを使用して、システムメッセージ、ユーザーメッセージ、アシスタントメッセージなど、複数のメッセージを LLM に送信できます。 ```java import org.springframework.ai.chat.ChatClient; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.messages.Message; import org.springframework.ai.chat.messages.SystemMessage; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.prompt.PromptTemplate; import org.springframework.ai.chat.prompt.SystemPromptTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; @RestController public class AiController { @Autowired private ChatClient chatClient; @GetMapping("/ai/generate-advanced") public String generateAdvanced(@RequestParam("topic") String topic, @RequestParam("context") String context) { // システムメッセージのテンプレート String systemTemplate = "あなたは {topic} について説明するアシスタントです。以下のコンテキストを考慮してください: {context}"; SystemPromptTemplate systemPromptTemplate = new SystemPromptTemplate(systemTemplate); Map<String, Object> systemModel = Map.of("topic", topic, "context", context); SystemMessage systemMessage = systemPromptTemplate.createMessage(systemModel); // ユーザーメッセージ UserMessage userMessage = new UserMessage("Spring AI について教えてください。"); // メッセージリストを作成 List<Message> messages = List.of(systemMessage, userMessage); // LLM にリクエストを送信 ChatResponse response = chatClient.call(messages); // 応答を抽出 Generation generation = response.getResult(); return generation.getOutput().getContent(); } } ``` この例では、`SystemMessage` を使用して LLM にコンテキストと指示を提供し、`UserMessage` を使用してユーザーの質問を送信します。 **8. まとめ** このドキュメントでは、Spring AI の MCP サポートを Spring Boot アプリケーションに統合する方法を説明しました。 `PromptTemplate` を使用してコンテキストをプロンプトに組み込む方法、`ChatRequest` オブジェクトを使用して複数のメッセージを送信する方法など、さまざまな方法で MCP を活用できます。 これらのテクニックを使用することで、LLM との対話を改善し、より正確で関連性の高い応答を得ることができます。 **補足** * このドキュメントは基本的な例を示しています。 実際のアプリケーションでは、エラー処理、ロギング、セキュリティなどの要素を考慮する必要があります。 * Spring AI は、さまざまな LLM プロバイダーをサポートしています。 使用するプロバイダーに応じて、設定と依存関係を調整する必要があります。 * MCP は進化し続けているプロトコルです。 Spring AI の最新バージョンを使用し、公式ドキュメントを参照して、最新の機能とベストプラクティスを確認してください。 この翻訳が、Spring AI での MCP の Spring Boot アプリケーションへの統合を理解するのに役立つことを願っています。

MCP_claude

MCP_claude

これは、Claude Desktop MCPクライアント用にMCPサーバーを構築する方法を示すためのものです。

Symbol MCP Server (REST API tools)

Symbol MCP Server (REST API tools)

シンボル MCP サーバー (REST API ツール)

MCP LLM Bridge

MCP LLM Bridge

Ollama から fetch URL MCP サーバーへの簡単なブリッジ

Mcp Server Python

Mcp Server Python

cursor_agents

cursor_agents

「MCPサーバーを使用して、専門家チームをエージェントフローに追加する」

Prometheus Alertmanager MCP Server

Prometheus Alertmanager MCP Server

Prometheus Alertmanager と統合された Model Context Protocol (MCP) サーバー

Modes MCP Server

Modes MCP Server

鏡 (Kagami)

Confluence Communication Server MCP Server

Confluence Communication Server MCP Server

鏡 (Kagami)

spring-mcp-server-sample

spring-mcp-server-sample

MCPサーバーサンプル

Filesystem MCP Server

Filesystem MCP Server

鏡 (Kagami)

Time-MCP

Time-MCP

「現在の日時を取得するためのMCPサーバー」 (Genzai no nichiji o shutoku suru tame no MCP sābā)

Effect CLI - Model Context Protocol

Effect CLI - Model Context Protocol

MCPサーバー、CLIツールとして公開

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 to display weather information. **Important Considerations:** * **Minecraft Protocol Complexity:** The actual Minecraft protocol is quite complex. This example simplifies things significantly. You'd need a proper library (like `mcstatus` or `nbt`) for more robust interaction. * **Client-Side Mod:** This server sends a custom packet. The Minecraft client *must* have a mod installed that knows how to receive and interpret this custom packet. Without a client-side mod, the client will ignore the packet, and nothing will happen. * **Security:** This is a basic example and doesn't include any security measures. Do not expose this to the open internet without proper security considerations. * **Error Handling:** The error handling is minimal. A production server would need much more robust error handling. * **MCP (Minecraft Protocol) Version:** The Minecraft protocol changes between versions. This example is a general concept and might need adjustments depending on the Minecraft version you're targeting. ```python import socket import struct import time import random # 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) CUSTOM_PACKET_ID = 0x7F # A custom packet ID (must match client-side mod) def create_weather_packet(temperature, humidity, wind_speed): """Creates a custom weather packet.""" # Format: Packet ID (1 byte), Temperature (float), Humidity (float), Wind Speed (float) packet_data = struct.pack('!bfff', CUSTOM_PACKET_ID, temperature, humidity, wind_speed) # Add packet length (VarInt) packet_length = len(packet_data) length_prefix = encode_varint(packet_length) return length_prefix + packet_data def encode_varint(value): """Encodes an integer as a Minecraft VarInt.""" 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 handle_client(conn, addr): """Handles a single client connection.""" print(f"Connected by {addr}") try: while True: # Simulate weather data temperature = random.uniform(10.0, 35.0) # Celsius humidity = random.uniform(30.0, 90.0) # Percentage wind_speed = random.uniform(0.0, 15.0) # m/s # Create the weather packet weather_packet = create_weather_packet(temperature, humidity, wind_speed) # Send the packet conn.sendall(weather_packet) print(f"Sent weather data: Temp={temperature:.2f}, Humidity={humidity:.2f}, Wind={wind_speed:.2f}") time.sleep(5) # Send weather data every 5 seconds except ConnectionResetError: print(f"Client {addr} disconnected.") except Exception as e: print(f"Error handling client {addr}: {e}") finally: conn.close() def main(): """Main server function.""" with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) s.listen() print(f"Weather MCP Server listening on {HOST}:{PORT}") while True: conn, addr = s.accept() handle_client(conn, addr) if __name__ == "__main__": main() ``` **Explanation:** 1. **Imports:** Imports necessary modules (`socket`, `struct`, `time`, `random`). 2. **Configuration:** * `HOST`: The IP address to listen on (localhost in this case). * `PORT`: The port to listen on. Choose a port that's not already in use. **Do not use the default Minecraft port (25565) unless you know what you're doing and are prepared to handle the full Minecraft handshake.** * `CUSTOM_PACKET_ID`: A unique ID for your custom packet. This *must* match the ID used in your client-side mod. IDs 0x00-0x1F and 0xFA-0xFF are generally reserved. 3. **`create_weather_packet(temperature, humidity, wind_speed)`:** * This function creates the custom packet that will be sent to the client. * `struct.pack('!bfff', ...)`: This packs the data into a binary format. * `!`: Network byte order (big-endian). Important for Minecraft. * `b`: Signed byte (for the packet ID). * `f`: Float (for temperature, humidity, and wind speed). * `encode_varint(packet_length)`: Encodes the packet length as a VarInt, which is required by the Minecraft protocol. 4. **`encode_varint(value)`:** * Encodes an integer as a Minecraft VarInt. VarInts are a variable-length integer encoding used in the Minecraft protocol. 5. **`handle_client(conn, addr)`:** * Handles the connection with a single client. * It enters a loop that simulates weather data, creates a packet, and sends it to the client every 5 seconds. * Includes basic error handling for client disconnections. 6. **`main()`:** * Creates a socket, binds it to the specified host and port, and listens for incoming connections. * When a client connects, it calls `handle_client()` to handle the connection. **How to Use:** 1. **Save:** Save the code as a Python file (e.g., `weather_server.py`). 2. **Run:** Execute the script from your terminal: `python weather_server.py` 3. **Create a Client-Side Mod:** You *must* create a Minecraft mod that: * Connects to the server at the specified `HOST` and `PORT`. * Listens for packets with the `CUSTOM_PACKET_ID`. * Parses the temperature, humidity, and wind speed from the packet. * Displays the weather information in the game (e.g., on the screen, in a chat message, etc.). 4. **Run Minecraft with the Mod:** Start Minecraft with your mod installed. 5. **Connect:** Your mod should connect to the server, and you should see the weather data being displayed in the game. **Example Client-Side Mod (Conceptual - Requires Actual Modding):** This is a *very* simplified conceptual example of what the client-side mod would need to do. You'd need to use a Minecraft modding framework (like Forge or Fabric) to actually implement this. ```java // (Conceptual Java code - Requires a Minecraft modding framework) import net.minecraft.client.Minecraft; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; public class WeatherMod { private static final int CUSTOM_PACKET_ID = 0x7F; // Must match server @SubscribeEvent public void onClientPacket(ClientCustomPacketEvent event) { PacketBuffer buffer = event.getPacket().payload(); int packetId = buffer.readByte(); if (packetId == CUSTOM_PACKET_ID) { float temperature = buffer.readFloat(); float humidity = buffer.readFloat(); float windSpeed = buffer.readFloat(); // Display the weather information (e.g., in chat) Minecraft.getMinecraft().player.sendChatMessage( String.format("Weather: Temp=%.2f, Humidity=%.2f, Wind=%.2f", temperature, humidity, windSpeed)); } } } ``` **Key Improvements and Considerations for a Real-World Implementation:** * **Minecraft Protocol Handshake:** Implement the full Minecraft handshake (status request, login, etc.) if you want to act as a "real" Minecraft server. Libraries like `mcstatus` can help with this. * **Asynchronous Handling:** Use threads or asynchronous I/O (e.g., `asyncio`) to handle multiple clients concurrently without blocking. * **Configuration:** Allow the server to be configured (e.g., through a configuration file) for the port, packet ID, and other settings. * **Data Persistence:** Store weather data in a database or file so it persists across server restarts. * **More Realistic Weather:** Implement a more sophisticated weather model that changes over time and is influenced by factors like biome and time of day. * **Client-Side Mod Features:** Add more features to the client-side mod, such as displaying the weather information on the screen, changing the sky color, or adding weather effects (rain, snow, etc.). * **Security:** Implement proper authentication and authorization to prevent unauthorized access to the server. This example provides a starting point. Building a fully functional weather server requires a significant amount of work, especially on the client-side mod. Good luck! **Japanese Translation:** ``` 以下は、Python での簡単な天気 MCP (Minecraft Protocol) サーバーの例です。 これは非常に基本的な例であり、Minecraft プロトコルのすべてを実装しているわけではありません。 天気情報を表示するために、カスタムパケットをクライアントに送信することに焦点を当てています。 **重要な考慮事項:** * **Minecraft プロトコルの複雑さ:** 実際の Minecraft プロトコルは非常に複雑です。 この例では、大幅に簡略化されています。 より堅牢なインタラクションには、適切なライブラリ (`mcstatus` や `nbt` など) が必要になります。 * **クライアント側の Mod:** このサーバーはカスタムパケットを送信します。 Minecraft クライアントには、このカスタムパケットを受信して解釈する方法を知っている Mod がインストールされている*必要*があります。 クライアント側の Mod がないと、クライアントはパケットを無視し、何も起こりません。 * **セキュリティ:** これは基本的な例であり、セキュリティ対策は含まれていません。 適切なセキュリティ対策なしに、これをオープンなインターネットに公開しないでください。 * **エラー処理:** エラー処理は最小限です。 本番サーバーには、より堅牢なエラー処理が必要です。 * **MCP (Minecraft Protocol) バージョン:** Minecraft プロトコルはバージョンによって異なります。 この例は一般的な概念であり、対象とする Minecraft のバージョンに応じて調整が必要になる場合があります。 ```python import socket import struct import time import random # 設定 HOST = '127.0.0.1' # ローカルホストでリッスン PORT = 25565 # ポートを使用 (デフォルトの Minecraft ポートを使用する場合は、注意が必要です) CUSTOM_PACKET_ID = 0x7F # カスタムパケット ID (クライアント側の Mod と一致する必要があります) def create_weather_packet(temperature, humidity, wind_speed): """カスタム天気パケットを作成します。""" # フォーマット: パケット ID (1 バイト), 温度 (float), 湿度 (float), 風速 (float) packet_data = struct.pack('!bfff', CUSTOM_PACKET_ID, temperature, humidity, wind_speed) # パケット長を追加 (VarInt) packet_length = len(packet_data) length_prefix = encode_varint(packet_length) return length_prefix + packet_data def encode_varint(value): """整数を Minecraft VarInt としてエンコードします。""" 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 handle_client(conn, addr): """単一のクライアント接続を処理します。""" print(f"Connected by {addr}") try: while True: # 天気データをシミュレート temperature = random.uniform(10.0, 35.0) # 摂氏 humidity = random.uniform(30.0, 90.0) # パーセント wind_speed = random.uniform(0.0, 15.0) # m/s # 天気パケットを作成 weather_packet = create_weather_packet(temperature, humidity, wind_speed) # パケットを送信 conn.sendall(weather_packet) print(f"Sent weather data: Temp={temperature:.2f}, Humidity={humidity:.2f}, Wind={wind_speed:.2f}") time.sleep(5) # 5 秒ごとに天気データを送信 except ConnectionResetError: print(f"Client {addr} disconnected.") except Exception as e: print(f"Error handling client {addr}: {e}") finally: conn.close() def main(): """メインサーバー関数。""" with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) s.listen() print(f"Weather MCP Server listening on {HOST}:{PORT}") while True: conn, addr = s.accept() handle_client(conn, addr) if __name__ == "__main__": main() ``` **説明:** 1. **インポート:** 必要なモジュール (`socket`, `struct`, `time`, `random`) をインポートします。 2. **設定:** * `HOST`: リッスンする IP アドレス (この場合はローカルホスト)。 * `PORT`: リッスンするポート。 すでに使用されていないポートを選択してください。 **デフォルトの Minecraft ポート (25565) を使用する場合は、注意が必要です。完全な Minecraft ハンドシェイクを処理する準備ができている場合にのみ使用してください。** * `CUSTOM_PACKET_ID`: カスタムパケットの一意の ID。 これは、クライアント側の Mod で使用される ID と*一致する*必要があります。 ID 0x00-0x1F および 0xFA-0xFF は通常予約されています。 3. **`create_weather_packet(temperature, humidity, wind_speed)`:** * この関数は、クライアントに送信されるカスタムパケットを作成します。 * `struct.pack('!bfff', ...)`: これは、データをバイナリ形式にパックします。 * `!`: ネットワークバイトオーダー (ビッグエンディアン)。 Minecraft にとって重要です。 * `b`: 符号付きバイト (パケット ID 用)。 * `f`: float (温度、湿度、風速用)。 * `encode_varint(packet_length)`: パケット長を Minecraft プロトコルに必要な VarInt としてエンコードします。 4. **`encode_varint(value)`:** * 整数を Minecraft VarInt としてエンコードします。 VarInt は、Minecraft プロトコルで使用される可変長整数エンコーディングです。 5. **`handle_client(conn, addr)`:** * 単一のクライアントとの接続を処理します。 * 天気データをシミュレートし、パケットを作成し、5 秒ごとにクライアントに送信するループに入ります。 * クライアントの切断に対する基本的なエラー処理が含まれています。 6. **`main()`:** * ソケットを作成し、指定されたホストとポートにバインドし、着信接続をリッスンします。 * クライアントが接続すると、`handle_client()` を呼び出して接続を処理します。 **使い方:** 1. **保存:** コードを Python ファイルとして保存します (例: `weather_server.py`)。 2. **実行:** ターミナルからスクリプトを実行します: `python weather_server.py` 3. **クライアント側の Mod を作成:** 次のことを行う Minecraft Mod を*必ず*作成してください。 * 指定された `HOST` と `PORT` でサーバーに接続します。 * `CUSTOM_PACKET_ID` を持つパケットをリッスンします。 * パケットから温度、湿度、風速を解析します。 * ゲーム内で天気情報を表示します (例: 画面上、チャットメッセージなど)。 4. **Mod を使用して Minecraft を実行:** Mod をインストールした状態で Minecraft を起動します。 5. **接続:** Mod がサーバーに接続し、ゲーム内で天気データが表示されるはずです。 **クライアント側の Mod の例 (概念 - 実際の Modding が必要):** これは、クライアント側の Mod が行う必要のあることの*非常に*簡略化された概念的な例です。 これを実際に実装するには、Minecraft Modding フレームワーク (Forge や Fabric など) を使用する必要があります。 ```java // (概念的な Java コード - Minecraft Modding フレームワークが必要) import net.minecraft.client.Minecraft; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; public class WeatherMod { private static final int CUSTOM_PACKET_ID = 0x7F; // サーバーと一致する必要があります @SubscribeEvent public void onClientPacket(ClientCustomPacketEvent event) { PacketBuffer buffer = event.getPacket().payload(); int packetId = buffer.readByte(); if (packetId == CUSTOM_PACKET_ID) { float temperature = buffer.readFloat(); float humidity = buffer.readFloat(); float windSpeed = buffer.readFloat(); // 天気情報を表示 (例: チャットで) Minecraft.getMinecraft().player.sendChatMessage( String.format("Weather: Temp=%.2f, Humidity=%.2f, Wind=%.2f", temperature, humidity, windSpeed)); } } } ``` **実際の実装のための重要な改善点と考慮事項:** * **Minecraft プロトコルハンドシェイク:** 「実際の」Minecraft サーバーとして機能する場合は、完全な Minecraft ハンドシェイク (ステータスリクエスト、ログインなど) を実装します。 `mcstatus` などのライブラリが役立ちます。 * **非同期処理:** スレッドまたは非同期 I/O (`asyncio` など) を使用して、ブロックせずに複数のクライアントを同時に処理します。 * **設定:** ポート、パケット ID、その他の設定について、サーバーを設定ファイルなどを介して設定できるようにします。 * **データの永続性:** 天気データをデータベースまたはファイルに保存して、サーバーの再起動後も永続するようにします。 * **より現実的な天気:** 時間の経過とともに変化し、バイオームや時刻などの要因の影響を受ける、より洗練された天気モデルを実装します。 * **クライアント側の Mod 機能:** 画面に天気情報を表示したり、空の色を変更したり、天候効果 (雨、雪など) を追加したりするなど、クライアント側の Mod にさらに機能を追加します。 * **セキュリティ:** サーバーへの不正アクセスを防ぐために、適切な認証と承認を実装します。 この例は出発点を提供します。 完全に機能する天気サーバーを構築するには、特にクライアント側の Mod でかなりの作業が必要です。 頑張ってください! ``` This translation aims to be accurate and understandable for a Japanese speaker familiar with programming concepts. I've tried to maintain the technical accuracy while making it readable.

GitHub MCP Server for Cursor IDE

GitHub MCP Server for Cursor IDE

Cursor IDE 用 GitHub MCP サーバー

Hello, MCP server.

Hello, MCP server.

基本的な MCP サーバー

Malaysia Prayer Time for Claude Desktop

Malaysia Prayer Time for Claude Desktop

マレーシアの礼拝時間データのためのモデルコンテキストプロトコル(MCP)サーバー

Configurable Puppeteer MCP Server

Configurable Puppeteer MCP Server

Puppeteer を使用してブラウザの自動化機能を提供する Model Context Protocol サーバー。環境変数を通じて設定可能なオプションを備えており、LLM がウェブページとやり取りしたり、スクリーンショットを撮ったり、ブラウザ環境で JavaScript を実行したりすることを可能にします。

spotify_mcp_server_claude

spotify_mcp_server_claude

カスタムの MCP フレームワークを使って構築された MCP サーバー

Postgers_MCP_for_AWS_RDS

Postgers_MCP_for_AWS_RDS

AWS RDS 上の Postgres DB にアクセスするための MCP サーバーです。

SQLGenius - AI-Powered SQL Assistant

SQLGenius - AI-Powered SQL Assistant

SQLGeniusは、Vertex AIのGemini Proを使用して自然言語をSQLクエリに変換する、AI搭載のSQLアシスタントです。MCPとStreamlitで構築されており、リアルタイムの可視化とスキーマ管理を備えた、BigQueryデータ探索のための直感的なインターフェースを提供します。

Structured Thinking

Structured Thinking

構造化思考ツール(テンプレート思考、検証思考など)のための統合されたMCPサーバー

Thirdweb Mcp

Thirdweb Mcp

CyberSecMCP

CyberSecMCP

セキュアメッセージ制御プレーン(MCP)サーバー - AIエージェント間の通信を管理するための堅牢なプラットフォーム

MCP-Forge

MCP-Forge

MCPサーバー用の便利な足場ツール

holaspirit-mcp-server

holaspirit-mcp-server

鏡 (Kagami)

Vite MCP Server

Vite MCP Server

Weather MCP Server

Weather MCP Server

カナダ政府の気象APIから天気予報データを提供する、モデルコンテキストプロトコル(MCP)サーバーです。カナダ国内のあらゆる場所の正確な5日間予報を、緯度と経度で取得できます。Claude Desktopやその他のMCP互換クライアントと簡単に統合できます。

MCP Custom Servers Collection

MCP Custom Servers Collection

複数のインストールに対応したカスタムMCPサーバーのコレクション

mcp-server-taiwan-aqi

mcp-server-taiwan-aqi

台湾(中華民国)の現在および過去24時間の空気質モニタリングステーションのデータを取得します。