How to Discover Tools and Print the Provider Menu Summary in OpenMontage
Use ToolRegistry.discover() to auto-discover all tools in the tools/ package, then call registry.provider_menu_summary() to generate a JSON summary showing available, configured, and unavailable providers per capability.
OpenMontage manages image generators, video models, and TTS engines through a central registry system. The ToolRegistry class in tools/tool_registry.py provides programmatic access to discovery and inventory functionality, enabling you to audit which AI providers are ready for use directly from the command line.
Understanding the ToolRegistry Architecture
The Central Registry Pattern
The ToolRegistry serves as the single source of truth for all tooling capabilities in OpenMontage. Located in tools/tool_registry.py, this class maintains an internal index of every discovered provider and their respective availability states. The registry also normalizes text for Windows cp1252 compatibility during initialization (see line 37 of tool_registry.py).
BaseTool and Capability Discovery
All tools must inherit from BaseTool (defined in tools/base_tool.py) and expose a capability attribute. The registry uses this attribute to categorize providers into capabilities like image_generation, video_generation, or text_to_speech. According to the calesthio/OpenMontage source code, only concrete subclasses advertising a valid capability are eligible for registration.
Step-by-Step Discovery Process
The discovery mechanism lazily loads tool classes when first requested. The discover() method, implemented starting at line 118 of tool_registry.py, walks the package tree under tools/ and registers any concrete subclass of BaseTool. This approach ensures that new providers are automatically detected without manual registration. The functionality is validated by the test suite in tests/tools/test_hyperframes_compose.py (lines 140-154), which verifies the dictionary shape and deduplication logic.
Generating the Provider Menu Summary
Once discovery completes, provider_menu_summary() aggregates the registry's state into a structured dictionary. Defined at lines 316-350 of tool_registry.py, this method returns counts categorized by availability status:
- available: Providers with valid credentials and connectivity
- configured: Providers with configuration present
- unavailable: Providers missing configuration or credentials
- total: Sum of all discovered providers for that capability
The resulting JSON structure resembles:
{
"image_generation": {"available": 5, "configured": 3, "unavailable": 2, "total": 5},
"video_generation": {"available": 4, "configured": 4, "unavailable": 0, "total": 4}
}
Real-world usage examples, such as scripts/kling_official_animated_explainer_e2e.py, demonstrate how agents call registry.provider_menu_summary() during pre-flight checks before executing generation tasks.
Command Line Methods to Discover Tools and Print the Summary
One-Liner Shell Command
Execute discovery and print the formatted summary directly from your terminal:
python -c "
import json
from tools.tool_registry import ToolRegistry
registry = ToolRegistry()
registry.discover()
summary = registry.provider_menu_summary()
print(json.dumps(summary, indent=2))
"
This command creates the registry, triggers the discovery walk, and outputs the provider menu as indented JSON.
Standalone Python Script
For reusable automation, create a dedicated script:
#!/usr/bin/env python3
import json
from tools.tool_registry import ToolRegistry
def main() -> None:
registry = ToolRegistry()
registry.discover() # Auto-discover all registered tools
summary = registry.provider_menu_summary()
print(json.dumps(summary, indent=2))
if __name__ == "__main__":
main()
Interactive REPL Usage
Inspect the registry interactively during development:
from tools.tool_registry import ToolRegistry
reg = ToolRegistry()
reg.discover()
reg.provider_menu_summary()
The interactive approach returns the raw dictionary, allowing you to manipulate or filter results before formatting.
Summary
ToolRegistryintools/tool_registry.pymanages all provider discovery and summary generation in OpenMontage.- Call
discover()(lines 118-133) to walk thetools/package and registerBaseToolsubclasses automatically. - Invoke
provider_menu_summary()(lines 316-350) to receive a JSON-compatible dictionary showing available, configured, and unavailable counts per capability. - Use the one-liner Python command for quick command-line audits, or import the registry into scripts for automated pre-flight checks.
- The output format includes available, configured, unavailable, and total counts for each capability type.
Frequently Asked Questions
What file contains the ToolRegistry class definition?
The ToolRegistry class is defined in tools/tool_registry.py. This file also contains the discover() method starting at line 118 and provider_menu_summary() starting at line 316.
How does OpenMontage determine which tools to include in the summary?
The registry walks the tools/ package tree and identifies every concrete subclass of BaseTool that defines a capability attribute. Only classes meeting these criteria are indexed and appear in the provider menu summary, as verified by tests in tests/tools/test_hyperframes_compose.py.
Can I run the discovery process without importing the entire OpenMontage application?
Yes. The ToolRegistry is self-contained and can be imported directly from tools.tool_registry. You can run discovery and generate the summary using a simple Python one-liner or standalone script without loading the full application stack or its dependencies.
What do the availability statuses mean in the provider menu summary?
Available indicates providers with valid credentials and network connectivity. Configured shows providers with configuration files or environment variables present. Unavailable marks providers missing required configuration or credentials. Total represents the sum of all discovered providers for that specific capability, regardless of status.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →