leejunyoung5819 mc-paper-plugin-test-mcp-26.3
공개마인크래프트 26.3 Paper 서버의 플러그인 테스트를 하려는 AI 에이전트를 위한 MCP 도구
| 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) |
| 3 | import path from 'node:path'; |
| 4 | import { Client } from '@modelcontextprotocol/sdk/client/index.js'; |
| 5 | import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'; |
| 6 | |
| 7 | const root = path.resolve(import.meta.dirname, '..'); |
| 8 | const transport = new StdioClientTransport({ command: process.execPath, args: [path.join(root, 'harness', 'mcp.ts')], cwd: root }); |
| 9 | const client = new Client({ name: 'mct-smoke', version: '0.0.1' }); |
| 10 | await client.connect(transport); |
| 11 | |
| 12 | const { tools } = await client.listTools(); |
| 13 | console.log(`tools (${tools.length}):`, tools.map((t) => t.name).join(', ')); |
| 14 | |
| 15 | async 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 | |
| 23 | await call('server_start'); |
| 24 | await call('client_launch', { name: 'Bot1' }); |
| 25 | const st = await call('state', { client: 'Bot1' }); |
| 26 | console.log(' inWorld:', JSON.parse(st.content[0].text).inWorld); |
| 27 | await call('screenshot', { client: 'Bot1', label: 'mcp-smoke' }); |
| 28 | await call('click_slot', { client: 'Bot1', slot: 0 }); // expected error: no container open |
| 29 | await call('chat', { client: 'Bot1', text: 'mcp smoke test', screenshot: true }); |
| 30 | await client.close(); |