BYOB MCP Server

BYOB MCP Server

Enables AI agents to dynamically discover and invoke containerized tools that can be registered at runtime without redeployment. Built on Cloudflare Workers with scale-to-zero containers for secure, isolated tool execution.

Category
访问服务器

README

BYOB MCP Server 🚀

Bring Your Own Binary: A dynamic MCP server built on Cloudflare Workers, Containers, and D1.

Enables AI agents to discover and invoke containerized tools registered at runtime—no redeployment needed.

Quick Start

# Install dependencies
npm install

# Start local dev server
npm run dev

# In another terminal, test the API
bash test-api.sh

# Deploy to production
npm run deploy

What This Is

A proof-of-concept demonstrating:

  • Dynamic Tool Registry - Tools stored in D1, queried by MCP server
  • Containerized Execution - Each tool runs in isolated Cloudflare Container
  • MCP Protocol - AI agents discover tools via Model Context Protocol
  • HTTP Registration API - Register new tools without redeploying
  • Scale-to-Zero - Containers only run when tools are invoked

Architecture

AI Agent (Claude) ──[MCP]──> Cloudflare Worker ──[HTTP]──> Universal Container
                                    │                         (ToolRunner)
                                    └──[SQL]──> D1 Registry
                                                              Supports:
                                                              • Echo
                                                              • Uppercase
                                                              • JQ
                                                              • Git Clone

Pre-Built Demo Tools

All four tools run in a single universal container:

  1. echo_message - Echoes back any JSON input
  2. why_are_we_yelling - Converts text to UPPERCASE
  3. query_json - Processes JSON with jq filters
  4. summarize_repo_readme - Clones a GitHub repo and summarizes its README

API Endpoints

GET /

Health check and server info

GET /api/tools

List all registered tools

POST /api/register-tool

Register a new tool

{
  "name": "my_tool",
  "description": "What this tool does",
  "containerClass": "echo",
  "schema": {
    "type": "object",
    "properties": {
      "input": {"type": "string"}
    }
  }
}

POST /mcp

MCP protocol endpoint (connect your AI agent here)

Example: Register a Tool

curl -X POST http://localhost:8787/api/register-tool \
  -H "Content-Type: application/json" \
  -d '{
    "name": "whisper",
    "description": "Echoes message in lowercase",
    "containerClass": "toolrunner",
    "schema": {
      "type": "object",
      "properties": {
        "message": {"type": "string"}
      },
      "required": ["message"]
    }
  }'

Connect to Claude Desktop

Edit your Claude Desktop config:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "byob-server": {
      "url": "http://localhost:8787/mcp"
    }
  }
}

Restart Claude Desktop, then ask:

  • "What tools do you have available?"
  • "Can you echo the message 'Hello BYOB!'?"
  • "Use why_are_we_yelling with text: hello world"
  • "Summarize the README from https://github.com/fiberplane/mcp-lite"

Documentation

Project Structure

├── src/
│   ├── index.ts          # Main Worker + MCP server
│   ├── containers.ts     # Container class definitions
│   └── types.ts          # TypeScript interfaces
├── containers/
│   ├── Dockerfile        # Universal container image
│   ├── server.js         # Multi-tool HTTP server
│   └── README.md         # Container documentation
├── migrations/
│   ├── 0001_initial_schema.sql
│   └── 0002_seed_example_tools.sql
└── wrangler.jsonc        # Cloudflare configuration

Adding New Tools

Since all tools use the same universal container, adding new tools is simple:

Option 1: Via API (No redeployment needed)

curl -X POST http://localhost:8787/api/register-tool \
  -H "Content-Type: application/json" \
  -d '{"name":"my_tool", "description":"...", ...}'

Option 2: Extend the Container

To add new operation types:

  1. Edit containers/server.js to handle new input patterns
  2. Add new tool definitions to migrations/0002_seed_example_tools.sql
  3. Redeploy

The single container approach keeps things simple for demos while still demonstrating the BYOB architecture.

Technology Stack

  • Runtime: Cloudflare Workers (V8 Isolates)
  • MCP: mcp-lite (not @modelcontextprotocol/sdk)
  • Web Framework: Hono
  • Database: Cloudflare D1 (SQLite)
  • Containers: Cloudflare Containers (Durable Objects)
  • Schema: Zod + JSON Schema

Deployment

Local Development

npm run dev
# Server runs on http://localhost:8787

Production Deployment

  1. Run migrations on remote database:
npx wrangler d1 execute byob-tools-registry --remote \
  --file=./migrations/0001_initial_schema.sql
npx wrangler d1 execute byob-tools-registry --remote \
  --file=./migrations/0002_seed_example_tools.sql
  1. Deploy Worker and Containers:
npm run deploy

Note: First deployment takes 2-5 minutes to build Docker images.

  1. Update Claude Desktop config with your production URL:
{
  "mcpServers": {
    "byob-server": {
      "url": "https://byob-mcp-server.YOUR_ACCOUNT.workers.dev/mcp"
    }
  }
}

Testing

# Automated API tests
bash test-api.sh

# Manual health check
curl http://localhost:8787/

# List tools
curl http://localhost:8787/api/tools | jq

# Test MCP protocol
curl -X POST http://localhost:8787/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

Key Features

Dynamic Discovery

Tools registered in D1 appear immediately to all connected AI agents—no redeployment required.

Secure Isolation

Each container runs in an isolated sandbox with resource limits and ephemeral storage.

Serverless Scale

Containers scale to zero when idle. Pay only for actual tool invocations.

Standard Interface

All containers expose POST /execute endpoint accepting/returning JSON.

Limitations

Container classes must be defined at deploy time in wrangler.jsonc. True runtime BYOB would require automatic Worker rebuild/redeploy when new containers are registered.

Workaround: Multiple logical tools can share the same container class, allowing significant flexibility without redeployment.

Resources

License

MIT - Built for hackathon demonstration

Contributing

This is a hackathon prototype. For questions or suggestions, open an issue!


Built with ☁️ Cloudflare Workers | 🐳 Containers | 🗄️ D1 | 🤖 MCP

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选