Skip to content

feat(relay): MCP server for AI coding agents and an AI agents dashboard page - #7

Merged
hallelx2 merged 4 commits into
mainfrom
halleluyaholudele/hal-2417-mcp
Oct 8, 2026
Merged

hallelx2 merged 4 commits into
mainfrom
halleluyaholudele/hal-2417-mcp

Conversation

@hallelx2

@hallelx2 hallelx2 commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

What

BridgeHook becomes a remote MCP server so coding agents (Claude Code, Cursor, VS Code, Codex) can build and debug webhook handlers against the user's real local server, with nothing installed.

Relay

  • /mcp: Streamable HTTP, stateless, JSON responses (official MCP SDK 1.32 web-standard transport) inside the Worker. Auth via agent token (Bearer dvc_…), any device token, or session; otherwise 401 + WWW-Authenticate.
  • Tools: list_webhook_urls, create_webhook_url (same port → same URL; relay keeps only a public key until the extension adopts the channel), set_response_mode, send_test_event (Stripe, GitHub, OpenAI Standard Webhooks, ElevenLabs, Vapi, generic; provider-exact signatures when given the endpoint secret; full intake; returns the sync reply or waits for the answer), wait_for_webhook, get_event, list_events, replay_event. All owner-scoped.
  • Agent tokens: device kind agent, excluded from the device cap, max 10/account.
  • rotate-key accepts device tokens (extension adopts agent-created channels; also needed by the CLI).
  • event-store.ts (shared replay + owned-event reads), test-events.ts (samples + signers), mcp reserved path.

Web: Dashboard › AI agents: create token (shown once) with setup for Claude Code, Cursor, VS Code, Codex; list/revoke; agent tokens hidden from Devices. Docs: AI agents (MCP) page. Copy no longer mentions an unreleased CLI.

Verification

  • Unit: relay 69/69, incl. signer tests against Node's HMAC (Stripe v1, GitHub sha256, Standard Webhooks) and the ElevenLabs SDK's constructEvent algorithm (verified from SDK source).
  • MCP e2e (official MCP client + real extension in Chromium + local relay/D1), 23/23: 401 without token; agent token mints although Free's single device is used, a second real device is still refused; 8 tools listed + instructions; create_webhook_url idempotent per port; extension adopts the agent-created channel (same id); signed Stripe test event verified by the local handler, agent sees the handler's real 500 error body; get_event shows stripe-signature; after the "fix" replay_event returns 200 verified; wait_for_webhook catches a real webhook with its answer; list tools work; sync Vapi tool call returns the handler's reply; another account's agent cannot read or send.
  • Dashboard e2e (Chromium), 12/12: nav item, empty state, create token, Claude/Cursor/VS Code/Codex snippets carry the token, Copy works, the token minted on the page works over MCP (8 tools), revoke → 401, agent tokens absent from Devices. Screenshot checked.
  • Regression: channel-host probe 18/18, auth e2e 16/16. pnpm -r typecheck, pnpm lint, web + docs builds; Worker bundle 700 KiB gzip (GitHub Actions cannot start: billing lock).

No migration (agent kind is a value in the existing devices.kind column).

Closes HAL-2417

Summary by Sourcery

Enable AI coding agents to build and debug local webhook handlers through an authenticated remote MCP server, with dashboard token management and provider-aware testing tools.

New Features:

  • Add a remote, stateless MCP server that lets authenticated AI coding agents create webhook URLs, send provider-style test events, inspect and replay events, and wait for real webhook traffic.
  • Add an AI agents dashboard for issuing, configuring, listing, and revoking agent tokens for Claude Code, Cursor, VS Code, and Codex.
  • Add documentation covering MCP authentication, client setup, available tools, and the local webhook forwarding workflow.

Bug Fixes:

  • Allow device-token clients to adopt channels created by agents or other clients through key rotation.
  • Ensure synchronous webhook failures expose the associated event ID for subsequent inspection.

Enhancements:

  • Separate agent tokens from regular device limits while enforcing a dedicated per-account token cap.
  • Share ownership-scoped event inspection and replay behavior between the dashboard API and MCP server.
  • Keep agent tokens out of the Devices dashboard and reserve the MCP path from webhook channel routing.

Build:

  • Add the official MCP SDK and Zod dependencies to the relay.

Documentation:

  • Document AI agent MCP integration and setup examples for supported coding agents.

Tests:

  • Add provider signature and sample-event tests for Stripe, GitHub, OpenAI Standard Webhooks, ElevenLabs, and Vapi.
  • Extend synchronous response tests to cover event ID propagation.

…rd page

A coding agent can now run the whole webhook loop against the user's real
local server with nothing installed: get a permanent URL for a port, fire a
realistic signed provider webhook, read exactly what the handler answered,
fix the code, replay.

Relay
- /mcp: MCP Streamable HTTP, stateless with JSON responses (official SDK
  1.32 web-standard transport), running inside the Worker. Auth: agent
  token (Bearer dvc_...), any device token, or the session; 401 with
  WWW-Authenticate otherwise. Server instructions describe the loop.
- Tools: list_webhook_urls, create_webhook_url (same port, same URL; the
  relay keeps only a public key until the extension adopts the channel),
  set_response_mode, send_test_event (Stripe, GitHub, OpenAI Standard
  Webhooks, ElevenLabs, Vapi, generic; signed like the provider when given
  the endpoint secret; delivered through full intake, returns the sync reply
  or waits for the answer), wait_for_webhook, get_event, list_events,
  replay_event (waits for the new answer). All owner-scoped.
- Agent tokens: device kind "agent", excluded from the device cap, at most
  10 per account.
- rotate-key accepts device tokens, so the extension adopts channels created
  by an agent (also needed by the CLI).
- Replay and owned-event reads move to event-store.ts, shared by the
  dashboard API and MCP. Provider samples and signers in test-events.ts,
  checked against Node's HMAC and the ElevenLabs SDK's verification.
- "mcp" is a reserved path segment.

Web: Dashboard > AI agents mints a token, shows it once with setup for
Claude Code, Cursor, VS Code and Codex, lists and revokes tokens; agent
tokens no longer appear under Devices. Docs: AI agents (MCP) page.
Copy no longer mentions a CLI that has not shipped.
@sourcery-ai

sourcery-ai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Sorry @hallelx2, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 8 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1e1f1758-e72f-4d5e-8a54-23b3ad227133
📥 Commits

Reviewing files that changed from the base of the PR and between 88ef5a0 and ef93ff4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (24)
  • apps/web/src/App.tsx
  • apps/web/src/components/DashboardLayout.tsx
  • apps/web/src/lib/me-api.ts
  • apps/web/src/pages/AiAgents.tsx
  • apps/web/src/pages/ChannelsList.tsx
  • apps/web/src/pages/DevicesList.tsx
  • docs/src/App.tsx
  • docs/src/components/Layout.tsx
  • docs/src/pages/AiAgents.tsx
  • relay/.gitignore
  • relay/package.json
  • relay/src/access.ts
  • relay/src/event-store.ts
  • relay/src/identity.ts
  • relay/src/index.ts
  • relay/src/mcp.ts
  • relay/src/routes/me-devices.ts
  • relay/src/routes/me.ts
  • relay/src/sync.test.ts
  • relay/src/sync.ts
  • relay/src/test-events.test.ts
  • relay/src/test-events.ts
  • relay/src/webhook-url.ts
  • relay/tsconfig.json
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR turns BridgeHook into an authenticated remote MCP server backed by the existing relay, extension delivery, sync, event-store, and replay flows, adds separately quota-managed agent tokens with a dashboard onboarding experience, and documents setup for major AI coding clients.

Sequence diagram for an AI agent webhook debugging loop

sequenceDiagram
    participant Agent as AI coding agent
    participant MCP as Relay MCP /mcp
    participant DB as D1 event store
    participant Extension as Chrome extension
    participant Local as Local webhook server

    Agent->>MCP: create_webhook_url(port)
    MCP->>DB: Create or find owned channel
    MCP-->>Agent: Permanent webhook URL
    Extension->>MCP: Adopt channel with same port
    Agent->>MCP: send_test_event(channel_id, provider, signing_secret)
    MCP->>MCP: buildTestEvent(provider)
    MCP->>DB: Store webhook event
    MCP->>Extension: Queue delivery
    Extension->>Local: Forward signed webhook
    Local-->>Extension: Handler response
    Extension->>DB: Store response status and body
    MCP->>DB: waitForAnswer(event_id)
    MCP-->>Agent: Event and real handler response
    Agent->>MCP: replay_event(event_id)
    MCP->>DB: queueReplay()
    MCP->>Extension: Notify replay
    Extension->>Local: Forward replay
    Local-->>Extension: Fixed handler response
    Extension->>DB: Store replay response
    MCP-->>Agent: Replay result
Loading

File-Level Changes

Change Details Files
Adds a stateless, authenticated Streamable HTTP MCP server in the Worker for end-to-end webhook development and debugging.
  • Registers the /mcp route using the official MCP SDK with JSON responses and sessionless transport.
  • Exposes eight owner-scoped tools for channel creation/listing, response mode management, provider test events, event waiting/inspection/listing, and replay.
  • Adds realistic Stripe, GitHub, OpenAI Standard Webhooks, ElevenLabs, Vapi, and generic payload generation with provider-compatible signatures.
  • Reuses full webhook intake, sync response handling, D1 event storage, extension delivery, and replay notification paths.
relay/src/index.ts
relay/src/mcp.ts
relay/src/test-events.ts
relay/src/event-store.ts
relay/src/test-events.test.ts
relay/package.json
relay/src/webhook-url.ts
relay/src/sync.ts
Introduces agent-token authentication and account-scoped lifecycle/quota handling without a schema migration.
  • Adds agent as a device kind and excludes active agent tokens from the regular device cap.
  • Enforces a maximum of ten active agent tokens per account.
  • Allows device-token authentication for channel adoption and event/replay access, while retaining session authentication.
  • Adds ownership checks for MCP channels and events and centralizes replay/event serialization logic.
relay/src/access.ts
relay/src/routes/me-devices.ts
relay/src/routes/me.ts
relay/src/event-store.ts
Adds a dashboard workflow for creating, configuring, listing, and revoking AI-agent MCP tokens.
  • Adds an authenticated AI agents page and navigation entry.
  • Displays newly minted tokens once and generates setup snippets for Claude Code, Cursor, VS Code, and Codex.
  • Lists and revokes agent tokens separately from regular devices.
  • Updates client API and device filtering to support the agent kind.
apps/web/src/App.tsx
apps/web/src/components/DashboardLayout.tsx
apps/web/src/pages/AiAgents.tsx
apps/web/src/lib/me-api.ts
apps/web/src/pages/DevicesList.tsx
Documents the MCP integration and removes obsolete CLI references from user-facing relay guidance.
  • Adds AI agents (MCP) documentation with endpoint authentication, client setup, tool reference, forwarding behavior, and example workflow.
  • Updates navigation to expose the new documentation page.
  • Clarifies that the extension, rather than an unreleased CLI, forwards events to localhost.
docs/src/App.tsx
docs/src/components/Layout.tsx
docs/src/pages/AiAgents.tsx
apps/web/src/pages/ChannelsList.tsx
relay/src/sync.ts
Integrates the MCP implementation and validation dependencies into the workspace build configuration.
  • Adds the MCP SDK and Zod dependencies.
  • Excludes Vitest test files from the Worker TypeScript compilation.
relay/package.json
pnpm-lock.yaml
relay/tsconfig.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

… secret errors

Review of PR #7:
- Agent tokens only authenticate on /mcp. Elsewhere they are rejected, so
  they cannot run as uncapped devices (POST /api/channels) or rotate a
  channel's key out from under the user's extension and answer its sync
  requests. Real executors still count against the device cap.
- send_test_event passes the forward path to intake explicitly, so a
  self-hosted relay without TUNNEL_DOMAIN no longer forwards to
  /<channelId>/path.
- In sync mode send_test_event returns after wait_seconds instead of
  blocking for the channel's whole sync timeout.
- A malformed OpenAI signing secret is a clear tool error, not a crash.
- Dashboard and docs say agent tokens only work with the MCP server.
Review follow-ups on the MCP server:
- replay_event runs checkReplay like the dashboard route, so a
  read-only account (ended trial, canceled plan) cannot queue replays
  through /mcp.
- create_webhook_url applies `label` to an existing port's channel
  instead of dropping it.
- send_test_event on a sync channel no longer leaves the delivery
  promise unobserved: it is settled, kept alive with waitUntil, and a
  relay refusal (allow-list 403, daily cap 429) is reported as an error
  rather than "still waiting". The race gives at least 2s so those
  refusals surface even at wait_seconds 0.
- 504/502 sync replies carry X-BridgeHook-Event-Id like a delivered
  reply, so senders and the agent can look the event up.
- The resolveReader docblock now says rotate-key accepts device tokens.
@hallelx2
hallelx2 merged commit 2ba1f35 into main Oct 8, 2026
2 of 6 checks passed
@hallelx2
hallelx2 deleted the halleluyaholudele/hal-2417-mcp branch October 8, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant