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

prompt-mcp-server

v1.0.3

Published

提示词模板和Cursor规则的MCP服务器 - A Model Context Protocol server for managing prompt templates and cursor rules

Readme

提示词模板 MCP 服务器

一个基于Node.js + TypeScript的MCP(Model Context Protocol)服务器,用于管理提示词模板和Cursor规则模板。

功能特性

提示词模板管理

  • 获取所有提示词模板列表
  • 根据名称或ID获取单个提示词模板
  • 搜索提示词模板
  • 按分类筛选提示词模板
  • 获取所有提示词分类

Cursor规则模板管理

  • 获取所有Cursor规则模板列表
  • 根据名称或ID获取单个Cursor规则模板
  • 搜索Cursor规则模板
  • 按编程语言、框架、分类筛选
  • 获取所有支持的编程语言和框架

技术栈

  • 运行时: Node.js 18+
  • 语言: TypeScript
  • 数据库: MySQL 8.0+
  • MCP SDK: @modelcontextprotocol/sdk
  • ORM: 原生MySQL2驱动
  • 代码规范: ESLint + Prettier

安装

从npm安装

npm install -g prompt-mcp-server

或者使用yarn:

yarn global add prompt-mcp-server

或者使用pnpm:

pnpm add -g prompt-mcp-server

从源码安装

1. 环境要求

  • Node.js >= 18.0.0
  • MySQL >= 8.0
  • pnpm (推荐) 或 npm/yarn

2. 克隆并安装依赖

git clone https://github.com/zhaopu/prompt-mcp-server.git
cd prompt-mcp-server
pnpm install

配置

数据库配置

重要:为了安全,数据库连接信息需要通过环境变量配置,不会硬编码在包中。

方法1: 使用环境变量

export DB_HOST=your_database_host
export DB_PORT=3306
export DB_USER=your_username
export DB_PASSWORD=your_password
export DB_NAME=your_database_name

方法2: 使用.env文件(推荐)

  1. 复制配置示例

    # 如果是全局安装
    cp $(npm root -g)/prompt-mcp-server/config.env.example .env
       
    # 如果是本地安装
    cp node_modules/prompt-mcp-server/config.env.example .env
  2. 编辑.env文件

    # 数据库配置
    DB_HOST=localhost
    DB_PORT=3306
    DB_USER=root
    DB_PASSWORD=your_password
    DB_NAME=your_database_name

3. 数据库配置

确保你的MySQL服务正在运行,并已创建相应的数据库。

执行数据库初始化脚本(如果是第一次使用):

# 使用mysql命令行工具
mysql -h your_host -u your_user -p your_database < database/init.sql

# 或者如果有权限,可以直接创建数据库
mysql -h your_host -u your_user -p -e "CREATE DATABASE IF NOT EXISTS your_database_name;"
mysql -h your_host -u your_user -p your_database_name < database/init.sql

4. 编译项目(仅源码安装需要)

pnpm run build

5. 启动服务

全局安装后使用

# 确保已配置环境变量或.env文件
prompt-mcp-server

从源码使用

# 开发模式
pnpm run dev

# 生产模式
pnpm run start

使用说明

首次启动

当你首次启动服务器时,如果缺少必要的数据库配置,会看到类似提示:

❌ 缺少必需的数据库环境变量:
   - DB_HOST
   - DB_USER
   - DB_PASSWORD
   - DB_NAME

请设置以下环境变量或创建.env文件:
DB_HOST=your_database_host
DB_PORT=3306
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=your_database_name

请按提示配置数据库连接信息。

成功启动

配置正确时,你会看到:

✅ 数据库配置验证通过
   - 主机: localhost:3306
   - 数据库: your_database_name
   - 用户: your_username
提示词MCP服务器启动成功

可用工具

提示词模板相关

  1. get-all-prompt-templates - 获取所有提示词模板列表

    • 参数: category (可选), limit (默认50), offset (默认0)
  2. get-prompt-template-by-name - 根据名称获取提示词模板

    • 参数: name (必需)
  3. get-prompt-template-by-id - 根据ID获取提示词模板

    • 参数: id (必需)
  4. search-prompt-templates - 搜索提示词模板

    • 参数: keyword (必需), category (可选), limit, offset
  5. get-prompt-categories - 获取所有提示词模板分类

Cursor规则模板相关

  1. get-all-cursor-rules-templates - 获取所有Cursor规则模板列表

    • 参数: category, language, framework, limit, offset (均可选)
  2. get-cursor-rules-template-by-name - 根据名称获取Cursor规则模板

    • 参数: name (必需)
  3. get-cursor-rules-template-by-id - 根据ID获取Cursor规则模板

    • 参数: id (必需)
  4. search-cursor-rules-templates - 搜索Cursor规则模板

    • 参数: keyword (必需), category, language, framework, limit, offset (可选)
  5. get-programming-languages - 获取所有支持的编程语言

  6. get-frameworks - 获取所有支持的框架

  7. get-cursor-rules-categories - 获取所有Cursor规则模板分类

项目结构

├── database/           # 数据库相关
│   └── init.sql       # 数据库初始化脚本
├── src/               # 源代码
│   ├── config/        # 配置文件
│   ├── database/      # 数据库连接
│   ├── services/      # 业务服务层
│   ├── types/         # TypeScript类型定义
│   └── index.ts       # 服务器入口
├── dist/              # 编译输出
├── config.env.example # 配置示例文件
├── package.json       # 项目配置
├── tsconfig.json      # TypeScript配置
├── .eslintrc.json     # ESLint配置
└── .prettierrc        # Prettier配置

开发指南

代码规范

项目采用严格的TypeScript配置和代码规范:

  • 使用ESLint进行代码静态检查
  • 使用Prettier进行代码格式化
  • 遵循函数式编程和面向对象编程的最佳实践

数据库设计

提示词模板表 (prompt_templates)

  • id: 主键
  • name: 模板名称(唯一)
  • title: 模板标题
  • description: 模板描述
  • content: 模板内容
  • category: 分类
  • tags: 标签(JSON数组)
  • author: 作者
  • version: 版本号
  • is_active: 是否激活
  • created_at: 创建时间
  • updated_at: 更新时间

Cursor规则模板表 (cursor_rules_templates)

  • 基本字段与提示词模板表相同
  • 额外字段:
    • language: 编程语言
    • framework: 框架/库

扩展开发

如需添加新功能:

  1. src/types/index.ts 中定义相关类型
  2. src/services/ 中创建业务服务
  3. src/index.ts 中注册新的MCP工具
  4. 更新文档

安全说明

  • 数据库连接信息通过环境变量配置,不会包含在npm包中
  • 请妥善保管你的.env文件,不要提交到版本控制系统
  • 建议在生产环境中使用专门的数据库用户,并限制权限

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!