molecule-core/platform/internal/middleware
Molecule AI Backend Engineer 18c00726b8 feat(platform): opencode MCP bridge — remote A2A tools over HTTP (#800)
Implements sub-issues #809 (MCPHandler), #810 (tool filtering), #811
(per-token rate limiting), #813 (opencode.json), #814 (docs).

Routes (registered under wsAuth — bearer token binds to :id):
  GET  /workspaces/:id/mcp/stream  — SSE transport (backwards compat)
  POST /workspaces/:id/mcp         — Streamable HTTP transport (primary)

Security conditions from review (all mandatory):
  C1: WorkspaceAuth middleware rejects requests without valid bearer token
  C2: MCPRateLimiter (120 req/min/token, SHA-256 keyed) applied on both routes
  C3: commit_memory/recall_memory with scope=GLOBAL → permission error;
      send_message_to_user excluded unless MOLECULE_MCP_ALLOW_SEND_MESSAGE=true

Tools: list_peers, get_workspace_info, delegate_task, delegate_task_async,
check_task_status, send_message_to_user (opt-in), commit_memory, recall_memory.
All mirror workspace-template/a2a_mcp_server.py TOOLS list.

Also adds: org-templates/molecule-dev/opencode.json, docs/integrations/opencode.md,
.env.example entries for MOLECULE_MCP_ALLOW_SEND_MESSAGE and MOLECULE_MCP_URL.

Tests: 29 new tests (20 handler + 9 middleware). All passing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 19:25:22 +00:00
..
mcp_ratelimit_test.go feat(platform): opencode MCP bridge — remote A2A tools over HTTP (#800) 2026-04-17 19:25:22 +00:00
mcp_ratelimit.go feat(platform): opencode MCP bridge — remote A2A tools over HTTP (#800) 2026-04-17 19:25:22 +00:00
ratelimit_test.go fix(router): call SetTrustedProxies(nil) to close IP-spoofing bypass (#179) 2026-04-15 17:32:54 +00:00
ratelimit.go fix: #93 category_routing + #105 X-RateLimit headers 2026-04-15 00:23:46 -07:00
securityheaders_test.go fix(platform): pin X-Content-Type-Options nosniff + add /orgs API prefix (#614) 2026-04-17 06:02:18 +00:00
securityheaders.go fix(platform): pin X-Content-Type-Options nosniff + add /orgs API prefix (#614) 2026-04-17 06:02:18 +00:00
tenant_guard_test.go fix(auth): TenantGuard same-origin bypass for EC2 tenant Canvas 2026-04-16 18:22:23 -07:00
tenant_guard.go fix(auth): TenantGuard same-origin bypass for EC2 tenant Canvas 2026-04-16 18:22:23 -07:00
wsauth_middleware_test.go test(security): route-specific #684 regression — three vulnerable admin routes 2026-04-17 15:25:41 +00:00
wsauth_middleware.go fix(auth): tighten AdminAuth to reject workspace bearer tokens when ADMIN_TOKEN is set (#684) 2026-04-17 15:08:54 +00:00