Skip to content

Index

templates

MCP tool templates — reusable tool definitions from TOML.

Classes

ToolTemplate

ToolTemplate(template_data: Dict[str, Any])

Bases: BaseTool

A tool dynamically constructed from a TOML template definition.

Source code in src/openjarvis/tools/templates/loader.py
def __init__(self, template_data: Dict[str, Any]) -> None:
    self._data = template_data
    self.tool_id = template_data.get("name", "template")
    self._name = template_data.get("name", "template")
    self._description = template_data.get("description", "")
    self._parameters = template_data.get("parameters", {})
    self._action = template_data.get("action", {})

Functions

discover_templates

discover_templates(directory: Optional[str | Path] = None) -> List[ToolTemplate]

Discover all TOML templates in a directory.

Source code in src/openjarvis/tools/templates/loader.py
def discover_templates(
    directory: Optional[str | Path] = None,
) -> List[ToolTemplate]:
    """Discover all TOML templates in a directory."""
    if directory is None:
        directory = Path(__file__).parent / "builtin"
    directory = Path(directory)
    if not directory.exists():
        return []
    templates = []
    for path in sorted(directory.glob("*.toml")):
        try:
            templates.append(load_template(path))
        except Exception as exc:
            logger.debug("Skipping unparseable template %s: %s", path, exc)
    return templates