Gathering detailed insights and metrics for @begda/mcp-client
Gathering detailed insights and metrics for @begda/mcp-client
Gathering detailed insights and metrics for @begda/mcp-client
Gathering detailed insights and metrics for @begda/mcp-client
npm install @begda/mcp-client
Typescript
Module System
Node Version
NPM Version
57.7
Supply Chain
90
Quality
72.6
Maintenance
100
Vulnerability
95.3
License
JavaScript (100%)
Total Downloads
402
Last Day
1
Last Week
12
Last Month
93
Last Year
402
Apache-2.0 License
2 Stars
8 Commits
1 Branches
1 Contributors
Updated on May 31, 2025
Minified
Minified + Gzipped
Latest Version
0.0.4
Package Id
@begda/mcp-client@0.0.4
Unpacked Size
485.07 kB
Size
129.61 kB
File Count
5
NPM Version
10.8.2
Node Version
20.18.1
Published on
Apr 17, 2025
Cumulative downloads
Total Downloads
1import {mcp_ollama_tools, mcp_server, run_tools} from './mcp-cli/index.js' 2import ollama from "ollama"; 3 4const config = { 5 6 "server-filesystem": { 7 "name": "文件操作", 8 "type": "stdio", 9 "description": "文件增加,删除,修改 智能体", 10 "isActive": true, 11 "registryUrl": "", 12 "command": "npx", //加载npm的 stdio服务 可以用npx 也可以用node,用node需要再本地环境下安装这个包 13 "args": [ 14 "-y", 15 "@modelcontextprotocol/server-filesystem", 16 "/Users/liaohui1080/Desktop/mcp-test-type/src/ddd", 17 "/Users/liaohui1080/Desktop/mcp-test-type/src/bb" 18 ] 19 }, 20 "zidonghua": { 21 "name": "自动化服务", 22 "type": "sse", 23 "description": "自动化智能体服务", 24 "isActive": true, 25 "baseUrl": "http://localhost:3002/sse" 26 }, 27 "echo": { 28 "name": "本地的stdio服务", 29 "type": "stdio", 30 "description": "", 31 "isActive": true, 32 "registryUrl": "", 33 "command": "node", //本地调用需要用node 34 "args": [ 35 "./echo.js" 36 ] 37 }, 38} 39 40//启动服务 41const {mcp_tools, mcp_resources, mcp_prompts} = await mcp_server(config) 42 43//设置ollama的工具配置 44const ollama_tools = mcp_ollama_tools(mcp_tools) 45 46//创建对话消息 47let messages = [ 48 { 49 role: "user", 50 content: ` 51 你是一个智能助手,你只能调用工具,如果没有工具返回文本:没有可调用工具. 52 用户输入:25年8月5日打开测试智能体的3号通风机 53 ` 54 }] 55 56// 运行模型 57const response = await ollama.chat({ 58 model: 'qwen2.5:7b', // 选择使用的模型 59 messages, // 传递用户输入的消息 60 tools: ollama_tools, // 传递工具信息 61 options: {temperature: 0} // 设置温度为 0,使回复尽可能稳定、确定 62}); 63 64//获取大模型返回的工具主体信息,这里面已经包含了调用的参数和返回结果 65const tool_calls = response.message.tool_calls 66 67// 运行工具返回结果 68try { 69 // 执行工具函数,按顺序运行 tool_calls 中的所有工具 70 const results = await run_tools(tool_calls, mcp_tools); 71 // 所有函数成功运行结束 72 console.log('✅ 所有工具函数执行完成'); 73 console.log('📦 执行结果:', JSON.stringify(results, null, 2)); // 美化输出 74} catch (error) { 75 // 捕获整个执行流程中的任何异常 76 console.error('❌ 工具执行过程中发生错误:'); 77 // 打印错误信息,更易调试 78 if (error instanceof Error) { 79 console.error('错误消息:', error.message); 80 console.error('堆栈信息:', error.stack); 81 } else { 82 console.error('未知错误:', error); 83 } 84}
No vulnerabilities found.
No security vulnerabilities found.
Last Day
0%
1
Compared to previous day
Last Week
100%
12
Compared to previous week
Last Month
-69.9%
93
Compared to previous month
Last Year
0%
402
Compared to previous year