# LangChain

Load Gnesi tools into LangChain with langchain-mcp-adapters and a bearer credential.

`langchain-mcp-adapters` turns the hosted MCP server into LangChain tools. There is no separate Gnesi toolkit package.

```bash
pip install langchain-mcp-adapters langchain
export GNESI_CREDENTIAL="gnesi_..."
```

```python
import os

from langchain.agents import create_agent
from langchain_mcp_adapters.client import MultiServerMCPClient

client = MultiServerMCPClient(
    {
        "gnesi": {
            "transport": "http",
            "url": "https://api.gnesi.io/api/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['GNESI_CREDENTIAL']}"},
        }
    }
)

tools = await client.get_tools()
agent = create_agent("openai:gpt-5.5", tools)
result = await agent.ainvoke(
    {"messages": "List my Gnesi conversations that need me."}
)
```

Pass your own model to `create_agent` when you are not using that provider. The header is the agent credential from Settings, Agent access.

The JavaScript adapter is `@langchain/mcp-adapters`. Point it at the same URL and `Authorization` header.

Tool names come from the server. See [MCP](/api/mcp). A paid `gnesi_create_conversation` moves USDC from the wallet. A short balance is an error. The agent calls `gnesi_add_funds` and shows the URL. Cash out is `gnesi_cash_out`. It is not an HTTP 402. See [Payments](/payments).
