Skip to content

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

Merged
benjaminshafii merged 9 commits into
different-ai:devfrom
reachjalil:feature/mcp-diagnostic-mock-server
Jul 13, 2026
Merged

benjaminshafii merged 9 commits into
different-ai:devfrom
reachjalil:feature/mcp-diagnostic-mock-server

Conversation

@reachjalil

@reachjalil reachjalil commented Jul 11, 2026 •

Copy link
Copy Markdown
Member

Important

Review status: focused local and GitHub verification pass. Jalil confirmed a real native Microsoft 365 connection and manually completed the package-driven OAuth/MCP initialization path against this lab. Catalog and safe-read behavior are additionally automated. This remains a draft while the fault walkthrough is reviewed.

Managerial summary

We set out to create a safe development environment where enterprise MCP behavior can be reproduced without depending on a customer tenant for every test.

This PR establishes that foundation in two clean layers:

  • @openwork/enterprise-mcp-mock-server: a reusable TypeScript package containing provider profiles, OAuth/MCP contracts, deterministic faults, runtime state, and test helpers.
  • @openwork-ee/enterprise-mock-lab: a standalone EE administrator app used to create, configure, start, stop, reset, probe, and delete local mock instances.

It does not change Den's production connection implementation. Den integration is reviewed separately in #2694, and combined proof is isolated in #2699.

Microsoft 365 and package scope

The Microsoft-named profiles in this lab are fixtures, not new production connectors. They let the generic remote MCP client rehearse Microsoft-shaped OAuth, catalog, and failure behavior without claiming that OpenWork added Microsoft Enterprise MCP, Work IQ, or Agent 365 as quick-add integrations.

OpenWork's existing Microsoft 365 quick add remains a separate native OAuth/Microsoft Graph integration. Jalil verified that native connection successfully, but it does not exercise this mock package or the package-first remote MCP client.

The longer-term direction is to put reusable remote MCP behavior behind package contracts. This PR provides the test foundation; it does not migrate native Microsoft 365 or claim that every connection already uses the package.

What existed and what this adds

Before Added here User/maintainer outcome
Enterprise failures were difficult to reproduce without a live provider. Declarative Microsoft and ServiceNow profiles plus phase-specific fault scenarios. A reviewer can intentionally reproduce one known failure at a time.
Mock behavior was mixed with application-specific concerns. A reusable package plus a separate admin lab app. Future tests can import a stable public contract without importing Den.
“Connected” could be confused with “provider operation works.” Three explicit levels: connection, catalog readiness, and provider operation. Evidence states exactly what was and was not proven.
Scenario changes could destroy a valid OAuth session even when the OAuth contract was unchanged. preserve-compatible-oauth retains only compatible, unexpired authority and resets all unsafe transient state. A developer can move between compatible faults without repeating consent unnecessarily.
A mock invalid-client response was too generic. Provider-specific invalid-client behavior for Microsoft Entra and ServiceNow. Den diagnostics can be tested against realistic provider-shaped errors.

Provider behavior represented

The package includes dated, explicit mock fixture profiles for:

  • ServiceNow inbound MCP onboarding;
  • Microsoft Work IQ;
  • Microsoft Enterprise MCP;
  • Agent 365 Mail preview; and
  • a standards-oriented synthetic enterprise control.

The profiles model OAuth discovery, exact redirect validation, confidential clients, PKCE, scopes/resources, token/refresh behavior, Streamable HTTP MCP initialization, sessions, pagination, catalogs, provider authorization failures, throttling, and operation errors.

These are deterministic development fixtures, not claims of live-provider conformance. Synthetic fields and known gaps are labeled in the profiles and documentation.

Important Azure localhost behavior

Real Microsoft 365 verification confirmed that Den's local callback is an exact URL such as:

http://localhost:<den-api-port>/v1/oauth-providers/microsoft-365/connect/callback

The mock now accepts exact HTTP OAuth callbacks on localhost, 127.0.0.1, and [::1], matching native-app loopback development behavior. It still rejects lookalike hosts, credentials, fragments, and non-loopback HTTP callbacks.

The admin lab uses an exact literal loopback origin: 127.0.0.1 by default, with literal [::1] also supported. It does not treat localhost as equivalent. This is a separate trust boundary from the provider OAuth callback and should not be normalized or interchanged.

Matching the real Microsoft and ServiceNow failures

Microsoft's oauth-invalid-client scenario now returns an Entra-shaped safe response:

  • HTTP 401;
  • invalid_client;
  • AADSTS7000215 / error code 7000215;
  • trace, correlation, and timestamp fields; and
  • remediation that distinguishes the client secret value from the secret ID.

The ServiceNow profile returns its own provider-specific invalid_client response and does not leak Microsoft terminology. Its wording is explicitly synthetic until an approved live ServiceNow tenant capture is available.

Neither response echoes the submitted secret.

Diagnostic levels

Level Question answered Example faults
Connection Can OAuth and MCP transport setup complete? invalid client, redirect mismatch, scope/resource failure, TCP refusal, MCP version/session failure
Readiness Is the advertised catalog complete and safe to consume? empty catalog, cursor loop, duplicate tool, invalid schema
Operation Can a provider-style request pass authorization and execution? provider ACL denial, throttling, unavailability, timeout after commit

Verification completed

  • reusable mock package: 162 local tests passed on Node 24;
  • the five restart/continuity cases passed five consecutive focused runs after stale keep-alive sockets were eliminated at scenario-restart boundaries;
  • standalone lab: 20 tests / 125 expectations passed;
  • package strict TypeScript check passed;
  • lab production build passed;
  • exact localhost, IPv4 loopback, IPv6 loopback, and unsafe-lookalike callback cases passed;
  • Microsoft and ServiceNow invalid-client payload and secret-redaction cases passed;
  • compatible OAuth continuity and incompatible/reset paths passed; and
  • git diff --check passed.

The combined client-to-mock proof in #2699 additionally verifies healthy and wrong-secret paths for both Microsoft Enterprise and ServiceNow through the packages' public exports.

What this does not prove

  • no real customer ServiceNow tenant was tested;
  • the mock Microsoft profiles do not replace the successful native Microsoft 365 OAuth check;
  • no customer proxy, CA, egress policy, Conditional Access, license, region, or consent posture was exercised;
  • synthetic provider results do not prove live ACL or business behavior; and
  • Jalil has not yet completed the manual Den-to-mock UI walkthrough.

Suggested review path

  1. Review the package/app boundary and the explicit provider fidelity labels.
  2. Open the lab on its exact displayed loopback URL (127.0.0.1 by default; [::1] when explicitly configured).
  3. Create a healthy ServiceNow instance using Den's exact localhost callback.
  4. Connect from Den and confirm catalog readiness.
  5. Switch to ServiceNow invalid client and confirm the failure source is token exchange.
  6. Repeat healthy and invalid-client checks with Microsoft Enterprise.
  7. Record Jalil's observations before this foundation is marked ready.

Related PRs

  • #2669 — structured MCP diagnostics, now merged into dev.
  • #2698 — safe native OAuth token-exchange errors learned from the real Microsoft 365 check.
  • #2694 — package-first enterprise MCP client.
  • #2699 — verification-only client/mock integration proof.
  • #2674 — controlled release and human-verification ledger.

@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 2:17am

@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 e1569ec and was exercised in the independent combined rehearsal, #2675.

The rehearsal confirmed the realistic pre-registered ServiceNow-style confidential-client path, the read-only catalog test, distinct credential and provider-permission failures, stable UI row targeting, bounded callback replacement, listener cleanup, fail-closed runtime controls, and operation-only denial and throttling faults.

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.

@reachjalil
reachjalil force-pushed the feature/mcp-diagnostic-mock-server branch from e1569ec to ababe2a Compare July 12, 2026 20:47
@reachjalil reachjalil changed the title feat(mcp): add enterprise diagnostic mock server feat(mcp): add package-first enterprise mock lab Jul 12, 2026

Copy link
Copy Markdown
Member

Validation update for exact head 499cd89a32fcdd61095edf1ac751647eeaac3c03:

  • Reusable enterprise mock package: 156/156 passed.
  • Standalone lab: 19/19 passed, 116 assertions.
  • Builds and typechecks passed.
  • Independent security/release audit found no blocker across loopback isolation, SSRF, secrets, CSRF/session handling, mutation approval/idempotency, fault fidelity, and cleanup.
  • GitHub product checks are green. The remaining Vercel failures are authorization contexts, not test failures.

Six-frame proof: https://8090-7v2blkfngnbivktq.daytonaproxy01.net/pr2670-exact-499cd/2026-07-12T21-48-09-300Z/fraimz.html

Disposition: test-ready, but intentionally left draft and unmerged.

@benjaminshafii
benjaminshafii marked this pull request as ready for review July 13, 2026 02:49
@benjaminshafii
benjaminshafii merged commit 9333856 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]>
@reachjalil
reachjalil deleted the feature/mcp-diagnostic-mock-server branch July 17, 2026 07:06

This branch was successfully deployed

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