Brume · Docs
Connectors

Create a connector

Implement a native connector, expose its tools, and make it available to a Brume workspace.

In brief

A native connector binds an API key to StructuredTool objects that the agent can use. You implement its contract, register it in the backend, then authorize its slug and key in the workspace.

Implement the native contract

NativeConnector is a runtime-checkable Protocol. It declares slug, name, logo, auth_type with the "api_key" value, followed by async validate_key(key) -> bool and get_tools(api_key) -> list[StructuredTool] (core/src/brume/connectors/native.py:13-23).

NativeProvider keeps these objects in memory, indexed by slug. It produces their catalog and delegates validation and tool creation (core/src/brume/connectors/native.py:26-59).

from langchain_core.tools import StructuredTool

from brume.acme_client import AcmeClient, AcmeError
from brume.tools.acme import make_acme_tools


class AcmeConnector:
    slug = "acme"
    name = "Acme"
    logo = "/connector-logos/acme.svg"
    auth_type = "api_key"

    async def validate_key(self, key: str) -> bool:
        if not key or not key.strip():
            return False
        try:
            await AcmeClient(api_key=key).get_status()
            return True
        except AcmeError:
            return False

    def get_tools(self, api_key: str) -> list[StructuredTool]:
        return make_acme_tools(AcmeClient(api_key=api_key))

Follow the yourtext-guru example

Write the asynchronous client. YTGClient centralizes the URL, adds the apiV2Key header, converts responses into Python objects, and retries 5xx errors (core/src/brume/ytg_client.py:23-68).

Validate and bind the key. YTGConnector.validate_key calls /status. get_tools then creates a client bound to that key and passes it to make_ytg_tools (core/src/brume/connectors/ytg.py:17-41).

Build the tools. The factory closes its coroutines over the client, then calls StructuredTool.from_function with coroutine, name, and description. The example returns five tools; it groups two calls with asyncio.gather and bounds long waits with polling (core/src/brume/tools/ytg.py:17-175).

def make_acme_tools(client: AcmeClient) -> list[StructuredTool]:
    async def _search(query: str) -> dict:
        """Search Acme for a query."""
        return await client.search(query)

    return [
        StructuredTool.from_function(
            coroutine=_search,
            name="acme_search",
            description="Search Acme and return matching records.",
        ),
    ]

Register the connector in Brume

An extension through contribution

The native registry is assembled in the code. Brume currently provides no plugin mechanism or entry point for discovering a connector. Adding one requires a repository contribution or a fork; see Contribute to Brume.

Import your class and add it to all four constructions:

NativeProvider(connectors=[YTGConnector(), AcmeConnector()])
  • workspace routes: core/src/brume/routes/connectors.py:26-27;
  • tenant connection listing: core/src/brume/routes/connector_catalog.py:274-278;
  • tenant native-key validation: core/src/brume/routes/connector_catalog.py:328-341;
  • tools passed to the agent: core/src/brume/routes/ws/agent_factory.py:183-188.

ConnectorRegistry then combines the Composio and native catalogs, followed by their tools (core/src/brume/connectors/registry.py:90-108, core/src/brume/connectors/registry.py:229-342).

Make the connector visible and active

For a standard workspace, add the slug to workspace_connector_whitelist. For a private workspace, add it to tenant_connector_catalog: _get_whitelist automatically exposes the tenant's entire catalog (core/src/brume/connectors/registry.py:22-45).

Next, save the key with the same slug as its provider. When use_tenant_connection is true, Brume first looks for the tenant key in api_keys with workspace_id IS NULL, decrypts it with brume.crypto.decrypt, then looks for the workspace key. Otherwise, the lookup starts at the workspace (core/src/brume/connectors/registry.py:48-87).

list_connectors sets is_active only when a key resolves. get_tools passes native tools to the agent only with that key (core/src/brume/connectors/registry.py:110-136, core/src/brume/connectors/registry.py:303-314).

Test the complete path

Mock the client's HTTP calls to verify the header, parameters, 5xx retries, and 4xx errors (core/tests/test_ytg_client.py:18-122). Follow the YTGConnector tests to cover metadata, valid and invalid keys, tool names, asynchronous invocation, errors, and polling (core/tests/test_ytg_tools.py:18-195).

Add the registry cases: empty allowlist, visible connector without a key, tenant source, and active tools (core/tests/test_connector_registry.py:31-171). Test the tenant-to-workspace cascade in _resolve_native_key directly (core/src/brume/connectors/registry.py:68-87).

Run the reference suite, then add your own files on the same model, named after your connector:

cd core
uv run pytest -q tests/test_ytg_client.py tests/test_ytg_tools.py tests/test_connector_registry.py

In a test workspace, finally verify the slug in the catalog, is_active after saving the key, then invoke each tool by name.

On this page