| 1234567891011121314151617181920212223242526 |
- import path from 'node:path';
- import { Client } from '@modelcontextprotocol/sdk/client/index.js';
- import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
- import manifest from '../skill-package-manifest.json' with { type: 'json' };
- const root = path.resolve(import.meta.dirname, '..');
- const transport = new StdioClientTransport({ command: process.execPath, args: [path.join(root, 'mcp', 'src', 'server.mjs')], cwd: root, stderr: 'pipe' });
- const client = new Client({ name: 'fmode-image-set-smoke', version: '0.1.0' });
- try {
- await client.connect(transport);
- const listed = await client.listTools();
- const names = listed.tools.map(tool => tool.name).sort();
- const expected = [...manifest.mcpTools].sort();
- if (JSON.stringify(names) !== JSON.stringify(expected)) throw new Error(`Tool mismatch: ${JSON.stringify(names)}`);
- for (const tool of listed.tools) {
- if (!tool.inputSchema) throw new Error(`Missing input schema: ${tool.name}`);
- if (!tool.outputSchema) throw new Error(`Missing output schema: ${tool.name}`);
- if (!tool.annotations) throw new Error(`Missing annotations: ${tool.name}`);
- }
- const response = await client.callTool({ name: 'fmode_image_set_plan', arguments: { request: '规划七张测试套图' } });
- const parsed = JSON.parse(response.content[0].text);
- if (parsed.status !== 'ok' || parsed.data.plan.items.length !== 7) throw new Error('MCP planning call failed.');
- console.log(JSON.stringify({ status: 'ok', tools: names.length, planId: parsed.data.plan.planId }, null, 2));
- } finally {
- await client.close();
- }
|