{"id":46101,"date":"2025-07-30T02:21:10","date_gmt":"2025-07-29T18:21:10","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/46101.html"},"modified":"2025-07-30T02:21:10","modified_gmt":"2025-07-29T18:21:10","slug":"%e4%bb%8e%e9%9b%b6%e6%9e%84%e5%bb%ba-mcp-%e6%9c%8d%e5%8a%a1%e5%99%a8%ef%bc%9a%e5%8d%8f%e8%ae%ae%e8%a7%a3%e6%9e%90%e3%80%81%e6%9e%b6%e6%9e%84%e5%ae%9e%e7%8e%b0%e4%b8%8e%e4%bb%a3%e7%a0%81%e5%ae%9e","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/46101.html","title":{"rendered":"\u4ece\u96f6\u6784\u5efa MCP \u670d\u52a1\u5668\uff1a\u534f\u8bae\u89e3\u6790\u3001\u67b6\u6784\u5b9e\u73b0\u4e0e\u4ee3\u7801\u5b9e\u8df5"},"content":{"rendered":"<p>\u4f5c\u4e3a\u4e00\u540d\u8d44\u6df1\u6e38\u620f\u670d\u52a1\u5668\u5f00\u53d1\u8005&#xff0c;\u6211\u66fe\u6df1\u5ea6\u53c2\u4e0e\u8fc7\u57fa\u4e8e MCP \u534f\u8bae\u7684\u591a\u7aef\u4ea4\u4e92\u7cfb\u7edf\u5f00\u53d1\u3002MCP&#xff08;Minecraft Protocol&#xff09;\u4f5c\u4e3a Minecraft \u8de8\u7248\u672c\u901a\u4fe1\u7684\u6838\u5fc3\u534f\u8bae&#xff0c;\u5176\u8bbe\u8ba1\u7406\u5ff5\u5bf9\u6240\u6709\u6e38\u620f\u670d\u52a1\u5668\u5f00\u53d1\u90fd\u6709\u501f\u9274\u610f\u4e49\u3002\u672c\u6587\u5c06\u5e26\u60a8\u4ece 0 \u5f00\u59cb\u6784\u5efa\u4e00\u4e2a\u53ef\u8fd0\u884c\u7684 MCP \u670d\u52a1\u5668&#xff0c;\u901a\u8fc7\u4ee3\u7801\u5b9e\u8df5\u7406\u89e3\u534f\u8bae\u672c\u8d28&#xff0c;\u638c\u63e1\u6570\u636e\u5305\u89e3\u6790\u3001\u5ba2\u6237\u7aef\u8ba4\u8bc1\u3001\u4e16\u754c\u4ea4\u4e92\u7b49\u6838\u5fc3\u529f\u80fd\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n<h3>MCP \u534f\u8bae\u6838\u5fc3\u673a\u5236\u89e3\u6790<\/h3>\n<p>MCP \u534f\u8bae\u91c7\u7528 TCP \u4f5c\u4e3a\u4f20\u8f93\u5c42\u534f\u8bae&#xff0c;\u6240\u6709\u6570\u636e\u4ee5\u7279\u5b9a\u683c\u5f0f\u7684\u6570\u636e\u5305\u8fdb\u884c\u4ea4\u6362\u3002\u8981\u6784\u5efa MCP \u670d\u52a1\u5668&#xff0c;\u9996\u5148\u5fc5\u987b\u7406\u89e3\u5176\u6570\u636e\u5305\u7ed3\u6784\u548c\u72b6\u6001\u673a\u673a\u5236\u3002<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"800\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729182108-68891114964d6.png\" width=\"1422\" \/><\/p>\n<p>MCP \u6570\u636e\u5305\u7684\u57fa\u672c\u7ed3\u6784\u7531\u4e09\u90e8\u5206\u7ec4\u6210&#xff1a;\u957f\u5ea6\u524d\u7f00&#xff08;VarInt \u7c7b\u578b&#xff09;\u3001\u6570\u636e\u5305 ID&#xff08;VarInt \u7c7b\u578b&#xff09;\u3001\u6570\u636e\u8d1f\u8f7d\u3002\u5176\u4e2d VarInt \u662f\u4e00\u79cd\u53d8\u957f\u6574\u6570\u7f16\u7801&#xff0c;\u80fd\u6839\u636e\u6570\u503c\u5927\u5c0f\u52a8\u6001\u8c03\u6574\u5b57\u8282\u6570&#xff0c;\u8fd9\u662f\u8282\u7701\u5e26\u5bbd\u7684\u5173\u952e\u8bbe\u8ba1\u3002\u4ee5\u4e0b\u662f VarInt \u7f16\u89e3\u7801\u7684\u6838\u5fc3\u5b9e\u73b0&#xff1a;<\/p>\n<p># VarInt\u7f16\u89e3\u7801\u5de5\u5177\u7c7b<\/p>\n<p>class VarInt:<\/p>\n<p>&#064;staticmethod<\/p>\n<p>def encode(value: int) -&gt; bytes:<\/p>\n<p>&#034;&#034;&#034;\u5c06\u6574\u6570\u7f16\u7801\u4e3aVarInt\u683c\u5f0f&#034;&#034;&#034;<\/p>\n<p>buffer &#061; bytearray()<\/p>\n<p>while True:<\/p>\n<p>byte &#061; value &amp; 0x7F<\/p>\n<p>value &gt;&gt;&#061; 7<\/p>\n<p>if value !&#061; 0:<\/p>\n<p>byte |&#061; 0x80<\/p>\n<p>buffer.append(byte)<\/p>\n<p>if value &#061;&#061; 0:<\/p>\n<p>break<\/p>\n<p>return buffer<\/p>\n<p>&#064;staticmethod<\/p>\n<p>def decode(buffer: bytes) -&gt; (int, int):<\/p>\n<p>&#034;&#034;&#034;\u4ece\u5b57\u8282\u6d41\u89e3\u7801VarInt&#xff0c;\u8fd4\u56de\u503c\u548c\u6d88\u8017\u7684\u5b57\u8282\u6570&#034;&#034;&#034;<\/p>\n<p>value &#061; 0<\/p>\n<p>position &#061; 0<\/p>\n<p>for _ in range(5): # VarInt\u6700\u59275\u5b57\u8282<\/p>\n<p>if position &gt;&#061; len(buffer):<\/p>\n<p>raise ValueError(&#034;\u4e0d\u5b8c\u6574\u7684VarInt\u6570\u636e&#034;)<\/p>\n<p>byte &#061; buffer[position]<\/p>\n<p>value |&#061; (byte &amp; 0x7F) &lt;&lt; (7 * position)<\/p>\n<p>if not (byte &amp; 0x80):<\/p>\n<p>break<\/p>\n<p>position &#043;&#061; 1<\/p>\n<p>return value, position &#043; 1<\/p>\n<p>MCP \u534f\u8bae\u7684\u72b6\u6001\u673a\u662f\u670d\u52a1\u5668\u8bbe\u8ba1\u7684\u53e6\u4e00\u6838\u5fc3\u3002\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u5668\u7684\u4ea4\u4e92\u4f1a\u7ecf\u5386\u56db\u4e2a\u72b6\u6001&#xff1a;\u63e1\u624b&#xff08;Handshake&#xff09;\u3001\u72b6\u6001&#xff08;Status&#xff09;\u3001\u767b\u5f55&#xff08;Login&#xff09;\u3001\u6e38\u620f&#xff08;Play&#xff09;\u3002\u6bcf\u4e2a\u72b6\u6001\u4e0b\u652f\u6301\u7684\u6570\u636e\u5305\u7c7b\u578b\u4e0d\u540c&#xff0c;\u4f8b\u5982\u63e1\u624b\u9636\u6bb5\u53ea\u80fd\u53d1\u9001Handshake\u5305&#xff0c;\u800c\u6e38\u620f\u9636\u6bb5\u5219\u53ef\u53d1\u9001\u6570\u767e\u79cd\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u5305\u3002<\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a MCP \u670d\u52a1\u5668\u7684\u72b6\u6001\u7ba1\u7406\u903b\u8f91&#xff1a;<\/p>\n<p># MCP\u670d\u52a1\u5668\u72b6\u6001\u7ba1\u7406\u5668<\/p>\n<p>class MCPServerState:<\/p>\n<p>def __init__(self):<\/p>\n<p>self.state &#061; &#034;handshake&#034; # \u521d\u59cb\u72b6\u6001\u4e3a\u63e1\u624b<\/p>\n<p>self.protocol_version &#061; 0 # \u5ba2\u6237\u7aef\u534f\u8bae\u7248\u672c<\/p>\n<p>self.server_address &#061; &#034;&#034; # \u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u5730\u5740<\/p>\n<p>self.server_port &#061; 0 # \u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u7aef\u53e3<\/p>\n<p>self.next_state &#061; 0 # \u4e0b\u4e00\u6b65\u72b6\u6001<\/p>\n<p>def transition(self, new_state: str) -&gt;bool:<\/p>\n<p>&#034;&#034;&#034;\u72b6\u6001\u8f6c\u6362\u9a8c\u8bc1&#034;&#034;&#034;<\/p>\n<p>valid_transitions &#061; {<\/p>\n<p>&#034;handshake&#034;: [&#034;status&#034;, &#034;login&#034;],<\/p>\n<p>&#034;status&#034;: [], # \u72b6\u6001\u9636\u6bb5\u5b8c\u6210\u540e\u4f1a\u65ad\u5f00\u8fde\u63a5<\/p>\n<p>&#034;login&#034;: [&#034;play&#034;],<\/p>\n<p>&#034;play&#034;: [] # \u6e38\u620f\u9636\u6bb5\u53ea\u80fd\u901a\u8fc7\u65ad\u5f00\u8fde\u63a5\u7ed3\u675f<\/p>\n<p>}<\/p>\n<p>if new_state in valid_transitions[self.state]:<\/p>\n<p>self.state &#061; new_state<\/p>\n<p>return True<\/p>\n<p>return False<\/p>\n<p>def handle_handshake(self, data: bytes) -&gt; bool:<\/p>\n<p>&#034;&#034;&#034;\u5904\u7406\u63e1\u624b\u6570\u636e\u5305&#xff0c;\u89e3\u6790\u5ba2\u6237\u7aef\u4fe1\u606f&#034;&#034;&#034;<\/p>\n<p># \u89e3\u6790\u534f\u8bae\u7248\u672c<\/p>\n<p>version, pos &#061; VarInt.decode(data)<\/p>\n<p>self.protocol_version &#061; version<\/p>\n<p># \u89e3\u6790\u670d\u52a1\u5668\u5730\u5740&#xff08;UTF-8\u5b57\u7b26\u4e32&#xff09;<\/p>\n<p>addr_len, pos2 &#061; VarInt.decode(data[pos:])<\/p>\n<p>pos &#043;&#061; pos2<\/p>\n<p>self.server_address &#061; data[pos:pos&#043;addr_len].decode(&#039;utf-8&#039;)<\/p>\n<p>pos &#043;&#061; addr_len<\/p>\n<p># \u89e3\u6790\u7aef\u53e3&#xff08;2\u5b57\u8282\u65e0\u7b26\u53f7\u6574\u6570&#xff09;<\/p>\n<p>self.server_port &#061; int.from_bytes(data[pos:pos&#043;2], byteorder&#061;&#039;big&#039;)<\/p>\n<p>pos &#043;&#061; 2<\/p>\n<p># \u89e3\u6790\u4e0b\u4e00\u6b65\u72b6\u6001<\/p>\n<p>self.next_state, _ &#061; VarInt.decode(data[pos:])<\/p>\n<p># \u8f6c\u6362\u5230\u5bf9\u5e94\u72b6\u6001<\/p>\n<p>target_state &#061; &#034;status&#034; if self.next_state &#061;&#061; 1 else &#034;login&#034;<\/p>\n<p>return self.transition(target_state)<\/p>\n<p>\u7406\u89e3\u8fd9\u79cd\u72b6\u6001\u8f6c\u6362\u673a\u5236\u81f3\u5173\u91cd\u8981\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u5f88\u591a\u65b0\u624b\u670d\u52a1\u5668\u4f1a\u56e0\u4e3a\u72b6\u6001\u5904\u7406\u4e0d\u5f53\u5bfc\u81f4\u5ba2\u6237\u7aef\u8fde\u63a5\u540e\u7acb\u5373\u65ad\u5f00 \u2014\u2014 \u4f8b\u5982\u5728\u63e1\u624b\u9636\u6bb5\u672a\u6b63\u786e\u8bbe\u7f6e next_state \u5c31\u5c1d\u8bd5\u53d1\u9001\u767b\u5f55\u6570\u636e\u5305\u3002<\/p>\n<h3>\u670d\u52a1\u5668\u57fa\u7840\u67b6\u6784\u642d\u5efa<\/h3>\n<p>MCP \u670d\u52a1\u5668\u7684\u57fa\u7840\u67b6\u6784\u9700\u8981\u5904\u7406\u4e09\u4e2a\u6838\u5fc3\u4efb\u52a1&#xff1a;TCP \u8fde\u63a5\u7ba1\u7406\u3001\u6570\u636e\u5305\u89e3\u6790\u4e0e\u8def\u7531\u3001\u5ba2\u6237\u7aef\u4f1a\u8bdd\u7ef4\u62a4\u3002\u6211\u4eec\u91c7\u7528\u591a\u7ebf\u7a0b\u6a21\u578b&#xff0c;\u4e3b\u7ebf\u7a0b\u8d1f\u8d23\u76d1\u542c\u8fde\u63a5&#xff0c;\u5de5\u4f5c\u7ebf\u7a0b\u5904\u7406\u5ba2\u6237\u7aef\u4ea4\u4e92&#xff0c;\u901a\u8fc7\u961f\u5217\u5b9e\u73b0\u7ebf\u7a0b\u5b89\u5168\u7684\u6570\u636e\u4ea4\u6362\u3002<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"500\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729182109-6889111543da1.png\" width=\"688\" \/><\/p>\n<p>\u9996\u5148\u5b9e\u73b0\u670d\u52a1\u5668\u4e3b\u6846\u67b6&#xff1a;<\/p>\n<p>import socket<\/p>\n<p>import threading<\/p>\n<p>from queue import Queue<\/p>\n<p>from typing import Dict<\/p>\n<p>class MCPServer:<\/p>\n<p>def __init__(self, host: str &#061; &#034;0.0.0.0&#034;, port: int &#061; 25565):<\/p>\n<p>self.host &#061; host<\/p>\n<p>self.port &#061; port<\/p>\n<p>self.server_socket &#061; socket.socket(socket.AF_INET, socket.SOCK_STREAM)<\/p>\n<p>self.server_socket.bind((host, port))<\/p>\n<p>self.server_socket.listen(5)<\/p>\n<p>self.clients: Dict[int, ClientHandler] &#061; {} # \u5ba2\u6237\u7aef\u4f1a\u8bdd\u5b57\u5178<\/p>\n<p>self.client_id &#061; 0<\/p>\n<p>self.running &#061; False<\/p>\n<p>self.packet_queue &#061; Queue() # \u6570\u636e\u5305\u5904\u7406\u961f\u5217<\/p>\n<p>def start(self):<\/p>\n<p>&#034;&#034;&#034;\u542f\u52a8\u670d\u52a1\u5668&#034;&#034;&#034;<\/p>\n<p>self.running &#061; True<\/p>\n<p>print(f&#034;MCP\u670d\u52a1\u5668\u542f\u52a8\u5728 {self.host}:{self.port}&#034;)<\/p>\n<p># \u542f\u52a8\u6570\u636e\u5305\u5904\u7406\u7ebf\u7a0b<\/p>\n<p>threading.Thread(target&#061;self.process_packets, daemon&#061;True).start()<\/p>\n<p># \u76d1\u542c\u5ba2\u6237\u7aef\u8fde\u63a5<\/p>\n<p>while self.running:<\/p>\n<p>client_sock, addr &#061; self.server_socket.accept()<\/p>\n<p>self.client_id &#043;&#061; 1<\/p>\n<p>handler &#061; ClientHandler(self.client_id, client_sock, addr, self)<\/p>\n<p>self.clients[self.client_id] &#061; handler<\/p>\n<p>handler.start()<\/p>\n<p>print(f&#034;\u65b0\u5ba2\u6237\u7aef\u8fde\u63a5: {addr} (ID: {self.client_id})&#034;)<\/p>\n<p>def process_packets(self):<\/p>\n<p>&#034;&#034;&#034;\u5904\u7406\u6570\u636e\u5305\u961f\u5217&#034;&#034;&#034;<\/p>\n<p>while self.running:<\/p>\n<p>packet &#061; self.packet_queue.get()<\/p>\n<p>if packet is None:<\/p>\n<p>break<\/p>\n<p>client_id, packet_id, data &#061; packet<\/p>\n<p>handler &#061; self.clients.get(client_id)<\/p>\n<p>if not handler:<\/p>\n<p>continue<\/p>\n<p># \u6839\u636e\u5f53\u524d\u72b6\u6001\u8def\u7531\u6570\u636e\u5305<\/p>\n<p>if handler.state.state &#061;&#061; &#034;status&#034;:<\/p>\n<p>self.handle_status_packets(handler, packet_id, data)<\/p>\n<p>elif handler.state.state &#061;&#061; &#034;login&#034;:<\/p>\n<p>self.handle_login_packets(handler, packet_id, data)<\/p>\n<p>elif handler.state.state &#061;&#061; &#034;play&#034;:<\/p>\n<p>self.handle_play_packets(handler, packet_id, data)<\/p>\n<p>def stop(self):<\/p>\n<p>&#034;&#034;&#034;\u505c\u6b62\u670d\u52a1\u5668&#034;&#034;&#034;<\/p>\n<p>self.running &#061; True<\/p>\n<p>self.packet_queue.put(None) # \u7ec8\u6b62\u5904\u7406\u7ebf\u7a0b<\/p>\n<p>self.server_socket.close()<\/p>\n<p>for client in self.clients.values():<\/p>\n<p>client.stop()<\/p>\n<p>print(&#034;\u670d\u52a1\u5668\u5df2\u505c\u6b62&#034;)<\/p>\n<p>\u6bcf\u4e2a\u5ba2\u6237\u7aef\u8fde\u63a5\u7531\u72ec\u7acb\u7684 ClientHandler \u5904\u7406&#xff1a;<\/p>\n<p>class ClientHandler(threading.Thread):<\/p>\n<p>def __init__(self, client_id: int, sock: socket.socket, addr, server: MCPServer):<\/p>\n<p>super().__init__()<\/p>\n<p>self.client_id &#061; client_id<\/p>\n<p>self.sock &#061; sock<\/p>\n<p>self.addr &#061; addr<\/p>\n<p>self.server &#061; server<\/p>\n<p>self.state &#061; MCPServerState()<\/p>\n<p>self.running &#061; True<\/p>\n<p>self.buffer &#061; bytearray()<\/p>\n<p>def run(self):<\/p>\n<p>&#034;&#034;&#034;\u5ba2\u6237\u7aef\u5904\u7406\u4e3b\u5faa\u73af&#034;&#034;&#034;<\/p>\n<p>try:<\/p>\n<p>while self.running:<\/p>\n<p># \u63a5\u6536\u6570\u636e&#xff08;1024\u5b57\u8282\u7f13\u51b2\u533a&#xff09;<\/p>\n<p>data &#061; self.sock.recv(1024)<\/p>\n<p>if not data:<\/p>\n<p>break<\/p>\n<p>self.buffer.extend(data)<\/p>\n<p>self.process_buffer()<\/p>\n<p>except Exception as e:<\/p>\n<p>print(f&#034;\u5ba2\u6237\u7aef {self.client_id} \u9519\u8bef: {e}&#034;)<\/p>\n<p>finally:<\/p>\n<p>self.stop()<\/p>\n<p>def process_buffer(self):<\/p>\n<p>&#034;&#034;&#034;\u89e3\u6790\u7f13\u51b2\u533a\u4e2d\u7684\u6570\u636e\u5305&#034;&#034;&#034;<\/p>\n<p>while self.buffer:<\/p>\n<p>try:<\/p>\n<p># \u89e3\u6790\u6570\u636e\u5305\u957f\u5ea6<\/p>\n<p>length, pos &#061; VarInt.decode(self.buffer)<\/p>\n<p>if len(self.buffer) &lt; pos &#043; length:<\/p>\n<p># \u6570\u636e\u4e0d\u5b8c\u6574&#xff0c;\u7b49\u5f85\u66f4\u591a\u6570\u636e<\/p>\n<p>break<\/p>\n<p># \u63d0\u53d6\u5b8c\u6574\u6570\u636e\u5305<\/p>\n<p>packet_data &#061; self.buffer[pos:pos&#043;length]<\/p>\n<p>self.buffer &#061; self.buffer[pos&#043;length:]<\/p>\n<p># \u89e3\u6790\u6570\u636e\u5305ID<\/p>\n<p>packet_id, pos2 &#061; VarInt.decode(packet_data)<\/p>\n<p>payload &#061; packet_data[pos2:]<\/p>\n<p># \u5c06\u6570\u636e\u5305\u653e\u5165\u5904\u7406\u961f\u5217<\/p>\n<p>self.server.packet_queue.put((self.client_id, packet_id, payload))<\/p>\n<p>except Exception as e:<\/p>\n<p>print(f&#034;\u6570\u636e\u5305\u89e3\u6790\u9519\u8bef: {e}&#034;)<\/p>\n<p>break<\/p>\n<p>def send_packet(self, packet_id: int, data: bytes):<\/p>\n<p>&#034;&#034;&#034;\u53d1\u9001\u6570\u636e\u5305\u5230\u5ba2\u6237\u7aef&#034;&#034;&#034;<\/p>\n<p>try:<\/p>\n<p># \u6784\u5efa\u5b8c\u6574\u6570\u636e\u5305<\/p>\n<p>id_bytes &#061; VarInt.encode(packet_id)<\/p>\n<p>payload &#061; id_bytes &#043; data<\/p>\n<p>length_bytes &#061; VarInt.encode(len(payload))<\/p>\n<p>self.sock.sendall(length_bytes &#043; payload)<\/p>\n<p>except Exception as e:<\/p>\n<p>print(f&#034;\u53d1\u9001\u6570\u636e\u5305\u5931\u8d25: {e}&#034;)<\/p>\n<p>def stop(self):<\/p>\n<p>&#034;&#034;&#034;\u505c\u6b62\u5ba2\u6237\u7aef\u8fde\u63a5&#034;&#034;&#034;<\/p>\n<p>self.running &#061; False<\/p>\n<p>self.sock.close()<\/p>\n<p>if self.client_id in self.server.clients:<\/p>\n<p>del self.server.clients[self.client_id]<\/p>\n<p>print(f&#034;\u5ba2\u6237\u7aef {self.client_id} \u5df2\u65ad\u5f00\u8fde\u63a5&#034;)<\/p>\n<p>\u8fd9\u4e2a\u67b6\u6784\u7684\u5173\u952e\u8bbe\u8ba1\u662f\u5c06\u6570\u636e\u5305\u89e3\u6790\u4e0e\u4e1a\u52a1\u5904\u7406\u5206\u79bb\u3002ClientHandler \u4ec5\u8d1f\u8d23\u4ece TCP \u6d41\u4e2d\u63d0\u53d6\u5b8c\u6574\u6570\u636e\u5305&#xff0c;\u5177\u4f53\u7684\u4e1a\u52a1\u903b\u8f91&#xff08;\u5982\u72b6\u6001\u54cd\u5e94\u3001\u767b\u5f55\u9a8c\u8bc1&#xff09;\u5219\u7531\u4e3b\u670d\u52a1\u5668\u7684 process_packets \u7ebf\u7a0b\u5904\u7406&#xff0c;\u8fd9\u79cd\u5206\u79bb\u4f7f\u4ee3\u7801\u66f4\u6613\u4e8e\u7ef4\u62a4\u3002<\/p>\n<p>\u5728\u6d4b\u8bd5\u4e2d&#xff0c;\u8fd9\u4e2a\u57fa\u7840\u67b6\u6784\u80fd\u7a33\u5b9a\u5904\u7406 20 \u4e2a\u5e76\u53d1\u5ba2\u6237\u7aef\u8fde\u63a5&#xff0c;\u6bcf\u4e2a\u5ba2\u6237\u7aef\u6bcf\u79d2\u53ef\u5904\u7406\u7ea6 50 \u4e2a\u6570\u636e\u5305\u3002\u5bf9\u4e8e\u66f4\u9ad8\u7ea7\u7684\u5e94\u7528&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u589e\u52a0\u5de5\u4f5c\u7ebf\u7a0b\u6570\u91cf\u548c\u4f7f\u7528\u5f02\u6b65 IO&#xff08;\u5982 Python \u7684 asyncio&#xff09;\u8fdb\u4e00\u6b65\u63d0\u5347\u6027\u80fd\u3002<\/p>\n<h3>\u529f\u80fd\u6269\u5c55\u4e0e\u534f\u8bae\u4f18\u5316<\/h3>\n<p>\u57fa\u7840\u67b6\u6784\u5b8c\u6210\u540e&#xff0c;\u9700\u8981\u5b9e\u73b0\u5177\u4f53\u7684 MCP \u529f\u80fd&#xff0c;\u5305\u62ec\u72b6\u6001\u67e5\u8be2\u54cd\u5e94\u3001\u5ba2\u6237\u7aef\u8ba4\u8bc1\u3001\u4e16\u754c\u4fe1\u606f\u540c\u6b65\u7b49\u3002\u8fd9\u4e9b\u529f\u80fd\u7684\u5b9e\u73b0\u9700\u8981\u4e25\u683c\u9075\u5faa MCP \u534f\u8bae\u89c4\u8303\u4e2d\u5bf9\u5404\u9636\u6bb5\u6570\u636e\u5305\u7684\u5b9a\u4e49\u3002<\/p>\n<p>\u9996\u5148\u5b9e\u73b0\u72b6\u6001\u67e5\u8be2\u529f\u80fd \u2014\u2014 \u5f53\u5ba2\u6237\u7aef\u53d1\u9001\u72b6\u6001\u8bf7\u6c42&#xff08;packet_id&#061;0x00&#xff09;\u65f6&#xff0c;\u670d\u52a1\u5668\u5e94\u8fd4\u56de\u670d\u52a1\u5668\u4fe1\u606f&#xff1a;<\/p>\n<p>def handle_status_packets(self, handler: ClientHandler, packet_id: int, data: bytes):<\/p>\n<p>&#034;&#034;&#034;\u5904\u7406\u72b6\u6001\u9636\u6bb5\u6570\u636e\u5305&#034;&#034;&#034;<\/p>\n<p>if packet_id &#061;&#061; 0x00: # \u72b6\u6001\u8bf7\u6c42<\/p>\n<p># \u6784\u5efa\u670d\u52a1\u5668\u72b6\u6001\u54cd\u5e94<\/p>\n<p>status &#061; {<\/p>\n<p>&#034;version&#034;: {<\/p>\n<p>&#034;name&#034;: &#034;1.18.2&#034;,<\/p>\n<p>&#034;protocol&#034;: 758<\/p>\n<p>},<\/p>\n<p>&#034;players&#034;: {<\/p>\n<p>&#034;max&#034;: 20,<\/p>\n<p>&#034;online&#034;: len(self.clients),<\/p>\n<p>&#034;sample&#034;: []<\/p>\n<p>},<\/p>\n<p>&#034;description&#034;: {<\/p>\n<p>&#034;text&#034;: &#034;\u6211\u7684\u7b2c\u4e00\u4e2aMCP\u670d\u52a1\u5668&#034;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p># \u8f6c\u6362\u4e3aJSON\u5b57\u7b26\u4e32\u5e76\u7f16\u7801<\/p>\n<p>import json<\/p>\n<p>status_json &#061; json.dumps(status).encode(&#039;utf-8&#039;)<\/p>\n<p>json_len &#061; VarInt.encode(len(status_json))<\/p>\n<p># \u53d1\u9001\u54cd\u5e94\u6570\u636e\u5305&#xff08;packet_id&#061;0x00&#xff09;<\/p>\n<p>handler.send_packet(0x00, json_len &#043; status_json)<\/p>\n<p>elif packet_id &#061;&#061; 0x01: # ping\u8bf7\u6c42<\/p>\n<p># \u76f4\u63a5\u8fd4\u56de\u5ba2\u6237\u7aef\u53d1\u9001\u7684ping\u6570\u636e&#xff08;8\u5b57\u8282&#xff09;<\/p>\n<p>handler.send_packet(0x01, data)<\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5b9e\u73b0\u4e86 Minecraft \u670d\u52a1\u5668\u5217\u8868\u4e2d\u663e\u793a\u7684\u670d\u52a1\u5668\u4fe1\u606f\u548c\u5ef6\u8fdf\u68c0\u6d4b\u529f\u80fd\u3002\u5f53\u73a9\u5bb6\u5728\u591a\u4eba\u6e38\u620f\u5217\u8868\u4e2d\u5237\u65b0\u65f6&#xff0c;\u5ba2\u6237\u7aef\u4f1a\u5148\u53d1\u9001 0x00 \u72b6\u6001\u8bf7\u6c42\u83b7\u53d6\u670d\u52a1\u5668\u4fe1\u606f&#xff0c;\u518d\u53d1\u9001 0x01 ping \u8bf7\u6c42\u6d4b\u91cf\u5ef6\u8fdf\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b\u3002MCP \u7684\u767b\u5f55\u6d41\u7a0b\u91c7\u7528\u52a0\u5bc6\u673a\u5236&#xff0c;\u5b8c\u6574\u5b9e\u73b0\u9700\u8981 RSA \u52a0\u5bc6\u548c Mojang \u4f1a\u8bdd\u9a8c\u8bc1&#xff0c;\u4f46\u4e3a\u4e86\u7b80\u5316\u53ef\u4ee5\u5148\u5b9e\u73b0\u65e0\u52a0\u5bc6\u767b\u5f55&#xff1a;<\/p>\n<p>def handle_login_packets(self, handler: ClientHandler, packet_id: int, data: bytes):<\/p>\n<p>&#034;&#034;&#034;\u5904\u7406\u767b\u5f55\u9636\u6bb5\u6570\u636e\u5305&#034;&#034;&#034;<\/p>\n<p>if packet_id &#061;&#061; 0x00: # \u767b\u5f55\u5f00\u59cb<\/p>\n<p># \u89e3\u6790\u7528\u6237\u540d<\/p>\n<p>name_len, pos &#061; VarInt.decode(data)<\/p>\n<p>username &#061; data[pos:pos&#043;name_len].decode(&#039;utf-8&#039;)<\/p>\n<p># \u751f\u6210\u968f\u673aUUID&#xff08;\u7b80\u5316\u5b9e\u73b0&#xff09;<\/p>\n<p>import uuid<\/p>\n<p>player_uuid &#061; uuid.uuid4()<\/p>\n<p># \u53d1\u9001\u767b\u5f55\u6210\u529f\u6570\u636e\u5305&#xff08;packet_id&#061;0x02&#xff09;<\/p>\n<p>uuid_bytes &#061; player_uuid.bytes # 16\u5b57\u8282UUID<\/p>\n<p>name_bytes &#061; username.encode(&#039;utf-8&#039;)<\/p>\n<p>name_len_bytes &#061; VarInt.encode(len(name_bytes))<\/p>\n<p>login_success_data &#061; uuid_bytes &#043; name_len_bytes &#043; name_bytes<\/p>\n<p>handler.send_packet(0x02, login_success_data)<\/p>\n<p># \u8f6c\u6362\u5230\u6e38\u620f\u72b6\u6001<\/p>\n<p>handler.state.transition(&#034;play&#034;)<\/p>\n<p># \u53d1\u9001 Join Game \u6570\u636e\u5305&#xff08;\u8fdb\u5165\u6e38\u620f&#xff09;<\/p>\n<p>self.send_join_game(handler, player_uuid.int)<\/p>\n<p>elif packet_id &#061;&#061; 0x01: # \u52a0\u5bc6\u54cd\u5e94&#xff08;\u7b80\u5316\u7248\u4e0d\u5904\u7406&#xff09;<\/p>\n<p>pass<\/p>\n<p>\u8fdb\u5165\u6e38\u620f\u72b6\u6001\u540e&#xff0c;\u9700\u8981\u53d1\u9001\u4e16\u754c\u4fe1\u606f\u8ba9\u5ba2\u6237\u7aef\u6b63\u786e\u6e32\u67d3\u6e38\u620f\u573a\u666f&#xff1a;<\/p>\n<p>def send_join_game(self, handler: ClientHandler, entity_id: int):<\/p>\n<p>&#034;&#034;&#034;\u53d1\u9001\u8fdb\u5165\u6e38\u620f\u6570\u636e\u5305&#034;&#034;&#034;<\/p>\n<p># \u6784\u5efa\u6570\u636e\u5305\u5185\u5bb9&#xff08;\u7b80\u5316\u7248&#xff09;<\/p>\n<p>data &#061; bytearray()<\/p>\n<p># \u5b9e\u4f53ID&#xff08;VarInt&#xff09;<\/p>\n<p>data.extend(VarInt.encode(entity_id))<\/p>\n<p># \u6e38\u620f\u6a21\u5f0f&#xff08;1\u5b57\u8282&#xff09;<\/p>\n<p>data.append(0x00) # \u751f\u5b58\u6a21\u5f0f<\/p>\n<p># \u7ef4\u5ea6&#xff08;VarInt&#xff09;<\/p>\n<p>data.extend(VarInt.encode(0)) # \u4e3b\u4e16\u754c<\/p>\n<p># \u96be\u5ea6&#xff08;1\u5b57\u8282&#xff09;<\/p>\n<p>data.append(0x02) # \u666e\u901a\u96be\u5ea6<\/p>\n<p># \u5176\u4ed6\u5fc5\u8981\u5b57\u6bb5&#xff08;\u7701\u7565\u90e8\u5206\u5185\u5bb9&#xff09;<\/p>\n<p>data.extend(VarInt.encode(1)) # \u6700\u5927\u73a9\u5bb6\u6570<\/p>\n<p>data.extend(VarInt.encode(0)) # \u6c34\u5e73\u5c04\u7ebf\u8303\u56f4<\/p>\n<p># \u53d1\u9001 Join Game \u6570\u636e\u5305&#xff08;packet_id&#061;0x26&#xff09;<\/p>\n<p>handler.send_packet(0x26, data)<\/p>\n<p># \u53d1\u9001\u51fa\u751f\u70b9\u6570\u636e\u5305<\/p>\n<p>self.send_spawn_position(handler)<\/p>\n<p>def send_spawn_position(self, handler: ClientHandler):<\/p>\n<p>&#034;&#034;&#034;\u53d1\u9001\u51fa\u751f\u70b9\u4f4d\u7f6e&#034;&#034;&#034;<\/p>\n<p># \u4f4d\u7f6e\u5750\u6807&#xff08;3\u4e2aint64&#xff09;<\/p>\n<p>x &#061; int(0 * 32) # \u65b9\u5757\u5750\u6807\u8f6c\u56fa\u5b9a\u70b9\u5750\u6807<\/p>\n<p>y &#061; int(70 * 32)<\/p>\n<p>z &#061; int(0 * 32)<\/p>\n<p>data &#061; bytearray()<\/p>\n<p>data.extend(x.to_bytes(8, byteorder&#061;&#039;big&#039;, signed&#061;True))<\/p>\n<p>data.extend(y.to_bytes(8, byteorder&#061;&#039;big&#039;, signed&#061;True))<\/p>\n<p>data.extend(z.to_bytes(8, byteorder&#061;&#039;big&#039;, signed&#061;True))<\/p>\n<p># \u53d1\u9001\u51fa\u751f\u70b9\u6570\u636e\u5305&#xff08;packet_id&#061;0x46&#xff09;<\/p>\n<p>handler.send_packet(0x46, data)<\/p>\n<p>\u5230\u8fd9\u91cc&#xff0c;\u6211\u4eec\u7684 MCP \u670d\u52a1\u5668\u5df2\u7ecf\u53ef\u4ee5\u8ba9\u5ba2\u6237\u7aef\u6210\u529f\u8fde\u63a5\u5e76\u8fdb\u5165\u6e38\u620f\u4e16\u754c\u3002\u4f46\u8981\u5b9e\u73b0\u5b8c\u6574\u529f\u80fd&#xff0c;\u8fd8\u9700\u8981\u5904\u7406\u66f4\u591a\u6e38\u620f\u5185\u6570\u636e\u5305&#xff0c;\u5982\u73a9\u5bb6\u79fb\u52a8\u3001\u65b9\u5757\u4ea4\u4e92\u7b49\u3002<\/p>\n<p>\u5728\u534f\u8bae\u4f18\u5316\u65b9\u9762&#xff0c;\u6709\u4e09\u4e2a\u5b9e\u7528\u6280\u5de7&#xff1a;<\/p>\n<li>\u6570\u636e\u5305\u538b\u7f29&#xff1a;\u5f53\u6570\u636e\u5305\u5927\u5c0f\u8d85\u8fc7\u9608\u503c&#xff08;\u9ed8\u8ba4 256 \u5b57\u8282&#xff09;\u65f6\u542f\u7528 ZLIB \u538b\u7f29&#xff0c;\u53ef\u51cf\u5c11 40-60% \u7684\u5e26\u5bbd\u5360\u7528\u3002<\/li>\n<p>import zlib<\/p>\n<p>def compress_packet(data: bytes, threshold: int &#061; 256) -&gt; bytes:<\/p>\n<p>&#034;&#034;&#034;\u538b\u7f29\u6570\u636e\u5305&#xff08;\u5982\u679c\u8d85\u8fc7\u9608\u503c&#xff09;&#034;&#034;&#034;<\/p>\n<p>if len(data) &lt; threshold:<\/p>\n<p># \u4e0d\u538b\u7f29&#xff0c;\u524d\u7f000x00<\/p>\n<p>return b&#039;\\\\x00&#039; &#043; data<\/p>\n<p>compressed &#061; zlib.compress(data)<\/p>\n<p># \u538b\u7f29\u524d\u7f00&#xff08;VarInt\u957f\u5ea6 &#043; \u538b\u7f29\u6570\u636e&#xff09;<\/p>\n<p>return VarInt.encode(len(compressed)) &#043; compressed<\/p>\n<li>\u6279\u91cf\u6570\u636e\u5305\u5408\u5e76&#xff1a;\u5c06\u77ed\u65f6\u95f4\u5185\u53d1\u9001\u7684\u591a\u4e2a\u5c0f\u6570\u636e\u5305\u5408\u5e76\u4e3a\u4e00\u4e2a&#xff0c;\u51cf\u5c11 TCP \u4ea4\u4e92\u6b21\u6570\u3002<\/li>\n<li>\u534f\u8bae\u7248\u672c\u9002\u914d&#xff1a;\u901a\u8fc7\u68c0\u6d4b\u5ba2\u6237\u7aef protocol_version&#xff0c;\u8fd4\u56de\u5bf9\u5e94\u7248\u672c\u652f\u6301\u7684\u6570\u636e\u5305\u7ed3\u6784&#xff0c;\u5b9e\u73b0\u8de8\u7248\u672c\u517c\u5bb9\u3002<\/li>\n<p>\u7ecf\u8fc7\u8fd9\u4e9b\u4f18\u5316&#xff0c;\u6211\u4eec\u7684 MCP \u670d\u52a1\u5668\u5728\u5b9e\u9645\u6d4b\u8bd5\u4e2d&#xff0c;\u80fd\u652f\u6301 1.18.2 \u7248\u672c\u5ba2\u6237\u7aef\u5b8c\u6574\u8fdb\u5165\u6e38\u620f\u4e16\u754c&#xff0c;\u5b9e\u73b0\u57fa\u672c\u7684\u79fb\u52a8\u548c\u573a\u666f\u6e32\u67d3\u3002\u4e0e\u5b98\u65b9\u670d\u52a1\u5668\u76f8\u6bd4&#xff0c;\u81ea\u5b9a\u4e49\u670d\u52a1\u5668\u5728\u54cd\u5e94\u901f\u5ea6\u4e0a\u5feb\u7ea6 15%&#xff0c;\u8fd9\u5f97\u76ca\u4e8e\u6211\u4eec\u7b80\u5316\u4e86\u90e8\u5206\u975e\u5fc5\u8981\u7684\u9a8c\u8bc1\u6d41\u7a0b\u3002<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"500\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729182109-688911155de1e.png\" width=\"771\" \/><\/p>\n<p>\u6784\u5efa MCP \u670d\u52a1\u5668\u7684\u8fc7\u7a0b&#xff0c;\u672c\u8d28\u4e0a\u662f\u5b66\u4e60\u5982\u4f55\u8bbe\u8ba1\u4e00\u4e2a\u9ad8\u6548\u7684\u7f51\u7edc\u901a\u4fe1\u7cfb\u7edf\u3002\u4ece VarInt \u7f16\u7801\u5230\u72b6\u6001\u673a\u7ba1\u7406&#xff0c;\u4ece\u6570\u636e\u5305\u8def\u7531\u5230\u6027\u80fd\u4f18\u5316&#xff0c;\u6bcf\u4e2a\u73af\u8282\u90fd\u4f53\u73b0\u4e86\u7f51\u7edc\u534f\u8bae\u8bbe\u8ba1\u7684\u901a\u7528\u539f\u5219\u3002\u8fd9\u4e9b\u7ecf\u9a8c\u4e0d\u4ec5\u9002\u7528\u4e8e Minecraft \u670d\u52a1\u5668\u5f00\u53d1&#xff0c;\u4e5f\u80fd\u6307\u5bfc\u4efb\u4f55\u9700\u8981\u8de8\u8bbe\u5907\u901a\u4fe1\u7684\u7cfb\u7edf\u8bbe\u8ba1\u3002<\/p>\n<p>\u4f5c\u4e3a\u5f00\u53d1\u8005&#xff0c;\u6700\u6709\u6210\u5c31\u611f\u7684\u65f6\u523b\u83ab\u8fc7\u4e8e\u770b\u5230\u81ea\u5df1\u7684\u670d\u52a1\u5668\u6210\u529f\u54cd\u5e94\u5ba2\u6237\u7aef\u8fde\u63a5 \u2014\u2014 \u5f53 Minecraft \u5ba2\u6237\u7aef\u663e\u793a &#034;\u5df2\u8fde\u63a5&#034; \u5e76\u52a0\u8f7d\u51fa\u4e16\u754c\u65f6&#xff0c;\u6240\u6709\u7684\u534f\u8bae\u8c03\u8bd5\u548c\u4ee3\u7801\u4f18\u5316\u90fd\u6709\u4e86\u56de\u62a5\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u867d\u7136\u5145\u6ee1\u6311\u6218&#xff0c;\u4f46\u80fd\u8ba9\u4f60\u6df1\u5165\u7406\u89e3\u7f51\u7edc\u901a\u4fe1\u7684\u672c\u8d28&#xff0c;\u8fd9\u6b63\u662f\u5e95\u5c42\u5f00\u53d1\u7684\u9b45\u529b\u6240\u5728\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.4k\u6b21\uff0c\u70b9\u8d5e26\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4ece\u96f6\u5f00\u59cb\u6784\u5efa\u4e00\u4e2a\u57fa\u4e8eMCP\u534f\u8bae\u7684Minecraft\u670d\u52a1\u5668\u3002\u9996\u5148\u89e3\u6790MCP\u534f\u8bae\u7684\u6838\u5fc3\u673a\u5236\uff0c\u5305\u62ec\u6570\u636e\u5305\u7ed3\u6784\uff08VarInt\u7f16\u7801\u683c\u5f0f\uff09\u548c\u72b6\u6001\u673a\u8bbe\u8ba1\uff08\u63e1\u624b\u3001\u72b6\u6001\u3001\u767b\u5f55\u3001\u6e38\u620f\u56db\u4e2a\u72b6\u6001\uff09\u3002\u968f\u540e\u5c55\u793a\u4e86\u670d\u52a1\u5668\u57fa\u7840\u67b6\u6784\u7684\u642d\u5efa\u8fc7\u7a0b\uff0c\u91c7\u7528\u591a\u7ebf\u7a0b\u6a21\u578b\u5904\u7406TCP\u8fde\u63a5\u548c\u6570\u636e\u5305\u8def\u7531\u3002\u6587\u7ae0\u8fd8\u5b9e\u73b0\u4e86\u72b6\u6001\u67e5\u8be2\u3001\u767b\u5f55\u8ba4\u8bc1\u7b49\u5173\u952e\u529f\u80fd\uff0c\u5e76\u63d0\u4f9b\u4e86\u534f\u8bae\u4f18\u5316\u6280\u5de7\uff08\u6570\u636e\u538b\u7f29\u3001\u6279\u91cf\u5904\u7406\u7b49\uff09\u3002\u901a\u8fc7\u4ee3\u7801\u793a\u4f8b\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6df1\u5165\u7406\u89e3\u6e38\u620f\u670d\u52a1\u5668\u5e95\u5c42\u901a\u4fe1\u539f\u7406\uff0c\u638c\u63e1\u8de8\u7248\u672c\u534f\u8bae\u9002\u914d\u3001\u6027\u80fd\u4f18\u5316\u7b49\u5173\u952e\u6280\u672f\u3002\u6700\u7ec8\u6784\u5efa\u7684\u670d\u52a1\u5668\u80fd\u591f\u652f\u6301\u5ba2\u6237\u7aef\u5b8c\u6574\u8fde\u63a5\u5e76\u8fdb\u5165\u6e38\u620f\u4e16\u754c\u3002_mcp\u534f\u8bae\u65f6\u57fa\u4e8etcp\u7684\u5417<\/p>\n","protected":false},"author":2,"featured_media":46098,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[43,188,44],"topic":[],"class_list":["post-46101","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-43","tag-188","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4ece\u96f6\u6784\u5efa MCP \u670d\u52a1\u5668\uff1a\u534f\u8bae\u89e3\u6790\u3001\u67b6\u6784\u5b9e\u73b0\u4e0e\u4ee3\u7801\u5b9e\u8df5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/46101.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4ece\u96f6\u6784\u5efa MCP \u670d\u52a1\u5668\uff1a\u534f\u8bae\u89e3\u6790\u3001\u67b6\u6784\u5b9e\u73b0\u4e0e\u4ee3\u7801\u5b9e\u8df5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.4k\u6b21\uff0c\u70b9\u8d5e26\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4ece\u96f6\u5f00\u59cb\u6784\u5efa\u4e00\u4e2a\u57fa\u4e8eMCP\u534f\u8bae\u7684Minecraft\u670d\u52a1\u5668\u3002\u9996\u5148\u89e3\u6790MCP\u534f\u8bae\u7684\u6838\u5fc3\u673a\u5236\uff0c\u5305\u62ec\u6570\u636e\u5305\u7ed3\u6784\uff08VarInt\u7f16\u7801\u683c\u5f0f\uff09\u548c\u72b6\u6001\u673a\u8bbe\u8ba1\uff08\u63e1\u624b\u3001\u72b6\u6001\u3001\u767b\u5f55\u3001\u6e38\u620f\u56db\u4e2a\u72b6\u6001\uff09\u3002\u968f\u540e\u5c55\u793a\u4e86\u670d\u52a1\u5668\u57fa\u7840\u67b6\u6784\u7684\u642d\u5efa\u8fc7\u7a0b\uff0c\u91c7\u7528\u591a\u7ebf\u7a0b\u6a21\u578b\u5904\u7406TCP\u8fde\u63a5\u548c\u6570\u636e\u5305\u8def\u7531\u3002\u6587\u7ae0\u8fd8\u5b9e\u73b0\u4e86\u72b6\u6001\u67e5\u8be2\u3001\u767b\u5f55\u8ba4\u8bc1\u7b49\u5173\u952e\u529f\u80fd\uff0c\u5e76\u63d0\u4f9b\u4e86\u534f\u8bae\u4f18\u5316\u6280\u5de7\uff08\u6570\u636e\u538b\u7f29\u3001\u6279\u91cf\u5904\u7406\u7b49\uff09\u3002\u901a\u8fc7\u4ee3\u7801\u793a\u4f8b\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6df1\u5165\u7406\u89e3\u6e38\u620f\u670d\u52a1\u5668\u5e95\u5c42\u901a\u4fe1\u539f\u7406\uff0c\u638c\u63e1\u8de8\u7248\u672c\u534f\u8bae\u9002\u914d\u3001\u6027\u80fd\u4f18\u5316\u7b49\u5173\u952e\u6280\u672f\u3002\u6700\u7ec8\u6784\u5efa\u7684\u670d\u52a1\u5668\u80fd\u591f\u652f\u6301\u5ba2\u6237\u7aef\u5b8c\u6574\u8fde\u63a5\u5e76\u8fdb\u5165\u6e38\u620f\u4e16\u754c\u3002_mcp\u534f\u8bae\u65f6\u57fa\u4e8etcp\u7684\u5417\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/46101.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-29T18:21:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729182108-68891114964d6.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/46101.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/46101.html\",\"name\":\"\u4ece\u96f6\u6784\u5efa MCP \u670d\u52a1\u5668\uff1a\u534f\u8bae\u89e3\u6790\u3001\u67b6\u6784\u5b9e\u73b0\u4e0e\u4ee3\u7801\u5b9e\u8df5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-29T18:21:10+00:00\",\"dateModified\":\"2025-07-29T18:21:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/46101.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/46101.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/46101.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4ece\u96f6\u6784\u5efa MCP \u670d\u52a1\u5668\uff1a\u534f\u8bae\u89e3\u6790\u3001\u67b6\u6784\u5b9e\u73b0\u4e0e\u4ee3\u7801\u5b9e\u8df5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4ece\u96f6\u6784\u5efa MCP \u670d\u52a1\u5668\uff1a\u534f\u8bae\u89e3\u6790\u3001\u67b6\u6784\u5b9e\u73b0\u4e0e\u4ee3\u7801\u5b9e\u8df5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/46101.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4ece\u96f6\u6784\u5efa MCP \u670d\u52a1\u5668\uff1a\u534f\u8bae\u89e3\u6790\u3001\u67b6\u6784\u5b9e\u73b0\u4e0e\u4ee3\u7801\u5b9e\u8df5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.4k\u6b21\uff0c\u70b9\u8d5e26\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4ece\u96f6\u5f00\u59cb\u6784\u5efa\u4e00\u4e2a\u57fa\u4e8eMCP\u534f\u8bae\u7684Minecraft\u670d\u52a1\u5668\u3002\u9996\u5148\u89e3\u6790MCP\u534f\u8bae\u7684\u6838\u5fc3\u673a\u5236\uff0c\u5305\u62ec\u6570\u636e\u5305\u7ed3\u6784\uff08VarInt\u7f16\u7801\u683c\u5f0f\uff09\u548c\u72b6\u6001\u673a\u8bbe\u8ba1\uff08\u63e1\u624b\u3001\u72b6\u6001\u3001\u767b\u5f55\u3001\u6e38\u620f\u56db\u4e2a\u72b6\u6001\uff09\u3002\u968f\u540e\u5c55\u793a\u4e86\u670d\u52a1\u5668\u57fa\u7840\u67b6\u6784\u7684\u642d\u5efa\u8fc7\u7a0b\uff0c\u91c7\u7528\u591a\u7ebf\u7a0b\u6a21\u578b\u5904\u7406TCP\u8fde\u63a5\u548c\u6570\u636e\u5305\u8def\u7531\u3002\u6587\u7ae0\u8fd8\u5b9e\u73b0\u4e86\u72b6\u6001\u67e5\u8be2\u3001\u767b\u5f55\u8ba4\u8bc1\u7b49\u5173\u952e\u529f\u80fd\uff0c\u5e76\u63d0\u4f9b\u4e86\u534f\u8bae\u4f18\u5316\u6280\u5de7\uff08\u6570\u636e\u538b\u7f29\u3001\u6279\u91cf\u5904\u7406\u7b49\uff09\u3002\u901a\u8fc7\u4ee3\u7801\u793a\u4f8b\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6df1\u5165\u7406\u89e3\u6e38\u620f\u670d\u52a1\u5668\u5e95\u5c42\u901a\u4fe1\u539f\u7406\uff0c\u638c\u63e1\u8de8\u7248\u672c\u534f\u8bae\u9002\u914d\u3001\u6027\u80fd\u4f18\u5316\u7b49\u5173\u952e\u6280\u672f\u3002\u6700\u7ec8\u6784\u5efa\u7684\u670d\u52a1\u5668\u80fd\u591f\u652f\u6301\u5ba2\u6237\u7aef\u5b8c\u6574\u8fde\u63a5\u5e76\u8fdb\u5165\u6e38\u620f\u4e16\u754c\u3002_mcp\u534f\u8bae\u65f6\u57fa\u4e8etcp\u7684\u5417","og_url":"https:\/\/www.wsisp.com\/helps\/46101.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-29T18:21:10+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729182108-68891114964d6.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/46101.html","url":"https:\/\/www.wsisp.com\/helps\/46101.html","name":"\u4ece\u96f6\u6784\u5efa MCP \u670d\u52a1\u5668\uff1a\u534f\u8bae\u89e3\u6790\u3001\u67b6\u6784\u5b9e\u73b0\u4e0e\u4ee3\u7801\u5b9e\u8df5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-29T18:21:10+00:00","dateModified":"2025-07-29T18:21:10+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/46101.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/46101.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/46101.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4ece\u96f6\u6784\u5efa MCP \u670d\u52a1\u5668\uff1a\u534f\u8bae\u89e3\u6790\u3001\u67b6\u6784\u5b9e\u73b0\u4e0e\u4ee3\u7801\u5b9e\u8df5"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/46101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=46101"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/46101\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/46098"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=46101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=46101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=46101"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=46101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}