> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dedaluslabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Connections

> How connections are named and resolved

## Single-Connection Servers

For single-connection servers, name is optional and dispatch auto-resolves:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
gmail = Connection(secrets=SecretKeys(token="GMAIL_TOKEN"))  # No name needed

async def _req(method, path, body=None):
    ctx = get_context()
    return await ctx.dispatch(HttpRequest(method=method, path=path, body=body))
```

## Connection Naming

Connection names are derived from your server's slug: `windsor/gmail-mcp` -> `gmail-mcp`.

If you hardcode a different name in `dispatch("gmail", ...)`, it will fail. Use auto-dispatch for single-connection servers.

## Multi-Connection Servers

When you have multiple connections, specify the target explicitly:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
await ctx.dispatch("gmail", HttpRequest(...))
await ctx.dispatch("calendar", HttpRequest(...))
```

Each connection requires a separate OAuth flow. Pass `connection_name` when creating the session:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
# API creates session with explicit connection name
session = await admin_api.create_oauth_session(
    server_id=deployment_id,
    scopes=["gmail.readonly"],
    connection_name="gmail",  # Stored with this name
)
```

## Debugging

Connection not found? Check what's in the JWT:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
@tool(description="Debug")
async def debug() -> dict:
    ctx = get_context()
    return {"connections": list(ctx.runtime.get("connections", {}).keys())}
```
