@miaocedata/mbi-bi-mcp 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 数据中台 BI MCP · 本地连接器
2
2
 
3
- 这是 Node.js 22+ 的 **stdio** MCP。它只通过中台对外接口取数,不直连任何底层数据引擎。它提供 `configure_platform`(设置/切换地址)、`reauthorize`(换账号后重新认证)、`get_analysis_config`(分析配置)、`get_business_ontology`(已发布本体)和 `query_metrics`(已登记指标查询)。客户须部署中台、持有有效 License,由中台管理员启用该租户的「外部问数」,再使用有资源权限的中台账号授权。无需单独签发 WorkBuddy License。
3
+ 这是 Node.js 22+ 的 **stdio** MCP。它只通过中台对外接口取数,不直连任何底层数据引擎,也不启动可见的 Sense X 对话。它提供 `configure_platform`(设置/切换地址)、`reauthorize`(换账号后重新认证)、`get_analysis_config`(分析配置)、`get_business_ontology`(已发布本体)、`query_metrics`(已登记指标查询),以及 `get_agent_profiles`、`get_agent_tools`、`call_agent_tool`。写看板、原生 Sheet 交付和 Mashup 大屏完全复用平台 `agent:write`、Agent Profile USE ACL、Profile 能力白名单和原有交付门禁。客户须部署中台、持有有效 License,由中台管理员启用该租户的「外部问数」,再使用有资源权限和相应 Profile 的中台账号授权。无需单独签发 WorkBuddy License。
4
4
 
5
5
  ## 本地联调(无需 npm 发布)
6
6
 
@@ -35,6 +35,18 @@ MBI_PLATFORM_URL = "https://bi.example.com"
35
35
 
36
36
  **标准部署只填 `MBI_PLATFORM_URL`。** 它是门户 HTTPS 地址(可含门户路径),`MBI_API_BASE_PATH` 是同源 API 前缀(默认 `/prod-api`,网关直接挂在同源根路径时设为空字符串)。浏览器须与连接器运行在同一台主机,且两者均可通过客户网络访问门户;不要关闭 TLS 校验。
37
37
 
38
+ **也可以直接填一个访问令牌:** 在 `env` 里增加 `MBI_ACCESS_TOKEN`(以 `bimcp_` 开头,49 个字符)。有值时连接器直接使用该令牌,**不再读取本机 `~/.mbi-bi/grant.json`,也不会打开浏览器**;令牌只驻留进程内存,绝不写盘。令牌无效或过期时工具返回 `AUTH_REQUIRED` 并提示去连接设置里更新,此时调用 `reauthorize` 不会生效(它只用于浏览器授权模式)。留空则完全走浏览器授权。适合无人值守、审核或自动化环境。
39
+
40
+ ```json
41
+ {
42
+ "env": {
43
+ "MBI_PLATFORM_URL": "https://bi.example.com",
44
+ "MBI_API_BASE_PATH": "/prod-api",
45
+ "MBI_ACCESS_TOKEN": "bimcp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
46
+ }
47
+ }
48
+ ```
49
+
38
50
  **也可以完全通过会话配置地址。** 用户明确说出门户地址后,Agent 调用 `configure_platform`;地址保存在本机 `~/.mbi-senseX/platform.json`,之后无需编辑宿主 `mcp.json`。示例:
39
51
 
40
52
  ```text
@@ -57,7 +69,7 @@ MBI_PLATFORM_URL = "https://bi.example.com"
57
69
 
58
70
  首次调用工具会打开浏览器。用中台账号登录,确认租户并点击批准,看到成功提示后在宿主重试同一工具。连接器把令牌缓存到本机用户目录 `~/.mbi-bi/grant.json`(POSIX 上以 0600 权限创建;Windows 位于当前用户配置文件目录下),令牌初始有效期为 7 天,并在每次成功使用时自动重新计算 7 天;进程重启后自动从该文件恢复未过期令牌。只有连续 7 天未使用或服务端判定失效(401)时才重新授权并要求批准。用户可以在门户 `/external-bi/connections` 撤销当前账号在当前租户下的全部 BI MCP 连接;撤销后本地缓存会在下一次请求被服务端拒绝时清除。连接器不要求提供中台密码或 Web token。
59
71
 
60
- 用户要换账号、换租户,或怀疑缓存令牌已经失效时,让 Agent 调用 `reauthorize`(无参数):它尽力撤销服务端令牌、删除本机缓存 `~/.mbi-bi/grant.json`,并立刻打开新的授权页;工具本身立即返回,不阻塞对话。用户在浏览器里批准后,重新调用目标工具即可。手工删除 `~/.mbi-bi/grant.json` 效果相同,但下一次工具调用仍会自动打开浏览器。注意授权回调只监听 127.0.0.1 的随机端口、等待 180 秒,宿主配置里的 `timeout` 必须大于这个窗口(建议 240000 或更大),否则进程会被提前结束、浏览器只剩 `ERR_CONNECTION_REFUSED`。
72
+ 用户要换账号、换租户,或怀疑缓存令牌已经失效时,让 Agent 调用 `reauthorize`(无参数):它尽力撤销服务端令牌、删除本机缓存 `~/.mbi-bi/grant.json`,并立刻打开新的授权页;工具本身立即返回,不阻塞对话。用户在浏览器里批准后,重新调用目标工具即可。手工删除 `~/.mbi-bi/grant.json` 效果相同,但下一次工具调用仍会自动打开浏览器。注意授权回调只监听 127.0.0.1 的随机端口、等待 300 秒(5 分钟),宿主配置里的 `timeout` 必须大于这个窗口(建议 360000 或更大),否则进程会被提前结束、浏览器只剩 `ERR_CONNECTION_REFUSED`。
61
73
 
62
74
  ## 查询语义和版本
63
75
 
@@ -65,9 +77,17 @@ MBI_PLATFORM_URL = "https://bi.example.com"
65
77
  2. `query_metrics` 每次只查询一个 App。要限定日期,例如传 `dateRange: { "dimensionId": "205", "from": "2026-10-01", "toExclusive": "2026-11-01" }`。起日包含,止日不包含,最多 366 天。用配置中 `dateRangeSupported` 的真实日历维度;有多个时明确指定,不能用字段名或表达式。
66
78
  3. 中台校验实际日期选择和指定版本的本体规则。不能安全应用筛选、版本无权访问或存在未支持的约束时,工具返回错误;不要移除用户要求的约束重试。旧服务端不支持这些新参数,本地连接器和中台各服务应按 [部署与验收](../mbi-agent-service/docs/50-external-bi-mcp-deployment.md) 配套升级。
67
79
 
80
+ ## Profile 控制的能力
81
+
82
+ 1. 调用 `get_agent_profiles`。只返回当前平台账号通过 USE/MANAGE ACL、且未停用、未被显式 DENY 的业务 Profile;同时给出当前角色下真正可用的能力。内部 `supervisor` 与 `demo_delivery` 不对外暴露。
83
+ 2. 调用 `get_agent_tools` 并传 `agentId`。平台会按 Profile 能力和角色过滤真实连接器工具:读取要求 `data_query`,连接器写操作要求 `data_change`,大屏要求 `mashup_board`,原生 Sheet 交付要求 `sheet_delivery`。所有写操作还必须具备 `agent:write`。
84
+ 3. 调用 `call_agent_tool`,传同一个 `agentId`、工具名和工具参数。服务端会重新读取当前用户、角色、Profile ACL、租户开关、License、App ACL 和工具放行状态。多步骤任务复用第一次返回的 `executionId`;写操作先调用 `update_plan`。不能在参数里传 `tenantId`、`userId` 或内部会话身份。
85
+
86
+ 如果 `agent:write` 被收回、Profile ACL 被撤销、Profile 被停用、能力被移出白名单或工具管理关闭,下一次调用会拒绝。`get_agent_tools` 不返回未授权的写工具;`publish_mashup_extension` 不直接开放,大屏发布必须经过 `mashup_board` 的版本化验收闸门。
87
+
68
88
  ## 打包与上架
69
89
 
70
- 运行 `npm pack --dry-run` 检查文件,再运行 `npm publish --access public` 发布到 `@miaocedata/mbi-bi-mcp@0.2.0`(发布前需在 npmjs.com 拥有 `miaocedata` 组织,否则会报 `404 Scope not found`),市场包用 `connector/mcp.json` 里固定的版本号启动。后续每次升级必须先递增 `package.json` 的版本号再发布,并同步修改 `connector/mcp.json` 与 `connector/connector-meta.json` 里的版本号;只向 WorkBuddy 提交所需连接器材料,不把中台服务、Python connector、客户地址或任何凭证打进市场包。
90
+ 运行 `npm pack --dry-run` 检查文件,再运行 `npm publish --access public` 发布到 `@miaocedata/mbi-bi-mcp@0.2.2`(发布前需在 npmjs.com 拥有 `miaocedata` 组织,否则会报 `404 Scope not found`),市场包用 `connector/mcp.json` 里固定的版本号启动。`connector/mcp.json` 的 `npmRegistries` 按 `registry.npmjs.org` → `registry.npmmirror.com` 顺序回退:npm 官方仓库是权威源,国内镜像只做兜底,避免只配镜像时新版本尚未同步导致 `npx` 404。后续每次升级必须先递增 `package.json` 的版本号再发布,并同步修改 `connector/mcp.json` 与 `connector/connector-meta.json` 里的版本号;只向 WorkBuddy 提交所需连接器材料,不把中台服务、Python connector、客户地址或任何凭证打进市场包。
71
91
 
72
92
  > **提审前须知(本地定制)**:当前 `src/client.js` 将滑动 7 天令牌持久化到本机用户目录(`~/.mbi-bi/grant.json`),目的是避免宿主关闭或每轮对话重启进程后反复授权。令牌文件不在本包目录内,不会随 `npm pack` 进入市场包;但长期凭据落盘属于安全敏感行为,正式提审前须重新评估是否接受。若需恢复短时令牌设计,用同目录的 `src/client.js.bak` 覆盖 `src/client.js`,并把上面的有效期说明同步改回。
73
93
 
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@miaocedata/mbi-bi-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Read-only stdio MCP adapter for authorized data platform deployments",
5
5
  "type": "module",
6
+ "license": "UNLICENSED",
6
7
  "engines": {
7
- "node": ">=22"
8
+ "node": ">=20.6.0"
8
9
  },
9
10
  "bin": {
10
11
  "mbi-bi-mcp": "src/index.js"
package/src/auth.js CHANGED
@@ -169,7 +169,8 @@ export function openBrowser(url) {
169
169
  });
170
170
  }
171
171
 
172
- export async function authorize(urls, { launch = openBrowser, fetcher = fetch, timeoutMs = 180_000, signal } = {}) {
172
+ // 授权窗口默认 5 分钟:宿主 mcp.json 的 timeout 必须比它更长,否则进程会先被结束,浏览器只能看到 ERR_CONNECTION_REFUSED。
173
+ export async function authorize(urls, { launch = openBrowser, fetcher = fetch, timeoutMs = 300_000, signal } = {}) {
173
174
  const state = random();
174
175
  const verifier = random();
175
176
  let accept;
package/src/client.js CHANGED
@@ -39,15 +39,47 @@ const allowedErrors = new Set(['AUTH_REQUIRED', 'AUTH_UNAVAILABLE', 'SCOPE_DENIE
39
39
  'RESOURCE_FORBIDDEN', 'RATE_LIMITED', 'INVALID_ARGUMENT', 'SEMANTIC_VERSION_MISMATCH', 'UNSUPPORTED_QUERY_CONSTRAINT',
40
40
  'DATE_DIMENSION_REQUIRED', 'DATE_DIMENSION_UNAVAILABLE', 'DATE_RANGE_NO_SELECTION', 'DATE_MEASURE_UNSUPPORTED',
41
41
  'DATE_RANGE_UNVERIFIED', 'ONTOLOGY_VERSION_UNAVAILABLE', 'ONTOLOGY_QUERY_NOT_ALLOWED', 'ONTOLOGY_CONSTRAINT_UNSUPPORTED',
42
- 'QLIK_IDENTITY_NOT_CONFIGURED', 'QLIK_QUERY_FAILED', 'CONFIG_TOO_LARGE', 'BI_SERVICE_UNAVAILABLE', 'ONTOLOGY_UNAVAILABLE']);
42
+ 'QLIK_IDENTITY_NOT_CONFIGURED', 'QLIK_QUERY_FAILED', 'CONFIG_TOO_LARGE', 'BI_SERVICE_UNAVAILABLE', 'ONTOLOGY_UNAVAILABLE',
43
+ 'AGENT_PROFILE_DISABLED', 'AGENT_PROFILE_FORBIDDEN', 'AGENT_PROFILE_NOT_FOUND', 'AGENT_CAPABILITY_FORBIDDEN',
44
+ 'AGENT_CAPABILITY_UNAVAILABLE', 'AGENT_WRITE_FORBIDDEN', 'AGENT_EXECUTION_BUSY', 'AGENT_EXECUTION_NOT_FOUND',
45
+ 'AGENT_EXECUTION_UNAVAILABLE', 'PLATFORM_IDENTITY_UNAVAILABLE', 'PLAN_REQUIRED', 'DELIVERY_GATE_REQUIRED',
46
+ 'TOOL_EXECUTION_FAILED']);
43
47
  const message = (structuredContent, isError) => ({ structuredContent, isError,
44
48
  content: [{ type: 'text', text: JSON.stringify(structuredContent) }] });
45
49
  const error = (code, description, requestId) => message({ error: { code, ...(description && { message: description }) },
46
50
  ...(typeof requestId === 'string' && /^[0-9a-f-]{36}$/i.test(requestId) && { requestId }) }, true);
47
51
 
52
+ // 把 Ajv 的校验失败翻译成用户能照着改的一句话,避免只回一个 INVALID_ARGUMENT 空壳。
53
+ function describeInvalidArguments(name, validator) {
54
+ if (!validator) return `未知工具:${name}`;
55
+ const parts = (validator.errors ?? []).slice(0, 3).map((item) => {
56
+ if (item.keyword === 'additionalProperties') return `不支持参数 ${item.params?.additionalProperty}`;
57
+ if (item.keyword === 'required') return `缺少必填参数 ${item.params?.missingProperty}`;
58
+ const where = item.instancePath ? item.instancePath.slice(1) : '参数';
59
+ return `${where} ${item.message}`;
60
+ });
61
+ return parts.length > 0 ? parts.join(';') : '参数不符合该工具声明的输入结构';
62
+ }
63
+
48
64
  const GRANT_FILE = join(homedir(), '.mbi-bi', 'grant.json');
49
65
  const PLATFORM_CONFIG_FILE = join(homedir(), '.mbi-senseX', 'platform.json');
50
66
  const GRANT_TOKEN = /^bimcp_[A-Za-z0-9_-]{43}$/;
67
+ const ENV_TOKEN = 'MBI_ACCESS_TOKEN';
68
+
69
+ // 连接配置里直接给出的令牌优先于本机缓存的授权文件:只驻留内存、绝不落盘、也不会触发浏览器授权。
70
+ // 返回 { token } 表示可用;返回 { error } 表示格式不合法,调用时直接把这个错误交给用户。
71
+ function resolveEnvToken(env) {
72
+ const raw = typeof env?.[ENV_TOKEN] === 'string' ? env[ENV_TOKEN].trim() : '';
73
+ // 宿主未替换的占位符按“未填写”处理,避免把字面量当成令牌
74
+ if (!raw || raw === '${MBI_ACCESS_TOKEN}') return undefined;
75
+ if (!GRANT_TOKEN.test(raw)) {
76
+ return {
77
+ error: '连接配置里的 MBI_ACCESS_TOKEN 格式不正确:应为 bimcp_ 加 43 位字母、数字、下划线或短横线。请在 WorkBuddy 连接设置中更新后重连。'
78
+ };
79
+ }
80
+ return { token: raw };
81
+ }
82
+
51
83
 
52
84
  function loadGrant(scope) {
53
85
  try {
@@ -109,6 +141,7 @@ export class PlatformClient {
109
141
  #grant;
110
142
  #grantStore;
111
143
  #scope;
144
+ #envToken;
112
145
  #pending;
113
146
  #lastStart = 0;
114
147
  #sequence = 0;
@@ -116,14 +149,18 @@ export class PlatformClient {
116
149
  #closed = false;
117
150
 
118
151
  constructor(urls, { fetcher = fetch, login = authorize, log = (text) => console.error(text),
119
- grantStore = persistentGrantStore, scope = urls.mcp.href } = {}) {
152
+ grantStore = persistentGrantStore, scope = urls.mcp.href, envToken } = {}) {
120
153
  this.urls = urls;
121
154
  this.fetcher = fetcher;
122
155
  this.login = login;
123
156
  this.log = log;
124
157
  this.#grantStore = grantStore;
125
158
  this.#scope = scope;
126
- this.#grant = grantStore.load(scope);
159
+ this.#envToken = envToken;
160
+ // 配置里的令牌有效时直接采用,并完全忽略本机缓存文件里的旧令牌
161
+ this.#grant = envToken?.token
162
+ ? { token: envToken.token, expiresAt: Number.POSITIVE_INFINITY }
163
+ : grantStore.load(scope);
127
164
  }
128
165
 
129
166
  close() {
@@ -139,8 +176,9 @@ export class PlatformClient {
139
176
 
140
177
  async revokeCurrent() {
141
178
  const grant = this.#grant;
142
- this.forgetGrant();
143
- if (!grant || !this.urls.revoke) return;
179
+ // 配置里的固定令牌不归本进程所有,切换地址时保留,避免把用户填的令牌撤销掉
180
+ if (!this.#envToken) this.forgetGrant();
181
+ if (this.#envToken || !grant || !this.urls.revoke) return;
144
182
  try {
145
183
  const response = await this.fetcher(this.urls.revoke, {
146
184
  method: 'POST', redirect: 'error', signal: AbortSignal.timeout(5000),
@@ -155,6 +193,14 @@ export class PlatformClient {
155
193
  // 工具本身不等待用户批准(授权页可能停留数分钟),立即返回,由用户在浏览器确认后重试目标工具。
156
194
  async reauthorize() {
157
195
  if (this.#closed) return error('BI_SERVICE_UNAVAILABLE');
196
+ // 令牌来自连接配置时浏览器授权不会生效,直接告诉用户去改配置
197
+ if (this.#envToken) {
198
+ return message({
199
+ reauthorized: false,
200
+ staticToken: true,
201
+ hint: '当前连接使用配置里固定的 MBI_ACCESS_TOKEN,浏览器重新授权不会生效。请在 WorkBuddy 的连接设置中更新令牌后重连。'
202
+ }, false);
203
+ }
158
204
  const revoked = Boolean(this.#grant);
159
205
  await this.revokeCurrent();
160
206
  // 重置频控,保证刚清完授权就能重新打开浏览器
@@ -171,6 +217,11 @@ export class PlatformClient {
171
217
 
172
218
  #needLogin() {
173
219
  if (this.#closed) return error('BI_SERVICE_UNAVAILABLE');
220
+ // 配置令牌模式下永不打开浏览器:空值/非法值都直接给出可操作的错误
221
+ if (this.#envToken) {
222
+ return error('AUTH_REQUIRED', this.#envToken.error
223
+ ?? '连接配置里的 MBI_ACCESS_TOKEN 已失效或已被撤销,请在 WorkBuddy 连接设置中更新后重连。');
224
+ }
174
225
  if (!this.#pending && Date.now() - this.#lastStart >= 10_000) {
175
226
  this.#lastStart = Date.now();
176
227
  this.#pending = Promise.resolve().then(() => this.login(this.urls, { fetcher: this.fetcher, signal: this.#stop.signal }))
@@ -184,14 +235,15 @@ export class PlatformClient {
184
235
 
185
236
  async call(name, args = {}) {
186
237
  const validator = validators.get(name);
187
- if (!validator || !validator(args)) return error('INVALID_ARGUMENT');
238
+ if (!validator || !validator(args)) return error('INVALID_ARGUMENT', describeInvalidArguments(name, validator));
188
239
  if (this.#closed) return error('BI_SERVICE_UNAVAILABLE');
189
240
  const grant = this.#grant;
190
241
  if (!grant || Date.now() >= grant.expiresAt) return this.#needLogin();
191
242
  const id = ++this.#sequence;
192
243
  try {
193
244
  const response = await this.fetcher(this.urls.mcp, {
194
- method: 'POST', redirect: 'error', signal: AbortSignal.any([AbortSignal.timeout(42_000), this.#stop.signal]),
245
+ method: 'POST', redirect: 'error', signal: AbortSignal.any([
246
+ AbortSignal.timeout(name === 'call_agent_tool' ? 280_000 : 42_000), this.#stop.signal]),
195
247
  headers: { 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream',
196
248
  'MCP-Protocol-Version': '2025-06-18', Authorization: `Bearer ${grant.token}` },
197
249
  body: JSON.stringify({ jsonrpc: '2.0', id, method: 'tools/call', params: { name, arguments: args } })
@@ -199,6 +251,9 @@ export class PlatformClient {
199
251
  if (!response.ok) {
200
252
  void response.body?.cancel().catch(() => {});
201
253
  if (response.status === 401) {
254
+ if (this.#envToken) {
255
+ return error('AUTH_REQUIRED', '连接配置里的 MBI_ACCESS_TOKEN 已失效或已被撤销,请在 WorkBuddy 连接设置中更新后重连。');
256
+ }
202
257
  if (this.#grant === grant) { this.#grant = undefined; this.#grantStore.clear(); }
203
258
  return error('AUTH_REQUIRED', '中台授权已失效;下次调用将重新打开登录。');
204
259
  }
@@ -227,7 +282,8 @@ export class PlatformClient {
227
282
  }
228
283
 
229
284
  #extend(grant) {
230
- if (this.#closed || this.#grant !== grant) return;
285
+ // 配置令牌的有效期由平台决定,本地不推算、也不写回文件
286
+ if (this.#envToken || this.#closed || this.#grant !== grant) return;
231
287
  const renewed = { token: grant.token, expiresAt: Date.now() + ACCESS_TOKEN_SECONDS * 1000 };
232
288
  this.#grant = renewed;
233
289
  this.#grantStore.save(renewed, this.#scope);
@@ -236,15 +292,17 @@ export class PlatformClient {
236
292
 
237
293
  export class PlatformSession {
238
294
  #env;
295
+ #envToken;
239
296
  #platformStore;
240
297
  #clientFactory;
241
298
  #client;
242
299
  #config;
243
300
 
244
301
  constructor(env, { platformStore = persistentPlatformStore,
245
- clientFactory = (urls, config) => new PlatformClient(urls,
246
- { scope: `${config.platformUrl}\n${config.apiBasePath}` }) } = {}) {
302
+ clientFactory = (urls, config, envToken) => new PlatformClient(urls,
303
+ { scope: `${config.platformUrl}\n${config.apiBasePath}`, envToken }) } = {}) {
247
304
  this.#env = env;
305
+ this.#envToken = resolveEnvToken(env);
248
306
  this.#platformStore = platformStore;
249
307
  this.#clientFactory = clientFactory;
250
308
  this.#reload();
@@ -258,7 +316,7 @@ export class PlatformSession {
258
316
  saved?.platformUrl ?? this.#env.MBI_PLATFORM_URL,
259
317
  saved?.apiBasePath ?? (saved ? undefined : this.#env.MBI_API_BASE_PATH)
260
318
  );
261
- this.#client = this.#config ? this.#clientFactory(this.#config.urls, this.#config) : undefined;
319
+ this.#client = this.#config ? this.#clientFactory(this.#config.urls, this.#config, this.#envToken) : undefined;
262
320
  } catch {
263
321
  this.#config = undefined;
264
322
  this.#client = undefined;
@@ -313,7 +371,7 @@ export class PlatformSession {
313
371
  await this.#client.revokeCurrent();
314
372
  this.#client.close();
315
373
  }
316
- const client = this.#clientFactory(next.urls, next);
374
+ const client = this.#clientFactory(next.urls, next, this.#envToken);
317
375
  this.#config = next;
318
376
  this.#client = client;
319
377
  this.#platformStore.save({ platformUrl: next.platformUrl, apiBasePath: next.apiBasePath });
package/src/index.js CHANGED
@@ -6,7 +6,7 @@ import { PlatformSession, tools } from './client.js';
6
6
 
7
7
  async function main() {
8
8
  const session = new PlatformSession(process.env);
9
- const server = new Server({ name: 'mbi-senseX', version: '0.2.0' }, { capabilities: { tools: {} } });
9
+ const server = new Server({ name: 'mbi-senseX', version: '0.2.2' }, { capabilities: { tools: {} } });
10
10
  server.setRequestHandler(ListToolsRequestSchema, () => ({ tools }));
11
11
  server.setRequestHandler(CallToolRequestSchema, ({ params }) => session.call(params.name, params.arguments));
12
12
  server.onerror = () => console.error('[mbi-senseX-mcp] MCP protocol error.');
@@ -220,5 +220,92 @@
220
220
  "readOnlyHint": true,
221
221
  "openWorldHint": false
222
222
  }
223
+ },
224
+ {
225
+ "name": "get_agent_profiles",
226
+ "description": "List Agent Profiles the current platform user is authorized to use. Server-side ACL, platform roles and Profile capability allowlists decide which write or delivery capabilities are available.",
227
+ "inputSchema": {
228
+ "type": "object",
229
+ "additionalProperties": false,
230
+ "properties": {}
231
+ },
232
+ "annotations": {
233
+ "readOnlyHint": true,
234
+ "openWorldHint": false
235
+ }
236
+ },
237
+ {
238
+ "name": "get_agent_tools",
239
+ "description": "List connector capabilities callable through one authorized Agent Profile. Reads require data_query plus an agent read/write role; writes require data_change plus agent:write.",
240
+ "inputSchema": {
241
+ "type": "object",
242
+ "additionalProperties": false,
243
+ "properties": {
244
+ "agentId": {
245
+ "type": "string",
246
+ "minLength": 1,
247
+ "maxLength": 64,
248
+ "pattern": "^[A-Za-z0-9_-]+$"
249
+ },
250
+ "query": {
251
+ "type": "string",
252
+ "maxLength": 80
253
+ },
254
+ "limit": {
255
+ "type": "integer",
256
+ "minimum": 1,
257
+ "maximum": 200
258
+ },
259
+ "includeWrites": {
260
+ "type": "boolean"
261
+ }
262
+ },
263
+ "required": [
264
+ "agentId"
265
+ ]
266
+ },
267
+ "annotations": {
268
+ "readOnlyHint": true,
269
+ "openWorldHint": false
270
+ }
271
+ },
272
+ {
273
+ "name": "call_agent_tool",
274
+ "description": "Execute an Agent Profile capability or an actual connector tool returned by get_agent_tools. Every call rechecks the current platform roles, Profile ACL and Profile capability allowlist. Reuse executionId for multi-step dashboard, delivery and plan state.",
275
+ "inputSchema": {
276
+ "type": "object",
277
+ "additionalProperties": false,
278
+ "properties": {
279
+ "agentId": {
280
+ "type": "string",
281
+ "minLength": 1,
282
+ "maxLength": 64,
283
+ "pattern": "^[A-Za-z0-9_-]+$"
284
+ },
285
+ "tool": {
286
+ "type": "string",
287
+ "minLength": 1,
288
+ "maxLength": 128
289
+ },
290
+ "arguments": {
291
+ "type": "object"
292
+ },
293
+ "executionId": {
294
+ "type": "string",
295
+ "minLength": 36,
296
+ "maxLength": 36,
297
+ "pattern": "^[0-9a-fA-F-]{36}$"
298
+ }
299
+ },
300
+ "required": [
301
+ "agentId",
302
+ "tool"
303
+ ]
304
+ },
305
+ "annotations": {
306
+ "readOnlyHint": false,
307
+ "destructiveHint": true,
308
+ "openWorldHint": false
309
+ }
223
310
  }
224
311
  ]