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

# LangGraph MCP API

> API reference for Aion MCP helpers in aion-authoring-langgraph.

The LangGraph MCP helpers live in the `aion-authoring-langgraph` package and are imported from
`aion.langgraph.authoring.mcp` or directly from `aion.langgraph.authoring`.

They are thin framework bindings over the shared `aion-mcp` endpoint helpers. The package does not
own Aion control-plane addressing models; those live in `aion-api-client`.

## Install

```bash theme={null}
pip install aion-authoring-langgraph
```

The helpers require `langchain-mcp-adapters` when actually loading MCP tools or constructing a
`MultiServerMCPClient`.

## Exports

```python theme={null}
from aion.langgraph.authoring.mcp import (
    AionLangGraphMcpResolver,
    aion_langgraph_mcp_client,
    aion_langgraph_mcp_server_config,
    aion_langgraph_mcp_server_config_sync,
    load_aion_mcp_tools,
)
```

## `AionLangGraphMcpResolver`

Reusable resolver for building LangChain MCP server config, constructing a client, or loading tools.

```python theme={null}
from aion.api import (
    CapabilityReference,
    CapabilitySubjectSource,
    RuntimeCapabilityReference,
)
from aion.langgraph.authoring.mcp import AionLangGraphMcpResolver

resolver = AionLangGraphMcpResolver(
    capability_references=[
        CapabilityReference.global_mcp(),
    ],
    runtime_capability_references=[
        RuntimeCapabilityReference.primary_mcp(
            CapabilitySubjectSource.INCOMING_DISTRIBUTION
        ),
    ],
)
```

| Parameter                       | Purpose                                                                   |
| ------------------------------- | ------------------------------------------------------------------------- |
| `capability_references`         | Explicit subject-kind-key references, including the global control plane. |
| `runtime_capability_references` | Templates resolved from `AionRuntimeContext` at request time.             |
| `principal_selector`            | Optional explicit principal selector for all endpoints.                   |
| `base_url`                      | Optional Aion API base URL override.                                      |
| `jwt_manager`                   | Optional async token manager.                                             |
| `sync_jwt_manager`              | Optional synchronous token manager.                                       |

### Methods

| Method                                  | Returns                                                           |
| --------------------------------------- | ----------------------------------------------------------------- |
| `await resolver.server_config(context)` | `MultiServerMCPClient` server config.                             |
| `resolver.server_config_sync(context)`  | Synchronous server config.                                        |
| `await resolver.load_tools(context)`    | LangChain-compatible tools from all resolved servers.             |
| `resolver.client(context)`              | `MultiServerMCPClient` instance from synchronous endpoint config. |

Runtime references require a context. If a runtime reference is configured and no context is supplied,
the helper raises `ValueError`.

## `aion_langgraph_mcp_server_config`

Builds the dictionary expected by `langchain_mcp_adapters.client.MultiServerMCPClient`.

```python theme={null}
from langchain_mcp_adapters.client import MultiServerMCPClient
from aion.langgraph.authoring.mcp import aion_langgraph_mcp_server_config

config = await aion_langgraph_mcp_server_config(
    runtime_context,
    capability_references=[
        CapabilityReference.global_mcp(),
    ],
)

client = MultiServerMCPClient(config)
tools = await client.get_tools()
```

The config uses Aion endpoint names as keys. Each value contains `transport`, `url`, and `headers`.
For remote Aion MCP endpoints, `transport` is `http`.

## `load_aion_mcp_tools`

Loads tools directly from the resolved endpoints.

```python theme={null}
from aion.langgraph.authoring.mcp import load_aion_mcp_tools

tools = await load_aion_mcp_tools(
    runtime_context,
    capability_references=[
        CapabilityReference.global_mcp(),
    ],
    runtime_capability_references=[
        RuntimeCapabilityReference.primary_mcp(
            CapabilitySubjectSource.INCOMING_DISTRIBUTION
        ),
    ],
)
```

This is useful when the graph or agent is constructed after the Aion runtime context exists.

## `aion_langgraph_mcp_client`

Creates a `MultiServerMCPClient` using synchronous endpoint construction.

```python theme={null}
from aion.langgraph.authoring.mcp import aion_langgraph_mcp_client

client = aion_langgraph_mcp_client(
    runtime_context,
    capability_references=[CapabilityReference.global_mcp()],
)
```

Use the lower-level server-config helper when you need to control client lifecycle yourself.

## Runtime context source

The LangGraph helpers do not read from global or thread-local state. Pass the current
`AionRuntimeContext` explicitly, usually from LangGraph's `Runtime[AionRuntimeContext]` object.

```python theme={null}
from langgraph.runtime import Runtime
from aion.core.runtime import AionRuntimeContext


async def node(state, runtime: Runtime[AionRuntimeContext]):
    tools = await resolver.load_tools(runtime.context)
    ...
```

## Related pages

* [LangGraph MCP Guide](/sdk/langgraph/guides/mcp)
* [AionRuntimeContext](/sdk/langgraph/api/runtime-context)
* [aion-mcp](/sdk/python/packages/aion-mcp)
