MCP工具服务器
MCP Tools Server是一个Minecraft服务器插件,它为大型语言模型(LLM)提供了一个API,以便与Minecraft Server交互。它利用模型上下文协议(MCP)将服务器功能作为AI助手可以调用的工具公开。
特性
- 服务器日志访问:通过API远程查看服务器日志
- 聊天监控:访问玩家聊天消息和Discord消息(通过DiscordSRV)
- 命令执行:远程执行Minecraft命令
- MCP兼容性:遵循模型上下文协议,与LLM无缝集成
- DiscordSRV集成:将您的Minecraft服务器聊天连接到Discord
需求
- 运行Paper/Spigot 1.19的Minecraft服务器+
- Java 17或更高版本
- DiscordSRV 插件(可选,用于Discord集成)
安装
- 从下载最新版本的JAR文件 发布 页
- 将JAR文件放在服务器的
plugins文件夹 - 重新启动服务器
- 该插件将在以下位置生成默认配置文件
plugins/MCPToolsServer/config.yml - 编辑配置文件以自定义设置(请参阅配置部分)
- 使用
/mcptools reload在游戏中应用更改
配置
插件的配置文件(config.yml)包含以下部分:
mcp:
server:
port: 8080 # Port for the MCP server
https: false # Whether to use HTTPS
access-token: "" # Access token for authentication (empty = no auth)
logs:
max-lines: 1000 # Maximum number of log lines to store
include-console: true # Include console logs
include-chat: true # Include player chat
include-commands: true # Include command execution
chat:
max-messages: 100 # Maximum number of chat messages to store
include-discord: true # Include Discord messages
commands:
allowed-prefixes: [] # Allowed command prefixes (empty = all)
blocked-prefixes: # Blocked command prefixes
- "op"
- "deop"
- "ban"
- "kick"
- "stop"
- "reload"
log-execution: true # Log command executionAPI使用
该插件公开了一个遵循模型上下文协议(MCP)的HTTP API。API端点为:
GET /info-获取服务器信息GET /tools/list-列出可用工具POST /tools/call-调用工具
可用工具
1.查看日志(view_logs)
检索服务器日志。
参数:
limit(整数,可选):要返回的日志行数(默认值:50,最大值:1000)filter(字符串,可选):按文本筛选日志logType(字符串,可选):要返回的日志类型(“全部”、“控制台”、“聊天”、“命令”)
请求示例:
{
"name": "view_logs",
"arguments": {
"limit": 100,
"filter": "error",
"logType": "console"
}
}2.查看聊天(view_chat)
检索聊天消息。
参数:
limit(整数,可选):要返回的消息数(默认值:20,最大值:100)player(字符串,可选):按玩家姓名筛选消息includeDiscord(布尔值,可选):是否包含Discord消息(默认值:true)
请求示例:
{
"name": "view_chat",
"arguments": {
"limit": 50,
"player": "Steve",
"includeDiscord": true
}
}3.执行命令(execute_command)
执行Minecraft命令。
参数:
command(string,必填):要执行的命令(不带前导斜线)asConsole(boolean,可选):是否作为控制台执行(默认值:true)player(string,可选):以玩家身份执行(仅当asConsole为false时)
请求示例:
{
"name": "execute_command",
"arguments": {
"command": "time set day",
"asConsole": true
}
}示例:使用curl调用API
# List available tools
curl -X GET http://localhost:8080/tools/list
# View logs
curl -X POST http://localhost:8080/tools/call \
-H "Content-Type: application/json" \
-d '{"name":"view_logs","arguments":{"limit":50}}'
# Execute a command
curl -X POST http://localhost:8080/tools/call \
-H "Content-Type: application/json" \
-d '{"name":"execute_command","arguments":{"command":"say Hello from API"}}'与LLM集成
此插件旨在与支持模型上下文协议的大型语言模型一起使用。API允许LLM:
- 通过以下方式发现可用工具
/tools/list端点 - 通过调用工具
/tools/call端点 - 处理结果并采取进一步行动
命令和权限
/mcptools reload-重新加载插件配置(权限:mcptools.admin)/mcptools status-显示当前插件状态(权限:mcptools.admin)
从源头构建
- 克隆存储库
- 使用Maven构建:
mvn clean package- 编译后的JAR将位于
target目录
贡献
欢迎投稿!请随时提交拉取请求。
