Skip to main content

ToolRegistry Server: Serve Custom Tools via OpenAPI and MCP for Function-Calling LLMs

Project description

toolregistry-server

PyPI version CI License: MIT

Define custom tools and serve them via OpenAPI or MCP interfaces. Built on ToolRegistry.

Overview

toolregistry-server lets you register Python functions as tools and expose them as services through multiple protocols. It provides:

  • Central Route Table: A unified routing layer that bridges ToolRegistry and protocol adapters
  • OpenAPI Adapter: Expose tools as RESTful HTTP endpoints with automatic OpenAPI schema generation
  • MCP Adapter: Expose tools via the Model Context Protocol for LLM integration
  • Authentication: Built-in Bearer token authentication support
  • CLI: Command-line interface for running servers

Ecosystem

Package Description PyPI Docs
toolregistry Core library — tool registration, schema generation, execution PyPI Docs
toolregistry-server Server adapters — expose tools via OpenAPI & MCP PyPI Docs
toolregistry-hub Ready-to-use tools — calculator, web search, file ops, etc. PyPI Docs
toolregistry (core)
       ↓
toolregistry-server (tool server)
       ↓
toolregistry-hub (tool collection + server config)

Installation

Basic Installation

pip install toolregistry-server

With OpenAPI Support

pip install toolregistry-server[openapi]

With MCP Support

pip install toolregistry-server[mcp]

Full Installation

pip install toolregistry-server[all]

Quick Start

Using RouteTable

from toolregistry import ToolRegistry
from toolregistry_server import RouteTable

# Create a registry and register tools
registry = ToolRegistry()

@registry.register
def greet(name: str) -> str:
    """Greet someone by name."""
    return f"Hello, {name}!"

# Create a route table
route_table = RouteTable(registry)

# List all routes
for route in route_table.list_routes():
    print(f"{route.path} -> {route.tool_name}")

Creating an OpenAPI Server

from toolregistry import ToolRegistry
from toolregistry_server import RouteTable
from toolregistry_server.openapi import create_openapi_app

# Setup registry and route table
registry = ToolRegistry()
# ... register tools ...
route_table = RouteTable(registry)

# Create FastAPI app
app = create_openapi_app(route_table)

# Run with uvicorn
if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

Creating an MCP Server

from toolregistry import ToolRegistry
from toolregistry_server import RouteTable
from toolregistry_server.mcp import create_mcp_server

# Setup registry and route table
registry = ToolRegistry()
# ... register tools ...
route_table = RouteTable(registry)

# Create MCP server
server = create_mcp_server(route_table)

# Run the server
if __name__ == "__main__":
    import asyncio
    asyncio.run(server.run())

Using the CLI

# Start OpenAPI server
toolregistry-server --mode openapi --port 8000

# Start MCP server (stdio)
toolregistry-server --mode mcp

# With authentication
toolregistry-server --mode openapi --auth-token "your-secret-token"

Architecture

┌─────────────────────────────────────────────────────────────┐
│                      ToolRegistry                           │
│                   (tool definitions)                        │
└─────────────────────────┬───────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────────────┐
│                       RouteTable                            │
│              (central routing layer)                        │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐         │
│  │ RouteEntry  │  │ RouteEntry  │  │ RouteEntry  │  ...    │
│  └─────────────┘  └─────────────┘  └─────────────┘         │
└─────────────────────────┬───────────────────────────────────┘
                          │
          ┌───────────────┼───────────────┐
          ▼               ▼               ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ OpenAPI Adapter │ │   MCP Adapter   │ │  gRPC Adapter   │
│   (FastAPI)     │ │   (MCP SDK)     │ │    (future)     │
└─────────────────┘ └─────────────────┘ └─────────────────┘
          │               │               │
          ▼               ▼               ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│  HTTP Clients   │ │   MCP Clients   │ │  gRPC Clients   │
└─────────────────┘ └─────────────────┘ └─────────────────┘

Documentation

Contributing

Contributions are welcome! Please see our Contributing Guide for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Related Projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toolregistry_server-0.3.0.tar.gz (61.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toolregistry_server-0.3.0-py3-none-any.whl (48.5 kB view details)

Uploaded Python 3

File details

Details for the file toolregistry_server-0.3.0.tar.gz.

File metadata

  • Download URL: toolregistry_server-0.3.0.tar.gz
  • Upload date:
  • Size: 61.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for toolregistry_server-0.3.0.tar.gz
Algorithm Hash digest
SHA256 605d31c60e0cdd0ba0da1f4c151f7ee777f2cb01eea52165d92cdbffca5b7672
MD5 125ad8cbbb54bc279af348e77dc22697
BLAKE2b-256 2ff4076227af90973aa7fa4969ed9731edb56608bfbc5e0da5d5b8a78a3e7736

See more details on using hashes here.

File details

Details for the file toolregistry_server-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for toolregistry_server-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05215cc266b7ba672a4c6c2f4acce044481f158a67c58e71eb0c78914af38940
MD5 eb753b545f6feee69beb97f267af02f1
BLAKE2b-256 20751e6afc90d72a2495514647f6b3f4df302d576c0629715acd6023c28bc2ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page