Skip to content

feat(mcp): add live connection diagnostic tracing - #2672

Closed
reachjalil wants to merge 11 commits into
different-ai:devfrom
reachjalil:feature/mcp-live-diagnostic-tracing
Closed

reachjalil wants to merge 11 commits into
different-ai:devfrom
reachjalil:feature/mcp-live-diagnostic-tracing

Conversation

@reachjalil

@reachjalil reachjalil commented Jul 11, 2026 •

Copy link
Copy Markdown
Member

Warning

Queue audit (2026-07-17): returned to draft — do not merge this revision. The live-diagnostics goal remains useful, but this 29-file / 16k-line branch predates the subsequently merged diagnostics endpoint, structured failure attribution, agent-context diagnostics, and current MCP recovery model. Rebuild only the missing persisted-timeline/SSE capability against current dev after confirming it is not already covered.

Important

Ready for review and merge. This branch is current with upstream/dev at 7ba1f09a; automated acceptance and current GitHub tests are green. The real-provider walkthroughs below remain useful release verification, but are not represented as completed customer-tenant validation.

Manager summary

This adds an administrator-only live diagnostic mode for remote MCP connections. It records the handshake from Den's point of view, shows the highest proven phase and immutable first failure, identifies the likely owner, and provides a safe next action without requiring access to server logs.

Connect remains the concise user-facing result. Diagnose is the detailed, persisted timeline beside it.

What administrators get

  • Progressive proof: Configured → Reachable → Authorized → Protocol Ready → Catalog Ready.
  • A live redacted timeline for network/TLS/HTTP, OAuth, MCP initialization, tool discovery, and continuity.
  • Durable tenant-scoped attempts/events retained for 24 hours, with SSE replay after refresh or disconnect.
  • Explicit continuation when provider authorization is required.
  • Safe reference IDs, retryability, likely action owner, and recommended remediation.
  • Cancellation and transactional cleanup when a connection is deleted.

Concurrency and trust boundaries

  • Administrator-only, tenant-scoped start/snapshot/SSE routes.
  • Signed OAuth state, single-use pending grants, generations, leases, credential-write fencing, and callback timeout handling.
  • Late callbacks cannot overwrite newer credentials or recreate a deleted connection.
  • The first failure remains authoritative instead of being replaced by cleanup noise.
  • Evidence is bounded and redacted: no tokens, secrets, provider payloads, tool arguments, customer content, or session identifiers.
  • Cleanup loops return stop handles and are shut down gracefully with the server.

Upstream integration

  • Preserves feat(mcp): add structured connection diagnostics #2669 structured diagnostic classification and safe Connect wording.
  • Preserves current OpenWork Connect OAuth hardening and the package/direct client selection boundary.
  • Combined proxy coverage now verifies both SSE replay and trace-context behavior.
  • Database migration was regenerated as 0037_woozy_night_nurse; rebase/regenerate if another schema PR lands first.

Validation

  • 208 focused checks passed across diagnostic persistence/routes/UI, observability/proxy behavior, enterprise MCP client, structured diagnostics, OAuth, URL guards, and Connect flows.
  • Types build, Den API production build, and Den Web typecheck passed.
  • Fresh schema push passed; repeat migration generation reports no schema changes.
  • GitHub schema/migration check, Linux/macOS OpenWork tests, and Den artifact builds passed on the current head.
  • No unresolved review threads or requested changes.

Review boundaries

  • No claim of validation against a real customer ServiceNow tenant.
  • Native Microsoft 365 quick-add remains its existing native-provider flow.
  • Catalog Ready proves catalog discovery, not a real provider read or mutation.
  • Cross-instance recovery of an in-flight authorization browser handoff is not claimed; interruption fails clearly and can be retried.

Recommended reviewer walkthrough

  1. Healthy mock reaches Catalog Ready and survives dialog refresh/reopen.
  2. Wrong secret fails at OAuth token acquisition without exposing the secret.
  3. Unreachable host is attributed to network/TCP.
  4. Malformed initialize leaves OAuth proven and fails MCP initialization.
  5. Empty catalog is described as a catalog outcome.
  6. Consent denial, deletion during a run, and both enterprise-client flag values behave as described.

@vercel

vercel Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-landing Ready Ready Preview, Comment, Open in v0 Jul 13, 2026 6:38pm

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@reachjalil is attempting to deploy a commit to the Different AI Team on Vercel.

A member of the Team first needs to authorize it.

@reachjalil

Copy link
Copy Markdown
Member Author

Agent integration rehearsal update — 2026-07-11

This source branch is published at 3e84bd3 and was exercised in the independent combined rehearsal, #2675.

The rehearsal confirmed post-OAuth resource-phase classification, diagnostic deletion and start-race cleanup, runner cancellation and recovery audit behavior, callback stability, and a visible Catalog Ready scope boundary that does not imply provider-operation readiness.

Status remains deliberately separate:

This PR remains based on upstream dev because the controlled parent branch exists only on the Jalil fork. #2674 is the approval ledger; this PR is the source and evidence branch.

Copy link
Copy Markdown
Member

Validation disposition: hold, do not merge this current head.

The live tracing direction is useful, but integration testing found additional runtime/security work that is not present on this PR head, including bounded JSON/SSE handling and cancellation, callback credential commit fencing, cross-replica authorization resume, stale-writer protection, and safe structured error mapping. The branch is also currently dirty against dev.

Those gaps were exercised and corrected in the isolated cumulative candidate. Final target behavior is green in production-mode fraimz, including version failure, fresh authorization retry, Catalog Ready, retained history, redaction, and cleanup:

https://8091-yqi40uufzdq9alcs.daytonaproxy01.net/cumulative-final/production-final-live/2026-07-12T23-24-30-595Z/fraimz.html

No merge or branch mutation performed.

@reachjalil
reachjalil marked this pull request as ready for review July 13, 2026 03:19
@reachjalil
reachjalil marked this pull request as draft July 13, 2026 03:22
…gnostic-tracing

# Conflicts:
#	ee/apps/den-api/src/capability-sources/external-mcp-connections.ts
#	ee/apps/den-api/src/routes/org/mcp-connections.ts
#	ee/apps/den-api/src/server.ts
…gnostic-tracing

# Conflicts:
#	packages/types/package.json
#	packages/types/src/index.ts
#	packages/types/tsup.config.ts
@reachjalil

Copy link
Copy Markdown
Member Author

Update after reviewing this hold against the current head:

The hold was valid for the head that existed when this comment was posted, but the named runtime/security gaps are now addressed on bb099d1a, which is synchronized with upstream/dev at 316b996c.

  • Bounded JSON/SSE handling and cancellation: response bodies, streams, catalogs, schemas, and cursors are bounded; discarded or aborted streams are cancelled. Den Web tests also cover malformed-stream and browser-abort cancellation.
  • Callback credential commit fencing: callback writes are bound to the encrypted single-use pending grant, client revision, diagnostic generation, active authorization claim, connection-row lock, and absolute lifecycle deadline. Losing/late callbacks cannot commit credentials.
  • Cross-replica authorization resume: signed state, PKCE grant, diagnostic attempt, generation, and callback claim are persisted, so callback completion is not tied to the original SSE subscriber or process. The intentional remaining boundary is narrower: an authorization URL that was never delivered before the originating process died is not reconstructed on another replica; the expired process lease becomes a clear retryable terminal result.
  • Stale-writer protection: DCR client revisions, authorization generations/leases, connection-row locking, and idempotent completion auditing reject stale or duplicate writers.
  • Safe structured error mapping: current dev's structured MCP diagnostics remain authoritative, while the live timeline persists only allowlisted/redacted evidence and preserves the immutable first failure.

The latest dev sync also brought in Microsoft 365 permission parity. The only merge conflicts were shared type-package exports; both the MCP diagnostic contract and Microsoft 365 contract are now exported and built.

Post-sync local verification:

  • Den API focused diagnostic/OAuth/Microsoft 365 matrix: 108 passed, 0 failed
  • Den Web diagnostic/proxy/Microsoft 365 matrix: 13 passed, 0 failed
  • @openwork/types build: passed
  • Den API production build: passed
  • git diff --check: passed

GitHub checks have restarted for this head and are still running. I would therefore treat the original blanket “do not merge this current head” disposition as outdated for the current head, while retaining the documented limitation around an authorization URL that was never delivered before process loss and keeping final merge subject to CI and the guided UI verification.

Copy link
Copy Markdown
Member Author

Closing during the 2026-07-27 repository-progress reconciliation. Its own queue audit says do not merge this stale 29-file revision because diagnostics endpoint, attribution, agent context, and recovery work landed later. No unmerged branch is being treated as delivered; any residual gap must be reproduced before new implementation.

@reachjalil reachjalil closed this Jul 27, 2026

This branch was successfully deployed

1 active deployment
Preview – openwork-landing — 4f96f71c Deployed Jul 13, 2026 by vercel[bot]
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.

2 participants