Skip to content

feat(mcp): add package-first enterprise MCP client - #2694

Merged
benjaminshafii merged 5 commits into
different-ai:devfrom
reachjalil:feature/enterprise-mcp-client
Jul 13, 2026
Merged

benjaminshafii merged 5 commits into
different-ai:devfrom
reachjalil:feature/enterprise-mcp-client

Conversation

@reachjalil

@reachjalil reachjalil commented Jul 12, 2026 •

Copy link
Copy Markdown
Member

Important

Review status: the package and Den adapter are automated-test complete. Cross-package testing found and fixed one important diagnostic attribution bug. Live Microsoft 365 native OAuth was verified separately; live Microsoft Enterprise MCP and ServiceNow MCP are not yet verified.

Managerial summary

This PR introduces a package-first reference implementation for Den's outbound enterprise MCP connections.

The application behavior lives in @openwork/enterprise-mcp-client; Den supplies infrastructure through explicit adapters for guarded network access, encrypted credentials, OAuth transactions, client registration, and structured diagnostics.

The new path is opt-in:

DEN_ENABLE_ENTERPRISE_MCP_CLIENT=true

Unset or false preserves current behavior. Invalid values fail startup. A failed request never silently falls back to another implementation.

Microsoft 365 and package scope

This is a provider-neutral implementation of standard remote MCP connections added by URL. The word enterprise describes its security, persistence, lifecycle, and diagnostic guarantees; it does not make the package specific to Microsoft Enterprise MCP.

OpenWork's Microsoft 365 quick add is currently a separate native OAuth/Microsoft Graph path. Jalil verified that native path successfully, but DEN_ENABLE_ENTERPRISE_MCP_CLIENT=true does not reroute it through this package. The flag selects Den's external MCP connection runtime only.

The future direction is to consolidate reusable remote MCP behavior behind package contracts. Migrating native Microsoft 365—or every other connection type—is outside this PR and requires a separate design and verification decision.

What existed and what this adds

Before Added here Practical outcome
Protocol, OAuth callbacks, persistence, network policy, and route behavior were concentrated in Den. A provider-neutral application package with explicit ports and a narrow client API. The core behavior can be tested independently and reused without importing Den.
Storage contracts resembled SDK callbacks and left race/commit authority implicit. Explicit registration, authorization, credential, lifecycle, and compare-and-swap contracts. Timeout, callback, refresh, deletion, and concurrent authorization outcomes are deterministic.
Global network behavior could be implicit. Outbound fetch is mandatory injection. Den must consciously provide SSRF, redirect, timeout, and response-bound policy.
A general error could obscure the request that actually failed. Stable operation phases plus separate last-request and first/last-failed request tracking. The administrator is directed to the real source of failure.

Important finding from the new mock verification

The wrong-secret rehearsal found a real attribution bug:

  1. OAuth token exchange correctly failed with HTTP 401.
  2. The SDK then made a successful OAuth metadata cleanup/discovery request.
  3. The package reported that later successful request as the failure location.

That could have sent an administrator to troubleshoot discovery instead of the client secret.

This PR now tracks successful request progress and failed request evidence separately. Terminal errors use the preserved failed phase. The same rehearsal now reports:

phase: oauth-token-exchange
category: authentication

for both Microsoft and ServiceNow invalid-client scenarios.

Security and lifecycle behavior

  • signed OAuth state is required before network or persistence work;
  • PKCE transactions are state-bound, expiring, capped, and single-use;
  • client registration and credential commits use revisions and lifecycle fences;
  • a timeout cannot persist credentials after the operation has settled;
  • callback and deletion share deterministic locking/commit authority;
  • access-token, refresh-token, client-secret, and registration expiration are explicit;
  • tool inputs, catalogs, response bodies, redirects, and request lifetimes are bounded; and
  • diagnostics exclude tokens, secrets, OAuth codes, verifiers, tool arguments, provider bodies, and customer content.

Administrator-facing behavior

Den remains the public diagnostic authority. The package supplies precise safe evidence: operation, failed outbound request phase, stable category/code, and retry/ownership guidance.

Examples:

  • refused endpoint → network/TCP failure owned by a network administrator;
  • wrong client secret → OAuth token exchange/authentication failure owned by an organization administrator;
  • expired authorization transaction → member restarts Connect;
  • expired registration → organization administrator renews registration;
  • token 401 → reconnect/credential action, distinct from provider-policy 403;
  • MCP tool isError: true → provider operation failure, never a successful request.

Native Microsoft provider wording learned from the real 365 check is handled in #2698.

Verification completed

On this source branch:

  • package suite: 23 tests passed;
  • focused enabled-mode Den matrix passed;
  • current-mode Den regression matrix passed;
  • Den-backed OAuth lifecycle and encrypted persistence tests passed;
  • package and Den TypeScript checks/builds passed; and
  • git diff --check passed.

On the isolated combined verification branch #2699:

  • healthy ServiceNow OAuth → MCP → full catalog → safe read passed;
  • wrong ServiceNow secret was attributed to OAuth token exchange;
  • healthy Microsoft Enterprise OAuth → MCP → full catalog → safe read passed;
  • wrong Microsoft secret returned an Entra-shaped 401 and was attributed to OAuth token exchange; and
  • the client suite passed 23 tests and the mock-owned cross-package suite added 4 integration scenarios (27 combined checks).

Manual browser verification also passed with the enterprise flag enabled: Den created a per-member external MCP connection, used the mock's exact callback, completed OAuth token exchange, validated the MCP resource token, negotiated MCP, accepted notifications/initialized, and displayed Connected as you. The package catalog and safe-read checks remain automated rather than personally UI-verified.

The combined proof imports both packages through their public exports. It does not copy their source or bypass their declared build boundary.

What remains unproven

  • a real customer ServiceNow MCP tenant;
  • a real Microsoft Enterprise MCP, Work IQ, or Agent 365 tenant;
  • customer proxy/CA/allowlist, Conditional Access, consent, licensing, region, or provider patch posture;
  • production provider mutations; and
  • long-running production rollout/rollback behavior.

Review order

  1. Review the package public contract and dependency direction.
  2. Review Den's guarded network and encrypted transaction adapters.
  3. Reproduce healthy and wrong-secret ServiceNow paths with #2670.
  4. Repeat with Microsoft Enterprise.
  5. Verify the UI names the failing phase and safe owner/action.
  6. Only then enable in an internal Den environment; rollback is a restart with the flag unset/false.

Related PRs

  • #2669 — structured MCP diagnostics, merged into dev.
  • #2670 — package-first enterprise mock lab.
  • #2698 — safe native OAuth provider errors.
  • #2699 — isolated cross-package verification proof.
  • #2674 — controlled release and human-verification ledger.

@vercel

vercel Bot commented Jul 12, 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 2:58am

@vercel

vercel Bot commented Jul 12, 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.

@benjaminshafii
benjaminshafii merged commit 4c85588 into different-ai:dev Jul 13, 2026
11 checks passed
benjaminshafii pushed a commit that referenced this pull request Jul 13, 2026
* feat(den): add Microsoft 365 permission parity

* feat(mcp): add package-first enterprise mock lab (#2670)

* feat(mcp): add enterprise mock foundation artifacts

* chore(mcp): wire enterprise mock workspaces

* ci(mcp): enforce enterprise mock checks

* fix(mcp): emit a truly invalid schema fault

* feat(mcp): configure exact mock OAuth redirects

* feat(mcp): strengthen mock OAuth verification

* fix(mcp): accept Azure localhost OAuth callbacks

* fix(mcp): close mock sockets across scenario restarts

* fix(mcp): make mock listener restarts explicit

* fix(oauth): surface safe token exchange failures (#2698)

* fix(oauth): surface safe token exchange failures

* test(oauth): use synthetic provider diagnostics

* feat(mcp): add package-first enterprise MCP client (#2694)

* feat(mcp): add enterprise MCP client package

* refactor(mcp): harden enterprise client contracts

* fix(mcp): preserve the first failing request phase

---------

Co-authored-by: Benjamin Shafii <[email protected]>

* feat(den): add Microsoft 365 permission parity

* fix(oauth): use localhost for local Den callbacks

---------

Co-authored-by: Benjamin Shafii <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – openwork-landing — 56c4f58e 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