项目介绍
MCP 插件
这是一个 MCP 插件项目,提供了快速创建 MCP 工具的框架。可用于 mcp_server_exe 的插件开发。
特点 | Features
| 中文 | 英文 |
|---|
| 提供命令行工具以快速创建 MCP 插件项目 | Command line tool for rapid MCP plugin project creation |
| 内置默认模板,包含基本工具示例 | |
| 支持 TypeScript 开发环境 | TypeScript development environment support |
| 集成测试框架(Jest) | |
安装 | Installation
全局安装(推荐)
npm install -g mcp-plugin
本地安装
npm install mcp-plugin
使用 | Usage
创建新项目 | Create New Project
# 创建新项目 | Create new project
mcp-plugin init
# 使用指定模板创建项目 | Create project with specific template
mcp-plugin init -t template-name
在项目创建过程中,您将被提示输入: | During project creation, you will be prompted for:
| 中文 | 英文 |
|---|
| 项目名称 | Project Name |
| 项目描述 | Project Description |
| 作者信息 | Author Information |
集成到 MCP 服务器
构建完成后,您可以启动 MCP 服务器并使用以下方式加载您的插件:
mcp_server-win-x64.exe --mcp-js ./dist/index.js
通过表单创建工具
| 中文 | 英文 |
|---|
| 您可以通过可视化表单快速生成自定义工具代码: | You can quickly generate custom tool code via a visual form: |
mcp-plugin create
- 启动后,浏览器会自动打开并访问本地工具生成器页面(默认端口 3366)。 | After running, your browser will open the local tool generator page (default port 3366).
- 在左侧填写工具名称、描述和参数字段,支持多种类型(字符串、数字、布尔值、日期、枚举等)。 | Fill in tool name, description, and parameter fields on the left. Multiple types supported (string, number, boolean, date, enum, etc).
- 可以添加多个参数字段并设置为可选。 | You can add multiple parameter fields and set them as optional.
- 中间区域实时预览生成的 TypeScript 工具代码和参数示例。 | The center area previews the generated TypeScript tool code and parameter example in real time.
- 右侧可以选择常用的模板快速开始。 | The right area provides common templates for quick start.
- 点击 "复制代码" 复制生成的代码,然后将其粘贴到项目的
src/tools 目录中使用。

默认模板工具示例
1. test-echo
| 中文 | 英文 |
|---|
| 功能:回显输入的消息 | |
| 参数: message (字符串) | Parameters: message (string) |
2. get-current-time
| 中文 | 英文 |
|---|
| 功能:获取当前时间 | Function: Get current time |
| 参数:无 | Parameters: none |
3. math-add
| 中文 | 英文 |
|---|
| 功能:计算两个数的和 | Function: Add two numbers |
| 参数: | Parameters: |
- A (数字):第一个数 | - a (number): first number
- B (数字):第二个数 | - b (number): second number
自定义开发
您可以在 src 目录中修改或添加新的工具。每个工具需要实现:
| 中文 | 英文 |
|---|
| 工具名称 | Tool Name |
| 工具描述 | Tool Description |
| 参数模式(使用 zod 定义) | Parameter schema (defined using zod) |
| 处理函数 | |
示例 | Example:
server.tool(
'tool-name', // 工具名称 | Tool name
'Tool description', // 工具描述 | Tool description
{
param: z.string() // 参数定义 | Parameter definition
},
async (args) => { // 处理函数 | Handler function
// 实现逻辑 | Implementation logic
return {
content: [
{
type: 'text',
text: 'result'
}
]
}
}
)
项目开发
- 进入项目目录: | 1 Enter project directory:
cd your-project-name
- 安装依赖: | 2 Install dependencies:
npm install
- 开发模式: | 3 Development mode:
npm run dev
- 构建项目: | 4 Build project:
npm run build
- 运行测试: | 5 Run tests:
npm test
许可证 | License
Apache