npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@begda/mcp-client

v0.0.4

Published

```js import {mcp_ollama_tools, mcp_server, run_tools} from './mcp-cli/index.js' import ollama from "ollama";

Readme

mcp-cli 使用说明

import {mcp_ollama_tools, mcp_server, run_tools} from './mcp-cli/index.js'
import ollama from "ollama";

const config = {

    "server-filesystem": {
        "name": "文件操作",
        "type": "stdio",
        "description": "文件增加,删除,修改 智能体",
        "isActive": true,
        "registryUrl": "",
        "command": "npx",  //加载npm的 stdio服务 可以用npx 也可以用node,用node需要再本地环境下安装这个包
        "args": [
            "-y",
            "@modelcontextprotocol/server-filesystem",
            "/Users/liaohui1080/Desktop/mcp-test-type/src/ddd",
            "/Users/liaohui1080/Desktop/mcp-test-type/src/bb"
        ]
    },
    "zidonghua": {
        "name": "自动化服务",
        "type": "sse",
        "description": "自动化智能体服务",
        "isActive": true,
        "baseUrl": "http://localhost:3002/sse"
    },
    "echo": {
        "name": "本地的stdio服务",
        "type": "stdio",
        "description": "",
        "isActive": true,
        "registryUrl": "",
        "command": "node", //本地调用需要用node
        "args": [
            "./echo.js"
        ]
    },
}

//启动服务
const {mcp_tools, mcp_resources, mcp_prompts} = await mcp_server(config)

//设置ollama的工具配置
const ollama_tools = mcp_ollama_tools(mcp_tools)

//创建对话消息
let messages = [
    {
        role: "user",
        content: `
          你是一个智能助手,你只能调用工具,如果没有工具返回文本:没有可调用工具.
          用户输入:25年8月5日打开测试智能体的3号通风机
        `
    }]

// 运行模型
const response = await ollama.chat({
    model: 'qwen2.5:7b', // 选择使用的模型
    messages, // 传递用户输入的消息
    tools: ollama_tools, // 传递工具信息
    options: {temperature: 0} // 设置温度为 0,使回复尽可能稳定、确定
});

//获取大模型返回的工具主体信息,这里面已经包含了调用的参数和返回结果
const tool_calls = response.message.tool_calls

// 运行工具返回结果
try {
    // 执行工具函数,按顺序运行 tool_calls 中的所有工具
    const results = await run_tools(tool_calls, mcp_tools);
    // 所有函数成功运行结束
    console.log('✅ 所有工具函数执行完成');
    console.log('📦 执行结果:', JSON.stringify(results, null, 2)); // 美化输出
} catch (error) {
    // 捕获整个执行流程中的任何异常
    console.error('❌ 工具执行过程中发生错误:');
    // 打印错误信息,更易调试
    if (error instanceof Error) {
        console.error('错误消息:', error.message);
        console.error('堆栈信息:', error.stack);
    } else {
        console.error('未知错误:', error);
    }
}