Skip to content

Commit 6c82ced

Browse files
committed
update docs
1 parent 4c84e0b commit 6c82ced

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [Running Your Server](#running-your-server)
1414
- [stdio](#stdio)
1515
- [HTTP with SSE](#http-with-sse)
16+
- [Browser Context Transport](#browser-context-transport)
1617
- [Testing and Debugging](#testing-and-debugging)
1718
- [Examples](#examples)
1819
- [Echo Server](#echo-server)
@@ -239,6 +240,29 @@ app.post("/messages", async (req, res) => {
239240
app.listen(3001);
240241
```
241242

243+
### Browser Context Transport
244+
245+
For in-browser applications, use the BrowserContextTransport to enable communication between browser contexts (same window, iframes, or web workers):
246+
247+
```typescript
248+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
249+
import { BrowserContextTransport } from "@modelcontextprotocol/sdk/browser-context-transport.js";
250+
251+
// Create paired transports
252+
const [clientTransport, serverTransport] = BrowserContextTransport.createChannelPair();
253+
254+
// Set up server
255+
const server = new McpServer({
256+
name: "browser-server",
257+
version: "1.0.0"
258+
});
259+
260+
// Connect server to its transport
261+
await server.connect(serverTransport);
262+
263+
// The clientTransport can be used with an MCP client
264+
```
265+
242266
### Testing and Debugging
243267

244268
To test your server, you can use the [MCP Inspector](https://github.com/modelcontextprotocol/inspector). See its README for more information.

0 commit comments

Comments
 (0)