Skip to main content

Python SDK for Watchlight AI Registry — AI agent and MCP server registry

Project description

wl-registry

Python SDK for Watchlight AI Registry — AI agent and MCP server registry.

Register, discover, and manage AI agents, MCP servers, scanners, and permissions through a type-safe Python client.

Installation

pip install wl-registry

Quick Start

Public Client (No Auth)

from wl_registry import WlRegistryClient, SelfRegisterAgentRequest

# Check service health
async with WlRegistryClient("http://localhost:8080/api/v1") as client:
    healthy = await client.health()

    # Self-register an agent
    resp = await client.register_agent(
        SelfRegisterAgentRequest(
            name="my-agent",
            agent_type="autonomous",
            description="My autonomous agent",
        )
    )
    print(f"Agent ID: {resp.id}, API Key: {resp.api_key}")

Scanner Client

Register and manage MCP servers discovered by scanners:

from wl_registry import WlRegistryScannerClient, RegisterServerRequest

async with WlRegistryScannerClient(
    scanner_id="scanner-uuid",
    api_key="scanner-api-key",
    base_url="http://localhost:8080/api/v1",
) as client:
    resp = await client.register_server(
        RegisterServerRequest(
            host_id="host-1",
            address="http://localhost:4000",
            transport="http",
            server_name="my-mcp-server",
            lease_ttl_seconds=300,
        )
    )
    print(f"Server {resp.server_id} registered")

    # Keep alive
    await client.heartbeat(resp.server_id)

Agent Client

Query accessible servers from the agent's perspective:

from wl_registry import WlRegistryAgentClient

async with WlRegistryAgentClient(
    agent_id="agent-uuid",
    api_key="agent-api-key",
) as client:
    servers = await client.get_accessible_servers()
    for srv in servers.servers:
        print(f"Can access: {srv.server_name} at {srv.address}")

    await client.heartbeat()

Admin Client

Full CRUD operations for managing the registry:

from wl_registry import (
    WlRegistryAdminClient,
    CreateAgentRequest,
    GrantPermissionRequest,
)

async with WlRegistryAdminClient(admin_key="admin-key") as client:
    # List all agents
    agents = await client.list_agents()
    print(f"Total agents: {agents.total}")

    # Create an agent
    agent = await client.create_agent(
        CreateAgentRequest(
            name="new-agent",
            agent_type="workflow",
            description="A workflow orchestrator",
        )
    )

    # Grant permission to access a server
    await client.grant_permission(
        agent.agent_id,
        GrantPermissionRequest(
            server_id="srv-uuid",
            allowed_tools=["read_file", "search"],
        ),
    )

    # Get agent statistics
    stats = await client.get_agent_stats()
    print(f"Active: {stats.active_agents}, Trusted: {stats.trusted_agents}")

Synchronous Clients

All clients have synchronous counterparts:

from wl_registry import WlRegistrySyncClient, WlRegistryAdminSyncClient

# Public
with WlRegistrySyncClient() as client:
    healthy = client.health()

# Admin
with WlRegistryAdminSyncClient(admin_key="key") as client:
    agents = client.list_agents()

Also available: WlRegistryScannerSyncClient, WlRegistryAgentSyncClient.

Error Handling

All exceptions inherit from WlRegistryError:

from wl_registry import (
    WlRegistryError,
    AuthenticationError,
    NotFoundError,
    ValidationError,
    ConflictError,
    ServiceUnavailable,
)

try:
    agent = await client.get_agent("nonexistent")
except NotFoundError as e:
    print(f"Agent not found: {e}")
except AuthenticationError:
    print("Invalid credentials")
except WlRegistryError as e:
    print(f"Registry error: {e}")
Exception HTTP Status Description
AuthenticationError 401, 403 Invalid or missing credentials
NotFoundError 404 Resource not found
ValidationError 400, 422 Invalid request data
ConflictError 409 Resource conflict (e.g., duplicate name)
ServiceUnavailable Connection error Service unreachable

Client Reference

Client Auth Key Methods
WlRegistryClient None health, get_registration_config, register_agent
WlRegistryScannerClient Scanner register_server, heartbeat, update_trust
WlRegistryAgentClient Agent get_accessible_servers, heartbeat
WlRegistryAdminClient Admin Full CRUD: servers, agents, permissions, scanners, tokens

Requirements

  • Python 3.10+
  • httpx >= 0.27.0
  • pydantic >= 2.0.0

License

Proprietary. See LICENSE for details.

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

wl_registry-0.1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wl_registry-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file wl_registry-0.1.0.tar.gz.

File metadata

  • Download URL: wl_registry-0.1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for wl_registry-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7be9b73c4c35116dc20c0a162388bc3ccc3a0d200c5fbc8e1213e9adfe4ad436
MD5 73ceeea5942a8ada42d396c571bde5d1
BLAKE2b-256 c96002baeba20afbca422f2bbedd2323f40ca8b961a405e494ffbb4e21962ace

See more details on using hashes here.

File details

Details for the file wl_registry-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wl_registry-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for wl_registry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e53e601acb7b401ddbfa93453094bdc2bfae232124bb66ba7a22b3ee90f92a0
MD5 770d7a5a764c1fa60852c7236653bf65
BLAKE2b-256 42ebf97eab2895c7c3afa45a00e59502fee6e84dfbea139b3a2c19073c306def

See more details on using hashes here.

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