
Attest Mcp
io.github.chudah1由 GitHub 帳號 chudah1 發布v0.1.0更新於 Oct 24, 2026
Credential enforcement middleware for MCP servers — verifies scoped tokens on every tool call
概覽
為既有 MCP 伺服器加裝的中介層,讓每次工具呼叫都須通過帶作用域的 Attest 憑證驗證,並記錄稽核事件。
- 可以做什麼
- 包裝既有 MCP 伺服器,讓每次工具呼叫在執行前都驗證 Attest 憑證
- 離線驗證憑證簽章與有效期限(依簽發方 JWKS),並檢查是否已撤銷
- 自動把工具名稱對應為 resource:action 作用域,支援單一工具或全域覆寫
- 呼叫被阻擋時,向呼叫方代理回傳結構化的機器可讀錯誤
- 對外提供解析後的作用域清單,並可在處理函式中讀取已驗證的憑證宣告
- 為每次工具呼叫送出稽核事件,並提供違規與投遞失敗回呼
- 適用情境
- 適合已自行運行 MCP 伺服器、希望在不改寫工具處理函式的前提下做到逐工具授權、委派追蹤與稽核紀錄的開發者。也適合先觀察記錄違規、確認無誤後再開啟阻擋的漸進式上線。
- 執行需求
- 以本機 npm 套件形式加入你自己的 MCP 伺服器專案,需搭配 MCP SDK 使用。需要一個可連線的 Attest 簽發伺服器(清單中以 ATTEST_BASE_URL 設定),需要網路存取以查詢 JWKS 與撤銷狀態,並需要該伺服器簽發的憑證。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Attest Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
@attest-dev/sdk/mcp
Attest credential enforcement middleware for Model Context Protocol servers.
Two lines to protect every tool call on an existing MCP server.
Install
@attest-dev/sdk ships both the core client and the MCP middleware as a single package with two entry points.
Two-line integration
withAttest patches server.tool() in place and returns the same server object typed as the original. Everything else — connect(), close(), transports — works unchanged.
How it works
On every tool call, before the handler executes:
- Extract credential from
extra.authInfo.token(MCP auth middleware path),extra.meta.attest_token, orextra.meta.authorization - Verify RS256 signature + expiry offline against the issuer's JWKS (fetched once, cached for 1 hour by default)
- Map tool name → scope using
scopeForTool()and check the credential'satt_scopecovers it - Check revocation via
GET /v1/revoked/{jti}(10-second in-process cache) - Pass through to the original handler on success
- Return a structured error on any failure — agent frameworks receive
isError: truewith a typed JSON payload - Fire audit event to
POST /v1/audit— async, never blocks the tool call
Scope mapping
Tool names are automatically mapped to resource:action scope strings. The first word (before the first _) becomes the action; the remainder becomes the resource.
Action aliases — these raw prefixes map to canonical actions:
Multi-word resources keep their underscores in the scope string. get_weather_forecast → weather_forecast:read. This is intentional — the full noun phrase is preserved as the resource. When issuing credentials, use the same string: scope: ["weather_forecast:read"].
Override at registration — pass a AttestToolOptions object as the final argument to server.tool(). This is the preferred way to set scope for non-standard tool names because the scope lives next to the tool definition:
The options object is consumed by withAttest and stripped before the MCP SDK sees the arguments — the SDK is unaware of it.
Override globally using toolScopeMap in options (applies to all tools that don't declare requiredScope explicitly):
Scope discovery endpoint
getAttestScopes() returns the live scope registry — every tool name mapped to its resolved scope string. Wire it to an HTTP endpoint so credential issuers can query what scopes a server requires without out-of-band coordination.
Response:
An orchestrator agent issues credentials by fetching this endpoint first:
No spreadsheet of scope strings. No manual sync between server and client. The server is the source of truth.
What an agent receives when blocked
isError: true signals the MCP framework that this is an error response. The reason field is machine-readable:
Options
Reading credential claims inside a tool handler
After withAttest has already verified the credential, use getAttestContext to read the claims without re-verifying:
Gradual rollout
Add Attest to an existing server without blocking traffic until you're confident the mapping is correct:
Flip requireCredential to true once violation rates drop to zero in your monitoring.
Audit logging
Every tool call — pass or fail — fires a POST /v1/audit to your Attest server. Delivery is async and never blocks tool execution.
Audit delivery is best-effort with structured error surfacing. For guaranteed delivery, configure onAuditError and implement your own retry queue.
Failures surface in priority order — nothing is ever silently dropped:
onAuditError(error, event)— you handle it (retry queue, fallback log, pager)onViolation({ reason: "audit_failure", ... })— surfaces to your existing monitoring ifonAuditErroris not setconsole.warn— last resort if neither callback is configured
Non-2xx responses from the audit endpoint are treated as delivery failures, not silent successes.
The audit event carries: event_type, jti, att_tid, att_uid, agent_id (mcp:<toolName>), scope, and an outcome meta field (allowed, scope_violation, blocked_revoked).
Query the audit chain for a task tree:
Full example
License
Apache-2.0
來源:sdks/typescript/mcp/README.md,提交 defffb9
工具
0版本歷史
1- v0.1.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分