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

low-code-mcp-stdio

v2.1.7

Published

low-code-mcp-stdio

Readme

Low-Code MCP Server

这是一个基于 Model Context Protocol (MCP) 的服务器项目,支持与 Cursor 等 AI 编辑器进行流式通信。

项目架构

核心组件

  1. McpServer: MCP 服务器核心
  2. StreamableHTTPServerTransport: 支持流式传输的 HTTP 传输层
  3. Express Server: HTTP 服务器框架
  4. 工具注册系统: 可扩展的工具注册机制

流式通信实现

1. 传输层流式支持

项目使用 StreamableHTTPServerTransport 来实现流式通信:

const transport = new StreamableHTTPServerTransport({
  sessionIdGenerator: () => randomUUID(),
  onsessioninitialized: (sessionId) => {
    transports[sessionId] = transport;
  },
});

2. 会话管理

每个 Cursor 连接都有唯一的 sessionId,通过会话管理确保流式通信的连续性:

const transports: { [sessionId: string]: StreamableHTTPServerTransport } = {};

3. 工具实现

工具通过标准的 MCP 接口返回内容,流式传输由传输层自动处理:

server.registerTool(
  "tool-name",
  {
    description: "工具描述",
    inputSchema: {
      // 输入参数定义
    }
  },
  async (args, { signal }) => {
    // 工具逻辑实现
    return {
      content: [
        {
          type: "text",
          text: "返回的内容"
        }
      ]
    };
  }
);

如何给 Cursor 以 Stream 形式返回结果

1. 自动流式传输

MCP 协议本身支持流式传输,当使用 StreamableHTTPServerTransport 时:

  • 工具返回的内容会自动以流式方式传输给 Cursor
  • 不需要在工具层面实现特殊的流式逻辑
  • 传输层会处理分块传输和实时推送

2. 工具实现要点

// 支持取消操作
async ({ message }, { signal }) => {
  if (signal?.aborted) {
    // 处理取消逻辑
    return;
  }
  
  // 工具逻辑
  return {
    content: [
      {
        type: "text",
        text: "处理结果"
      }
    ]
  };
}

3. 流式传输的优势

  • 实时响应: Cursor 可以实时显示工具执行结果
  • 用户体验: 用户无需等待完整结果,可以立即看到部分输出
  • 资源效率: 避免长时间阻塞,支持取消操作

运行项目

# 安装依赖
pnpm install

# 开发模式运行
pnpm dev

# 生产模式运行
pnpm start

# 测试服务器
pnpm test

服务器将在 http://localhost:8000/low-code-mcp 启动。

在 Cursor 中配置

  1. 打开 Cursor 设置
  2. 找到 MCP 配置部分
  3. 添加以下配置:
{
  "mcpServers": {
    "low-code-mcp": {
      "command": "node",
      "args": ["/path/to/your/project/dist/index.js"],
      "env": {
        "NODE_ENV": "production"
      }
    },
    "low-code-mcp-streamable": {
      "transport": "http",
      "url": "http://localhost:8000/low-code-mcp?name=1",
      "name": "low-code-mcp",
      "version": "1.0.0"
    },
  }
}
  1. 重启 Cursor
  2. 现在你可以在 Cursor 中使用以下工具:
    • hello-world: 获取一个打招呼的方式
    • stream-demo: 演示流式返回结果的工具
    • advanced-stream: 高级流式工具,演示长时间任务和进度更新
    • real-time-data: 实时数据流工具,模拟数据采集

工具扩展

要添加新工具,只需:

  1. src/tools/ 目录下创建新的工具文件
  2. 实现工具逻辑
  3. src/index.ts 中注册工具

MCP 协议特点

  • 标准化: 遵循 MCP 协议标准
  • 可扩展: 支持动态工具注册
  • 流式支持: 原生支持流式数据传输
  • 会话管理: 支持多会话并发处理