如何将 Hugging Face 远程 MCP 连接到 VS Code

约 1 分钟即可把 Hugging Face 的远程 MCP 服务端接入 VS Code。如需排查 OAuth / 401 问题,可先用 OAuth 2.1 调试器体检端点。

🛡️ Official✓ VerifiedStreamable HTTPBearer Token🛡️ A+~369 tok12 tools
Streamable HTTPhttps://huggingface.co/mcp

🔒 Client-side only — never leaves your browser.

Install in VS Code →

Or add to .vscode/mcp.json:

{
  "servers": {
    "huggingface": {
      "type": "http",
      "url": "https://huggingface.co/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}

接入步骤

  1. 打开 MCP 配置 — 使用本页 vscode: deeplink 一键安装,或在项目根目录创建 .vscode/mcp.json。
  2. 添加服务端 — 写入 { "servers": { "huggingface": { "type": "http", "url": https://huggingface.co/mcp } } }。
  3. 完成认证 — 在 Hugging Face 控制台获取凭据,并将其作为 Authorization: Bearer <密钥> 请求头加入配置。
  4. 验证 — 重启 Copilot Chat 选择 Agent 模式后可看到工具。在 在线 Inspector 中粘贴 https://huggingface.co/mcp 并运行 initialize + tools/list 验证连通性。

🧰 工具预览(12)

ToolSafetyDescriptionParameters
hf_doc_search
~31 tok
🟢 ReadSearch Hugging Face documentation.—
hf_doc_fetch
~30 tok
🟢 ReadFetch a Hugging Face docs page.—
model_search
~29 tok
🟢 ReadSearch models on the Hub.—
dataset_search
~30 tok
🟢 ReadSearch datasets on the Hub.—
space_search
~29 tok
🟢 ReadSearch Spaces on the Hub.—
paper_search
~29 tok
🟢 ReadSearch papers on the Hub.—
hub_repo_details
~31 tok
🟢 ReadGet details of a Hub repository.—
hf_whoami
~29 tok
🟢 ReadGet the authenticated HF user.—
space_info
~28 tok
🟢 ReadGet details of a Space.—
use_space
~28 tok
🟠 WriteCall a Hugging Face Space.—
model_info
~27 tok
🟢 ReadGet model card info.—
dataset_info
~28 tok
🟢 ReadGet dataset card info.—

更多连接指南