Define custom tools and serve them via OpenAPI or MCP interfaces
Project description
toolregistry-server
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
ToolRegistryand 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
The ToolRegistry ecosystem consists of three packages:
| Package | Description | Repository |
|---|---|---|
toolregistry |
Core library - Tool model, ToolRegistry, client integration | Oaklight/ToolRegistry |
toolregistry-server |
Tool server - define tools and serve via OpenAPI/MCP | Oaklight/toolregistry-server |
toolregistry-hub |
Tool collection - Built-in tools, default server configuration | Oaklight/toolregistry-hub |
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
- ToolRegistry - Core library
- toolregistry-hub - Built-in tool collection
- Model Context Protocol - MCP specification
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toolregistry_server-0.1.3.tar.gz.
File metadata
- Download URL: toolregistry_server-0.1.3.tar.gz
- Upload date:
- Size: 56.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc4bdcd33434ea79a8be5a294c99d1983ce37781f5bb2ab3a74fcd8b0e02e535
|
|
| MD5 |
2dc0f4a4eb0f6779835b664866d56b2b
|
|
| BLAKE2b-256 |
495751d159bd6c60277e6a8f53ddca9fd5394cc112e1c090570599b6421206ce
|
File details
Details for the file toolregistry_server-0.1.3-py3-none-any.whl.
File metadata
- Download URL: toolregistry_server-0.1.3-py3-none-any.whl
- Upload date:
- Size: 45.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80bc6417472599c79e4654c977b986ec12c0587df0ecc8f0612aeb07fc8fcf3c
|
|
| MD5 |
f439da18285a2baf40510a2ab14576f0
|
|
| BLAKE2b-256 |
8fa906205de99ff7241988c16f595eba84ebe526f1faefe686b0f08b06637447
|