-
Notifications
You must be signed in to change notification settings - Fork 772
Browser context transport #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/browser-context-transport.ts
Outdated
private static generateSessionId(): string { | ||
// Current timestamp as prefix (in base 36 for shorter string) | ||
const timePrefix = Date.now().toString(36); | ||
|
||
// Random suffix | ||
const randomSuffix = Math.random().toString(36).substring(2, 10); | ||
|
||
return `${timePrefix}-${randomSuffix}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the sse
transport the crypto UUID is used. there is a browser compatible implementation that can be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, updated
It's not released yet now. How can I experience this feature? |
I appreciate the work that's gone into this implementation, and have done similar things in my own projects, but I don't think we should include this in the SDK. The SDK should remain focused only on the things that are part of the standard MCP spec. Perhaps it'd be useful to maintain this as its own, separate npm package? |
fix(sidebar): maintain order when changing values
Browser-based MCP Transport Implementation
Added a browser-based MCP transport implementation to enable client-server communication entirely within the browser environment.
#219
Motivation and Context
BrowserContextTransport
allows for MCP servers to run directly in the browser alongside clients, enabling new application architectures.How Has This Been Tested?
Breaking Changes
None. This is a new addition that doesn't affect existing functionality.
Types of changes
Checklist
Additional context
The implementation uses the browser's
MessageChannel
API to create paired channels for bidirectional communication between MCP client and MCP server.Resources
Quick Start Examples
Creating a Transport Pair
Most basic use case - both ends in same context:
With Web Workers
For cases where you want to run the server in a Web Worker:
With Iframes
For cross-domain scenarios, you might want to use iframes: