
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 分