| 123456789101112131415161718192021222324252627282930313233343536 |
- // Read-only inspection through the already installed VOC MCP. No collection calls.
- const fs = require('node:fs');
- const path = require('node:path');
- const { createRequire } = require('node:module');
- const root = 'C:/Users/JSHY/AppData/Roaming/npm/node_modules/@vocmarket/voc-skill';
- const req = createRequire(path.join(root, 'mcp/src/server.js'));
- const { Client } = req('@modelcontextprotocol/sdk/client/index.js');
- const { StdioClientTransport } = req('@modelcontextprotocol/sdk/client/stdio.js');
- const { readCredentialContext } = req('./core/credentials.js');
- const credentials = readCredentialContext({});
- const out = path.resolve('work/product-reviews');
- fs.mkdirSync(out, { recursive: true });
- const transport = new StdioClientTransport({command:process.execPath,args:[path.join(root,'mcp/src/server.js')],cwd:root,stderr:'pipe',env:{...process.env,VOC_SKILL_NO_UPDATE_CHECK:'1'}});
- transport.stderr?.on('data',()=>{});
- const client = new Client({name:'ksf-review-readonly-access',version:'1.0.0'});
- function sanitize(value) {
- let raw=JSON.stringify(value);
- for(const secret of [credentials.newApiToken,credentials.sessionToken])if(secret)raw=raw.split(secret).join('[REDACTED]');
- return JSON.parse(raw);
- }
- (async()=>{
- try{
- await client.connect(transport,{timeout:15000});
- const calls=[
- {name:'voc_api_search',arguments:{query:'评论',platform:'jd',limit:20}},
- {name:'voc_api_search',arguments:{query:'评论',platform:'taobao',limit:20}},
- {name:'voc_billing_query',arguments:{operations:[{model:'voc-e-commerce',path:'jd/get-item-comments/v1',count:1},{model:'voc-e-commerce',path:'taobao/get-item-comment/v3',count:1}],createPaymentQr:false}},
- {name:'voc_usage_report',arguments:{from:'2026-11-06T00:00:00+08:00',to:'2026-11-07T00:00:00+08:00',groupBy:['usageTraceId','module'],limit:1000,pageSize:200,refresh:true}},
- ];
- for(let i=0;i<calls.length;i++){
- const result=sanitize(await client.callTool(calls[i],undefined,{timeout:30000}));
- fs.writeFileSync(path.join(out,'access-'+i+'.json'),JSON.stringify({request:calls[i],response:result},null,2));
- console.log(JSON.stringify({tool:calls[i].name,isError:result.isError,status:result.structuredContent?.status,summary:result.structuredContent?.summary,errors:result.structuredContent?.errors}));
- }
- }finally{await client.close();await transport.close();}
- })().catch(e=>{console.log(JSON.stringify({ok:false,error:e.name}));process.exitCode=1;});
|