gomcp-worker

gomcp-worker

Cloudflare Workers 上的 MCP 服务器,通过 CDP 控制 Lightpanda 浏览器,支持导航、搜索、获取 Markdown 和链接提取。

Category
Visit Server

README

gomcp-worker

Cloudflare Workers 版本的 gomcp(Lightpanda Browser 的 MCP Server)。这次总算把最致命的坑补上了,不再是那种“接口能回 200,但灵魂已经离职”的半成品。

功能特性

  • ✅ 支持 MCP 协议版本 2025-03-26
  • ✅ Streamable HTTP JSON-RPC
  • initialize 分配会话,后续请求强制复用 Mcp-Session-Id
  • ✅ Durable Objects 会话生命周期管理(关闭/过期后返回 404
  • ✅ 根 CDP WebSocket 自动 Target.createTarget + Target.attachToTarget
  • resources/list / prompts/list 空响应兼容
  • notifications/cancelled 使用正确的 requestId
  • ✅ 工具执行失败按 result.isError 返回
  • ✅ Workers 兼容的 HTML → Markdown 转换(优先纯解析库,失败时回退轻量转换器)
  • ✅ 轻量 SSE 握手入口:GET /mcp / GET /sse

可用工具

工具 描述 必需参数
goto 导航到指定 URL url
search 使用 DuckDuckGo 搜索 text
markdown 获取当前页面 Markdown
links 提取当前页面链接

部署

1. 安装依赖

npm install

2. 配置密钥

wrangler secret set CDP_URL

示例值:

wss://your-lightpanda-instance:9222

CDP_URL 应指向 浏览器根 WebSocket。Worker 会在连上后自动创建 target 并 attach,不需要你手搓 page session。

3. 本地开发

npm run dev

4. 部署到 Cloudflare

npm run deploy

注意:wrangler.toml 已包含 MCPSession 的 Durable Object migration。后续如重命名 Durable Object 类,必须继续追加 migration,而不是修改已有 tag。

MCP 客户端示例

{
  "mcpServers": {
    "lightpanda": {
      "url": "https://your-worker.workers.dev/mcp"
    }
  }
}

直接调用示例

1. 初始化并拿到 Mcp-Session-Id

curl -i -X POST https://your-worker.workers.dev/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"initialize","params":{},"id":1}'

2. 带上 Mcp-Session-Id 调用后续方法

curl -X POST https://your-worker.workers.dev/mcp \
  -H "Content-Type: application/json" \
  -H "Mcp-Session-Id: <session-id-from-initialize>" \
  -d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":2}'

说明

  • initialize 会返回新的 Mcp-Session-Id;后续 tools/list / ping / tools/call / GET /mcp / DELETE /mcp 都必须带上它。
  • GET /mcpGET /sse 是轻量 SSE 握手入口,不负责旧版 /messages 传输。
  • initialize / tools/list / ping / resources/list / prompts/list 不依赖 CDP;只有 tools/call 需要连接浏览器。
  • resources/listprompts/list 当前返回空数组,这是故意的,不是服务器在摆烂——虽然看起来很像。

许可证

Apache-2.0

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured