| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #!/usr/bin/env node
- const path = require('path');
- const { Client } = require('@modelcontextprotocol/sdk/client/index.js');
- const { StdioClientTransport } = require('@modelcontextprotocol/sdk/client/stdio.js');
- async function main() {
- const cwd = path.resolve(__dirname, '..');
- const client = new Client({
- name: 'voc-intelligence-smoke',
- version: '0.1.2'
- });
- const transport = new StdioClientTransport({
- command: process.execPath,
- args: ['mcp/src/server.js'],
- cwd,
- stderr: 'pipe'
- });
- const stderr = transport.stderr;
- if (stderr) {
- stderr.on('data', chunk => {
- process.stderr.write(chunk);
- });
- }
- await client.connect(transport);
- try {
- const tools = await client.listTools();
- const toolNames = tools.tools.map(tool => tool.name);
- if (!toolNames.includes('voc_xiaohongshu_trend_run')) {
- throw new Error(`Expected tool voc_xiaohongshu_trend_run, got: ${toolNames.join(', ')}`);
- }
- if (!toolNames.includes('voc_xiaohongshu_preference_update')) {
- throw new Error(`Expected tool voc_xiaohongshu_preference_update, got: ${toolNames.join(', ')}`);
- }
- const preferenceResult = await client.callTool({
- name: 'voc_xiaohongshu_preference_update',
- arguments: {
- message: '保留奶油风和全屋定制翻车方向,不要纯风格美图,下一版更偏门店转化话术',
- memory: '../outputs/claude-code-xhs-mcp-smoke/xiaohongshu-trend-memory.json'
- }
- });
- const preferenceStructured = preferenceResult.structuredContent || {};
- if (preferenceStructured.status !== 'ok') {
- throw new Error(`Expected ok preference result, got: ${JSON.stringify(preferenceStructured)}`);
- }
- const result = await client.callTool({
- name: 'voc_xiaohongshu_trend_run',
- arguments: {
- collectionMode: 'sample',
- profile: 'memory-templates/xiaohongshu-trend-profile.json',
- memory: '../outputs/claude-code-xhs-mcp-smoke/xiaohongshu-trend-memory.json',
- output: '../outputs/claude-code-xhs-mcp-smoke'
- }
- });
- const structured = result.structuredContent || {};
- if (structured.status !== 'ok') {
- throw new Error(`Expected ok result, got: ${JSON.stringify(structured)}`);
- }
- console.log(JSON.stringify({
- status: 'ok',
- tools: toolNames,
- assistantMessagePreview: String(structured.assistantMessage || '').slice(0, 120),
- preferenceMemoryApplied: Boolean(structured.summary && structured.summary.preferenceMemoryApplied),
- files: structured.files || []
- }, null, 2));
- } finally {
- await client.close();
- }
- }
- main().catch(error => {
- console.error(error);
- process.exit(1);
- });
|