Skip to main content
Glama

Cloudflare Playwright MCP

Official
by cloudflare
index.ts1.13 kB
import { McpAgent } from 'agents/mcp'; import { env } from 'cloudflare:workers'; import type { BrowserEndpoint } from '@cloudflare/playwright'; import { endpointURLString } from '@cloudflare/playwright'; import { createConnection } from '../../src/index.js'; import { ToolCapability } from '../../config.js'; import type { Server } from '@modelcontextprotocol/sdk/server/index.js'; type Options = { vision?: boolean; capabilities?: ToolCapability[]; }; export function createMcpAgent(endpoint: BrowserEndpoint, options?: Options): typeof McpAgent<typeof env, {}, {}> { const cdpEndpoint = typeof endpoint === 'string' ? endpoint : endpoint instanceof URL ? endpoint.toString() : endpointURLString(endpoint); const connection = createConnection({ capabilities: ['core', 'tabs', 'pdf', 'history', 'wait', 'files', 'testing'], browser: { cdpEndpoint, }, ...options, }); return class PlaywrightMcpAgent extends McpAgent<typeof env, {}, {}> { server = connection.then(server => server.server as unknown as Server); async init() { // do nothing } }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cloudflare/playwright-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server