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

@zhaixiaowei/mcp-prompt-optimizer

v1.0.1

Published

MCP server for optimizing and enhancing prompts for better AI interactions

Downloads

15

Readme

提示词优化 MCP 服务器

一个模型上下文协议 (MCP) 服务器,为 AI 交互提供智能能提示词优化功能。此服务器在提供实用的提示词增强功的同时,展示了 MCP 的核心概念。

🎯 展示的核心 MCP 概念

此服务器展示了模型上下文协议的基本概念:

1. 服务器架构

  • 服务器实例: 处理客户端请求的主要 MCP 服务器
  • 传输层: 使用 StdioServerTransport 实现命令行兼容性
  • 能力: 向 MCP 客户端声明提供工具的能力

2. 工具系统

  • 工具定义: 基于 JSON Schema 的工具规范
  • 输入验证: 使用模式进行结构化参数验证
  • 响应格式化: 标准化的 MCP 响应格式

3. 通信协议

  • 请求处理器: 实现 ListToolsRequestSchemaCallToolRequestSchema
  • 错误处理: 正确的 MCP 错误响应格式化
  • 异步操作: 非阻塞工具执行

🚀 功能特性

提示词优化器通过多种优化策略提供全面的提示词增强:

优化目标

  • 清晰度 (Clarity): 移除模糊语言,提高具体性
  • 具体性 (Specificity): 添加具体细节和约束条件
  • 结构 (Structure): 用逻辑流程组织内容
  • 上下文 (Context): 融入相关背景信息
  • 可执行性 (Actionable): 使指令更具体和可执行
  • 简洁性 (Conciseness): 在保持清晰度的同时去除冗余
  • 示例 (Examples): 添加说明性示例
  • 格式 (Format): 指定清晰的输出格式要求

分析能力

  • 提示词长度分析
  • 清晰度和具体性评分
  • 上下文和约束检测
  • 示例和格式识别

📦 安装

使用 npm 全局安装

npm install -g @zhaixiaowei/mcp-prompt-optimizer

使用 npx (推荐用于 Cursor)

npx @zhaixiaowei/mcp-prompt-optimizer

本地项目安装

npm install @zhaixiaowei/mcp-prompt-optimizer

🔧 配置

在 Cursor 中使用

要在 Cursor 中使用此 MCP 服务器,请将以下配置添加到你的 cursor的mcp配置中 文件中:

方法 1: 使用 npx (推荐)

{
  "mcpServers": {
    "prompt-optimizer": {
      "command": "npx",
      "args": [
        "-y",
        "@zhaixiaowei/mcp-prompt-optimizer"
      ]
    }
  }
}

🛠️ 使用方法

配置完成后,你可以在 Cursor 中通过调用 optimize_prompt 工具来使用提示词优化器:

基本使用

请优化这个提示词: "写一些关于 AI 的内容"

带参数的高级使用

使用 optimize_prompt 工具,参数如下:
- originalPrompt: "写一些关于 AI 的内容"
- context: "这是为技术博客文章准备的"
- targetAudience: "软件开发者"
- optimizationGoals: ["clarity", "specificity", "examples"]
- style: "technical"

示例工具调用

{
  "originalPrompt": "写一些关于 AI 的内容",
  "context": "面向开发者的技术博客文章",
  "targetAudience": "软件开发者",
  "optimizationGoals": ["clarity", "specificity", "structure", "examples"],
  "style": "technical"
}

📊 响应格式

工具返回全面的优化结果:

{
  "optimizedPrompt": "你的提示词的增强版本...",
  "improvements": [
    "通过移除模糊语言增强了清晰度",
    "添加了具体的约束条件和要求",
    "重新组织内容,使其具有清晰的章节"
  ],
  "reasoning": "所做更改的详细分析...",
  "originalLength": 25,
  "optimizedLength": 150,
  "score": 8.5
}

🎯 使用场景

对于开发者

  • 优化 API 文档提示词
  • 增强代码审查指令
  • 改进技术规范请求

对于内容创作者

  • 完善写作提示词以获得更好的输出
  • 构建复杂的内容请求
  • 为创意简报增加清晰度

对于研究人员

  • 改进数据分析提示词
  • 构建研究问题
  • 增强方法论描述

🔍 工作原理

  1. 分析阶段: 服务器分析你的原始提示词的清晰度、具体性、结构和其他因素
  2. 优化阶段: 根据你的目标应用选定的优化策略
  3. 增强阶段: 为你的目标受众和期望风格调整提示词
  4. 评分阶段: 根据应用的增强功能计算改进分数
  5. 推理阶段: 提供所做更改的详细解释

🤝 贡献

此服务器是模型上下文协议服务器集合的一部分。欢迎贡献!

📄 许可证

MIT 许可证 - 详情请参阅 LICENSE 文件。

🔗 相关链接