# 插件开发与本地调试

> 创建两种 manifest，验证本地发现路径，并处理变量与同名优先级。

- 网址：https://funcoding.ai/agents/cursor/customize/plugin-development/
- 核实日期：2026-10-07（命令、配置和价格以官方文档为准）
- 官方来源：[Cursor 官方文档：Plugins](https://cursor.com/docs/plugins)

---
先决定插件是否只需要可移植 Skills/MCP，再选择 manifest 格式。组件目录和 manifest 应放在同一个插件根目录中。

## 可移植 Agent Plugin

```text
my-plugin/
├── plugin.json
├── skills/
│   └── code-reviewer/
│       └── SKILL.md
└── mcp.json
```

根 manifest 使用 Agent Plugins schema：

```json
{
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
  "name": "my-plugin",
  "description": "Portable code review tools",
  "version": "1.0.0",
  "author": { "name": "Your Name" }
}
```

Cursor 不会在 mcp.json 展开标准的 ${PLUGIN_ROOT} 或 ${PLUGIN_DATA}；插件根目录使用 ${CURSOR_PLUGIN_ROOT}。

## Cursor Plugin

需要 Rules、Agents、Commands 或 Hooks 时，把 manifest 放在 .cursor-plugin/plugin.json。此格式只要求 name，组件可从默认目录发现，也可用 manifest 指定自定义路径。

```json
{
  "name": "my-plugin",
  "description": "Custom development tools",
  "version": "1.0.0"
}
```

完整组件字段应查官方 Plugins reference，不要把另一格式的 manifest 路径混用。

## 本地加载

1. 创建 ~/.cursor/plugins/local/my-plugin。
2. 复制完整插件内容，包括对应 manifest。
3. 重启 Cursor，或运行 Developer: Reload Window。
4. 在 Customize 检查预期 Rules、Skills 与 MCP 是否出现。

只有允许本地导入时才会加载。Teams/Enterprise 管理员可控制 Allow Local Plugin Imports，Enterprise 默认关闭。如果市场已安装同名插件，该版本优先于本地副本。

符号链接的目标必须仍位于 ~/.cursor/plugins/local 内，指向其他磁盘目录的链接会被跳过。CLI 另支持 `--plugin-dir <path>`，使用前核对[参数参考](https://funcoding.ai/agents/cursor/cli/reference/)。

## 发布

验证触发、配置和实际工具调用后，可在官方 marketplace/publish 提交审核。Cursor Plugins 的多插件仓库可使用 .cursor-plugin/marketplace.json，团队分发流程见[团队市场](https://funcoding.ai/agents/cursor/customize/team-marketplaces/)。
