Skip to main content

LangChain tools wrapping Toolstem MCP servers (Finance + SEC EDGAR) with x402 USDC micropayments

Project description

langchain-toolstem

LangChain tools wrapping Toolstem MCP servers (Finance + SEC EDGAR) with x402 USDC micropayments — Python edition.

Surface Tools Endpoint
Finance get_stock_snapshot, get_company_metrics, compare_companies https://mcp.toolstem.com/mcp/finance
SEC EDGAR get_company_filings_summary, get_insider_signal, get_institutional_signal, get_material_events_digest, compare_disclosure_signals https://mcp.toolstem.com/mcp/sec

initialize and tools/list are free. Each tools/call costs $0.01 USDC on Base mainnet.

TypeScript sibling: langchain-toolstem

Install

pip install langchain-toolstem

With x402 payment support:

pip install 'langchain-toolstem[x402]'

Quick Start

Free Discovery (no wallet needed)

from langchain_toolstem import create_finance_tools, create_sec_tools

# List available tools — free, no payment required
finance_tools = await create_finance_tools()
sec_tools = await create_sec_tools()

for t in finance_tools + sec_tools:
    print(f"{t.name}: {t.description[:80]}")

Paid Tool Calls (with wallet)

from langchain_toolstem import create_finance_tools, create_x402_httpx_client

# Create a paying HTTP client (needs USDC on Base mainnet)
client = await create_x402_httpx_client("0xYOUR_PRIVATE_KEY")

# Tools automatically pay 0.01 USDC per call
tools = await create_finance_tools(http_client=client)
result = await tools[0].ainvoke({"symbol": "AAPL"})
print(result)

With LangGraph Agent

from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

from langchain_toolstem import create_finance_tools, create_x402_httpx_client

client = await create_x402_httpx_client(os.environ["X402_PRIVATE_KEY"])
tools = await create_finance_tools(http_client=client)

agent = create_react_agent(ChatOpenAI(model="gpt-4o"), tools)
result = await agent.ainvoke({
    "messages": [{"role": "user", "content": "Analyze NVDA stock"}]
})

API Reference

create_finance_tools(**kwargs) -> list[StructuredTool]

Discover and return the 3 Finance tools.

create_sec_tools(**kwargs) -> list[StructuredTool]

Discover and return the 5 SEC EDGAR tools.

create_x402_httpx_client(private_key, *, max_payment_usd=1.0) -> httpx.AsyncClient

Create an httpx.AsyncClient that auto-pays x402 USDC micropayments on HTTP 402.

discover_toolstem_tools(url, **kwargs) -> list[StructuredTool]

Low-level: connect to any Toolstem MCP endpoint and return LangChain tools.

Common kwargs for all functions:

Parameter Type Default Description
http_client httpx.AsyncClient None Paying client from create_x402_httpx_client
headers dict[str, str] None Extra headers for every request
url str endpoint default Override the MCP endpoint URL

Network Details

Field Value
Chain Base mainnet (eip155:8453)
Token USDC
Contract 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Price per call $0.01
Wallets Any EVM wallet (Coinbase Smart Wallet, MetaMask, etc.)

Walletless Playground

Try the tools without a wallet at toolstem.com/playground — real, cached responses, no payment required.

Development

git clone https://github.com/toolstem/langchain-toolstem-python
cd langchain-toolstem-python
pip install -e '.[dev]'
pytest

Publishing to PyPI

This package uses PyPI Trusted Publishing (OIDC) — no API tokens needed.

One-time setup:

  1. Go to pypi.org/manage/account/publishing
  2. Add a new pending publisher:
    • PyPI project name: langchain-toolstem
    • Owner: toolstem
    • Repository: langchain-toolstem-python
    • Workflow: publish.yml
    • Environment: pypi
  3. Tag a release: git tag v0.1.0 && git push origin v0.1.0
  4. GitHub Actions will build and publish automatically.

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_toolstem-0.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

langchain_toolstem-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for langchain_toolstem-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6fb00e0fa45db2eb1eb30b2ec12897389852d48322ec97cd0c0d0e05a95d6eea
MD5 ba725c40a6f25bc87e4ed013d178ed6a
BLAKE2b-256 398612470df8e2ef808baf3bb6c0a068505917dba27040ed199e67dda908da04

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on toolstem/langchain-toolstem-python

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_toolstem-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_toolstem-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8a3b1d867773d817a96d240950bc509c6b18fdbf16b8b1d75da1db32a95a7e9
MD5 3d8d103c9abcbbd471815f940163c240
BLAKE2b-256 43b299a17ccead44948395143a95808bc276e6472c809568b5f38301a0e9340d

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on toolstem/langchain-toolstem-python

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