leejunyoung5819mc-paper-plugin-test-mcp-26.3

공개

마인크래프트 26.3 Paper 서버의 플러그인 테스트를 하려는 AI 에이전트를 위한 MCP 도구

30줄1.6 KB
1// Smoke test for the MCP server: connects like an agent would, lists tools, calls a few.
2// Usage: node tests/mcp-smoke.ts (expects the server + a client "Bot1" to be running, or starts them)
3import path from 'node:path';
4import { Client } from '@modelcontextprotocol/sdk/client/index.js';
5import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
6
7const root = path.resolve(import.meta.dirname, '..');
8const transport = new StdioClientTransport({ command: process.execPath, args: [path.join(root, 'harness', 'mcp.ts')], cwd: root });
9const client = new Client({ name: 'mct-smoke', version: '0.0.1' });
10await client.connect(transport);
11
12const { tools } = await client.listTools();
13console.log(`tools (${tools.length}):`, tools.map((t) => t.name).join(', '));
14
15async function call(name: string, args: Record<string, unknown> = {}) {
16 const r: any = await client.callTool({ name, arguments: args });
17 const kinds = r.content.map((c: any) => (c.type === 'image' ? `image(${c.mimeType}, ${Math.round(c.data.length / 1024)}KB b64)` : 'text'));
18 console.log(`${name} -> isError=${!!r.isError} content=[${kinds.join(', ')}]`);
19 if (r.isError) console.log(' ', r.content[0].text);
20 return r;
21}
22
23await call('server_start');
24await call('client_launch', { name: 'Bot1' });
25const st = await call('state', { client: 'Bot1' });
26console.log(' inWorld:', JSON.parse(st.content[0].text).inWorld);
27await call('screenshot', { client: 'Bot1', label: 'mcp-smoke' });
28await call('click_slot', { client: 'Bot1', slot: 0 }); // expected error: no container open
29await call('chat', { client: 'Bot1', text: 'mcp smoke test', screenshot: true });
30await client.close();