Skip to content

feat: replace McpAdapter with thin Scope3McpClient#130

Merged
EmmaLouise2018 merged 8 commits intomainfrom
EmmaLouise2018/slim-sdk-overhaul
Apr 1, 2026
Merged

feat: replace McpAdapter with thin Scope3McpClient#130
EmmaLouise2018 merged 8 commits intomainfrom
EmmaLouise2018/slim-sdk-overhaul

Conversation

@EmmaLouise2018
Copy link
Copy Markdown
Collaborator

Summary

  • Replaced the McpAdapter class (3 layers of indirection: callToolrequest() → typed resource methods) with a thin Scope3McpClient connection helper
  • MCP consumers now get direct callTool(), readResource(), and listTools() passthroughs — no unnecessary abstraction over what the MCP server already provides
  • Scope3Client is now REST-only, keeping typed resource methods where they make sense (humans, CLI, programmatic use)
  • Net -490 lines of code

Motivation

The v2 buyer MCP surface is 4 tools — api_call, ask_about_capability, help, health. MCP consumers (Claude, ChatGPT, Cursor) already have an MCP client. The server handles auth, routing, and validation. The typed resource methods were just a second abstraction over what api_call already does.

The real value for MCP consumers is:

  • A connection helper (auth + correct URL)
  • Re-exported CallToolResult / ReadResourceResult types
  • Zod schemas available for optional client-side validation

Not a full adapter that wraps callTool in request in typed resource methods.

What changed

File Change
src/mcp-client.ts New — thin Scope3McpClient with callTool/readResource/listTools
src/adapters/mcp.ts Deleted — removed McpAdapter indirection layer
src/client.ts Simplified to REST-only, removed adapter selection
src/types/index.ts Removed AdapterType, removed adapter config option
src/index.ts Updated exports, clear docs for two entry points

Test plan

  • All 230 existing tests pass (15 suites)
  • New mcp-client.test.ts covers: init, connect/disconnect, callTool, readResource, listTools, auto-connect, retry after failure
  • Type check passes
  • Lint passes

The McpAdapter wrapped callTool in request() in typed resource methods —
3 layers of indirection over what the MCP server already provides.
MCP consumers already have an MCP client; the server handles auth,
routing, and validation. The SDK was an unnecessary abstraction layer.

New architecture:
- Scope3McpClient: thin connection helper (auth + URL) with direct
  callTool/readResource/listTools passthroughs
- Scope3Client: REST-only, keeps typed resource methods where they
  make sense (humans, CLI, programmatic REST use)

Net -490 lines.
@EmmaLouise2018 EmmaLouise2018 requested a review from a team March 31, 2026 02:34
- Fix reconnect lifecycle: recreate transport/client in doConnect(),
  reset all state in disconnect() via finally block
- Add sanitizeForLogging to callTool debug output (security regression)
- Remove unused persona/version from Scope3McpClientConfig
- Use ListToolsResult from MCP SDK instead of lossy inline type
- Validate and trim apiKey (reject whitespace-only)
- Update README.md and docs/getting-started.md (remove stale adapter refs)
- Add 7 new tests: reconnect, error handling, concurrency
…est coverage

- Fix reporting validation bug (discarded return value)
- Add apiKey trimming and exhaustive persona switch in client
- Block path traversal (..) in validateResourceId
- Fix empty path in Zod error formatting
- Add 9 resource test suites (agents, bundles, campaigns, etc.)
- Expand base adapter tests (validateResourceId, sanitizeForLogging)
- Expand REST adapter, client, and webhook-server tests
- 364 tests across 24 suites, all passing
Replaces the partner persona with storefront across the entire SDK.
Adds all missing buyer resources (event sources, measurement data,
catalogs, audiences, syndication, tasks, property lists, creatives)
and storefront resources (storefront CRUD, inventory sources, readiness,
billing, notifications). Syncs bundled skill.md with live API.
…2 API

Add unit tests for all 8 new buyer resources (event sources, measurement
data, catalogs, audiences, syndication, tasks, property lists, creatives).
Rename partner workflow scripts to storefront. Update buyer guide with
new resource documentation. Fix all remaining partner references.
…rage

- Add 23 new type definitions for all untyped resources (EventSource,
  Catalog, Audience, Creative, Task, PropertyList, Syndication, etc.)
- Replace all Promise<unknown> returns with properly typed responses
- Rename CLI partners.ts to storefront.ts, update imports
- Fix README stale test:partner reference
- Fix storefront-guide and buyer-guide doc examples to match actual types
- Add 18 new client tests for tasks, propertyListChecks, buyer
  cross-access guards, and all new sub-resource accessors
Copy link
Copy Markdown
Collaborator

@benminer benminer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing stuck out to me here. Looks good!

…e3McpClient

Declares experimental apps capability so servers can send interactive
UI frames. Adds idle auto-disconnect (default 5min) to prevent leaked
connections. Adds token expiry awareness that cleanly disconnects and
throws instead of producing cryptic server errors.
…rage

Add comprehensive tests for OAuth (openBrowser, waitForCallback), REST
adapter edge cases (TimeoutError, non-Error throws, error envelopes),
MCP client (idle timer, token expiry with Date, debug mode), CLI format
(data envelopes, formatValue edges), and CLI commands (config, advertisers,
storefront). Brings suite to 39 suites / 491 tests.
@EmmaLouise2018 EmmaLouise2018 merged commit 29db459 into main Apr 1, 2026
6 checks passed
@EmmaLouise2018 EmmaLouise2018 deleted the EmmaLouise2018/slim-sdk-overhaul branch April 1, 2026 20:00
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