Skip to main content

LangChain toolkit for KeeperHub — reliable onchain execution, DeFi protocol actions, and AI workflow generation for any LangChain agent

Project description

keeperhub-langchain

PyPI Python License Tests

Give any Python LangChain agent onchain superpowers — 24 tools for DeFi, transfers, ENS, workflows, and more.


Skill Install

npx agentskills install keeperhub

Install

pip install keeperhub-langchain

With MCP bridge (adds KeeperHub's official workflow tools):

pip install "keeperhub-langchain[workflows]"

5-Minute Quickstart

import asyncio, os
from langchain_keeperhub import KeeperHubToolkit
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

# pip install keeperhub-langchain langchain-openai langgraph
# export KEEPERHUB_API_KEY=kh_...
# export OPENAI_API_KEY=sk-...

async def main():
    toolkit = KeeperHubToolkit(testnet_only=True)  # safe for dev
    agent = create_react_agent(
        model=ChatOpenAI(model="gpt-4o-mini"),
        tools=toolkit.get_tools(),
    )
    result = await agent.ainvoke({
        "messages": [("user", "What blockchains does KeeperHub support?")]
    })
    print(result["messages"][-1].content)
    # → "KeeperHub supports 19 chains: Ethereum, Base, Arbitrum, Optimism..."

asyncio.run(main())

Get your API key at app.keeperhub.com → Settings → API Keys.


Safety

# Block all mainnet writes — safe for development
toolkit = KeeperHubToolkit(testnet_only=True)

# Restrict to specific chains only
toolkit = KeeperHubToolkit(
    testnet_only=True,
    allowed_chain_ids={"11155111", "84532"},  # Sepolia, Base Sepolia
)

Applies to transfer_funds, contract_call, check_and_execute. Returns a structured error instead of executing on mainnet.


Execution History

# SQLite-backed — zero extra deps
toolkit = KeeperHubToolkit(history=True)           # ~/.keeperhub/executions.db
toolkit = KeeperHubToolkit(history="./project.db") # custom path

# Or bring your own store
from langchain_keeperhub import SqliteExecutionStore
toolkit = KeeperHubToolkit(history=SqliteExecutionStore("./executions.db"))

When history=True, every transfer_funds call is persisted with execution ID, network, amount, and recipient. get_execution_status updates the row with the tx hash when the transaction completes.


MCP Bridge (Optional)

# Combines native tools + KeeperHub's official MCP tools
toolkit = KeeperHubToolkit(
    workflows=True,
    mcp_include={"list_workflows", "execute_workflow", "ai_generate_workflow"},
)
tools = await toolkit.aget_tools()  # must use async when workflows=True

All 24 Tools

Chains

Tool Description
keeperhub_list_chains List all 19 supported blockchains
keeperhub_fetch_contract_abi Fetch verified ABI, auto-resolves EIP-1967/UUPS/Diamond proxies

Web3

Tool Description
keeperhub_transfer_funds Send ETH or any ERC-20 token
keeperhub_contract_call Read or write any smart contract function
keeperhub_check_and_execute Atomic condition check + transaction
keeperhub_estimate_gas Estimate gas cost before submitting

Workflows

Tool Description
keeperhub_list_workflows List all org workflows
keeperhub_execute_workflow Run a workflow by ID
keeperhub_generate_workflow Create a workflow from plain English
keeperhub_get_execution_status Poll status, get tx hash

DeFi

Tool Description
keeperhub_list_protocols Browse all 396 available protocol actions
keeperhub_protocol_action Execute any action — Aave V3/V4, Uniswap, Lido, Compound V3, Morpho, Yearn V3, Curve, CowSwap, Aerodrome
keeperhub_get_action_schema Get required params for any action
keeperhub_search_actions Search 396 actions by keyword

Payments

Tool Description
keeperhub_pay_and_run Execute a paid workflow via x402 (Base USDC) or MPP (Tempo USDC.e)

Identity

Tool Description
keeperhub_register_agent Register agent on-chain (ERC-8004) — mints identity NFT
keeperhub_wallet_balance Check managed wallet balance across all chains
keeperhub_provision_wallet Provision new Turnkey-backed agentic wallet

ENS

Tool Description
keeperhub_ens_resolve Resolve ENS name → address (e.g. vitalik.eth)
keeperhub_ens_text_record Read ENS text records (avatar, email, twitter, url)
keeperhub_ens_lookup Reverse lookup — address → ENS name

Chainlink

Tool Description
keeperhub_chainlink_ccip Cross-chain token transfer via Chainlink CCIP
keeperhub_chainlink_price Get latest price from Chainlink oracle

Utility

Tool Description
keeperhub_run_code Execute custom JavaScript in KeeperHub sandbox
keeperhub_math_aggregate Sum, average, median, min, max

Config Reference

Parameter Type Default Description
api_key str env KEEPERHUB_API_KEY KeeperHub API key
base_url str https://app.keeperhub.com API base URL
timeout float 30.0 Per-request timeout in seconds
tools list[str] None (all 24) Allowlist of tool names to load
testnet_only bool False Block all mainnet writes
allowed_chain_ids set[str] None Chain ID allowlist
history bool | str | Store False Execution history store
workflows bool False Enable MCP bridge
agent_context dict None Session/goal metadata for observability

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

keeperhub_langchain-0.3.1.tar.gz (42.6 kB view details)

Uploaded Source

Built Distribution

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

keeperhub_langchain-0.3.1-py3-none-any.whl (47.0 kB view details)

Uploaded Python 3

File details

Details for the file keeperhub_langchain-0.3.1.tar.gz.

File metadata

  • Download URL: keeperhub_langchain-0.3.1.tar.gz
  • Upload date:
  • Size: 42.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for keeperhub_langchain-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f5d28bfc21641ceb666c03b83c6c53c75b16544df64b0d8339436d4b111c8f05
MD5 6fc8bcfe9341aa52eaf1e0da6691001c
BLAKE2b-256 0ea2292b49fd5e0b2b06d82a798c8128ed2d05d7ecf0797000e2b7e27d0a76cd

See more details on using hashes here.

File details

Details for the file keeperhub_langchain-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for keeperhub_langchain-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 467c67b3e6f4fe37217f2ab399a848a6c4bd2a46740d6e9f2df3eb439ded8332
MD5 f321a682885fe05d6e9736f815f71396
BLAKE2b-256 00c9fc4775aa15d230b580990264ff230c2d1685320e97441d9e8d7f5491f5e8

See more details on using hashes here.

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