Skip to main content
Glama

BYOB MCP Server

by ndisidore

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:

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

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

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.

  1. Quick Start
    1. What This Is
      1. Architecture
        1. Pre-Built Demo Tools
          1. API Endpoints
            1. GET /
            2. GET /api/tools
            3. POST /api/register-tool
            4. POST /mcp
          2. Example: Register a Tool
            1. Connect to Claude Desktop
              1. Documentation
                1. Project Structure
                  1. Adding New Tools
                    1. Option 1: Via API (No redeployment needed)
                    2. Option 2: Extend the Container
                  2. Technology Stack
                    1. Deployment
                      1. Local Development
                      2. Production Deployment
                    2. Testing
                      1. Key Features
                        1. Dynamic Discovery
                        2. Secure Isolation
                        3. Serverless Scale
                        4. Standard Interface
                      2. Limitations
                        1. Resources
                          1. License
                            1. Contributing

                              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/ndisidore/cf-byob-mcp'

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