MCP远程代理部署工具

通过Helm在Kubernetes上部署带有Azure AD认证代理的MCP远程服务器,提供安全的身份验证和请求转发功能。

  • by ChandraMohan0316
  • Go Template
  • 本地部署
  • 更新于
在 GitHub 查看 ChandraMohan0316/toolhive-mcp-runner-with-oauth

使用说明

toolhive mcp运行器

在Kubernetes上部署ToolHive的嵌入式OAuth 2.0/AAzure AD身份验证代理后面的任何远程MCP(模型上下文协议)服务器。单一Helm版本提供 MCPRemoteProxy, MCPExternalAuthConfigAWS ALB入口,以及所有必需的Kubernetes机密。

运作原理

MCP Client  ──HTTPS──►  AWS ALB  ──►  ToolHive Proxy  ──bearer token──►  Upstream MCP Server
                                           │
                                     Azure AD OIDC
                                   (OAuth 2.0 consent)
  • 客户端在任何请求到达上游之前通过Azure AD进行身份验证。
  • 上游承载令牌由代理注入,永远不会暴露给客户端。
  • RSA签名密钥和HMAC密钥在首次安装时自动生成,并在升级过程中保留。

先决条件

要求 注意事项
Kubernetes≥1.26 EKS推荐
Helm≥3.10 需要OCI依赖支持
AWS负载平衡器控制器 具有适当的IAM权限
ACM证书 用于目标主机名
Azure AD应用程序注册 已配置客户端密钥和重定向URI

ToolHive CRD(MCPRemoteProxy, MCPExternalAuthConfig)ToolHive运算符是 捆绑为子图表依赖项 并根据此图表自动安装。您不需要单独安装它们,除非它们已经存在于集群中(在这种情况下设置 prerequisites.installCRDs: false 和 prerequisites.installOperator: false).

添加Helm存储库

helm repo add toolhive-mcp https://<GITHUB_OWNER>.github.io/<GITHUB_REPO>
helm repo update

替换 <GITHUB_OWNER> 和 <GITHUB_REPO> 使用您的GitHub组织和存储库名称。

安装

helm install <release-name> toolhive-mcp/toolhive-mcp \
  --namespace toolhive \
  --create-namespace \
  --values my-values.yaml \
  --set server.bearerToken="<upstream-bearer-token>" \
  --set oauth.azure.clientSecret="<azure-client-secret>"

通过传递秘密 --set 而不是将它们存储在值文件中。

配置

复制 values-sample.yaml 作为起点:

helm show values toolhive-mcp/toolhive-mcp > my-values.yaml

所需值

必须提供以下所有七个值——如果缺少任何值,图表会很快失败,并出现明显的错误。

密钥 描述
server.remoteUrl 上游MCP服务器的URL(例如。 https://api.githubcopilot.com/mcp/)
server.bearerToken 承载令牌转发到上游;从未接触过客户
ingress.host 公共主机名(例如。 mcp.example.com)
ingress.certificateArn 用于TLS终止的ACM证书ARN
oauth.azure.tenantId Azure AD租户ID
oauth.azure.clientId Azure AD应用程序(客户端)ID
oauth.azure.clientSecret Azure AD客户端机密

完整值参考

密钥 默认值 描述
server.remoteUrl "" 上游MCP服务器URL
server.bearerToken "" 在代理上注入承载令牌→上游支腿
ingress.host "" 公共主机名(https:// 前缀会自动删除)
ingress.certificateArn "" ACM证书ARN
ingress.idleTimeoutSeconds 3600 ALB空闲连接超时
ingress.scheme internet-facing ALB方案: internet-facing 或 internal
oauth.accessTokenLifespan 1h OAuth访问令牌TTL
oauth.refreshTokenLifespan 168h OAuth刷新令牌TTL(7天)
oauth.authCodeLifespan 10m 授权码TTL
oauth.azure.tenantId "" Azure AD租户ID
oauth.azure.clientId "" Azure AD应用程序(客户端)ID
oauth.azure.clientSecret "" Azure AD客户端机密
oauth.azure.scopes [openid, profile, email] 从Azure AD请求的OIDC作用域
proxy.image ghcr.io/stacklok/toolhive/proxyrunner:latest ToolHive代理运行程序映像
proxy.port 8080 代理侦听器端口
proxy.debug false 启用调试日志记录
namespace toolhive 目标命名空间
prerequisites.installCRDs true 将ToolHive CRD安装为子图表
prerequisites.installOperator true 将ToolHive运算符安装为子图表
prerequisites.createSigningSecrets true 自动生成RSA和HMAC签名密钥

禁用先决条件

如果集群中已安装ToolHive CRD或运算符,请禁用捆绑的子图表以避免冲突:

prerequisites:
  installCRDs: false
  installOperator: false

安装后步骤

1.获取ALB主机名

kubectl get ingress <release-name>-ingress -n toolhive \
  -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'

2.创建DNS记录

在Route 53(或您的DNS提供商)中,创建一个 别名记录:

<your-hostname>  →  <alb-address>.us-east-1.elb.amazonaws.com

3.在Azure AD中注册重定向URI

将以下重定向URI添加到Azure AD应用程序注册中:

https://<your-hostname>/oauth/callback

Azure门户: 应用程序注册→ 您的应用程序→ 认证→ 添加一个平台→ Web → 重定向URI

4.添加到MCP客户端配置

{
  "mcpServers": {
    "<your-server-name>": {
      "type": "http",
      "url": "https://<your-hostname>/mcp"
    }
  }
}

在第一次连接时,客户端将提示进行Azure AD身份验证。

升级

helm upgrade <release-name> toolhive-mcp/toolhive-mcp \
  --namespace toolhive \
  --values my-values.yaml \
  --set server.bearerToken="<upstream-bearer-token>" \
  --set oauth.azure.clientSecret="<azure-client-secret>"

签名秘密在升级过程中得到保留——除非手动删除,否则不会发生密钥轮换。

卸载

helm uninstall <release-name> --namespace toolhive

这 toolhive-signing-key 和 toolhive-hmac-key 秘密被注释为 helm.sh/resource-policy: keep 并且是 不 卸载时删除。仅当您要停用整个ToolHive安装时,才手动删除它们。

图表依赖关系

图表 版本 存储库 条件
toolhive-operator-crds 0.0.106 oci://ghcr.io/stacklok/toolhive prerequisites.installCRDs
toolhive-operator 0.5.28 oci://ghcr.io/stacklok/toolhive prerequisites.installOperator

发布新版本

通过GitHub操作(推荐)

  1. 碰撞 version 在 charts/toolhive-mcp/Chart.yaml.
  2. 承诺并推动 main.

chart-releaser 打包图表,创建GitHub Release,并更新 index.yaml 在 gh-pages 自动分支。