3 lines
976 B
JavaScript
3 lines
976 B
JavaScript
const fs=require('fs');
|
|
(async()=>{const {Client}=await import('@modelcontextprotocol/sdk/client/index.js');const {StreamableHTTPClientTransport}=await import('@modelcontextprotocol/sdk/client/streamableHttp.js');const rows=JSON.parse(fs.readFileSync('/tmp/librechat-mcp-servers.json','utf8'));const results=await Promise.all(rows.filter(s=>s.auth==='none').map(async s=>{const client=new Client({name:'librechat-integration-check',version:'1.0.0'});try{await client.connect(new StreamableHTTPClientTransport(new URL(s.url)),{timeout:10000});let count=0,cursor;do{const data=await client.listTools(cursor?{cursor}:undefined,{timeout:10000});count+=data.tools.length;cursor=data.nextCursor;}while(cursor);return {id:s.id,connected:true,tools:count};}catch(e){return {id:s.id,connected:false,error:e.message.slice(0,180)}}finally{await client.close().catch(()=>{});}}));console.log(JSON.stringify(results));process.exit(0)})().catch(e=>{console.error(e.name);process.exit(1)});
|