@atlasauth/pca-mcp-rs

中文文档
0.4.3发布于 2026/10/28MITTypeScriptCommonJS近 30 天下载 1715

MCP authorization resource-server for the 2026-07-28 spec: serve RFC 9728 PRM + Client-ID Metadata Documents, enforce RFC 8707 resource indicators + RFC 9207 issuer validation + scope accumulation, and wire PCA FROST step-up into the MCP step-up challenge

原始使用文档
文档目录5 节
  1. Install
  2. Usage
  3. API
  4. Status
  5. License

@atlasauth/pca-mcp-rs

MCP authorization resource server for the 2026-07-28 MCP authorization revision, backed by Proof-Carrying Authority (PCA). Where @atlasauth/pca-mcp wraps tool handlers on the client so each call carries a PCActn, this package makes the server that receives those calls a correct OAuth 2.1 resource server: it serves RFC 9728 Protected Resource Metadata, validates Client-ID Metadata Documents, enforces RFC 8707 resource binding and RFC 9207 issuer validation, accumulates scopes down the delegation chain, and issues RFC 9470 step-up challenges. The authority is the PCActn, not a bearer token: its signed aud is the resource binding.

Install

npm i @atlasauth/pca-mcp-rs @atlasauth/pca

Everything is pure and runtime-neutral (no Node builtins, no framework), so it mounts on Express, Fastify, Hono, Next.js, Fetch handlers or any router.

Usage

import { prmHandler, authorizeRequest } from '@atlasauth/pca-mcp-rs';

const resource = 'https://mcp.example.com';
const authorizationServers = ['https://as.example.com'];

// 1. Serve the Protected Resource Metadata (RFC 9728) at the returned path.
const prm = prmHandler({ resource, authorizationServers, scopesSupported: ['refund:write'] });
// GET prm.path  ->  JSON prm.body

// 2. Admit each tool call.
const result = await authorizeRequest(req /* { headers, body? } */, {
  resource,                                   // must equal the PCActn's signed `aud`
  authorizationServers,                       // allowed grant issuers (RFC 9207)
  resolveGrant: async (ref) => grants.get(ref) ?? null,
  prmUrl: `${resource}${prm.path}`,
  tool: 'refund',
  toolScopes: { refund: 'refund:write' },
  toolStepUp: { refund: 2 },                  // optional: require a guardian (2) or principal (3) co-sign
});

if (!result.ok) {
  // result.status is 401 or 403; send the challenge header with the response.
  return new Response(JSON.stringify({ error: result.error }), {
    status: result.status,
    headers: { 'WWW-Authenticate': result.wwwAuthenticate },
  });
}
result.pcactn; result.grantedScopes; result.checks;

authorizeRequest reads the PCActn from the PCA-Action header (base64url) or a JSON body { pcactn }, and fails closed: any missing, mismatched or unverifiable element is denied with the correct status and WWW-Authenticate challenge, and unexpected errors deny with 403.

API

  • protectedResourceMetadata(opts), prmHandler(opts), WELL_KNOWN_OAUTH_PRM - RFC 9728 metadata.
  • authorizeRequest(req, opts), extractPCActn(req) - the admission check.
  • wwwAuthenticateChallenge(opts) - build a WWW-Authenticate: Bearer ... value.
  • clientIdMetadataDocument(opts), verifyCimd(input, opts?) - Client-ID Metadata Documents (https client_id, redirect URI checks).
  • accumulateScopes(caveats, base?), isScopeCaveat - scope narrowing from scope caveats.
  • requiredRolesForTier, verifyStepUp, StepUpChallenge - step-up helpers.

Status

Step-up is cryptographically verified and has no presence-check default. When several tier sources apply (requiredTier, toolStepUp[tool], the riskTiers tier) the effective tier is their maximum, and toolStepUp without a tool fails closed (R3-08). When a tier applies (toolStepUp, requiredTier, or riskTiers), pass stepUpSignerSet (the agent, guardian and principal public keys): every share is verified against it with the tier as the required t (tier 2 = t 2, tier 3 = t 3, so tier 3 needs a verified principal share), through the PCA threshold verifier. Or pass your own stepUpSatisfied, which must verify the shares itself. With neither, the call fails closed. riskTiers needs a serverRisk(pcactn, grant) callback that recomputes risk from server-held data; the agent's signed risk_claim.r is never used. authorizeRequest calls the PCA core verifier with the grant and audience only; it takes no replay store or revocation list, so add those around it if you need them. PCA cryptography has not been independently audited.

License

MIT - see LICENSE

版本与发布记录

@atlasauth/pca-mcp-rs 共发布 8 个版本,首次发布于 2026/10/08;过去 12 个月发布了 8 个版本。

版本发布日期距今
0.4.3latest2026/10/2813 天前
0.4.22026/10/2614 天前
0.4.12026/10/1228 天前
0.4.02026/10/1228 天前
0.3.02026/10/091 个月前
0.2.02026/10/091 个月前

关于 @atlasauth/pca-mcp-rs 的常见问题

@atlasauth/pca-mcp-rs 是什么?

MCP authorization resource-server for the 2026-07-28 spec: serve RFC 9728 PRM + Client-ID Metadata Documents, enforce RFC 8707 resource indicators + RFC 9207 issuer validation + scope accumulation, and wire PCA FROST step-up into the MCP step-up challenge

如何安装 @atlasauth/pca-mcp-rs?

在项目目录运行 npm install @atlasauth/pca-mcp-rs,或使用 pnpm add / yarn add / bun add。

@atlasauth/pca-mcp-rs 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@atlasauth/pca-mcp-rs 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@atlasauth/pca-mcp-rs 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@atlasauth/pca-mcp-rs 可以商用吗?

@atlasauth/pca-mcp-rs 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@atlasauth/pca-mcp-rs 的下载量有多少?

根据 npm 官方下载统计,@atlasauth/pca-mcp-rs 在 2026/10/07 – 2026/11/05 这 30 天内被下载 1,715 次,日均约 57 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@atlasauth/pca-mcp-rs 还在维护吗?

最新版本 0.4.3 发布于 2026/10/28(13 天前);至今共发布 8 个版本,其中过去 12 个月发布了 8 个;首次发布于 2026/10/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。