Skip to content

Plugin Manifest — 为 Claude Code 打包一键安装包

源码:python/dcc_mcp_core/plugin_manifest.py · Issue #410 · Claude Code 插件参考

English

将 MCP 服务器 URL、技能路径、可选 sub-agent 打包成单个 JSON 清单,Claude Code 用户一键安装即可使用。

使用场景

  • 向用户交付预配置好的 DCC 集成(maya-mcpblender-mcp),无需手工编辑 claude_desktop_config.json
  • 和服务器 URL 一起分发精选技能包。
  • 对齐上游 MCP experimental-ext-skills 扩展——支持直接由服务器分发技能。

导入

python
from dcc_mcp_core import (
    PluginManifest,
    build_plugin_manifest,
    export_plugin_manifest,
)

PluginManifest(dataclass)

字段类型说明
namestr插件名(如 "maya-mcp"
versionstr插件版本
descriptionstrClaude Code UI 中显示
mcp_serverslist[dict]每项含 "url" 和可选 "headers"
skillslist[str]技能目录绝对路径
sub_agentslist[dict]可选 sub-agent 定义(默认 []

方法:

  • .to_dict() -> dict — JSON 可序列化字典
  • .to_json(indent=2) -> str — 格式化 JSON 字符串

build_plugin_manifest(dcc_name, mcp_url, skill_paths=None, *, version="0.1.0", description=None, api_key=None, extra_mcp_servers=None, sub_agents=None) -> dict

组装清单字典。

参数类型默认说明
dcc_namestrDCC 标识,用作插件名 <dcc>-mcp
mcp_urlstr | NoneMCP 端点 URL;None 生成仅技能的包
skill_pathslist[str] | NoneNone纳入的目录;不存在的会被 DEBUG 过滤
versionstr"0.1.0"插件版本
descriptionstr | None自动None 时根据 dcc_name 生成
api_keystr | NoneNone注入首个 server 的 headers.AuthorizationBearer <key>
extra_mcp_serverslist[dict] | NoneNone额外 MCP server 条目
sub_agentslist[dict] | NoneNonesub-agent 定义

返回符合 Claude Code 插件 Schema 的 JSON 可序列化字典。INFO 级日志汇总写入服务器/技能数量。

python
from dcc_mcp_core import build_plugin_manifest, export_plugin_manifest

manifest = build_plugin_manifest(
    dcc_name="maya",
    mcp_url="https://mcp.example.com/mcp",
    skill_paths=["/opt/skills/maya-geometry", "/opt/skills/maya-render"],
    version="1.2.0",
    api_key="s3cret-studio-token",
)
export_plugin_manifest(manifest, "dist/maya-mcp.plugin.json")

export_plugin_manifest(manifest, path, *, indent=2) -> Path

把清单字典写入磁盘,父目录自动创建,返回解析后的 pathlib.Path

推荐用法 — DccServerBase.plugin_manifest()

基于 DccServerBase 构建时,使用 #410 新增的便捷方法自动从运行中的服务器取回 mcp_urlskill_paths

python
class MayaServer(DccServerBase):
    def __init__(self):
        super().__init__(dcc_name="maya", http_config=McpHttpConfig(port=8765))

server = MayaServer()
handle = server.start()
manifest = server.plugin_manifest(version="1.2.0")   # dict

清单结构

json
{
  "name": "maya-mcp",
  "version": "1.2.0",
  "description": "MCP plugin for Maya — provides AI-accessible tools via dcc-mcp-core.",
  "mcp_servers": [
    {
      "url": "https://mcp.example.com/mcp",
      "headers": { "Authorization": "Bearer s3cret-studio-token" }
    }
  ],
  "skills": [
    "/opt/skills/maya-geometry",
    "/opt/skills/maya-render"
  ]
}

参见

Released under the MIT License.