统一地址:https://test-apim-gateway.xxx.com/mcp-agg/1.0.0/.well-known/oauth-protected-resource
返回样式
{
“resource”: “https://test-apim-gateway.xxx.com/test/1.0.0/mcp”,
“authorization_servers”: [
“https://kc.com/auth/realms/xx/protocol/openid-connect/token”
],
“scopes_supported”: [
“openid”,
“wso2-role”

]
}

在apimgt.org.wso2.carbon.apimgt.gateway项目中做了相关适配合
在admin平台添加自定义的key manager ,状态为关闭,避免对其它api产生影响

image

设置kc相关的idp配置,状态为关闭,否则会影响默认的key manager

image

这样,在访问这个mcp端点时,authorization_servers就变成了kc的地址,而不是wso2默认的key manager的地址。

查看是否安装成功,如果没有生效,执行下面代码也可能让它生效,有时是缓存问题
C:\Users\User>curl -k -s “https://apim.xxx.com/api/am/publisher/v4/swagger.yaml” | grep -A 25 “refresh-tools”
/mcp-servers/{mcpServerId}/refresh-tools:
post:
tags:
- MCP Servers
summary: Refresh MCP tools from the backend
description: |
Re-synchronizes tool definitions from the upstream MCP endpoint for MCP servers of subtype SERVER_PROXY,
or reapplies MCP tool mappings from the current stored OpenAPI / backend definition for other MCP server subtypes.
The MCP server metadata is persisted the same way as a regular update, and matching per-tool policies and
scopes are preserved when tool names are unchanged (proxy subtype).
operationId: refreshMCPServerTools
parameters:
- $ref: “#/components/parameters/mcpServerId”
responses:
“200”:
description: |
OK.
MCP server tools refreshed; response body is the updated MCP server.
content:
application/json:
schema:
$ref: “#/components/schemas/MCPServer”
“400”:
$ref: “#/components/responses/BadRequest”
“403”:
$ref: “#/components/responses/Forbidden”

      \ \"https://127.0.0.1:9443/api/am/publisher/v4/mcp-servers/7a2298c4-c905-403f-8fac-38c73301631f/refresh-tools\""

/mcp-servers/{mcpServerId}/comments:
get:
tags:
- Comments
summary: Retrieve MCP Server Comments
description: |
Get a list of Comments that are already added to MCP Server
operationId: getAllCommentsOfMCPServer
parameters:
- $ref: “#/components/parameters/mcpServerId”
- $ref: “#/components/parameters/requestedTenant”
- $ref: “#/components/parameters/limit”
- $ref: “#/components/parameters/offset”
- $ref: “#/components/parameters/includeCommenterInfo”
responses:
“200”:
description: |
OK.
Comments list is returned.
content:
application/json:
schema:
$ref: “#/components/schemas/CommentList”
“404”:
$ref: “#/components/responses/NotFound”

workbuddy认证流程
MCP 服务
企查查 OAuth
.credentials.json
WorkBuddy 主进程
连接器面板
MCP 服务
企查查 OAuth
.credentials.json
WorkBuddy 主进程
连接器面板
点击连接 qcc-company
发现元数据 + 注册/加载 client_id
saveClientInfo (mcpClientInfo)
打开浏览器授权页
回调 workbuddy://…/oauth/callback?code=
code 换 access_token + refresh_token
saveTokens (mcpOAuth)
带 Bearer 调用 tools/list、tools/call
流程

POST /mcp-law-agg/1.0.0/mcp

401 + WWW-Authenticate

读 oauth-protected-resource

授权页 / 换 token

校验 Bearer

WorkBuddy 客户端

apim-gateway.xxx.com
WSO2 APIM 资源服务器

testcas.xxx.com
Keycloak 授权服务器

流程

授权服务器
APIM 网关
WorkBuddy
授权服务器
APIM 网关
WorkBuddy
用户登录并同意
POST /mcp (initialize 或 tools/list,无 Token)
401 + WWW-Authenticate
auth() 发现 OAuth 元数据
打开浏览器授权页
workbuddy://…/oauth/callback?code=
用 code 换 access_token
带 Bearer 重试 MCP 请求
流程

APIM Gateway
Keycloak
APIM 元数据
WorkBuddy
APIM Gateway
Keycloak
APIM 元数据
WorkBuddy
网关校验 KC JWT 或自动换 WSO2 token
GET oauth-protected-resource
authorization_servers = Keycloak realm
OAuth 登录 + 换票
KC JWT
MCP + Bearer KC JWT
200 / tools
workbuddy连接器流程

flowchart LR
A[连接器 UI 显示法律聚合] --> B[用户 mcp.json 有条目]
C[点击连接] --> D[查找 connectors/mcp-law-agg/mcp.json]
D --> E[文件不存在 → 报错]

本地部署一下拦截器
文件 作用
connectors-marketplace/connectors/test/mcp.json MCP 端点配置(连接时读取)
connectors-marketplace/connectors/test/connector-meta.json 名称、描述、示例
connectors-marketplace/connectors/test/skills/SKILL.md 连接成功后的 Skill
connectors-marketplace/connectors/test/icon.svg 连接器图标
connectors-marketplace/icons/test.svg 市场列表图标
connectors-marketplace/.codebuddy-connector/connectors.json 已登记 test(含 type: “mcp”)
MCP 地址:

https://test-apim-gateway.xxx.com/mcp-law-agg/1.0.0/mcp

keycloak开始PKCE
Keycloak 要求「客户端必须启用 PKCE」——在服务端配置
WorkBuddy 不能在连接器配置里给 DCR 增加自定义字段(当前版本没有该入口)。应在 Keycloak 侧处理:

方案 A:Realm / Client Policy 强制 PKCE(推荐)

Realm → Client policies → Policies
添加 PKCE Enforcer(pkce-enforcer)
对 public 客户端或 DCR 创建的客户端生效
这样即使用 DCR 注册的客户端未勾选 PKCE,每次授权仍强制带 code_challenge,与 WorkBuddy 行为一致。
注意:WorkBuddy 每次点「连接」会清本地 client_id 再 DCR;要稳定用预建 client,需要产品支持静态 client_id,或接受 DCR 后由脚本批量改客户端属性。

方案 C:DCR 之后用 Admin API 补属性
对 DCR 生成的 client_id 调用 Admin REST API,设置:

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐