---
author: OOMOL
author_url: https://oomol.com/zh-cn/about/
title: 为 OpenConnector 创建 HubSpot MCP auth app
description: 创建 HubSpot MCP auth app，配置 OpenConnector redirect URL，并通过 OAuth 连接 HubSpot。
lang: zh-CN
canonical_url: https://oomol.com/zh-cn/docs/openconnector-hubspot-oauth-app/
markdown_url: https://oomol.com/zh-cn/docs/openconnector-hubspot-oauth-app.md
---

# 为 OpenConnector 创建 HubSpot MCP auth app

OpenConnector 当前 HubSpot provider 使用 HubSpot remote MCP OAuth flow。你需要在 HubSpot 中创建 MCP auth app，复制它的 client ID 和 client secret，然后把这些值保存到 OpenConnector 的 `hubspot` service。

## OpenConnector service

| Service ID | Provider | Auth type |
| --- | --- | --- |
| `hubspot` | HubSpot remote MCP server | OAuth2 with PKCE |

HubSpot provider 通过 `https://mcp.hubspot.com` 连接。HubSpot 侧的权限和账号授权流程由 MCP auth app 管理。

## 前置条件

- 一个正在运行的 OpenConnector runtime。
- 可以访问 HubSpot Developer Platform 和 MCP Auth Apps 的 HubSpot 账号。
- 有权限为目标 HubSpot account 创建 MCP auth app。
- 用户在浏览器中打开的 OpenConnector origin，例如 `http://localhost:3000` 或 `https://connect.example.com`。

## 第 1 步：确定 OpenConnector callback URL

在 OpenConnector origin 后拼接 `/oauth/callback`，得到 callback URL。本地测试使用 `http://localhost:3000/oauth/callback`。公开部署时，请先设置 `OOMOL_CONNECT_ORIGIN`，重启 OpenConnector 后使用公开 callback URL，例如 `https://connect.example.com/oauth/callback`。

## 第 2 步：创建 HubSpot MCP auth app

在 HubSpot 中：

1. 打开要连接的 HubSpot account。
2. 打开 **Development**。
3. 打开 **MCP Auth Apps**。
4. 创建新的 MCP auth app。
5. 输入一个容易识别的 app name。
6. 将 redirect URL 设置为 OpenConnector 的准确 callback URL。
7. 保存 app。

HubSpot 官方文档见 [Integrate AI tools with the HubSpot MCP server](https://developers.hubspot.com/docs/apps/developer-platform/build-apps/integrate-with-the-remote-hubspot-mcp-server)。

## 第 3 步：复制 client credentials

从 HubSpot MCP auth app 详情中复制：

| HubSpot 字段 | OpenConnector 字段 |
| --- | --- |
| Client ID | `clientId` |
| Client Secret | `clientSecret` |

## 第 4 步：在 OpenConnector 中保存 HubSpot client

优先使用 OpenConnector Web 控制台：

1. 打开 OpenConnector Web 控制台，例如 `http://localhost:3000`。
2. 打开 **Providers**，选择 **HubSpot**。
3. 点击 **Configure OAuth Client** 或 **Edit OAuth Client**。
4. 粘贴 HubSpot client ID 和 client secret。
5. 点击 **Save OAuth Client**。

## 第 5 步：连接并测试

保存 OAuth client 后，在 HubSpot provider 页面点击 **Connect**。选择 HubSpot account，批准访问，回到 OpenConnector，并确认 provider 页面显示账号已连接。

运行 `hubspot.list_properties` 等 CRM action 前，先查看控制台里的 action 详情。

## 排查建议

| 现象 | 检查项 |
| --- | --- |
| HubSpot 提示 client ID 无效 | 使用 MCP auth app 页面显示的 Client ID；其他 HubSpot app 类型使用不同的 ID。 |
| Redirect 或 callback 失败 | HubSpot 中的 redirect URL 必须和 `<openconnector-origin>/oauth/callback` 完全一致。 |
| Token exchange 失败 | 确认 HubSpot MCP auth app 支持 OAuth with PKCE，并且 OpenConnector 使用的是当前 HubSpot provider。 |
| 授权到了错误 HubSpot account | 先退出浏览器里的其他 HubSpot 账号，或使用独立浏览器 profile 授权。 |
| Action 返回 permission error | 检查已连接 HubSpot 用户权限，以及 HubSpot MCP app 当前访问规则。 |
