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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zjb522/mcpyh

v1.0.9

Published

云湖 (MCP) API 的 npm 包,用于在 Trae 中使用云湖 API

Readme

MCP (云湖) npm 包

这是一个用于在 Trae 中使用云湖 (MCP) API 的 npm 包,提供了完整的 API 封装,包括消息发送、批量发送、流式发送、消息编辑、消息撤回、消息列表获取、文件上传、看板管理等功能。

在 Trae 中使用(推荐)

配置 Trae MCP

将以下内容添加到 Trae 的 MCP 配置文件中(路径:C:\Users\你的用户名\AppData\Roaming\Trae CN\User\mcp.json):

{
  "mcpServers": {
    "mcpyh": {
      "command": "npx",
      "args": [
        "@zjb522/mcpyh"
      ],
      "env": {
        "MCP_TOKEN": "你的云湖机器人token"
      }
    }
  }
}

注意:将 你的云湖机器人token 替换为实际的 token。

3. 重启 Trae

配置完成后,重启 Trae 使配置生效。

4. 使用 MCP 功能

在 Trae 的 AI 对话中,你可以直接要求 AI 使用云湖功能,例如:

  • "发送消息给用户 7058262,内容是 '你好'"
  • "获取群 xxx 的最新消息"
  • "设置看板显示 '欢迎使用'"

在代码中使用

安装

npm install @zjb522/mcpyh

初始化

const MCP = require('@zjb522/mcpyh');

// 替换为你的机器人 token
const token = 'your_bot_token';
const mcp = new MCP(token);

发送消息

// 发送文本消息
const result = await mcp.sendMessage('7058262', 'user', 'text', {
  text: '这里是消息内容',
  buttons: [
    [
      {
        text: '复制',
        actionType: 2,
        value: 'xxxx'
      },
      {
        text: '点击跳转',
        actionType: 1,
        url: 'http://www.baidu.com'
      }
    ]
  ]
});
console.log(result);

批量发送消息

const result = await mcp.batchSendMessage(['7058262', '7058263'], 'user', 'text', {
  text: '这里是消息内容'
});
console.log(result);

流式发送消息

const result = await mcp.sendStreamMessage('7058262', 'user', 'text', '这里是流式消息内容');
console.log(result);

编辑消息

const result = await mcp.editMessage('msgId', '7058262', 'user', 'text', {
  text: '修改后的消息内容'
});
console.log(result);

撤回消息

const result = await mcp.recallMessage('msgId', '7058262', 'user');
console.log(result);

获取消息列表

// 获取最近 10 条消息
const result = await mcp.getMessages('7058262', 'user', '', 10);
console.log(result);

上传图片

const fs = require('fs');
const path = require('path');

const imagePath = path.join(__dirname, 'test.jpg');
const imageStream = fs.createReadStream(imagePath);

const result = await mcp.uploadImage(imageStream);
console.log(result);

上传视频

const fs = require('fs');
const path = require('path');

const videoPath = path.join(__dirname, 'test.mp4');
const videoStream = fs.createReadStream(videoPath);

const result = await mcp.uploadVideo(videoStream);
console.log(result);

上传文件

const fs = require('fs');
const path = require('path');

const filePath = path.join(__dirname, 'test.txt');
const fileStream = fs.createReadStream(filePath);

const result = await mcp.uploadFile(fileStream);
console.log(result);

设置看板

// 设置用户看板
const result = await mcp.setBoard('7058262', 'user', 'text', '你好');
console.log(result);

// 设置全局看板
const result = await mcp.setBoardAll('text', '欢迎使用云湖');
console.log(result);

取消看板

// 取消用户看板
const result = await mcp.dismissBoard('7058262', 'user');
console.log(result);

// 取消全部看板
const result = await mcp.dismissBoardAll();
console.log(result);

API 文档

构造函数

  • new MCP(token): 创建 MCP 实例
    • token: 机器人的 token

方法

消息相关

  • sendMessage(recvId, recvType, contentType, content, parentId): 发送消息
  • batchSendMessage(recvIds, recvType, contentType, content): 批量发送消息
  • sendStreamMessage(recvId, recvType, contentType, data): 流式发送消息
  • editMessage(msgId, recvId, recvType, contentType, content): 编辑消息
  • recallMessage(msgId, chatId, chatType): 撤回消息
  • getMessages(chatId, chatType, messageId, before, after): 获取消息列表

文件上传

  • uploadImage(image): 上传图片
  • uploadVideo(video): 上传视频
  • uploadFile(file): 上传文件

看板管理

  • setBoard(chatId, chatType, contentType, content, memberId, expireTime): 设置用户看板
  • setBoardAll(contentType, content, expireTime): 设置全局看板
  • dismissBoard(chatId, chatType, memberId): 取消用户看板
  • dismissBoardAll(): 取消全部看板

错误处理

所有方法都会返回 Promise,在调用时需要使用 try/catch 捕获可能的错误。

注意事项

  • 所有接口都有频次限制,请注意控制调用频率
  • 上传文件大小限制:图片不超过 10MB,视频和文件不超过 20MB
  • 流式消息仅支持 text 和 markdown 类型

许可证

ISC