Skip to content

Conversation

@naji247
Copy link
Member

@naji247 naji247 commented Nov 26, 2025

Summary

  • Add edge runtime compatibility for Cloudflare Workers, Vercel Edge, and Deno Deploy
  • Lazy-load Node.js-specific modules (fs, os, path) to prevent crashes in edge environments
  • Guard process signal handlers and process.cwd() calls that may not exist in edge runtimes
  • Add console.log fallback for logging in environments without filesystem access
  • Update mcpcat-api dependency to 0.1.6
  • Bump version to 0.1.9

Changes

  • exceptions.ts: Lazy-load fs module for context_line extraction; guard process.cwd()
  • eventQueue.ts: Guard process.once signal handlers for graceful shutdown
  • logging.ts: Lazy-load fs/os/path with console fallback for edge environments
  • package.json: Update mcpcat-api to 0.1.6, bump version to 0.1.9

Test plan

  • Run existing test suite (pnpm test)
  • Verify new edge runtime compatibility tests pass
  • Test SDK import in a Cloudflare Workers environment
  • Verify exception capture works without filesystem access
  • Confirm logging falls back to console.log in edge environments

Make the SDK compatible with edge runtimes (Cloudflare Workers, Vercel Edge,
Deno Deploy) by gracefully handling missing Node.js APIs:

- Lazy-load fs module for context_line extraction in exceptions.ts
- Guard process.once signal handlers in eventQueue.ts
- Lazy-load fs/os/path modules in logging.ts with console fallback
- Guard process.cwd() calls which may not exist in edge environments
- Update mcpcat-api dependency to 0.1.6

Add comprehensive test suite for edge runtime compatibility scenarios.
MCP SDK 1.23.0 now supports both Zod v3 and v4, which have different
internal structures. This caused context parameter injection to fail.

Changes:
- Add zod-compat.ts with version-agnostic detection and utilities
- Update context-parameters.ts to use zod-compat utilities
- Update tracingV2.ts to use zod-compat for schema shape access
- Update Zod dependency to support both v3 and v4
- Add comprehensive tests for zod-compat utilities

Tested with MCP SDK versions 1.21.2 and 1.23.0.
cwd = process.cwd();
}
} catch {
// process.cwd() not available in this environment
Copy link
Member

Choose a reason for hiding this comment

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

maybe add a writeToLog here?

@naji247 naji247 merged commit 1e95431 into main Nov 26, 2025
8 checks passed
@naji247 naji247 deleted the fix/cloudflare-workers branch November 26, 2025 18:34
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.

3 participants