Connecting a payment tool
How to add a payment tool to a LangChain agent
Load a remote MCP payment server's tools into a LangChain agent with langchain.mcp, send the bearer token from your environment and pause payments for review.
Install langchain[mcp], connect with MCPAdapter(Client(url, auth=token)), where Client is fastmcp's client carrying the bearer token, then pass await adapter.list_tools() to create_agent. Add HumanInTheLoopMiddleware with interrupt_on for the payment tool so a person approves each call.
Why is this harder than it sounds?
LangChain's MCP support has moved. Most tutorials use MultiServerMCPClient from the separate langchain-mcp-adapters package, whose README now says it is no longer actively maintained. LangChain's docs replace it with the langchain.mcp namespace (langchain[mcp] 1.4.0 or later), which is in beta, and headers and auth now sit on a fastmcp client or transport rather than in a config dict. Agents built with LangChain also tend to run in services that take input from many people, so whatever text reaches the model can try to steer a payment call. The framework can pause a call for review; the amount and recipient limits have to live on the payment server.
How do you do it?
- Create a credential and install. Make a dedicated endpoint with small limits and a simulated source, export VEYRA_TOKEN, and install with pip install "langchain[mcp]". LangChain's docs require version 1.4.0 or later for the langchain.mcp namespace.
- Connect with the bearer token. from fastmcp.client import Client; from langchain.mcp import MCPAdapter. Then: async with MCPAdapter(Client("https://veyra.money/api/mcp", auth=os.environ["VEYRA_TOKEN"])) as adapter: tools = await adapter.list_tools(). LangChain's auth docs say auth accepts a bearer-token string, the literal "oauth", or any httpx.Auth. The migration guide also shows StreamableHttpTransport(url, headers={"Authorization": "Bearer …"}) if you prefer an explicit header.
- Build the agent with a review step. from langchain.agents import create_agent; from langchain.agents.middleware import HumanInTheLoopMiddleware; from langgraph.checkpoint.memory import InMemorySaver. Then: agent = create_agent(model, tools, middleware=[HumanInTheLoopMiddleware(interrupt_on={"create_payment": {"allowed_decisions": ["approve", "reject"]}})], checkpointer=InMemorySaver()). LangChain's docs say human-in-the-loop requires a checkpointer; use a persistent one in production.
- Use the tool names you actually got. Print the names list_tools returns before writing interrupt_on. LangChain's docs say that with several servers in one MCPConfig, every tool is prefixed with its config key, so create_payment can arrive as veyra_create_payment.
- Resume after review. Run the agent with a thread_id in config. When it pauses, show the pending call to a person, then resume with agent.invoke(Command(resume={"decisions": [{"type": "approve"}]}), config=config), or a reject decision with a message for the model.
- Test on the simulated source. Ask the agent to report its budget, then to make one small payment and one in your approval band. Check the second comes back awaiting approval and the agent passes on the link instead of paying again.
What it does not mean
- interrupt_on is not a spending limit. It shows a person the call; the amount and recipient rules are enforced, or not, by the payment server.
- Leaving the async with block doesn't disconnect the tools. LangChain's docs say the tools stay callable after the context exits, and by default each call opens and releases its own session.
- A MultiServerMCPClient tutorial isn't wrong for the old package, but it isn't the current API. LangChain's migration guide says the transport key goes away and headers move to a fastmcp transport.
- The model choosing not to call create_payment is not a control. Treat every tool you load as one the model may call.
Common questions
Do I still need langchain-mcp-adapters?
Not for new code. LangChain's migration guide says langchain.mcp replaces it and tells you to uninstall it and install langchain[mcp]. Existing code on MultiServerMCPClient, with transport "http", a url and a headers dict, keeps the same shape until you migrate.
Can several users share one agent?
LangChain's auth docs show building a client per user with that user's own token. Give each person their own payment endpoint, so one person's agent can't spend under another's budget.
Is langchain.mcp stable?
LangChain's migration guide says the namespace is in beta and the API may change. Pin your version and check the docs when you upgrade.
Where does Veyra fit?
Veyra's endpoint works as a plain URL target: https://veyra.money/api/mcp over Streamable HTTP, with a static bearer token beginning veyra_. It has no OAuth flow, so pass the token string rather than "oauth". Veyra's docs don't include a LangChain walkthrough; the setup above uses only the documented endpoint and header. Seven tools load: get_capabilities, get_budget, list_payment_sources, create_payment, get_payment, list_payments and cancel_payment. create_payment needs an idempotency_key, and reusing it on a retry is what stops a second payment. Limits, the approval band and the recipient allowlist are applied on Veyra's server whatever the agent's middleware does.

Sources
Terms on this page
- MCP serverAn MCP server is a service that offers tools, resources or prompts to AI applications using the Model Context Protocol, an open protocol built on JSON-RPC 2.0.
- Idempotency keyAn idempotency key is a unique value a client attaches to a request so that, if the same request is sent again with the same key, the server returns the original result instead of performing the action a second time.
- Recipient allowlistA recipient allowlist is a list of approved payees, such as wallet addresses, that a payment system checks before it lets an agent pay; payments to anyone not on the list are held or refused.
This page explains how agent payments and the related technology work. It is not financial, investment, legal or tax advice. Protocols and provider features change; check the linked official sources before relying on a detail.