跳到正文
Anthropic Engineering·· 2025-06-26精选AI 评分67

Anthropic 为 Claude Desktop 推出 Desktop Extensions,MCP 服务器可一键安装

Desktop Extensions: One-click MCP server installation for Claude Desktop

AI 导读

Anthropic 发布 Desktop Extensions,把本地 MCP 服务器及其依赖打包成单个 .mcpb 文件,用户双击即可在 Claude Desktop 中安装,无需终端、配置文件或处理依赖冲突。

推荐理由

Anthropic 官方给出 MCP 服务器一键安装的打包格式与开源工具链,读者可据此判断本地 MCP 生态的分发门槛变化。

正文 · AI 翻译

译文尚不完整,完整内容请切换到原文。

  • 文件扩展名更新

    2025年9月11日

    Claude Desktop Extensions 现在使用 .mcpb(MCP Bundle)文件扩展名,而不再使用 .dxt。现有的 .dxt 扩展仍可继续使用,但我们建议开发者今后为新扩展使用 .mcpb。所有功能保持不变——这纯粹是命名约定的更新。

—

去年我们发布 Model Context Protocol (MCP) 时,我们看到开发者构建了令人惊叹的本地服务器,让 Claude 能够访问从文件系统到数据库的各种资源。但我们不断听到同样的反馈:安装太复杂了。用户需要开发者工具,必须手动编辑配置文件,还经常卡在依赖问题上。

今天,我们推出 Desktop Extensions——一种全新的打包格式,让安装 MCP 服务器变得像点击按钮一样简单。

解决 MCP 安装问题

本地 MCP 服务器为 Claude Desktop 用户解锁了强大的能力。它们可以与本地应用程序交互、访问私有数据,并与开发工具集成——同时将所有数据保留在用户自己的机器上。然而,当前的安装流程造成了显著的障碍:

  • 需要开发者工具:用户需要安装 Node.js、Python 或其他运行时
  • 手动配置:每个服务器都需要编辑 JSON 配置文件
  • 依赖管理:用户必须解决包冲突和版本不匹配问题
  • 没有发现机制:寻找有用的 MCP 服务器需要在 GitHub 上搜索
  • 更新复杂:保持服务器为最新版本意味着手动重新安装

这些摩擦点意味着,MCP 服务器尽管功能强大,但对非技术用户来说基本上仍然难以使用。

推出 Desktop Extensions

Desktop Extensions(.mcpb 文件)通过将整个 MCP 服务器——包括所有依赖项——打包成一个可安装的单一包来解决这些问题。以下是用户端的变化:

之前:

# Install Node.js first 
npm install -g @example/mcp-server 
# Edit ~/.claude/claude_desktop_config.json manually 
# Restart Claude Desktop 
# Hope it works

之后:

  1. 下载一个 .mcpb 文件
  2. 双击用 Claude Desktop 打开
  3. 点击“安装”

就这样。无需终端,无需配置文件,没有依赖冲突。

架构概览

Desktop Extension 是一个 zip 压缩包,其中包含本地 MCP 服务器以及一个 manifest.json,后者描述了 Claude Desktop 和其他支持桌面扩展的应用需要了解的一切。

extension.mcpb (ZIP archive)
├── manifest.json         # Extension metadata and configuration
├── server/               # MCP server implementation
│   └── [server files]    
├── dependencies/         # All required packages/libraries
└── icon.png             # Optional: Extension icon

# Example: Node.js Extension
extension.mcpb
├── manifest.json         # Required: Extension metadata and configuration
├── server/               # Server files
│   └── index.js          # Main entry point
├── node_modules/         # Bundled dependencies
├── package.json          # Optional: NPM package definition
└── icon.png              # Optional: Extension icon

# Example: Python Extension
extension.mcpb (ZIP file)
├── manifest.json         # Required: Extension metadata and configuration
├── server/               # Server files
│   ├── main.py           # Main entry point
│   └── utils.py          # Additional modules
├── lib/                  # Bundled Python packages
├── requirements.txt      # Optional: Python dependencies list
└── icon.png              # Optional: Extension icon

Desktop Extension 中唯一必需的文件是 manifest.json。Claude Desktop 处理了所有复杂性:

  • 内置运行时:我们在 Claude Desktop 中内置了 Node.js,消除了外部依赖
  • 自动更新:有新版本可用时,扩展会自动更新
  • 安全密钥:API 密钥等敏感配置存储在操作系统钥匙串中

清单文件包含人类可读的信息(如名称、描述或作者)、功能声明(工具、提示)、用户配置以及运行时要求。大多数字段都是可选的,因此最小版本相当简短,不过在实践中,我们预计所有三种受支持的扩展类型(Node.js、Python 以及经典二进制文件/可执行文件)都会包含文件:

{
  "mcpb_version": "0.1",                    // MCPB spec version this manifest conforms to
  "name": "my-extension",                   // Machine-readable name (used for CLI, APIs)
  "version": "1.0.0",                       // Semantic version of your extension
  "description": "A simple MCP extension",  // Brief description of what the extension does
  "author": {                               // Author information (required)
    "name": "Extension Author"              // Author's name (required field)
  },
  "server": {                               // Server configuration (required)
    "type": "node",                         // Server type: "node", "python", or "binary"
    "entry_point": "server/index.js",       // Path to the main server file
    "mcp_config": {                         // MCP server configuration
      "command": "node",                    // Command to run the server
      "args": [                             // Arguments passed to the command
        "${__dirname}/server/index.js"      // ${__dirname} is replaced with the extension's directory
      ]                              
    }
  }
}

There are a number of convenience options available in the manifest spec that aim to make the installation and configuration of local MCP servers easier. The server configuration object can be defined in a way that makes room both for user-defined configuration in the form of template literals as well as platform-specific overrides. Extension developers can define, in detail, what kind of configuration they want to collect from users.

让我们看一个具体示例,了解清单如何协助配置。在下面的清单中,开发者声明用户需要提供一个 api_key。在用户提供该值之前,Claude 不会启用该扩展,它会自动将该值保存在操作系统的密钥保管库中,并在启动服务器时透明地将 ${user_config.api_key} 替换为用户提供的值。同样,${__dirname} 将被替换为扩展解压目录的完整路径。

{
  "mcpb_version": "0.1",
  "name": "my-extension",
  "version": "1.0.0",
  "description": "A simple MCP extension",
  "author": {
    "name": "Extension Author"
  },
  "server": {
    "type": "node",
    "entry_point": "server/index.js",
    "mcp_config": {
      "command": "node",
      "args": ["${__dirname}/server/index.js"],
      "env": {
        "API_KEY": "${user_config.api_key}"
      }
    }
  },
  "user_config": {
    "api_key": {
      "type": "string",
      "title": "API Key",
      "description": "Your API key for authentication",
      "sensitive": true,
      "required": true
    }
  }
}

一个包含大部分可选字段的完整 manifest.json 可能如下所示:

{
  "mcpb_version": "0.1",
  "name": "My MCP Extension",
  "display_name": "My Awesome MCP Extension",
  "version": "1.0.0",
  "description": "A brief description of what this extension does",
  "long_description": "A detailed description that can include multiple paragraphs explaining the extension's functionality, use cases, and features. It supports basic markdown.",
  "author": {
    "name": "Your Name",
    "email": "[email protected]",
    "url": "https://your-website.com"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/your-username/my-mcp-extension"
  },
  "homepage": "https://example.com/my-extension",
  "documentation": "https://docs.example.com/my-extension",
  "support": "https://github.com/your-username/my-extension/issues",
  "icon": "icon.png",
  "screenshots": [
    "assets/screenshots/screenshot1.png",
    "assets/screenshots/screenshot2.png"
  ],
  "server": {
    "type": "node",
    "entry_point": "server/index.js",
    "mcp_config": {
      "command": "node",
      "args": ["${__dirname}/server/index.js"],
      "env": {
        "ALLOWED_DIRECTORIES": "${user_config.allowed_directories}"
      }
    }
  },
  "tools": [
    {
      "name": "search_files",
      "description": "Search for files in a directory"
    }
  ],
  "prompts": [
    {
      "name": "poetry",
      "description": "Have the LLM write poetry",
      "arguments": ["topic"],
      "text": "Write a creative poem about the following topic: ${arguments.topic}"
    }
  ],
  "tools_generated": true,
  "keywords": ["api", "automation", "productivity"],
  "license": "MIT",
  "compatibility": {
    "claude_desktop": ">=1.0.0",
    "platforms": ["darwin", "win32", "linux"],
    "runtimes": {
      "node": ">=16.0.0"
    }
  },
  "user_config": {
    "allowed_directories": {
      "type": "directory",
      "title": "Allowed Directories",
      "description": "Directories the server can access",
      "multiple": true,
      "required": true,
      "default": ["${HOME}/Desktop"]
    },
    "api_key": {
      "type": "string",
      "title": "API Key",
      "description": "Your API key for authentication",
      "sensitive": true,
      "required": false
    },
    "max_file_size": {
      "type": "number",
      "title": "Maximum File Size (MB)",
      "description": "Maximum file size to process",
      "default": 10,
      "min": 1,
      "max": 100
    }
  }
}

要查看扩展和清单示例,请参阅 MCPB 仓库中的示例。

manifest.json 中所有必需和可选字段的完整规范可以在我们的 开源工具链 中找到。

构建你的第一个扩展

让我们以将一个现有的 MCP 服务器打包为桌面扩展为例进行说明。我们将使用一个简单的文件系统服务器作为示例。

步骤 1:创建清单

首先,为你的服务器初始化一个清单:

npx @anthropic-ai/mcpb init

这个交互式工具会询问你的服务器信息并生成完整的 manifest.json。如果你想快速生成最基本的 manifest.json,可以运行带有 --yes 参数的命令。

步骤 2:处理用户配置

如果你的服务器需要用户输入(例如 API 密钥或允许的目录),请在清单中声明:

"user_config": {
  "allowed_directories": {
    "type": "directory",
    "title": "Allowed Directories",
    "description": "Directories the server can access",
    "multiple": true,
    "required": true,
    "default": ["${HOME}/Documents"]
  }
}

Claude Desktop 将:

  • 显示用户友好的配置界面
  • 在启用扩展之前验证输入
  • 安全地存储敏感值
  • 根据开发者配置,将配置作为参数或环境变量传递给服务器

在下面的示例中,我们将用户配置作为环境变量传递,但也可以作为参数传递。

"server": {
   "type": "node",
   "entry_point": "server/index.js",
   "mcp_config": {
   "command": "node",
   "args": ["${__dirname}/server/index.js"],
   "env": {
      "ALLOWED_DIRECTORIES": "${user_config.allowed_directories}"
   }
   }
}

步骤 3:打包扩展

将所有内容打包成一个 .mcpb 文件:

npx @anthropic-ai/mcpb pack

此命令:

  1. 验证你的清单
  2. 生成 .mcpb 归档文件

步骤 4:本地测试

将你的 .mcpb 文件拖入 Claude Desktop 的设置窗口。你将看到:

  • 关于扩展的人类可读信息
  • 所需的权限和配置
  • 一个简单的“安装”按钮

高级功能

跨平台支持

扩展可以适应不同的操作系统:

"server": {
  "type": "node",
  "entry_point": "server/index.js",
  "mcp_config": {
    "command": "node",
    "args": ["${__dirname}/server/index.js"],
    "platforms": {
      "win32": {
        "command": "node.exe",
        "env": {
          "TEMP_DIR": "${TEMP}"
        }
      },
      "darwin": {
        "env": {
          "TEMP_DIR": "${TMPDIR}"
        }
      }
    }
  }
}

动态配置

使用模板字面量表示运行时值:

  • ${__dirname}:扩展的安装目录
  • ${user_config.key}:用户提供的配置
  • ${HOME}, ${TEMP}:系统环境变量

功能声明

帮助用户提前了解功能:

"tools": [
  {
    "name": "read_file",
    "description": "Read contents of a file"
  }
],
"prompts": [
  {
    "name": "code_review",
    "description": "Review code for best practices",
    "arguments": ["file_path"]
  }
]

扩展目录

我们推出时,Claude Desktop 内置了一个精选的扩展目录。用户可以浏览、搜索并一键安装——无需搜索 GitHub 或审查代码。

虽然我们预计桌面扩展规范以及 macOS 和 Windows 版 Claude 中的实现会随着时间的推移而演变,但我们期待看到扩展以创造性的方式扩展 Claude 能力的多种用途。

要提交你的扩展:

  1. 确保它遵循提交表单中的指南
  2. 在 Windows 和 macOS 上进行测试
  3. 提交你的扩展
  4. 我们的团队会审查质量和安全性

构建开放生态系统

我们致力于围绕 MCP 服务器构建开放生态系统,并相信其能够被多个应用和服务普遍采用的能力已使社区受益。秉持这一承诺,我们开源了 Desktop Extension 规范、工具链,以及 Claude 在 macOS 和 Windows 上用于实现自身对 Desktop Extensions 支持的模式和关键函数。我们希望 MCPB 格式不仅能让本地 MCP 服务器对 Claude 更具可移植性,也能对其他 AI 桌面应用如此。

我们正在开源:

  • 完整的 MCPB 规范
  • 打包和验证工具
  • 参考实现代码
  • TypeScript 类型和模式

这意味着:

  • 对于 MCP 服务器开发者:一次打包,即可在任何支持 MCPB 的环境中运行
  • 对于应用开发者:无需从零开始即可添加扩展支持
  • 对于用户:在所有支持 MCP 的应用中获得一致的体验

该规范和工具链特意以 0.1 作为版本号,因为我们期待与更广泛的社区合作,共同演进和改变这一格式。我们期待听到您的反馈。

安全与企业考量

我们理解扩展会带来新的安全考量,尤其是对企业而言。在 Desktop Extensions 的预览版中,我们内置了多项保障措施:

对于用户

  • 敏感数据保留在操作系统钥匙串中
  • 自动更新
  • 能够审计已安装的扩展

对于企业

  • 支持组策略(Windows)和 MDM(macOS)
  • 能够预装已批准的扩展
  • 将特定扩展或发布者列入阻止列表
  • 完全禁用扩展目录
  • 部署私有扩展目录

有关如何在您的组织中管理扩展的更多信息,请参阅我们的文档。

开始使用

准备好构建您自己的扩展了吗?以下是如何开始:

对于 MCP 服务器开发者:查看我们的开发者文档——或者直接在本地 MCP 服务器目录中运行以下命令开始:

npm install -g @anthropic-ai/mcpb
mcpb init
mcpb pack

对于 Claude Desktop 用户:更新到最新版本,并在设置中查找 Extensions 部分

对于企业:查看我们的企业文档以了解部署选项

使用 Claude Code 构建

在 Anthropic 内部,我们发现 Claude 非常擅长以最少的干预构建扩展。如果您也想使用 Claude Code,我们建议您简要说明您希望扩展做什么,然后在提示中添加以下上下文:

I want to build this as a Desktop Extension, abbreviated as "MCPB". Please follow these steps:

1. **Read the specifications thoroughly:**
   - https://github.com/anthropics/mcpb/blob/main/README.md - MCPB architecture overview, capabilities, and integration patterns
   - https://github.com/anthropics/mcpb/blob/main/MANIFEST.md - Complete extension manifest structure and field definitions
   - https://github.com/anthropics/mcpb/tree/main/examples - Reference implementations including a "Hello World" example

2. **Create a proper extension structure:**
   - Generate a valid manifest.json following the MANIFEST.md spec
   - Implement an MCP server using @modelcontextprotocol/sdk with proper tool definitions
   - Include proper error handling and timeout management

3. **Follow best development practices:**
   - Implement proper MCP protocol communication via stdio transport
   - Structure tools with clear schemas, validation, and consistent JSON responses
   - Make use of the fact that this extension will be running locally
   - Add appropriate logging and debugging capabilities
   - Include proper documentation and setup instructions

4. **Test considerations:**
   - Validate that all tool calls return properly structured responses
   - Verify manifest loads correctly and host integration works

Generate complete, production-ready code that can be immediately tested. Focus on defensive programming, clear error messages, and following the exact
MCPB specifications to ensure compatibility with the ecosystem.

结论

Desktop Extensions 代表了用户与本地 AI 工具交互方式的根本性转变。通过消除安装摩擦,我们让强大的 MCP 服务器对每个人都触手可及——而不仅仅是开发者。

在内部,我们使用桌面扩展来分享高度实验性的 MCP 服务器——有些有趣,有些实用。一个团队进行了实验,看看当我们的模型直接连接到 GameBoy 时能走多远,类似于我们的“Claude plays Pokémon”研究。我们使用 Desktop Extensions 打包了一个单一扩展,它打开了流行的PyBoy GameBoy 模拟器,并让 Claude 进行控制。我们相信,将模型的能力与用户本地机器上已有的工具、数据和应用程序连接起来,存在着无数机会。

A desktop showing the PyBoy MCP with Super Mario Land start screen

我们迫不及待想看到你构建的作品。曾经为我们带来数千个 MCP 服务器的同一种创造力,如今只需一键即可触达数百万用户。准备好分享你的 MCP 服务器了吗?提交你的扩展以供审核。

来源:Anthropic Engineering · anthropic.com