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

# Building Agents

> Connect your AI agent to Monei using the MCP SDK

If you are building an AI agent that needs to handle payments, the Monei MCP server gives you everything through a single connection. No need to stitch together multiple payment APIs.

## Python

Using the official MCP Python SDK:

```python theme={null}
import asyncio
from mcp import ClientSession
from mcp.client.sse import sse_client

async def main():
    async with sse_client("https://mcp.monei.cc/sse") as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()

            # List available tools
            tools = await session.list_tools()
            print([t.name for t in tools.tools])

            # Call a tool
            result = await session.call_tool("get_wallet", {})
            print(result)

asyncio.run(main())
```

## LangChain and LangGraph

```python theme={null}
from langchain_mcp_adapters.tools import load_mcp_tools
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent

client = MultiServerMCPClient({
    "monei": {
        "url": "https://mcp.monei.cc/sse",
        "transport": "sse",
    }
})

tools = await client.get_tools()
agent = create_react_agent(model, tools)

response = await agent.ainvoke({
    "messages": "What is my Monei wallet balance?"
})
```

## Node.js

Using the official MCP TypeScript SDK:

```typescript theme={null}
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";

const transport = new SSEClientTransport(
  new URL("https://mcp.monei.cc/sse")
);

const client = new Client(
  { name: "my-agent", version: "1.0.0" },
  { capabilities: {} }
);

await client.connect(transport);

// List tools
const { tools } = await client.listTools();

// Call a tool
const result = await client.callTool({
  name: "get_wallet",
  arguments: {}
});
```

## Authentication in code

When connecting programmatically, the server will initiate the OAuth flow. To skip the interactive OAuth prompt in automated environments, run the server locally with your API key set as an environment variable and connect to localhost instead:

```bash theme={null}
MONEI_API_KEY=your_key npx @mrmonei/mcp-server
```

Then connect your agent to `http://localhost:3000/sse`.

## What to build

Some patterns that work well with the Monei MCP server:

**Payment execution agent** takes a natural language instruction from a user, resolves the intent, verifies the recipient, gets confirmation, and executes the payment.

**Bill autopayment agent** monitors due dates and pays electricity, cable, or data bills automatically when triggered.

**Offramp agent** watches for favorable exchange rates and initiates a crypto to naira offramp when conditions are met.

**Portfolio monitoring agent** checks balances across NGN wallet, EVM chains, and Solana on a schedule and reports changes.

**Transaction reconciliation agent** fetches transaction history and matches it against expected records.
