Discover Awesome MCP Servers
Extend your agent with 31,319 capabilities via MCP servers.
- All31,319
- Developer Tools3,867
- Search1,714
- Research & Data1,557
- AI Integration Systems229
- Cloud Platforms219
- Data & App Analysis181
- Database Interaction177
- Remote Shell Execution165
- Browser Automation147
- Databases145
- Communication137
- AI Content Generation127
- OS Automation120
- Programming Docs Access109
- Content Fetching108
- Note Taking97
- File Systems96
- Version Control93
- Finance91
- Knowledge & Memory90
- Monitoring79
- Security71
- Image & Video Processing69
- Digital Note Management66
- AI Memory Systems62
- Advanced AI Reasoning59
- Git Management Tools58
- Cloud Storage51
- Entertainment & Media43
- Virtualization42
- Location Services35
- Web Automation & Stealth32
- Media Content Processing32
- Calendar Management26
- Ecommerce & Retail18
- Speech Processing18
- Customer Data Platforms16
- Travel & Transportation14
- Education & Learning Tools13
- Home Automation & IoT13
- Web Search Integration12
- Health & Wellness10
- Customer Support10
- Marketing9
- Games & Gamification8
- Google Cloud Integrations7
- Art & Culture4
- Language Translation3
- Legal & Compliance2
Homework Grading MCP
Enables automated grading of student homework images using Qwen3-VL multimodal model, supporting multiple subjects and question types with detailed feedback and batch processing capabilities.
Crawl4AI MCP Server
GetUTC MCP Server
Provides accurate UTC time by aggregating and verifying data from multiple reliable sources like WorldClockAPI, Google, and GitHub. It enables users to retrieve time in various formats including ISO, Unix timestamps, and human-readable strings with automatic source fallback for reliability.
TypeScript MCP Server Boilerplate
A boilerplate project for quickly developing Model Context Protocol (MCP) servers using TypeScript SDK, with example implementations of calculator and greeting tools plus resource management capabilities.
Roam Research MCP Server
A Model Context Protocol server that enables Claude Desktop to read from and write to Roam Research graphs, allowing for retrieving page content, finding references, and adding blocks to existing or daily pages.
TailscaleMCP
Enables comprehensive management of Tailscale networks including device management, DNS configuration, file sharing via Taildrop, security monitoring, and network automation with built-in Grafana/Prometheus observability stack.
Model Context Protocol .NET Samples
好的,这是关于使用 .NET 创建和使用 MCP 服务器和客户端的综合示例集: **概述** MCP (Minecraft Protocol) 是 Minecraft 客户端和服务器之间用于通信的协议。 使用 .NET,你可以创建自定义的 MCP 服务器和客户端,以实现各种目的,例如: * **机器人:** 自动执行游戏中的任务。 * **代理:** 修改客户端和服务器之间的流量。 * **服务器插件:** 扩展服务器的功能。 * **自定义客户端:** 创建具有自定义功能的 Minecraft 客户端。 **示例集** 以下示例将涵盖创建和使用 MCP 服务器和客户端的关键方面。 这些示例使用 C# 和一些流行的 .NET 库,例如: * **`System.Net.Sockets`:** 用于网络通信的基础类。 * **`BinaryReader` 和 `BinaryWriter`:** 用于读取和写入二进制数据。 * **`NbtCompound` (来自 `fNbt` 或类似库):** 用于处理 NBT (Named Binary Tag) 数据,Minecraft 使用它来存储世界数据和实体数据。 * **`ZlibStream` (来自 `Ionic.Zlib` 或类似库):** 用于处理数据压缩。 **重要提示:** MCP 协议非常复杂,并且会随着 Minecraft 版本的更新而变化。 这些示例旨在提供一个起点,你需要根据你使用的 Minecraft 版本调整代码。 强烈建议参考官方 Minecraft 协议文档和社区资源。 **1. 建立连接 (客户端)** ```csharp using System; using System.Net.Sockets; using System.IO; public class MinecraftClient { private string _serverAddress; private int _serverPort; private TcpClient _client; private NetworkStream _stream; private BinaryReader _reader; private BinaryWriter _writer; public MinecraftClient(string serverAddress, int serverPort) { _serverAddress = serverAddress; _serverPort = serverPort; } public void Connect() { try { _client = new TcpClient(_serverAddress, _serverPort); _stream = _client.GetStream(); _reader = new BinaryReader(_stream); _writer = new BinaryWriter(_stream); Console.WriteLine("Connected to server!"); } catch (Exception ex) { Console.WriteLine($"Error connecting: {ex.Message}"); } } public void Disconnect() { if (_client != null && _client.Connected) { _reader.Close(); _writer.Close(); _stream.Close(); _client.Close(); Console.WriteLine("Disconnected from server."); } } // 示例:发送握手数据包 public void SendHandshake(int protocolVersion, string serverAddress, int serverPort, int nextState) { // 构建握手数据包 using (MemoryStream packetData = new MemoryStream()) using (BinaryWriter packetWriter = new BinaryWriter(packetData)) { // Packet ID (0x00) packetWriter.Write((byte)0x00); // Protocol Version (VarInt) WriteVarInt(packetWriter, protocolVersion); // Server Address (String) WriteString(packetWriter, serverAddress); // Server Port (Unsigned Short) packetWriter.Write((ushort)serverPort); // Next State (VarInt) WriteVarInt(packetWriter, nextState); // 获取数据包内容 byte[] packetBytes = packetData.ToArray(); // 发送数据包长度 (VarInt) WriteVarInt(_writer, packetBytes.Length); // 发送数据包内容 _writer.Write(packetBytes); _writer.Flush(); } } // 示例:发送请求数据包 (用于获取服务器状态) public void SendRequest() { // 构建请求数据包 using (MemoryStream packetData = new MemoryStream()) using (BinaryWriter packetWriter = new BinaryWriter(packetData)) { // Packet ID (0x00) packetWriter.Write((byte)0x00); // 获取数据包内容 byte[] packetBytes = packetData.ToArray(); // 发送数据包长度 (VarInt) WriteVarInt(_writer, packetBytes.Length); // 发送数据包内容 _writer.Write(packetBytes); _writer.Flush(); } } // 示例:读取响应数据包 (用于获取服务器状态) public string ReadResponse() { // 读取数据包长度 (VarInt) int packetLength = ReadVarInt(_reader); // 读取数据包内容 byte[] packetBytes = _reader.ReadBytes(packetLength); using (MemoryStream packetData = new MemoryStream(packetBytes)) using (BinaryReader packetReader = new BinaryReader(packetData)) { // 读取 Packet ID byte packetId = packetReader.ReadByte(); if (packetId == 0x00) { // 读取 JSON 响应 string jsonResponse = ReadString(packetReader); return jsonResponse; } else { Console.WriteLine($"Unexpected packet ID: 0x{packetId:X2}"); return null; } } } // Helper functions for reading and writing VarInts and Strings private void WriteVarInt(BinaryWriter writer, int value) { while (true) { if ((value & ~0x7F) == 0) { writer.Write((byte)value); return; } writer.Write((byte)((value & 0x7F) | 0x80)); value >>= 7; } } private int ReadVarInt(BinaryReader reader) { int numRead = 0; int result = 0; byte read; do { read = reader.ReadByte(); int value = (read & 0x7f); result |= (value << (7 * numRead)); numRead++; if (numRead > 5) { throw new InvalidOperationException("VarInt is too big"); } } while ((read & 0x80) != 0); return result; } private void WriteString(BinaryWriter writer, string value) { byte[] stringBytes = System.Text.Encoding.UTF8.GetBytes(value); WriteVarInt(writer, stringBytes.Length); writer.Write(stringBytes); } private string ReadString(BinaryReader reader) { int length = ReadVarInt(reader); byte[] stringBytes = reader.ReadBytes(length); return System.Text.Encoding.UTF8.GetString(stringBytes); } public static void Main(string[] args) { MinecraftClient client = new MinecraftClient("localhost", 25565); // 替换为你的服务器地址和端口 client.Connect(); // 获取服务器状态 client.SendHandshake(763, "localhost", 25565, 1); // 763 是 1.17.1 的协议版本,根据你的 Minecraft 版本调整 client.SendRequest(); string response = client.ReadResponse(); if (response != null) { Console.WriteLine($"Server Status: {response}"); } client.Disconnect(); } } ``` **2. 建立连接 (服务器)** ```csharp using System; using System.Net; using System.Net.Sockets; using System.Threading; using System.IO; public class MinecraftServer { private TcpListener _listener; private bool _isRunning; public MinecraftServer(int port) { _listener = new TcpListener(IPAddress.Any, port); } public void Start() { _listener.Start(); _isRunning = true; Console.WriteLine("Server started. Listening for connections..."); while (_isRunning) { try { TcpClient client = _listener.AcceptTcpClient(); Console.WriteLine("Client connected."); // 为每个客户端创建一个新线程 Thread clientThread = new Thread(() => HandleClient(client)); clientThread.Start(); } catch (SocketException ex) { Console.WriteLine($"SocketException: {ex.Message}"); Stop(); } } } public void Stop() { _isRunning = false; _listener.Stop(); Console.WriteLine("Server stopped."); } private void HandleClient(TcpClient client) { using (NetworkStream stream = client.GetStream()) using (BinaryReader reader = new BinaryReader(stream)) using (BinaryWriter writer = new BinaryWriter(stream)) { try { // 处理客户端连接 while (client.Connected) { if (stream.DataAvailable) { // 读取数据包长度 int packetLength = ReadVarInt(reader); // 读取数据包内容 byte[] packetBytes = reader.ReadBytes(packetLength); // 处理数据包 ProcessPacket(packetBytes, writer); } else { // 如果没有数据,则短暂休眠以避免 CPU 占用 Thread.Sleep(10); } } } catch (IOException ex) { Console.WriteLine($"IOException: {ex.Message}"); } catch (Exception ex) { Console.WriteLine($"Exception: {ex.Message}"); } finally { Console.WriteLine("Client disconnected."); client.Close(); } } } private void ProcessPacket(byte[] packetBytes, BinaryWriter writer) { using (MemoryStream packetData = new MemoryStream(packetBytes)) using (BinaryReader packetReader = new BinaryReader(packetData)) { // 读取 Packet ID byte packetId = packetReader.ReadByte(); switch (packetId) { case 0x00: // Handshake HandleHandshake(packetReader, writer); break; // 其他数据包处理逻辑 default: Console.WriteLine($"Unknown packet ID: 0x{packetId:X2}"); break; } } } private void HandleHandshake(BinaryReader reader, BinaryWriter writer) { // 读取协议版本 int protocolVersion = ReadVarInt(reader); // 读取服务器地址 string serverAddress = ReadString(reader); // 读取服务器端口 ushort serverPort = reader.ReadUInt16(); // 读取下一个状态 int nextState = ReadVarInt(reader); Console.WriteLine($"Handshake received: Protocol Version = {protocolVersion}, Server Address = {serverAddress}, Server Port = {serverPort}, Next State = {nextState}"); // 根据下一个状态执行不同的操作 switch (nextState) { case 1: // Status SendStatusResponse(writer); break; case 2: // Login // TODO: 处理登录 break; default: Console.WriteLine($"Unknown next state: {nextState}"); break; } } private void SendStatusResponse(BinaryWriter writer) { // 构建服务器状态 JSON string jsonResponse = @"{ ""version"": { ""name"": ""1.17.1"", ""protocol"": 763 }, ""players"": { ""max"": 100, ""online"": 0, ""sample"": [] }, ""description"": { ""text"": ""A Minecraft Server"" } }"; // 构建响应数据包 using (MemoryStream packetData = new MemoryStream()) using (BinaryWriter packetWriter = new BinaryWriter(packetData)) { // Packet ID (0x00) packetWriter.Write((byte)0x00); // JSON 响应 (String) WriteString(packetWriter, jsonResponse); // 获取数据包内容 byte[] packetBytes = packetData.ToArray(); // 发送数据包长度 (VarInt) WriteVarInt(writer, packetBytes.Length); // 发送数据包内容 writer.Write(packetBytes); writer.Flush(); } } // Helper functions for reading and writing VarInts and Strings private int ReadVarInt(BinaryReader reader) { int numRead = 0; int result = 0; byte read; do { read = reader.ReadByte(); int value = (read & 0x7f); result |= (value << (7 * numRead)); numRead++; if (numRead > 5) { throw new InvalidOperationException("VarInt is too big"); } } while ((read & 0x80) != 0); return result; } private void WriteVarInt(BinaryWriter writer, int value) { while (true) { if ((value & ~0x7F) == 0) { writer.Write((byte)value); return; } writer.Write((byte)((value & 0x7F) | 0x80)); value >>= 7; } } private string ReadString(BinaryReader reader) { int length = ReadVarInt(reader); byte[] stringBytes = reader.ReadBytes(length); return System.Text.Encoding.UTF8.GetString(stringBytes); } private void WriteString(BinaryWriter writer, string value) { byte[] stringBytes = System.Text.Encoding.UTF8.GetBytes(value); WriteVarInt(writer, stringBytes.Length); writer.Write(stringBytes); } public static void Main(string[] args) { MinecraftServer server = new MinecraftServer(25565); // 替换为你想要的端口 server.Start(); } } ``` **3. 处理数据包** MCP 协议定义了许多不同类型的数据包,每个数据包都有特定的 ID 和结构。 你需要根据你想要实现的功能来处理这些数据包。 * **客户端到服务器:** * **握手 (Handshake):** 客户端连接时发送的第一个数据包,用于协商协议版本和指定下一个状态(状态或登录)。 * **登录 (Login):** 用于验证客户端身份。 * **聊天消息 (ChatMessage):** 客户端发送的聊天消息。 * **命令 (Command):** 客户端执行的命令。 * **移动 (Movement):** 客户端的位置和方向。 * **挖掘 (Digging):** 客户端挖掘方块的动作。 * **放置 (Placement):** 客户端放置方块的动作。 * **服务器到客户端:** * **状态响应 (Status Response):** 服务器发送的服务器状态信息。 * **登录成功 (Login Success):** 服务器验证客户端身份后发送。 * **聊天消息 (ChatMessage):** 服务器发送的聊天消息。 * **游戏状态 (GameState):** 服务器发送的游戏状态信息。 * **实体更新 (Entity Update):** 服务器发送的实体位置和属性更新。 * **方块更新 (Block Update):** 服务器发送的方块更新。 * **区块数据 (Chunk Data):** 服务器发送的区块数据。 **示例:处理聊天消息 (服务器)** ```csharp // 在 ProcessPacket 方法中添加以下代码 case 0x03: // Chat Message (客户端 -> 服务器) HandleChatMessage(packetReader, writer); break; // 新的 HandleChatMessage 方法 private void HandleChatMessage(BinaryReader reader, BinaryWriter writer) { string message = ReadString(reader); Console.WriteLine($"Received chat message: {message}"); // 示例:将消息广播给所有连接的客户端 BroadcastChatMessage(message); } // 广播聊天消息 private void BroadcastChatMessage(string message) { // 构建聊天消息数据包 (服务器 -> 客户端) using (MemoryStream packetData = new MemoryStream()) using (BinaryWriter packetWriter = new BinaryWriter(packetData)) { // Packet ID (0x0E for 1.17.1) packetWriter.Write((byte)0x0E); // Message (JSON format) string jsonMessage = $"{{\"text\":\"{message}\"}}"; WriteString(packetWriter, jsonMessage); // Position (0: chat box, 1: system message, 2: above hotbar) packetWriter.Write((byte)0); // Sender UUID (all zeros for now) for (int i = 0; i < 16; i++) { packetWriter.Write((byte)0); } // 获取数据包内容 byte[] packetBytes = packetData.ToArray(); // 发送数据包长度 (VarInt) WriteVarInt(writer, packetBytes.Length); // 发送数据包内容 writer.Write(packetBytes); writer.Flush(); } } ``` **4. 处理 NBT 数据** Minecraft 使用 NBT (Named Binary Tag) 格式来存储世界数据、实体数据和物品数据。 你需要一个 NBT 库来读取和写入 NBT 数据。 `fNbt` 是一个流行的选择。 **示例:读取区块数据 (服务器)** ```csharp // 需要安装 fNbt NuGet 包 using fNbt; // 在 ProcessPacket 方法中添加以下代码 case 0x22: // Chunk Data (服务器 -> 客户端) HandleChunkData(packetReader, writer); break; // 新的 HandleChunkData 方法 private void HandleChunkData(BinaryReader reader, BinaryWriter writer) { // 读取区块坐标 int chunkX = reader.ReadInt32(); int chunkZ = reader.ReadInt32(); // 读取 Primary Bit Mask int primaryBitMask = ReadVarInt(reader); // 读取 NBT 数据长度 int nbtLength = reader.ReadInt32(); // 读取 NBT 数据 byte[] nbtData = reader.ReadBytes(nbtLength); // 使用 Zlib 解压缩 NBT 数据 using (MemoryStream compressedStream = new MemoryStream(nbtData)) using (Ionic.Zlib.ZlibStream decompressedStream = new Ionic.Zlib.ZlibStream(compressedStream, Ionic.Zlib.CompressionMode.Decompress)) { // 从解压缩的流中读取 NBT 数据 NbtCompound rootTag = NbtCompound.ReadFrom(decompressedStream); // 处理 NBT 数据 Console.WriteLine($"Chunk Data received: X = {chunkX}, Z = {chunkZ}, Root Tag = {rootTag.Name}"); // 示例:遍历区块中的所有实体 if (rootTag.Contains("Entities")) { NbtList entities = rootTag["Entities"] as NbtList; if (entities != null) { foreach (NbtCompound entity in entities.OfType<NbtCompound>()) { // 获取实体类型 string entityType = entity["id"].AsString(); Console.WriteLine($" Entity: {entityType}"); } } } } } ``` **5. 数据压缩** Minecraft 使用 Zlib 压缩来减少网络流量。 你需要一个 Zlib 库来压缩和解压缩数据。 `Ionic.Zlib` 是一个流行的选择。 **示例:压缩数据 (服务器)** ```csharp // 需要安装 Ionic.Zlib NuGet 包 using Ionic.Zlib; // 压缩数据 private byte[] CompressData(byte[] data) { using (MemoryStream compressedStream = new MemoryStream()) using (ZlibStream compressionStream = new ZlibStream(compressedStream, CompressionMode.Compress, CompressionLevel.BestCompression)) { compressionStream.Write(data, 0, data.Length); compressionStream.Close(); return compressedStream.ToArray(); } } // 解压缩数据 private byte[] DecompressData(byte[] data) { using (MemoryStream compressedStream = new MemoryStream(data)) using (ZlibStream decompressionStream = new ZlibStream(compressedStream, CompressionMode.Decompress)) using (MemoryStream decompressedStream = new MemoryStream()) { decompressionStream.CopyTo(decompressedStream); return decompressedStream.ToArray(); } } ``` **关键点和注意事项** * **协议版本:** 确保你使用的协议版本与你的 Minecraft 版本匹配。 协议版本会随着 Minecraft 的更新而变化。 * **VarInt:** Minecraft 使用 VarInt (Variable-length Integer) 来表示长度和其他值。 你需要正确地读取和写入 VarInt。 * **字符串:** Minecraft 使用 UTF-8 编码的字符串,并使用 VarInt 来表示字符串的长度。 * **NBT 数据:** 使用 NBT 库来处理 NBT 数据。 * **数据压缩:** 使用 Zlib 库来压缩和解压缩数据。 * **线程:** 在服务器端,为每个客户端创建一个新线程,以避免阻塞主线程。 * **错误处理:** 添加适当的错误处理,以处理网络错误和其他异常。 * **安全性:** 注意安全性,特别是处理登录和身份验证时。 * **异步操作:** 考虑使用异步操作来提高性能,特别是处理网络 I/O 时。 * **资源管理:** 确保正确地释放所有资源,例如流和套接字。 **进一步学习** * **Minecraft 协议文档:** [https://wiki.vg/Protocol](https://wiki.vg/Protocol) (这是最重要的资源) * **fNbt 库:** [https://github.com/fragmer/fNbt](https://github.com/fragmer/fNbt) * **Ionic.Zlib 库:** [https://github.com/rbradley/Ionic.Zlib](https://github.com/rbradley/Ionic.Zlib) * **Minecraft 社区论坛和 Wiki:** 搜索 "Minecraft protocol" 和 "Minecraft API" 可以找到很多有用的信息和示例。 **总结** 这些示例提供了一个使用 .NET 创建和使用 MCP 服务器和客户端的起点。 你需要根据你想要实现的功能来扩展这些示例。 记住,MCP 协议非常复杂,并且会随着 Minecraft 版本的更新而变化。 请务必参考官方 Minecraft 协议文档和社区资源。 **中文翻译:** 好的,这里是一份关于使用 .NET 创建和使用 MCP 服务器和客户端的综合示例集: **概述** MCP (Minecraft 协议) 是 Minecraft 客户端和服务器之间用于通信的协议。 使用 .NET,你可以创建自定义的 MCP 服务器和客户端,以实现各种目的,例如: * **机器人:** 自动执行游戏中的任务。 * **代理:** 修改客户端和服务器之间的流量。 * **服务器插件:** 扩展服务器的功能。 * **自定义客户端:** 创建具有自定义功能的 Minecraft 客户端。 **示例集** 以下示例将涵盖创建和使用 MCP 服务器和客户端的关键方面。 这些示例使用 C# 和一些流行的 .NET 库,例如: * **`System.Net.Sockets`:** 用于网络通信的基础类。 * **`BinaryReader` 和 `BinaryWriter`:** 用于读取和写入二进制数据。 * **`NbtCompound` (来自 `fNbt` 或类似库):** 用于处理 NBT (命名二进制标签) 数据,Minecraft 使用它来存储世界数据和实体数据。 * **`ZlibStream` (来自 `Ionic.Zlib` 或类似库):** 用于处理数据压缩。 **重要提示:** MCP 协议非常复杂,并且会随着 Minecraft 版本的更新而变化。 这些示例旨在提供一个起点,你需要根据你使用的 Minecraft 版本调整代码。 强烈建议参考官方 Minecraft 协议文档和社区资源。 **(以下代码示例的中文翻译,由于篇幅限制,只翻译关键部分,并保留代码中的英文注释)** **1. 建立连接 (客户端)** ```csharp // ... (省略代码) // 示例:发送握手数据包 public void SendHandshake(int protocolVersion, string serverAddress, int serverPort, int nextState) { // 构建握手数据包 // ... (省略代码) } // 示例:发送请求数据包 (用于获取服务器状态) public void SendRequest() { // 构建请求数据包 // ... (省略代码) } // 示例:读取响应数据包 (用于获取服务器状态) public string ReadResponse() { // 读取数据包长度 (VarInt) // ... (省略代码) } // Helper functions for reading and writing VarInts and Strings // 辅助函数,用于读取和写入 VarInt 和字符串 // ... (省略代码) public static void Main(string[] args) { MinecraftClient client = new MinecraftClient("localhost", 25565); // 替换为你的服务器地址和端口 client.Connect(); // 获取服务器状态 // ... (省略代码) client.Disconnect(); } } ``` **2. 建立连接 (服务器)** ```csharp // ... (省略代码) private void HandleClient(TcpClient client) { // ... (省略代码) } private void ProcessPacket(byte[] packetBytes, BinaryWriter writer) { // ... (省略代码) } private void HandleHandshake(BinaryReader reader, BinaryWriter writer) { // ... (省略代码) } private void SendStatusResponse(BinaryWriter writer) { // ... (省略代码) } // Helper functions for reading and writing VarInts and Strings // 辅助函数,用于读取和写入 VarInt 和字符串 // ... (省略代码) public static void Main(string[] args) { MinecraftServer server = new MinecraftServer(25565); // 替换为你想要的端口 server.Start(); } } ``` **3. 处理数据包** MCP 协议定义了许多不同类型的数据包,每个数据包都有特定的 ID 和结构。 你需要根据你想要实现的功能来处理这些数据包。 * **客户端到服务器:** * **握手 (Handshake):** 客户端连接时发送的第一个数据包,用于协商协议版本和指定下一个状态(状态或登录)。 * **登录 (Login):** 用于验证客户端身份。 * **聊天消息 (ChatMessage):** 客户端发送的聊天消息。 * **命令 (Command):** 客户端执行的命令。 * **移动 (Movement):** 客户端的位置和方向。 * **挖掘 (Digging):** 客户端挖掘方块的动作。 * **放置 (Placement):** 客户端放置方块的动作。 * **服务器到客户端:** * **状态响应 (Status Response):** 服务器发送的服务器状态信息。 * **登录成功 (Login Success):** 服务器验证客户端身份后发送。 * **聊天消息 (ChatMessage):** 服务器发送的聊天消息。 * **游戏状态 (GameState):** 服务器发送的游戏状态信息。 * **实体更新 (Entity Update):** 服务器发送的实体位置和属性更新。 * **方块更新 (Block Update):** 服务器发送的方块更新。 * **区块数据 (Chunk Data):** 服务器发送的区块数据。 **示例:处理聊天消息 (服务器)** ```csharp // ... (省略代码) ``` **4. 处理 NBT 数据** Minecraft 使用 NBT (命名二进制标签) 格式来存储世界数据、实体数据和物品数据。 你需要一个 NBT 库来读取和写入 NBT 数据。 `fNbt` 是一个流行的选择。 **示例:读取区块数据 (服务器)** ```csharp // ... (省略代码) ``` **5. 数据压缩** Minecraft 使用 Zlib 压缩来减少网络流量。 你需要一个 Zlib 库来压缩和解压缩数据。 `Ionic.Zlib` 是一个流行的选择。 **示例:压缩数据 (服务器)** ```csharp // ... (省略代码) ``` **关键点和注意事项** * **协议版本:** 确保你使用的协议版本与你的 Minecraft 版本匹配。 协议版本会随着 Minecraft 的更新而变化。 * **VarInt:** Minecraft 使用 VarInt (可变长度整数) 来表示长度和其他值。 你需要正确地读取和写入 VarInt。 * **字符串:** Minecraft 使用 UTF-8 编码的字符串,并使用 VarInt 来表示字符串的长度。 * **NBT 数据:** 使用 NBT 库来处理 NBT 数据。 * **数据压缩:** 使用 Zlib 库来压缩和解压缩数据。 * **线程:** 在服务器端,为每个客户端创建一个新线程,以避免阻塞主线程。 * **错误处理:** 添加适当的错误处理,以处理网络错误和其他异常。 * **安全性:** 注意安全性,特别是处理登录和身份验证时。 * **异步操作:** 考虑使用异步操作来提高性能,特别是处理网络 I/O 时。 * **资源管理:** 确保正确地释放所有资源,例如流和套接字。 **进一步学习** * **Minecraft 协议文档:** [https://wiki.vg/Protocol](https://wiki.vg/Protocol) (这是最重要的资源) * **fNbt 库:** [https://github.com/fragmer/fNbt](https://github.com/fragmer/fNbt) * **Ionic.Zlib 库:** [https://github.com/rbradley/Ionic.Zlib](https://github.com/rbradley/Ionic.Zlib) * **Minecraft 社区论坛和 Wiki:** 搜索 "Minecraft protocol" 和 "Minecraft API" 可以找到很多有用的信息和示例。 **总结** 这些示例提供了一个使用 .NET 创建和使用 MCP 服务器和客户端的起点。 你需要根据你想要实现的功能来扩展这些示例。 记住,MCP 协议非常复杂,并且会随着 Minecraft 版本的更新而变化。 请务必参考官方 Minecraft 协议文档和社区资源。 **重要提示:** 由于代码量巨大,我只翻译了关键部分和注释。 你需要仔细阅读英文代码,并结合 Minecraft 协议文档进行理解和修改。 祝你成功!
Time & Location MCP Server
An MCP server that automatically detects and provides current time and location information based on system timezone and IP geolocation.
SAP HANA MCP Server by CData
SAP HANA MCP Server by CData
Weather MCP Server
Provides weather information through OpenWeather API, enabling users to get current weather conditions, 5-day forecasts, and perform temperature conversions for any city. Offers a secure interface for AI assistants to access comprehensive weather data including temperature, humidity, wind, and pressure information.
mcp-alphabanana
Local MCP server for generating image assets with Google Gemini (Nano Banana 2 / Pro). Supports transparent PNG/WebP output, exact resizing/cropping, up to 14 reference images, and Google Search grounding.
Tox Testing MCP Server
一个 MCP 服务器,它执行 tox 命令来运行项目中的 Python 测试(使用 pytest),允许用户运行所有测试或特定的测试组、文件、用例或目录。 **Explanation of terms:** * **MCP Server:** MCP likely refers to a specific type of server or system within a particular context. Without more context, it's difficult to provide a more precise translation. It could stand for "Management Control Panel" or something similar. I've left it as "MCP" in the translation. * **tox:** A generic test automation tool. * **pytest:** A popular Python testing framework. * **Test groups:** Refers to logical groupings of tests, often defined in `tox.ini` or similar configuration files. * **Test files:** Python files containing test functions or classes. * **Test cases:** Individual test functions or methods within a test class. * **Directories:** Folders containing test files.
uuid-mcp-server
Confluence MCP Server by CData
Confluence MCP Server by CData
GitLab Docs MCP Server
Provides AI assistants instant access to GitLab's official documentation with intelligent search, section filtering, and full content retrieval across 2,494 documentation pages including CI/CD, API, admin, and development guides.
youtube-mcp
MCP server for YouTube creator-ops — video metadata, comments, playlists, channel analytics, plus a ComfyUI bridge for AI thumbnail generation.
Ureanl-Blender-MCP
Unreal-Blender MCP 是一个统一的服务器,它使用 MCP(机器控制协议)方法,通过 AI 代理来控制 Blender 和 Unreal Engine。
MCP Template
A generic template for developing MCP servers with basic examples including echo tool, server info resource, and greeting prompt. Provides a starting point for building custom MCP servers with Bun.
AnyCrawl MCP Server
Enables web scraping and crawling capabilities for LLM clients, supporting single-page scraping, multi-page website crawling, and web search with multiple engines (Playwright, Cheerio, Puppeteer) and flexible output formats including markdown, HTML, text, and screenshots.
StatCan Web Data Service MCP Server
一个使用加拿大统计局 (StatCAN) 数据的 MCP 服务器
Perplexity2 MCP Server
Enables AI-powered search and analysis of Google data through the Perplexity2 API, allowing users to discover insights and enhance decision-making capabilities.
Google Docs MCP Server
Provides comprehensive interaction with Google Docs, featuring specialized support for document tabs, nested structures, and markdown conversion. It enables users to list, read, create, and perform complex batch updates on documents using Google service accounts.
Access
Self-hosted credential store and API proxy for AI agents. One Bearer token, all your services. Handles OAuth refresh, encrypted storage, audit logging, and per-agent permissioning.
MCP Weather Server
A lightweight server that exposes weather-related tools (get_coordinates and get_forecast) using the Modular Command Protocol, designed for integration with AI agents and LLMs.
Zoho CRM MCP Server
A Model Context Protocol server that integrates AI assistants with Zoho CRM, enabling contact and deal management operations through natural language.
mcp-server-playwright
Fess MCP Server
用于与 Fess 搜索引擎交互的 MCP 服务器。
🚀 NexusHub
NexusHub 是一个强大的模型上下文协议 (MCP) 服务器,它充当 AI 工作流程和工具集成的中心连接点。
BSL Atlas
An MCP server for 1C:Enterprise that provides AI assistants with access to configuration data via vector search, structural indexing, and call graphs. It enables semantic code queries and rapid metadata object lookups without requiring the direct reading of raw files.
MCP Server Mermaid
MCP Server Mermaid