Agents

LangChain

Load Openhandle tools into a LangChain agent through the MCP adapters, or call the REST API from a plain tool.

Option A: MCP adapters

The langchain-mcp-adapters package connects to MCP servers and turns their tools into LangChain tools. Check the package docs for the current transport names.

from langchain_mcp_adapters.client import MultiServerMCPClient
import os

client = MultiServerMCPClient({
    "openhandle": {
        "transport": "streamable_http",
        "url": "https://api.openhandle.dev/mcp",
        "headers": {"Authorization": f"Bearer {os.environ['OPENHANDLE_TEST_KEY']}"},
    }
})

tools = await client.get_tools()

Give tools to your agent. Every Openhandle operation is now callable.

Option B: a plain tool

import os, requests
from langchain_core.tools import tool

@tool
def instagram_profile(handle: str) -> dict:
    """Public Instagram profile by handle."""
    response = requests.get(
        f"https://api.openhandle.dev/v1/instagram/profiles/@{handle}",
        headers={"Authorization": f"Bearer {os.environ['OPENHANDLE_TEST_KEY']}"},
        timeout=15,
    )
    return response.json()

Notes

  • Answers share one envelope on every platform: platform, resource, capturedAt, source, data.
  • A null metric means the platform did not expose it. Tell the model not to read it as zero.
  • The Python SDK wraps the REST API with typed responses if you prefer that to raw requests.

On this page