Skip to main content

LangChain tool wrapper for Graph Advocate — onchain data routing via plain-English queries (subgraphs, GraphQL, REST).

Project description

langchain-graph-advocate

LangChain tool wrapper for Graph Advocate — drop-in onchain data routing for AI agents. Plain-English queries return a working GraphQL query, subgraph ID, or REST call you can execute against The Graph or Token API.

  • 15,500+ subgraphs across 20+ chains
  • Wallet balances, token holders, DEX swaps, NFTs, lending data, prediction markets, ENS domains, ERC-8004 agent discovery
  • Free first 10 queries/day per sender; $0.01 USDC after via x402 (Base)

Install

pip install langchain-graph-advocate

# Optional: paid usage past the free tier
pip install 'langchain-graph-advocate[x402]'

Quick start

Free tier (no setup)

from langchain_graph_advocate import GraphAdvocateTool

tool = GraphAdvocateTool()

result = tool.invoke({"request": "Top 20 USDC holders on Ethereum"})
print(result)
# Returns JSON with recommendation, query_ready, curl_example, alternatives

Paid mode (auto-pay past free tier)

import os
from langchain_graph_advocate import GraphAdvocateTool

tool = GraphAdvocateTool(
    x402_private_key=os.environ["X402_PRIVATE_KEY"],
    max_usdc_per_call=0.05,
)

The wallet that signs payments needs USDC on Base. Get USDC at bridge.base.org or any DEX.

Use it in an agent

from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate
from langchain_graph_advocate import GraphAdvocateTool

llm = ChatAnthropic(model="claude-opus-4-7")
tools = [GraphAdvocateTool()]

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are an onchain analyst. Use the graph_advocate tool to "
               "answer any onchain data questions."),
    ("user", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])

agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)

executor.invoke({"input": "Who are the top 10 USDC holders on Ethereum?"})

What you get back

{
  "recommendation": "token-api",
  "reason": "getV1EvmHolders returns ranked holder lists by token contract.",
  "confidence": "high",
  "query_ready": {
    "tool": "getV1EvmHolders",
    "args": {
      "network": "mainnet",
      "contract": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "limit": 20
    }
  },
  "curl_example": "curl 'https://token-api.thegraph.com/...'",
  "get_started": "Free API key: https://thegraph.com/studio/",
  "alternatives": []
}

Your agent then runs the query_ready against the Graph gateway (or whichever service was recommended) using a free API key from thegraph.com/studio.

Pricing

Tier Price How
Free 10 queries/day per sender Just call the tool — no setup
Paid $0.01 USDC Pass x402_private_key to auto-pay

Why this exists

Without Graph Advocate, an agent that wants Aave liquidations on Base has to: (1) discover candidate subgraphs, (2) compare query volumes for reliability, (3) read schemas, (4) write GraphQL, (5) test against the indexer. That's 5–10 minutes of model + tool time per data question.

Graph Advocate returns the working query in one HTTP round trip for $0.01.

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_graph_advocate-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_graph_advocate-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_graph_advocate-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_graph_advocate-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for langchain_graph_advocate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c8c8c63b85ca52daa466ff81ded4fb9f137ec931dda1460b1dbf6755014807fe
MD5 71c3c53cdb4371edc4ce7d7dbeb2b33e
BLAKE2b-256 ca491e253e5a5ef4bd7bebe07160c55af153833b1f5df37102a18e5e60355563

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_graph_advocate-0.1.0.tar.gz:

Publisher: publish.yml on PaulieB14/langchain-graph-advocate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_graph_advocate-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_graph_advocate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00beb052b822789393b389b05712d976f0f057d3b52b523621e936797054579d
MD5 82b5598a04b04e665f00636058d58301
BLAKE2b-256 94fe84e8b49b7a111ab66e6ae51088ced34cdc05407551a25a5fd093368d13c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_graph_advocate-0.1.0-py3-none-any.whl:

Publisher: publish.yml on PaulieB14/langchain-graph-advocate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page