Skip to content

test(mcp): verify package-first client against enterprise mocks - #2699

Closed
reachjalil wants to merge 21 commits into
different-ai:devfrom
reachjalil:feature/enterprise-mcp-client-verification
Closed

reachjalil wants to merge 21 commits into
different-ai:devfrom
reachjalil:feature/enterprise-mcp-client-verification

Conversation

@reachjalil

@reachjalil reachjalil commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

Warning

Verification-only branch — do not merge as the production feature.

This draft composes #2670 and #2694 on current upstream dev so they can be tested together without destroying their separate review boundaries.

Managerial summary

This rehearsal answers one question: can the new package-first enterprise MCP client operate correctly against realistic, independently packaged Microsoft and ServiceNow fixtures?

Yes, after the rehearsal found and corrected one important source-attribution defect in #2694.

The final automated journey proves for both providers:

OAuth discovery
→ pre-registered confidential client
→ PKCE browser authorization
→ token commit
→ authenticated MCP initialize
→ complete paged catalog
→ representative safe read
→ clean shutdown

It separately proves that an invalid client secret fails specifically at OAuth token exchange.

Microsoft 365 and fixture scope

This PR verifies the provider-neutral remote MCP package against Microsoft-shaped and ServiceNow-shaped mock fixtures. It does not add those provider products as production quick-add connectors.

OpenWork's existing Microsoft 365 quick add remains a separate native OAuth/Microsoft Graph integration and does not exercise @openwork/enterprise-mcp-client. Jalil verified that native connection independently. The Microsoft Enterprise row below is a deterministic remote-MCP fixture, not a claim that Microsoft 365 quick add was migrated.

The long-term direction is to consolidate reusable remote MCP behavior behind package contracts. Migrating native Microsoft 365 or every connection type is outside this verification PR.

Sources and upstream status

Source Purpose Status in this rehearsal
Upstream dev Includes merged structured diagnostics #2669 Current base; no duplicate #2669 implementation
#2670 Package-first mock server and protected EE lab Merged only for verification
#2694 Package-first enterprise MCP client and Den adapters Merged only for verification

The source branches remain the authoritative implementation PRs. Fixes found here were committed back to their source owner before this rehearsal was rerun.

Verification matrix

Provider fixture Healthy proof Negative proof Result
ServiceNow inbound MCP confidential OAuth, PKCE, MCP initialize, complete catalog, lookup_incidents safe read wrong client secret Passed; first failure is oauth-token-exchange
Microsoft Enterprise MCP mock fixture Entra-shaped confidential OAuth, PKCE, MCP initialize, complete catalog, safe query suggestion wrong secret with AADSTS7000215 fixture Passed; first failure is oauth-token-exchange

What the rehearsal found

Failure-source attribution bug

The token endpoint returned invalid_client, then the MCP SDK performed a later successful authorization-server metadata request while cleaning up. The client reported the last request (oauth-server-discovery) instead of the last failed request (oauth-token-exchange).

That would have sent an administrator to the wrong owner and violated the core diagnostic requirement.

The correction in #2694 now tracks:

  • lastRequestPhase for successful-operation tracing; and
  • lastFailedRequestPhase for terminal error attribution.

Azure localhost callback mismatch

The original mock redirect validator accepted literal loopback IPs but rejected http://localhost/.... The real Azure development registration and successful Den callback use localhost. #2670 now accepts exact localhost, 127.0.0.1, and [::1] loopback callbacks. The protected lab UI uses a separate exact literal loopback origin (127.0.0.1 by default, optionally [::1]) and never treats localhost as equivalent.

The callback is never normalized: the mock registers and compares exactly what Den displays.

Automated validation

pnpm --filter @openwork/enterprise-mcp-client test
pnpm --filter @openwork/enterprise-mcp-client typecheck
git diff --check

Result: 23 client-package tests plus 4 mock-owned cross-package integration scenarios passed:

  1. healthy ServiceNow OAuth/MCP/catalog/safe-read;
  2. ServiceNow invalid client secret;
  3. healthy Microsoft OAuth/MCP/catalog/safe-read;
  4. Microsoft invalid client secret with Entra-shaped evidence.

The test command builds the mock through its public package export before importing it. It does not bypass the package boundary with a relative source import.

The source mock suites also pass:

  • reusable mock package: 162 tests;
  • standalone lab: 24 tests, including the four client/mock integration scenarios;
  • protected EE lab: 20 tests / 125 expectations.

Interactive review environment

Full instructions are in docs/enterprise-mcp-client-verification.md.

The local setup runs:

  • isolated Den with DEN_ENABLE_ENTERPRISE_MCP_CLIENT=true;
  • isolated MySQL database and seeded Alex demo administrator;
  • protected loopback Enterprise Mock Lab;
  • separate provider data-plane listeners.

For OAuth, register Den's exact callback. If Den prints http://localhost:<port>/..., keep localhost. The lab UI's own exact literal loopback origin is a separate security boundary.

The integration test is owned by the standalone mock lab, so the production client package has no mock dependency. This keeps Den's pruned Docker workspace installable while still testing both packages through their public contracts.

Manual package-path checkpoint

With DEN_ENABLE_ENTERPRISE_MCP_CLIENT=true, Jalil observed a successful browser callback for the external MCP connection. Safe mock events prove OAuth discovery, user authorization, token acquisition, resource validation, MCP initialization, and notifications/initialized. OpenWork then displayed Connected as you. Full catalog pagination and the representative safe read are automated evidence above, not yet a personal UI checkpoint.

What this proves—and does not

Proved:

  • explicit package dependency direction;
  • injected network and persistence contracts;
  • confidential OAuth and PKCE for both provider families;
  • exact first failure attribution;
  • full catalog pagination;
  • representative safe reads;
  • secret non-echo and clean shutdown.

Not proved:

  • a customer ServiceNow family/patch/ACL/domain/network;
  • Microsoft tenant eligibility or current preview rollout;
  • real Microsoft or ServiceNow provider operations;
  • customer proxy/custom CA/egress/Conditional Access;
  • mutation approval or production rollout.

This rehearsal reduces integration risk. It does not replace approved nonproduction tenant verification or maintainer acceptance of either source PR.

@vercel

vercel Bot commented Jul 13, 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:19am

@vercel

vercel Bot commented Jul 13, 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 reachjalil closed this Jul 13, 2026

This branch was successfully deployed

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

1 participant