Skip to content

Commit 2664b96

Browse files
authored
Merge pull request #17 from cloudflare/fix-cors
Fix CORS and add streamable http support
2 parents bd1d8fe + 29bd4a6 commit 2664b96

File tree

3 files changed

+115
-45
lines changed

3 files changed

+115
-45
lines changed

cloudflare/example/src/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,18 @@ import { createMcpAgent } from '@cloudflare/playwright-mcp';
44

55
export const PlaywrightMCP = createMcpAgent(env.BROWSER);
66

7-
export default PlaywrightMCP.mount('/sse');
7+
export default {
8+
fetch(request: Request, env: Env, ctx: ExecutionContext) {
9+
const { pathname } = new URL(request.url);
10+
11+
switch (pathname) {
12+
case '/sse':
13+
case '/sse/message':
14+
return PlaywrightMCP.serveSSE('/sse').fetch(request, env, ctx);
15+
case '/mcp':
16+
return PlaywrightMCP.serve('/mcp').fetch(request, env, ctx);
17+
default:
18+
return new Response('Not Found', { status: 404 });
19+
}
20+
},
21+
};

cloudflare/package-lock.json

Lines changed: 98 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cloudflare/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
},
2727
"dependencies": {
2828
"@cloudflare/playwright": "^0.0.10",
29-
"agents": "^0.0.75",
29+
"@modelcontextprotocol/sdk": "^1.13.3",
30+
"agents": "^0.0.101",
3031
"yaml": "^2.7.1",
3132
"zod-to-json-schema": "^3.24.5"
3233
},

0 commit comments

Comments
 (0)