
Evolith Architecture Governance
io.github.beyondnetcode由 GitHub 帳號 beyondnetcode 發布v1.3.3更新於 Oct 24, 2026
Executable architecture governance: an unevaluated rule is reported as a failure, never a pass.
概覽
讓助理依 Evolith 架構治理規則驗證程式庫,檢視拓撲、模式、ADR 與 SDLC 閘門,並套用經核准的修正。
- 可以做什麼
- 提供 55 個工具、12 個以上資源與 8 個提示詞用於架構治理。唯讀工具可依 GOV、INH、ACL、OCB 規則驗證儲存庫、偵測架構漂移、評估 SDLC 階段閘門、列出拓撲、模式與 ADR,並檢索架構知識庫。約 20 個寫入類工具會變更檔案:產生雛型、建立 ADR、MoSCoW 矩陣、代理安裝/升級/移除、在 GitHub 上建立衛星儲存庫、修改設定、升級以及自動修正。
- 適用情境
- 當助理需要依 Evolith 治理與架構規則檢查程式庫、審查 SDLC 階段就緒狀態,或建立與升級 Evolith 衛星儲存庫時適用。它適合已使用 Evolith Core 及其規則集的團隊,而非一般程式碼審查。
- 執行需求
- 本機 Node.js 程序,透過 npx 執行 npm 套件 @beyondnet/evolith-mcp,預設使用 stdio。可透過 TRANSPORT、PORT、MCP_HTTP_HOST 啟用 HTTP 傳輸。選用設定包括 EVOLITH_API_KEY、JWT_SECRET、用於資源快取的 REDIS_URL 以及 OpenTelemetry 相關變數。清單中未宣告任何憑證。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Evolith Architecture Governance,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
@beyondnet/evolith-mcp
Evolith MCP Gateway — First-Class Model Context Protocol Server
Bilingual navigation: Versión en Español
Decouples the MCP server from the CLI. It is a first-class product that exposes the MCP tools as a Gateway talking to @beyondnet/evolith-core (the reusable business-logic layer), instead of shelling out to CLI subprocesses.
Table of contents
- Architecture diagram
- Transports
- Installation and configuration
- Authentication
- Available tools (55)
- Available resources (12 + dynamic)
- Available prompts (8)
- Mutative operations
- Internal architecture
- Agent use cases
- Client configuration
- SmartCLI integration
- Extension guide
- Observability
- Good practices
- Troubleshooting
Architecture diagram
Transports
The default port is
3000(main.ts: envPORTor--port, falling back to3000). The49100used in the examples is an arbitrary value, not the default.Logs are always written to stderr (Pino), because stdout is reserved for the JSON-RPC stream of the stdio transport.
Installation and configuration
Installation
Usage
Environment variables
The binary also accepts the flags
--transport/-t,--port/-p,--api-keyand--allow-no-auth(HTTP only), as well as theevolith-mcp versionsubcommand.
Authentication
stdio transport
No request authentication is required: the process is local, single-user, and the agent runs it directly. The transport establishes an explicit local session principal (id=local-stdio-session, role=local-session, roles=[local-session, operator], scopes=[read, write]) that is recorded in the audit trail of every call (GT-572).
This is not an authorization bypass: ABAC (native + OPA) is still evaluated on every tools/call with that identity, the deploy tools are still denied in production (they require architect), and every mutative tool still demands the HITL gate { apply, approvalToken }. --allow-no-auth / EVOLITH_MCP_ALLOW_NO_AUTH do not apply to stdio (there is no request authentication to skip); if they are passed together with --transport stdio, the server warns about it on stderr at startup.
HTTP transport
In production (NODE_ENV=production), authentication is mandatory: validateAuth() ignores EVOLITH_MCP_ALLOW_NO_AUTH and rejects every request without a valid credential (401). The value of EVOLITH_API_KEY is an arbitrary secret (any string; no prefix required) compared by equality. It is accepted in either of these two headers:
/health is public (a liveness probe) and requires no credential.
When an OAuth issuer is configured, /.well-known/oauth-protected-resource (and the path-inserted /.well-known/oauth-protected-resource/<path>) is also public: it is the RFC 9728 document an unauthenticated client reads to discover which authorization server to go to, so gating it behind the credential it is trying to obtain would make discovery impossible. It carries no MCP data — only the issuer, the resource identifier and the scope names. A 401 from a protected resource additionally carries a WWW-Authenticate: Bearer resource_metadata="…", scope="…" challenge, which is the discovery mechanism MCP clients must prefer. Without an issuer the endpoint returns 404 rather than publishing a document with an empty authorization_servers.
Client registration never flows through this server: it is a resource server, and the 2026-07-28 revision has clients obtain a client_id from a Client ID Metadata Document (or pre-registration) at the authorization server. Dynamic Client Registration is deprecated and is not implemented here; protected-resource-metadata.spec.ts fails the build if a registration endpoint is ever introduced.
Protocol revisions
The server answers two protocol revisions on the same HTTP endpoint:
Both revisions run through one dispatch, so ABAC (native + OPA), the scope gate, the approval gate and the audit trail are the same code on either path. The 2025-11-25 path is retained because the published SDK still declares it as its latest revision; it is not an alternative design.
On the 2026-07-28 path a state-changing tool answers resultType: "input_required" with an elicitation/create request and an opaque requestState. The client gathers the human's approval and retries the original call — new JSON-RPC id, same parameters, plus requestState and inputResponses. The requestState is sealed with AES-256-GCM and bound to the principal, the tenant, the originating call and a short TTL, so it cannot be replayed across users, calls or time. A caller that already holds an approval may still pass { apply: true, approvalToken } inline and skip the round trip, exactly as on the 2025-11-25 path.
The
ApiKeyProvisioningService(below) is an advanced and optional mechanism for issuing keys with anevk_prefix, a SHA-256 hash and a TTL. It is independent of the startupEVOLITH_API_KEYdescribed here.
API key provisioning
The ApiKeyProvisioningService manages the lifecycle of the keys:
Keys carry scopes: read, write, admin. They are bound to a tenant.
ABAC model
The AbacEvaluator controls which tools each user may invoke, based on their roles:
ABAC codes:
Tool classification (substring heuristic). The internal role sets are DEVELOPER = {developer, qa}, OPERATOR = {operator, sre} and ARCHITECT = {architect, admin}. The read/write/deploy classification of each tool is a heuristic over its name (abac-evaluator.ts): it counts as read if the name contains read/list/get (or does not begin with evolith-); as write if it contains write/replace/run/fix/advance; as deploy if it contains deploy/publish/merge. Because of that heuristic, evolith-phase-advance is classified as write (the advance substring), even though it only proposes the transition. A tool that fits no group is rejected with ABAC-03.
Authentication precedence (HTTP). The guard (mcp-server-auth.ts) evaluates the API key first: if the Authorization: Bearer <token> or the x-api-key header matches EVOLITH_API_KEY, it grants an admin context (role admin, every tool allowed). Only if the key does not match and JWT_SECRET is defined does it try to validate the Bearer as a JWT HS256; in that case the roles in the JWT payload are what feed ABAC. /health is public. In production, auth is mandatory (it ignores EVOLITH_MCP_ALLOW_NO_AUTH).
Available tools (55)
The tools are obtained at runtime via tools/list. All of them return raw data, which the Gateway wraps in a SuccessEnvelope or an ErrorEnvelope.
The count is derived from the registration sources by the generated Product Surface Inventory (
tools/*.ts,resources.service.ts,prompts.service.ts); the tables below name every tool, grouped by area. When they disagree,tools/listand the inventory win.
Validation
evolith-composable-validate schema:
Modes are enabled by combining fields. Several of them can be used in a single call.
Evaluation (ADR-0101)
Architecture
Patterns
Topologies
evolith-topology-list schema:
evolith-topology-get schema:
Available topologies: modular-monolith, distributed-modules, microservices, serverless, edge-computing, event-driven, data-mesh, agentic-ai
SDLC gates
¹
evolith-phase-advanceonly proposes the transition — it does not execute it. Executing it is the responsibility of the operator or of the Tracker.
SDLC
MoSCoW
² The three MoSCoW tools that write to
.evolith/moscow/{phase}.json(create,update,remove) declaremutative: trueinmoscow.tools.tssince 2026-07-11, so the dispatcher demandsapply/approvalTokenfor them;load,list,validateandreportare reads.
ADRs
Agents
Satellites
Scaffolding and initialization
Upgrades
Knowledge
Remediation
Configuration
Observability
CLI parity reads (GT-682)
Three CLI commands that had no MCP counterpart, ported as read-only tools over the CLI's own readers in core-domain. Their write modes (history --clear/--replay, profile create/switch/delete, standards --init/--validate/--export) stay on the CLI.
Available resources (12 + dynamic)
Resources are obtained via resources/list and read via resources/read.
Static resources (resources/list)
Dynamic URIs (reachable via resources/read)
Available prompts (8)
Prompts are obtained via prompts/list and invoked via prompts/get.
Mutative operations
Tools marked as mutative (mutative: true) require explicit approval in order to prevent accidental changes. The dispatcher (mcp-tool-dispatch.ts:137) rejects the call with FORBIDDEN unless the request carries both fields:
applymust be exactlytrue.approvalTokenmust be a non-empty string. The server never logs it in the clear: it reduces it to asha256:…fingerprint before auditing it.
The
approvalTokenis the approval contract at the protocol level. Some tool schemas still declare aconfirmfield, and the helperisMutationAllowed()exists (it readsmcp.allowMutationsfromevolith.yaml), but the guard that actually blocks execution inhandleCallToolisapply+approvalToken— neitherconfirmnormcp.allowMutationsreplaces it.
Mutative tools
Exactly 20 tools declare
mutative: truein the code (2026-09-20; the other 35 are reads). The set is what the dispatcher protects by construction — a tool is guarded because it is mutative, not because it is listed here.evolith-upgrade-planandevolith-phase-advanceare deliberately reads: they compute and propose, they do not write.
Internal architecture
The Gateway is a NestJS application (modules + dependency injection).
WatcherService
WatcherService watches workspace files (e.g. evolith.yaml) in order to invalidate caches or trigger re-validations when the user edits the configuration while the Gateway is running. It is enabled automatically on the long-lived stdio transport.
CorpusResourceHandler
Handles access to documentary corpus resources (ADRs, playbooks, specs) so that agents can read structured architectural context without invoking mutative tools.
Agent use cases
1. Repository validation from Claude Desktop
The prompt guides the agent to use evolith-validate and to report the blocking violations.
2. Agent onboarding from Cursor
The agent will invoke evolith-agent-install and evolith-agent-validate in sequence.
3. Automated architecture review
Combines SDLC and Architecture validation in a single call.
4. A full SDLC cycle with MoSCoW + gate check
5. Querying the topologies before validating
Client configuration
Cursor (~/.cursor/config.json)
Claude Desktop (claude_desktop_config.json)
Custom agent (HTTP transport)
SmartCLI integration
Migration plan away from evolith-cli mcp
Phase 1 — Coexistence (current): evolith-cli mcp keeps working. evolith-mcp serve is the new entry point.
Phase 2 — Deprecation: evolith-cli mcp will emit a console.warn. Migrate the Cursor / Claude Desktop configurations to evolith-mcp.
Phase 3 — Removal: Drop the MCP code from @beyondnet/evolith-cli in a major version bump. The CLI keeps its validation commands.
Behavioural differences
Extension guide
To add a new tool:
- Create
src/tools/my-tool.tool.tsimplementingMcpTool(schema,execute; addreadonly mutative = trueif it changes state). - Inject whichever domain service it needs (from
@beyondnet/evolith-core). - Return raw data —
McpServerServicewraps it automatically in aSuccessEnvelopeand captures errors into anErrorEnvelope. - Register the tool in
tools.module.ts: add the provider and include it in theMCP_TOOLSfactory.
For mutative tools, add readonly mutative = true. The dispatcher will then demand { "apply": true, "approvalToken": "..." } in the request before it runs the tool.
Observability
Pino logs → stderr
Every log goes to stderr (never stdout). Structured JSON format with correlationId, tool, duration and success.
evolith-metrics tool
Returns the internal metrics of the Gateway:
OpenTelemetry
Audit Logger
Every tool call is recorded with: toolName, userId, tenant, environment, allowed (ABAC), durationMs and correlationId. The records go to stderr in JSON format.
Good practices
- Use prompts as the entry point for agent workflows — they spare the agent from having to reason out the sequence of tools.
- Do not confirm mutative calls in bulk without first validating with the equivalent read-only tools.
- Run
evolith-validatebeforeevolith-auto-fixso you know the real scope of the changes. - On production HTTP, rotate the API keys every 90 days and restrict scopes to the minimum needed.
- Redis is optional but recommended on long-lived installations, to avoid repeated filesystem reads in
resources/read. - Use
evolith-composable-validateinstead of separate calls when several modes are needed — it cuts latency and correlates the results.
Troubleshooting
stdio: logs appear interleaved with the MCP response
Logs go to stderr. If the client merges stdout and stderr, separate the streams:
stdio: Refusing to start the MCP stdio transport (GT-572)
Under NODE_ENV=production, the stdio transport does not receive the local-session principal implicitly: it demands the same configured credential as any other production surface. Without it the server does not start — it fails loudly at startup on stderr and exits with code 78 (EX_CONFIG), instead of advertising all of its tools and then denying every tools/call with FORBIDDEN.
Fixes (any one of them):
--allow-no-auth / EVOLITH_MCP_ALLOW_NO_AUTH is an HTTP-only development switch and deliberately does not stand in for the production credential.
HTTP: 401 Unauthorized
Check that EVOLITH_API_KEY is configured on the server and that the request sends the same value in Authorization: Bearer <key> or x-api-key: <key>. The value is compared for exact equality (no evk_ prefix required). Under NODE_ENV=production, auth is mandatory even with EVOLITH_MCP_ALLOW_NO_AUTH=true.
Tool not found (Tool not found in registry)
The tool may not be registered in tools.module.ts. Check that the provider has been added and that the name in schema.name matches exactly the one being invoked.
ABAC-02: No roles present
The user context (mcp-user-context) carries no roles. On the HTTP transport, check that the JWT or the user context carries the role claims correctly.
Redis unavailable
The cache degrades gracefully. Resources are served straight from the filesystem with no cache, and a warning is emitted in the logs.
OPA: policy.wasm not found
The OPA evaluator requires sdk/cli/rulesets/opa/policy.wasm under CORE_PATH. The behaviour when a policy is missing is fail-closed (GT-348/349), not fail-open: if the file does not exist and NODE_ENV === "production", the evaluator returns allowed: false with the ABAC_POLICY_MISSING violation (a hard denial). Only in non-production environments does the OPA evaluator abstain, returning allowed: true so that the native policy decides. An error inside the OPA engine always denies. To force native evaluation, do not specify engine: "opa".
License
ISC — Beyondnet
來源:src/packages/mcp-server/README.md,提交 2d396da
工具
0版本歷史
1- v1.3.3最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分