Skeleton MCP Server

Skeleton MCP Server

A template project for building Model Context Protocol servers with FastMCP framework, providing example CRUD API implementations, Docker support, and development best practices.

Category
访问服务器

README

Playwright MCP Proxy

A proxy server for Microsoft's playwright-mcp that provides efficient handling of large binary data (screenshots, PDFs) through blob storage.

Features

  • Playwright Browser Automation: Full access to all playwright-mcp browser automation tools
  • Efficient Binary Handling: Large screenshots and PDFs are automatically stored as blobs to reduce token usage
  • Blob Storage: Built-in blob management using mcp-mapped-resource-lib
  • Automatic Cleanup: TTL-based automatic expiration of old blobs
  • Docker Support: Containerized deployment with multi-runtime support (Python + Node.js + Playwright)
  • Configurable: Extensive configuration options for both playwright and blob storage

Quick Start

Prerequisites

  • Python 3.10 or higher
  • Node.js 18+ (for playwright-mcp)
  • uv package manager (recommended)
  • Docker (optional, for containerized deployment)

Installation

  1. Clone this repository:
git clone <this-repo> playwright-proxy-mcp
cd playwright-proxy-mcp
  1. Install dependencies:
uv sync
  1. Create your environment file:
cp .env.example .env
# Edit .env with your configuration (defaults are sensible)
  1. Run the server:
uv run playwright-proxy-mcp

The server will:

  • Start the playwright-mcp subprocess via npx
  • Initialize blob storage
  • Listen for MCP client connections on stdio

Docker Deployment

Build and run with Docker Compose:

docker compose up -d

This will:

  • Build a container with Python, Node.js, and Playwright browsers
  • Create persistent volumes for blob storage and playwright output
  • Start the proxy server on port 8000

Configuration

Configure the proxy via environment variables in .env:

Playwright Browser Settings

  • PLAYWRIGHT_BROWSER: Browser to use (chromium, firefox, webkit) - default: chromium
  • PLAYWRIGHT_HEADLESS: Run headless - default: true
  • PLAYWRIGHT_CAPS: Capabilities (vision,pdf,testing,tracing) - default: vision,pdf
  • PLAYWRIGHT_TIMEOUT_ACTION: Action timeout in ms - default: 5000
  • PLAYWRIGHT_TIMEOUT_NAVIGATION: Navigation timeout in ms - default: 60000

Blob Storage Settings

  • BLOB_STORAGE_ROOT: Storage directory - default: /mnt/blob-storage
  • BLOB_MAX_SIZE_MB: Max size per blob - default: 500
  • BLOB_TTL_HOURS: Time-to-live for blobs - default: 24
  • BLOB_SIZE_THRESHOLD_KB: Size threshold for blob storage - default: 50
  • BLOB_CLEANUP_INTERVAL_MINUTES: Cleanup frequency - default: 60

See .env.example for all available options.

How It Works

Binary Data Interception

The proxy automatically detects large binary data in playwright tool responses:

  1. When playwright tools return screenshots or PDFs
  2. If the data size exceeds the threshold (default: 50KB)
  3. The proxy stores the binary data as a blob
  4. The response is transformed to include a blob reference instead

Before (direct playwright-mcp):

{
  "screenshot": "data:image/png;base64,iVBORw0KGgo...500KB of data..."
}

After (through proxy):

{
  "screenshot": "blob://1733577600-a3f2c1d9e4b5.png",
  "screenshot_size_kb": 500,
  "screenshot_mime_type": "image/png",
  "screenshot_blob_retrieval_tool": "get_blob",
  "screenshot_expires_at": "2024-12-08T10:00:00Z"
}

Retrieving Blobs

Use the get_blob tool to retrieve binary data when needed:

result = await get_blob("blob://1733577600-a3f2c1d9e4b5.png")
# Returns the original base64-encoded image data

Available Tools

Playwright Tools (Proxied)

All playwright-mcp tools are available:

  • playwright_navigate: Navigate to a URL
  • playwright_click: Click an element
  • playwright_fill: Fill a form field
  • playwright_screenshot: Take a screenshot (auto-stored as blob if large)
  • playwright_get_visible_text: Get page text
  • And many more...

Blob Management Tools

  • get_blob(blob_id): Retrieve binary data by blob ID
  • list_blobs(mime_type, tags, limit): List available blobs with filtering
  • delete_blob(blob_id): Delete a blob from storage

Architecture

┌─────────────────────────────────┐
│  MCP Client (Claude Desktop)   │
└────────────┬────────────────────┘
             │ stdio
┌────────────▼────────────────────┐
│  FastMCP Proxy (Python)         │
│  - Binary Interception          │
│  - Blob Storage Integration     │
│  - Tool Forwarding              │
└────────────┬────────────────────┘
             │ stdio
┌────────────▼────────────────────┐
│  playwright-mcp (Node.js/npx)   │
│  - Browser Automation           │
│  - Screenshot/PDF Generation    │
└─────────────────────────────────┘

Testing

Run the test suite:

uv run pytest -v

Lint the code:

uv run ruff check src/ tests/
uv run ruff format src/ tests/

Project Structure

src/playwright_proxy_mcp/
├── server.py              # Main MCP proxy server
├── types.py               # TypedDict definitions
├── playwright/            # Playwright proxy components
│   ├── config.py         # Configuration loading
│   ├── process_manager.py # Subprocess management
│   ├── blob_manager.py   # Blob storage wrapper
│   ├── middleware.py     # Binary interception
│   └── proxy_client.py   # Proxy client integration
└── api/
    └── blob_tools.py     # Blob retrieval tools

Benefits

Token Savings

Large screenshots can consume 50,000+ tokens. With blob storage:

  • Screenshots stored as blobs use ~100 tokens for the reference
  • Retrieve full data only when needed
  • Automatic cleanup prevents storage bloat

Performance

  • Faster response times for tool calls
  • Reduced context window usage
  • Efficient deduplication of identical screenshots

Troubleshooting

npx not found

Ensure Node.js is installed and npx is in your PATH:

node --version
npx --version

Playwright browser installation fails

Install browsers manually:

npx playwright@latest install chromium --with-deps

Blob storage permissions

Ensure the blob storage directory is writable:

chmod -R 755 /mnt/blob-storage

License

MIT

Contributing

Contributions welcome! Please open an issue or pull request.

Resources

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选