feat(mcp): 增加游戏内方块调试桥接
新增 stdio MCP server 和 mcp 子命令,通过调试会话状态文件连接内置 TCP bridge,并提供 place_block 工具。 Bridge 将请求投递到服务端 System 的游戏线程执行,限制请求大小与队列长度,并按会话端口安全清理状态文件和连接。
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import mod.server.extraServerApi as serverApi
|
||||
|
||||
from . import IPCSystem, Lifecycle
|
||||
from . import IPCSystem, Lifecycle, MCPBridge
|
||||
|
||||
|
||||
ServerSystem = serverApi.GetServerSystemCls()
|
||||
@@ -16,13 +16,18 @@ class DebugServerSystem(ServerSystem):
|
||||
if not self._initialized:
|
||||
Lifecycle.activate(self)
|
||||
IPCSystem.ON_SERVER_INIT()
|
||||
MCPBridge.ON_SERVER_INIT()
|
||||
self._initialized = True
|
||||
IPCSystem.UPDATE_SERVER()
|
||||
MCPBridge.UPDATE()
|
||||
return ServerSystem.Update(self)
|
||||
|
||||
def Destroy(self):
|
||||
try:
|
||||
IPCSystem.ON_SERVER_EXIT()
|
||||
MCPBridge.ON_SERVER_EXIT()
|
||||
finally:
|
||||
self._initialized = False
|
||||
Lifecycle.deactivate(self)
|
||||
try:
|
||||
IPCSystem.ON_SERVER_EXIT()
|
||||
finally:
|
||||
self._initialized = False
|
||||
Lifecycle.deactivate(self)
|
||||
|
||||
Reference in New Issue
Block a user