igrid-sce-mcp-tool
igrid-sce-mcp-tool v4 — 读取 / 写入 / 管理
用于现有 iGrid-Prometheus REST API 的 Node.js/JavaScript MCP 集成层。iGrid 后端和现有的八个工具拆分保持不变;此版本在 MCP 工具级别添加了基于 SAP BTP XSUAA 角色的授权。
授权模型
该项目现在定义了三个 XSUAA 作用域、三个角色模板和三个预定义角色集合:
角色集合 | 角色模板 | 作用域 | 允许的 MCP 操作 |
|
|
| 仅 GET/读取工具 |
|
|
| 仅 POST/写入工具 |
|
|
| 全部八个工具 |
授权检查在公共 MCP toolHandler 中执行,在任何下游 iGrid API 请求之前。缺少所需作用域的用户将收到 Forbidden: MCP 工具错误。
Related MCP server: agent-sudo-mcp
恰好 8 个 MCP 工具
Bearer 组 — src/tools/bearer-tools.js
igrid_list_domains→GET /api/hub/datasets→ 读取/管理igrid_get_template→GET /api/hub/template/:domain→ 读取/管理igrid_run_agent→POST /api/ai/run→ 写入/管理igrid_propose_action→POST /api/ai/action/propose→ 写入/管理igrid_decide_action→POST /api/ai/action/decide→ 写入/管理igrid_metrics→GET /api/ai/metrics→ 读取/管理
x-api-key 组 — src/tools/api-key-tools.js
igrid_ingest_csv→POST /api/ingest/:domain→ 写入/管理igrid_export_csv→GET /api/export/:domain→ 读取/管理
igrid_propose_action 被有意归类为写入,因为请求的授权规则基于实际的 HTTP 操作,且此工具使用 POST。
不公开 igrid_health MCP 工具。/healthz 仅保留为应用程序健康端点。
现有下游 iGrid 行为保持不变
六个工具继续使用 iGrid Bearer/服务会话。
igrid_ingest_csv和igrid_export_csv继续使用 iGridx-api-key通道。未引入 Destination 或 Connectivity 服务。
未硬编码任何凭据或密钥。
重要文件
xs-security.json XSUAA scopes, role templates, role collections
src/auth/xsuaa.js XSUAA authentication + OAuth metadata
src/auth/authorization.js Read/Write/Admin authorization checks
src/context/auth-context.js Per-request auth context propagation
src/tools/response.js Common MCP tool-level enforcement
src/tools/bearer-tools.js 6 Bearer tools and permission mapping
src/tools/api-key-tools.js 2 x-api-key tools and permission mapping环境
IGRID_BASE_URL=https://igrid-prometheus.azurewebsites.net
IGRID_API_KEY=<IGRID_API_KEY>
IGRID_BEARER_TOKEN=<optional pre-issued iGrid Bearer>
IGRID_SERVICE_EMAIL=<optional approved iGrid service email>
IGRID_SERVICE_PASSWORD=<optional approved iGrid service password>
IGRID_MFA_CODE=<optional MFA code>
IGRID_MFA_BODY_JSON=<approved MFA JSON body using {{code}}>
IGRID_REQUEST_TIMEOUT_MS=30000
MCP_TRANSPORT=http
MCP_HOST=0.0.0.0
MCP_PORT=8080
MCP_PATH=/mcp
# Local stdio / local HTTP test authorization only.
# Ignored for a hosted request authenticated through XSUAA.
MCP_LOCAL_ROLE=Admin
MCP_HTTP_AUTH_TOKEN=对于 Bearer 工具,优先使用预先颁发的 IGRID_BEARER_TOKEN。如果不存在,现有的令牌管理器可以在提供所需 MFA 配置的情况下使用已批准的 iGrid 登录/MFA 契约。
构建
npm install
npm run check
npm run security:check
npm test
npx mbt build -t mta_archivesBTP 部署
cf login
cf target -o <ORG> -s <SPACE>
cf deploy mta_archives/igrid-sce-mcp-tool_4.0.0.mtar -f部署后设置 iGrid 密钥:
cf set-env igrid-sce-mcp-tool IGRID_API_KEY '<IGRID_API_KEY>'
cf set-env igrid-sce-mcp-tool IGRID_BEARER_TOKEN '<IGRID_BEARER_TOKEN>'
cf restart igrid-sce-mcp-tool或者,当使用已批准的服务登录/MFA 流程时:
cf set-env igrid-sce-mcp-tool IGRID_SERVICE_EMAIL '<SERVICE_EMAIL>'
cf set-env igrid-sce-mcp-tool IGRID_SERVICE_PASSWORD '<SERVICE_PASSWORD>'
cf set-env igrid-sce-mcp-tool IGRID_MFA_BODY_JSON '<APPROVED_JSON_WITH_{{code}}>'
cf restart igrid-sce-mcp-toolXSUAA 角色分配
部署会根据 xs-security.json 创建/更新 XSUAA 服务实例 igrid-sce-mcp-tool-xsuaa。
部署后,在 SAP BTP 子账户中:
打开 安全 → 角色集合。
确认预定义的集合
iGrid-MCP-Read、iGrid-MCP-Write和iGrid-MCP-Admin存在。将
iGrid-MCP-Read分配给只读用户。将
iGrid-MCP-Write分配给只写用户。仅将
iGrid-MCP-Admin分配给需要同时使用 GET 和 POST MCP 工具的用户。重新认证 MCP 客户端,使其新令牌包含已分配的作用域。
如果用户只有读取权限,POST 工具将在 MCP 层失败。如果用户只有写入权限,GET 工具将失败。管理员可以调用全部八个工具。
OAuth / Claude 远程 MCP
使用已部署的端点:
https://<BTP_ROUTE>/mcpOAuth 发现元数据现在会公布 XSUAA 的 read、write 和 admin 作用域。对于用户特定的角色强制执行,请使用能生成用户令牌的 OAuth 流程(通常是授权码),以便用户的 BTP 角色集合在令牌中得以体现。
服务密钥仍然可以提供 XSUAA OAuth 客户端凭据,但 client_credentials 令牌是技术客户端身份,不应被视为继承了人类用户的角色集合。
本地 stdio
本地 stdio 没有 BTP 用户 JWT,因此角色行为通过 MCP_LOCAL_ROLE 模拟。默认值为 Admin,以保留之前的本地行为。
只读本地测试:
MCP_LOCAL_ROLE=Read npm run start:stdio只写本地测试:
MCP_LOCAL_ROLE=Write npm run start:stdio完整本地测试:
MCP_LOCAL_ROLE=Admin npm run start:stdioClaude Desktop/Code 示例:
{
"mcpServers": {
"igrid-sce-mcp-tool": {
"command": "node",
"args": ["/ABSOLUTE/PATH/igrid-sce-mcp-tool/src/server.js"],
"env": {
"MCP_TRANSPORT": "stdio",
"MCP_LOCAL_ROLE": "Read",
"IGRID_BASE_URL": "https://igrid-prometheus.azurewebsites.net",
"IGRID_API_KEY": "<IGRID_API_KEY>",
"IGRID_BEARER_TOKEN": "<IGRID_BEARER_TOKEN>"
}
}
}
}角色验收测试
使用三个用户(或三个用户角色分配),并在每次分配后获取新令牌。
读取用户
预期成功:
igrid_list_domains
igrid_get_template
igrid_metrics
igrid_export_csv预期 Forbidden::
igrid_run_agent
igrid_propose_action
igrid_decide_action
igrid_ingest_csv写入用户
预期成功:
igrid_run_agent
igrid_propose_action
igrid_decide_action
igrid_ingest_csv预期 Forbidden::
igrid_list_domains
igrid_get_template
igrid_metrics
igrid_export_csv管理员用户
全部八个工具应通过 MCP 角色检查。下游 iGrid 身份验证/授权和请求验证仍然适用。
安全说明
权限检查在 iGrid API 调用之前执行。
XSUAA 控制入站 MCP 权限;iGrid 对下游凭据和业务授权保持权威。
切勿将 iGrid API 密钥、iGrid 密码、Bearer 令牌、XSUAA 客户端密钥或服务密钥放入源代码管理。
有关简洁的安全模型,请参阅
README-SECURITY.md。
Available Tools
8 toolsigrid_decide_actionDecide governed actionADestructive
WRITE role: approve or reject a previously proposed action. Requires explicit humanConfirmed=true; iGrid remains authoritative for downstream authorization.
Inputs: decision (required), humanConfirmed (required), note, request, +1 more.
igrid_export_csvExport governed CSVCRead-only
READ role: export an iGrid domain through GET /api/export/:domain using the documented x-api-key M2M endpoint.
Inputs: domain (required).
igrid_get_templateGet domain CSV templateARead-only
READ role: return the contract-accurate CSV template for an iGrid domain.
Inputs: domain (required).
igrid_ingest_csvIngest CSV into iGridCDestructive
WRITE role: send CSV to iGrid through POST /api/ingest/:domain using the documented x-api-key M2M endpoint.
Inputs: csv (required), domain (required).
igrid_list_domainsList iGrid domainsARead-only
READ role: discover current iGrid hub datasets with counts and freshness.
Inputs: no named parameters.
igrid_metricsGet iGrid AI metricsARead-only
READ role: return token/cost observability metrics for the iGrid AI assistant.
Inputs: no named parameters.
igrid_propose_actionPropose governed actionA
WRITE role: submit a governed action proposal through POST /api/ai/action/propose. It remains a dry-run proposal and does not approve the action.
Inputs: request (required).
igrid_run_agentRun iGrid AI agentCDestructive
WRITE role: run an existing iGrid AI agent through POST /api/ai/run.
Inputs: request (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct operation: listing domains, exporting/ingesting CSV, getting templates, running agents, proposing/deciding actions, and metrics. There is no overlap or ambiguity between them.
All tools follow the consistent pattern 'igrid_<verb>_<object>' (e.g., igrid_export_csv, igrid_propose_action). The name 'igrid_metrics' uses a noun instead of verb but still fits the pattern as a read operation. Overall, naming is highly predictable.
With 8 tools, the server is well-scoped for its purpose: managing iGrid data domains and AI agent actions. The number is neither too small nor too large, each tool serves a clear function.
The tool surface covers key workflows: domain discovery, CSV import/export, template retrieval, agent execution, action governance, and metrics. Minor gaps exist, such as no tool for listing past proposed actions or viewing action history, but core functionality is complete.
Related MCP Connectors
Supervised API-write gateway for AI agents with policy, human approval and execution receipts.
Credential broker for AI agents: scoped, revocable API access with policy enforcement and audit.
Security gateway for AI agents: policy, approval, and audited execution, no secrets shared.
Governed access to sensitive data, secrets and APIs for AI agents. A signed proof for each decision.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceProvides a trust and governance layer for AI agents, enabling secure API access, credential vaulting, paid execution with human approval, and automatic call resume.2-
- AlicenseAqualityCmaintenanceLocal zero-trust permission gateway for AI agents. Enforces policy-based tool authorization, human approvals, scoped permissions, and cryptographically verifiable audit logs.494 PyPI5Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to discover and execute tools via a secure MCP server with JWT authentication, RBAC, rate limiting, and audit logging.1MIT
- AlicenseNot gradedqualityDmaintenanceProvides a secure MCP gateway for AI agents to access APIs without exposing raw credentials, with scoped access, audit logging, and OAuth support.MIT