Add webhook notifications and an MCP server#9
Merged
Conversation
Webhooks: the service layer now emits domain events (goal.created, plan.created, signal.received, replan.completed, outcome.recorded, goal.status_changed) behind a Notifier interface, nop by default like Metrics. internal/webhook delivers them best-effort: buffered async queue, retries with exponential backoff and jitter, HMAC-SHA256 signature header, graceful drain on shutdown, and a dde_webhook_deliveries_total counter. Configured via DDE_WEBHOOK_*; disabled when no URL is set. MCP: internal/mcp exposes the use-cases as Model Context Protocol tools (evaluate, create_goal, generate_plan, submit_signal, record_outcome, and the read/lifecycle tools) over two transports: a new "dde mcp" stdio command and a streamable HTTP endpoint at /mcp on the API server, sharing the live service. Tool errors mirror the REST status mapping. Plan-version outputs are untyped because provenance carries raw source payloads (json.RawMessage), which schema inference would mistype. The per-request timeout middleware now wraps only the REST and operational routes, and the connection write deadline is removed, so long-lived MCP streams are not severed. Service wiring shared by serve and mcp is extracted into buildService.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two integration surfaces for the engine:
Webhook event notifications — the service layer emits domain events (
goal.created,plan.created,signal.received,replan.completed,outcome.recorded,goal.status_changed) behind aNotifierinterface (nop by default, mirroringMetrics).internal/webhookdelivers them best-effort: buffered async queue, retries with exponential backoff + jitter, HMAC-SHA256X-DDE-Signature, graceful drain,dde_webhook_deliveries_total{event,result}metric. Enabled byDDE_WEBHOOK_URL; off by default.MCP server —
internal/mcpexposes the use-cases as 10 MCP tools via the officialmodelcontextprotocol/go-sdk, over two transports:dde mcp(stdio) for Claude Code/Desktop and agent runtimes; logs on stderr, stdout is JSON-RPC only/mcpon the API server, sharing the live service with RESTTool error messages mirror the REST status mapping. Plan-version outputs are untyped because provenance carries raw source payloads (
json.RawMessage), which schema inference mistypes.Notable changes
buildServiceextracted incmd/dde— serve and mcp share storage/engine/webhook/queue wiring and shutdown ordering (replan drain → webhook drain → repo close)WriteTimeoutremoved so long-lived MCP streams surviveDDE_WEBHOOK_{URL,SECRET,TIMEOUT,RETRIES,EVENTS}docs/mcp.md(new), webhooks section indocs/api.md, README updatesTesting
go test ./... -racegreen across all packages; golangci-lint 0 issuesinternal/app/notify_test.go), dispatcher behaviour incl. retries/HMAC/overflow/drain (internal/webhook), MCP client round-trips over in-memory transports (internal/mcp),/mcpmount + timeout scoping (internal/api)serve; MCP stdio handshake; MCP-over-HTTP session seeing REST-created goals