feat(redstone): connect minecraft.wiki via three new MCP tools
Redstone can now query the official Minecraft wiki and deliver crafting recipe / item images straight into the chat. New: mcp/lib/minecraft-wiki-tools.ts exports three tools, all hitting https://minecraft.wiki/api.php (MediaWiki API, formatversion=2): - wiki_search(query, limit?) — opensearch top results, namespace 0, returns { title, description, url } for each hit. - wiki_page(title, thumb_size?) — extracts|pageimages → intro extract (plain text, ~600 chars) + thumbnail_url + page_url. - wiki_page_images(title, filter?, limit?) — generator=images + prop=imageinfo (iiprop=url|mime|size) returns every image embedded on the page along with its direct https URL. The `filter` substring is case-insensitive against the filename — pass 'recipe' / 'craft' / 'grid' to surface crafting-recipe diagrams. Bot wiring (bot/bot.ts): - import minecraftWikiTools, merge into allTools so it flows through the existing OpenRouter + Gemini function/tool schemas automatically. - Persona prompt teaches the model the canonical flow: wiki_search → wiki_page → wiki_page_images(filter='recipe') → tg_send_photo(url, caption). Composes with the already-existing tg_send_photo tool — no new telegram tool needed. User-Agent on every wiki request, 15s timeout, JSON-only. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1059,6 +1059,7 @@ import {
|
||||
} from "/mc/mcp/lib/types.ts";
|
||||
import { telegramTools } from "/mc/mcp/lib/telegram-tools.ts";
|
||||
import { minecraftTools } from "/mc/mcp/lib/minecraft-tools.ts";
|
||||
import { minecraftWikiTools } from "/mc/mcp/lib/minecraft-wiki-tools.ts";
|
||||
|
||||
const tgClient = createTgClient(TOKEN);
|
||||
const mcRuntime = createMcRuntime({
|
||||
@@ -1072,7 +1073,7 @@ const mcRuntime = createMcRuntime({
|
||||
backupSh: `${MC_DIR}/backup.sh`,
|
||||
});
|
||||
const toolCtx: ToolCtx = { tg: tgClient, db, mc: mcRuntime };
|
||||
const allTools = [...telegramTools, ...minecraftTools];
|
||||
const allTools = [...telegramTools, ...minecraftTools, ...minecraftWikiTools];
|
||||
const toolsByName = new Map(allTools.map((t) => [t.name, t]));
|
||||
// Hidden from Redstone's view: emoji→sticker is handled by post-processing
|
||||
// the reply text, so the model never has to manage file_ids itself.
|
||||
@@ -1202,6 +1203,7 @@ function redstonePersona(user: User, chatType: string, chatId: number, srv: stri
|
||||
"- Telegram chat: send messages/polls/reactions/dice/stickers/photos, edit/pin/delete your own messages, query chat info (tg_*).",
|
||||
"- Minecraft server: check status (server_status), start/stop/restart services (server_up/down/restart), tail logs (server_logs), look up players in the bot's database (players_list/player_get).",
|
||||
"- Admin-only tools (the caller's role is shown in the context block): run RCON commands (rcon), trigger a world backup (backup), and modify player records (player_upsert/set_*/remove, seen_list). If a non-admin asks for one, politely refuse and don't call it.",
|
||||
"- Minecraft wiki: look things up on minecraft.wiki and surface images into the chat. Usual flow for a 'how do I craft X?' / 'what is X?' question: wiki_search to pick the exact page title → wiki_page for a one-line summary + thumbnail → wiki_page_images with filter='recipe' or 'craft' or 'grid' to find a crafting-grid image, then tg_send_photo to send the image URL straight into the chat (caption it briefly).",
|
||||
"- When you use a tool, you usually don't need a separate text reply unless you're adding context — the tool's effect IS the response. After a server_status / players_list lookup, summarize the answer in one sentence.",
|
||||
"",
|
||||
"Stickers — drop emojis inline and the bot does the rest:",
|
||||
|
||||
Reference in New Issue
Block a user