MCP clients need a long-lived credential that works only on the MCP routes (a login token dies in 15 minutes)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- github-actions, typescript
- 領域
- api, authentication, backend, devops, documentation, security
調査の方向性
Start by reviewing auth/jwt.ts, auth/authorize.ts, worker.ts, routes/admin.ts, and the listed authorization and audit tests. Confirm the owner decisions on lifetime, caller-only minting, secret rotation, and endpoint scope before implementing the planned changes. Done means scoped tokens work only on the MCP routes, existing access tokens still work there, invalid tokens are rejected elsewhere, audit and startup-safety tests pass, workflows and documentation are updated, and the audit checks remain consistent.
索引モデルが issue の本文から書いたものです。
説明
Problem
Claude Desktop reaches WorkWell's MCP server through mcp-remote with a fixed Authorization: Bearer <JWT> header (docs/MCP.md). The only bearer token the backend issues is the login access token: 900 s (createJwt default, backend-ts/src/auth/jwt.ts), and mcp-remote cannot refresh a fixed header. So the connection dies 15 minutes after each mint, and Claude Desktop reports the WorkWell MCP server as disconnected on every launch.
Verified 2026-09-24:
- No route accepts anything but that access token.
extractPrincipal(auth/authorize.ts) verifies onlyWORKWELL_AUTH_JWT_SECRETaccess tokens; there is no API key or service credential anywhere inbackend-ts/src. - The 30-day
WORKWELL_AUTH_ACCESS_TTL_SECONDSthat once covered this was read only by the Java backend; the TypeScript port never wired it, and #703 removes it from the workflows. - Making every access token long-lived is rejected: access tokens are stateless and unrevocable, so a 30-day one outlives logout for every browser user (and undoes #688's revocation).
ROLE_MCP_CLIENTalso opens/cds-services/**and/$cql(auth/authorize.ts), so a new credential must not simply reuse the role gate.
Workaround until this ships: disable the workwell entry in Claude Desktop's MCP settings, or re-mint a token from /api/auth/login per session.
Design
A separate token that is long-lived and accepted only on /sse and /mcp/**.
- Own secret: signed with
WORKWELL_MCP_TOKEN_SECRET, neverWORKWELL_AUTH_JWT_SECRET. The ordinary verifier therefore cannot accept an MCP token even if the route check is wrong, and rotating the MCP secret revokes every MCP token without signing anyone out of the app. Unset secret = feature off. - Claims:
{ sub, role, scope: "mcp", jti, iat, exp }.sub/roleare the minting user's, so the audit actor (MCP_TOOL_CALLED), the demo-account profile refusal and the per-tool role gates inmcp/dispatch.tsbehave exactly as today. The tools stay read-only. - Route scope: the MCP verifier is consulted only when the path is
/sseor/mcp/**. Everywhere else, including/cds-services/**,/$cql,/api/**and/api/auth/*, an MCP token is an unauthenticated request. The MCP routes keep accepting a normal access token. - Minting:
POST /api/admin/mcp-tokens{ ttlDays }(ADMIN, via the existing/api/admin/**rule), for the caller only. Default 30 days, cap 90. Audit-first:MCP_TOKEN_MINTED(subject, role,jti,expiresAt; never the token) is written before the token is returned, once. - No table. Revocation is all-at-once by rotating the secret. That is acceptable on a synthetic-data sandbox with a few MCP users; per-token revocation is the PHI-phase step below.
Plan (one PR, feat/mcp-scoped-token)
auth/jwt.ts: export the HS256 sign/verify helpers (don't copy them); add a smallauth/mcp-token.tsthat issues and verifies the scoped token (rejects a missing or wrongscope, expired, or wrong-secret token).auth/authorize.ts+worker.ts:extractPrincipaltakes the pathname and an optional MCP verifier, used only on/sseand/mcp/**;rebuildAuthIfNeededbuilds it fromWORKWELL_MCP_TOKEN_SECRETand rebuilds when either secret changes.config/startup-safety.ts: when set in production, the MCP secret passes the same strength rule as the JWT secret and must differ from it.- Mint route under
routes/admin.ts, audit-first, added toaudit/audit-order.test.ts. Re-runscripts/audit-order-sweep.pyand keepDATA_MODEL_CONTRACTS.md§4's count in step if it moves. Add to the OpenAPI spec if admin routes are listed there. - Workflows: add
WORKWELL_MCP_TOKEN_SECRETto the three deploy workflows and both reconcilers (mirrored). The owner createsWORKWELL_MCP_TOKEN_SECRET_TWH/_MAUI/_STAGINGin GitHub secrets. - Docs:
MCP.md(mint, configuremcp-remote, rotate to revoke),DEPLOY.mdsecret table, one gap line inPRODUCTION_READINESS_2026-07.md(below),JOURNAL.md.
Tests (each mutation-checked: break the guard, see the test fail)
- An MCP token authenticates
/sseand/mcp/**and is 401 on/api/cases,/api/admin/*,/cds-services/*,/$cql. - A normal access token still works on the MCP routes.
verifyAccessTokenrejects an MCP token (secret separation), and a main-secret token carryingscope: "mcp"is not accepted as an MCP token.- Expired, wrong-scope and tampered MCP tokens are 401.
- Secret unset: the mint route answers 404 and no MCP token verifies.
- A demo account's MCP token is refused on a profile that refuses demo accounts (Maui).
- Mint is audit-first; the event payload never contains the token;
ttlDaysabove 90 or below 1 is a 400. - Startup safety refuses a weak MCP secret, or one equal to the JWT secret, in production.
Decisions for the owner before building
- Lifetime: default 30 days, cap 90?
- Caller-only minting, or may an admin mint for a named service account (e.g. a
ROLE_MCP_CLIENT+ROLE_CASE_MANAGERidentity)? Recommendation: caller-only first. - Revoke by rotating the secret (no DDL) for the sandbox, per-token revocation later? Recommendation: yes.
- Endpoint + documented
curlonly, or also a button on the Admin page? Recommendation: endpoint only first.
Not in scope
- OAuth for
mcp-remote(it supports the MCP authorization flow, but WorkWell would need an authorization server). - Per-token revocation. Before the PHI phase, replace the stateless token with stored, hashed API keys: per-key revocation, last-used time, a list in Admin. That is a table (owner DDL); record it in
PRODUCTION_READINESS_2026-07.mdas part of this PR. /cds-services/**and/$cql. They keep their current credential.
- 主要言語
- TypeScript
- スター
- 0
- フォーク
- 0
- 平均マージ
- 4時間 39分
- マージ済み PR(30日)
- 99
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Taleef7/workwell のほかの issue
-
frontend maui-pilot pilot-ask question
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
documentation owner-ops waiting
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
owner-ops waiting
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
backend enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
backend maui-pilot webchart-convergence
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
Taleef7/workwell の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
openedx/frontend-app-authoring#3274 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
area/documentation status/need-triage
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
google-gemini/gemini-cli#29548 ·
メンテナーはふだん 1 日以内に返信
-
sdk-typescript vector-store
難易度 2/5 半日 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信