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

flex-mcp

v1.1.21

Published

可运营 MCP Node 服务 - 支持多用户管理、MCP 协议、脚本执行

Readme

flex-mcp

可运营 MCP Node 服务 - 支持多用户管理、MCP 协议、脚本执行。

📦 安装

npm install -g flex-mcp

或使用 npx(无需安装):

npx flex-mcp <command>

🚀 快速开始

一键部署(推荐)

# 全局安装后
flex-mcp deploy

这会自动:

  • ✅ 创建 .env 配置文件
  • ✅ 初始化数据库
  • ✅ 启动服务器

分步操作

# 1. 初始化项目(创建 .env 文件,初始化数据库)
flex-mcp init

# 2. 启动服务器
flex-mcp start

# 3. 查看帮助
flex-mcp help

🌐 访问运营页面

服务器启动后,在浏览器中访问:

  • 管理员登录页面(运营页面): http://localhost:3000/admin/login
    • 默认账号:admin / 123456
  • 用户登录页面: http://localhost:3000/user/login
  • API 端点: http://localhost:3000/api
  • 健康检查: http://localhost:3000/health

💡 提示: 如果修改了端口(如 PORT=5666),请访问 http://localhost:5666/admin/login

在代码中使用

import { startServer } from 'flex-mcp';

await startServer({
  port: 3000,
  host: '0.0.0.0',
});

⚙️ 配置

环境变量

服务器启动后会在当前目录创建 .env 文件,你可以修改以下配置:

# 服务器配置
PORT=3000                    # 服务器端口(默认: 3000)
HOST=0.0.0.0                 # 服务器主机(默认: 0.0.0.0)

# 超级管理员账号
ADMIN_USERNAME=admin          # 管理员用户名(默认: admin)
ADMIN_PASSWORD=123456         # 管理员密码(默认: 123456)

# 数据目录(可选)
DATA_DIR=./.data              # 数据目录(默认: ./.data)

# 数据库路径(可选)
DATABASE_URL=./.data/database.sqlite

# JWT 密钥(可选,生产环境请修改)
JWT_SECRET=your-secret-key-here

# CORS 配置(可选)
CORS_ORIGIN=*                 # CORS 来源(默认: *)

# 禁用统计(可选)
DISABLE_TELEMETRY=false       # 禁用使用统计(默认: false)

修改端口

# 方式 1: 修改 .env 文件中的 PORT
PORT=5666 flex-mcp start

# 方式 2: 使用环境变量
export PORT=5666
flex-mcp start

功能特性

  • ✅ MCP 协议支持(SSE + HTTP)
  • ✅ 多用户管理和认证
  • ✅ MCP 组件加载(NPM/URL/stdio)
  • ✅ TypeScript 脚本执行
  • ✅ 变量系统
  • ✅ REST API

🔌 连接 Cursor

1. 创建 MCP 用户

  1. 访问管理员页面:http://localhost:3000/admin/login
  2. 登录后进入"用户管理"
  3. 创建新用户,记录邮箱和 API Key

2. 配置 Cursor

在 Cursor 的 MCP 配置文件中添加:

macOS/Linux: ~/.cursor/mcp.json
Windows: %APPDATA%\Cursor\mcp.json

{
  "mcpServers": {
    "flex-mcp": {
      "url": "http://localhost:3000/mcp/sse",
      "headers": {
        "email": "YOUR_EMAIL",
        "apiKey": "YOUR_API_KEY"
      }
    }
  }
}

注意:

  • YOUR_EMAIL 替换为你的用户邮箱
  • YOUR_API_KEY 替换为你的 API Key
  • 如果服务器运行在其他端口,修改 URL 中的端口号

3. 重启 Cursor

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

📊 功能使用

管理员功能

登录管理员页面后,你可以:

  1. 用户管理

    • 创建、编辑、删除用户
    • 查看用户 API Key
    • 重置用户 API Key
  2. 配置管理

    • 创建 MCP 配置
    • 配置 MCP 组件(NPM/URL/stdio)
    • 管理变量(支持密钥占位符)
    • 导入/导出配置
  3. 系统监控

    • 查看系统状态
    • 查看使用统计

用户功能

登录用户页面后,你可以:

  1. 表管理

    • 创建、编辑、删除表
    • 定义表结构(列、类型、约束)
    • 管理表数据
  2. 脚本执行

    • 编写和执行 TypeScript 脚本
    • 使用 MCP 工具
    • 访问表数据
    • 使用变量
  3. 提示词管理

    • 创建和管理提示词模板
    • 使用变量占位符

📝 API 文档

认证

用户登录

curl -X POST http://localhost:3000/api/auth/user/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "apiKey": "your-api-key"
  }'

管理员登录

curl -X POST http://localhost:3000/api/auth/admin/login \
  -H "Content-Type: application/json" \
  -d '{
    "username": "admin",
    "password": "123456"
  }'

用户管理

# 获取用户列表(需要管理员权限)
curl http://localhost:3000/api/users \
  -H "Authorization: Bearer YOUR_TOKEN"

配置管理

# 获取配置列表
curl http://localhost:3000/api/configs \
  -H "Authorization: Bearer YOUR_TOKEN"

💻 在代码中使用

import { startServer } from 'flex-mcp';

await startServer({
  port: 3000,
  host: '0.0.0.0',
});

❓ 常见问题

Q: 如何修改管理员密码?

A: 修改 .env 文件中的 ADMIN_PASSWORD 环境变量,然后重启服务器。

Q: 如何修改端口?

A: 修改 .env 文件中的 PORT 环境变量,或使用环境变量:PORT=5666 flex-mcp start

Q: 数据存储在哪里?

A: 默认存储在 ./.data 目录下,可以通过 DATA_DIR 环境变量修改。

Q: 如何备份数据?

A: 备份 ./.data 目录下的 database.sqlite 文件即可。

Q: 如何重置数据库?

A: 删除 ./.data 目录下的 database.sqlite 文件,然后重新运行 flex-mcp init

📚 更多文档

详细使用指南请参考:USAGE.md

许可证

MIT

作者

llj