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:
- Go to pypi.org/manage/account/publishing
- Add a new pending publisher:
- PyPI project name:
langchain-toolstem - Owner:
toolstem - Repository:
langchain-toolstem-python - Workflow:
publish.yml - Environment:
pypi
- PyPI project name:
- Tag a release:
git tag v0.1.0 && git push origin v0.1.0 - GitHub Actions will build and publish automatically.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fb00e0fa45db2eb1eb30b2ec12897389852d48322ec97cd0c0d0e05a95d6eea
|
|
| MD5 |
ba725c40a6f25bc87e4ed013d178ed6a
|
|
| BLAKE2b-256 |
398612470df8e2ef808baf3bb6c0a068505917dba27040ed199e67dda908da04
|
Provenance
The following attestation bundles were made for langchain_toolstem-0.1.0.tar.gz:
Publisher:
publish.yml on toolstem/langchain-toolstem-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_toolstem-0.1.0.tar.gz -
Subject digest:
6fb00e0fa45db2eb1eb30b2ec12897389852d48322ec97cd0c0d0e05a95d6eea - Sigstore transparency entry: 1724423639
- Sigstore integration time:
-
Permalink:
toolstem/langchain-toolstem-python@32d83f5d49443aa036f98356630db47aaafe2e28 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/toolstem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@32d83f5d49443aa036f98356630db47aaafe2e28 -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_toolstem-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_toolstem-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8a3b1d867773d817a96d240950bc509c6b18fdbf16b8b1d75da1db32a95a7e9
|
|
| MD5 |
3d8d103c9abcbbd471815f940163c240
|
|
| BLAKE2b-256 |
43b299a17ccead44948395143a95808bc276e6472c809568b5f38301a0e9340d
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_toolstem-0.1.0-py3-none-any.whl -
Subject digest:
a8a3b1d867773d817a96d240950bc509c6b18fdbf16b8b1d75da1db32a95a7e9 - Sigstore transparency entry: 1724423819
- Sigstore integration time:
-
Permalink:
toolstem/langchain-toolstem-python@32d83f5d49443aa036f98356630db47aaafe2e28 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/toolstem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@32d83f5d49443aa036f98356630db47aaafe2e28 -
Trigger Event:
push
-
Statement type: