Skip to main content

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:

  • Registry Builder: Protocol-agnostic config loading and source registration (registry_builder)
  • Protocol Adapters: OpenAPIAdapter (FastAPI/REST) and MCPAdapter (Model Context Protocol)
  • App Orchestration: App class for building registries and dispatching to any adapter; subclass prepare_registry() for custom registries
  • Authentication: Unified Bearer token support (auth.load_tokens)
  • CLI: toolregistry-server openapi / toolregistry-server mcp with --config, --profile, and more

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

# Base (RouteTable, registry_builder, auth)
pip install toolregistry-server

# With OpenAPI support
pip install toolregistry-server[openapi]

# With MCP support
pip install toolregistry-server[mcp]

# Full
pip install toolregistry-server[all]

Quick Start

Programmatic — OpenAPI server

from toolregistry import ToolRegistry
from toolregistry_server import RouteTable
from toolregistry_server.adapters.openapi import OpenAPIAdapter

registry = ToolRegistry()

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

route_table = RouteTable(registry)
adapter = OpenAPIAdapter(route_table)
adapter.run(host="0.0.0.0", port=8000)

Programmatic — MCP server

import asyncio
from toolregistry import ToolRegistry
from toolregistry_server import RouteTable
from toolregistry_server.adapters.mcp import MCPAdapter

registry = ToolRegistry()
# ... register tools ...
route_table = RouteTable(registry)

adapter = MCPAdapter(route_table)
adapter.run(transport="stdio")                        # blocking
# or: asyncio.run(adapter.run_async(transport="sse", host="0.0.0.0", port=8000))

High-level — App class

from toolregistry_server.app import App

# From a config file
App().serve_openapi(config_path="tools.yaml", host="0.0.0.0", port=8000)
App().serve_mcp(config_path="tools.yaml", transport="stdio")

# From a pre-built registry
from toolregistry import ToolRegistry
registry = ToolRegistry()
# ... register tools ...
App().serve_openapi(registry=registry, port=9000)

Custom App subclass

Override prepare_registry to add built-in tools, hooks, or metadata:

from toolregistry_server.app import App

class MyApp(App):
    def prepare_registry(self, **kwargs):
        from toolregistry import ToolRegistry
        registry = ToolRegistry()
        registry.register(my_builtin_tool)
        # optionally apply user config on top
        if kwargs.get("config_path"):
            from toolregistry_server import apply_config, load_config
            apply_config(registry, load_config(kwargs["config_path"]))
        return registry

MyApp().serve_openapi(host="0.0.0.0", port=8000)

CLI

# OpenAPI server from config file
toolregistry-server openapi --config tools.yaml --port 8000

# MCP server (stdio)
toolregistry-server mcp --config tools.yaml --transport stdio

# MCP server (SSE)
toolregistry-server mcp --config tools.yaml --transport sse --port 8000

# With deployment profile (disables network/filesystem tools)
toolregistry-server openapi --config tools.yaml --profile remote

# With Bearer token auth
toolregistry-server openapi --config tools.yaml --tokens /path/to/tokens.txt

Config File

JSONC and YAML are both supported. Three source types: python, mcp, openapi.

mode: denylist     # or "allowlist"
disabled: []       # namespaces to exclude (denylist mode)

tools:
  # Python module — all public functions
  - type: python
    module: my_package.tools
    namespace: my_tools

  # Python class
  - type: python
    class: my_package.Calculator
    namespace: calculator

  # MCP server (stdio subprocess)
  - type: mcp
    transport: stdio
    command: ["python", "-m", "my_mcp_server"]
    namespace: mcp_tools

  # MCP server (SSE / streamable-http)
  - type: mcp
    transport: http
    url: http://localhost:8080/mcp
    namespace: remote_mcp

  # OpenAPI endpoint
  - type: openapi
    url: https://api.example.com/openapi.json
    namespace: external_api
    auth:
      type: bearer
      token_env: EXTERNAL_API_TOKEN

See examples/config.yaml and examples/config.jsonc for full examples.

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    registry_builder                         │
│   load_config · apply_config · register_*_source            │
│   apply_profile · PROFILE_DISABLE_TAGS                      │
└─────────────────────────┬───────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────────────┐
│                       RouteTable                            │
│              (central routing layer)                        │
└─────────────────────────┬───────────────────────────────────┘
                          │
          ┌───────────────┼───────────────┐
          ▼               ▼               ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│  OpenAPIAdapter │ │   MCPAdapter    │ │  (your adapter) │
│   (FastAPI)     │ │  stdio/sse/http │ │  Adapter ABC    │
└─────────────────┘ └─────────────────┘ └─────────────────┘
          │               │
          ▼               ▼
┌─────────────────┐ ┌─────────────────┐
│  HTTP Clients   │ │   MCP Clients   │
└─────────────────┘ └─────────────────┘

Adding a New Adapter

  1. Subclass Adapter from toolregistry_server.adapters
  2. Implement run(**kwargs) and create_and_run(cls, route_table, **kwargs)
  3. Optionally implement add_cli_arguments(parser) for CLI integration
  4. Call App().serve(MyAdapter, ...) — no changes to App needed

Deployment Profiles

--profile applies tag-based tool filtering at startup:

Profile Disables
remote FILE_SYSTEM, DESTRUCTIVE, PRIVILEGED tagged tools
local NETWORK tagged tools

Documentation

Contributing

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

License

MIT — see LICENSE.

Related Projects

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.4.3.tar.gz (75.9 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.4.3-py3-none-any.whl (62.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: toolregistry_server-0.4.3.tar.gz
  • Upload date:
  • Size: 75.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for toolregistry_server-0.4.3.tar.gz
Algorithm Hash digest
SHA256 00a04151ff97d3054a8048a09a862df1af3e9105e7bb0f990fbaa1d529577955
MD5 2e17030a36ffd8ca9f6c676416f7b2eb
BLAKE2b-256 639ee89bca4f8b7997f121d2962dcd979712cc515eab34175d7fa576a3377a36

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolregistry_server-0.4.3.tar.gz:

Publisher: release.yml on Oaklight/toolregistry-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for toolregistry_server-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 484715d629930f6815413bb4358701dda87bc8aa3770b65bc79565eac7e08714
MD5 6cc230d2564c9b9de503b8b12da26b23
BLAKE2b-256 4d657b1d1290b561dc18d5c01e41226f3143465a153dc7792b220c2078263ae9

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolregistry_server-0.4.3-py3-none-any.whl:

Publisher: release.yml on Oaklight/toolregistry-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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