How to Use Pocketsflow MCP in a Custom LangChain Agent
To use Pocketsflow MCP in a custom LangChain agent, point LangChain's MultiServerMCPClient at https://www.pocketsflow.com/mcp with the http transport and a Pocketsflow API key in an Authorization: Bearer header. Start with a pk_test_ key and keep only the look-up tools, and your agent can report on your Pocketsflow store without changing anything.
What Pocketsflow gives a LangChain agent
Pocketsflow's MCP server is part of the Pocketsflow backend, so there is nothing to host. It speaks stateless Streamable HTTP: the agent posts tools/list and tools/call and gets JSON back. Each tool call runs the matching public API endpoint as your account, with the same validation and the same data scoping as the REST API. Pocketsflow exposes 303 tools in total.
Chat apps like Claude and ChatGPT connect with a sign-in and an Allow access button. A LangChain script usually runs with no browser, so the Pocketsflow docs point it to an API key instead.
How to connect LangChain to Pocketsflow MCP
- In the Pocketsflow dashboard, switch to test mode and open Developers, API keys. Create a key for this agent. It starts with
pk_test_. - Install LangChain's MCP adapter and set your keys as environment variables. Never put a key in the code or in git.
- Create a
MultiServerMCPClientwith the Pocketsflow URL, thehttptransport and the bearer header. - Load the tools with
get_tools(), filter them to look-ups, and pass them tocreate_agent. - Run a read-only prompt and check the answer against your dashboard.
pip install langchain-mcp-adapters langgraph "langchain[openai]"
export OPENAI_API_KEY=...
export POCKETSFLOW_API_KEY=pk_test_...A minimal Pocketsflow LangChain agent in Python
This Pocketsflow example follows the code in LangChain's own langchain-mcp-adapters README. The headers field is sent with every HTTP request, which is how the Pocketsflow key reaches the server. The model string comes from that README; any chat model LangChain supports works the same way.
import asyncio
import os
from langchain.agents import create_agent
from langchain_mcp_adapters.client import MultiServerMCPClient
READ_ONLY = ("get_", "list_", "search_")
async def main():
client = MultiServerMCPClient(
{
"pocketsflow": {
"transport": "http",
"url": "https://www.pocketsflow.com/mcp",
"headers": {
"Authorization": f"Bearer {os.environ['POCKETSFLOW_API_KEY']}"
},
}
}
)
tools = await client.get_tools()
tools = [tool for tool in tools if tool.name.startswith(READ_ONLY)]
print(f"{len(tools)} read-only Pocketsflow tools loaded")
agent = create_agent("openai:gpt-4.1", tools)
result = await agent.ainvoke(
{"messages": "List my last 10 Pocketsflow orders and total them."}
)
print(result["messages"][-1].content)
asyncio.run(main())With a pk_test_ key, every call reads and writes test data only, whatever the dashboard toggle says. Pocketsflow keeps the key's mode for the whole request.
Why the Pocketsflow agent keeps only look-up tools
Pocketsflow names its tools verb_resource, so a name filter is enough to start safe. The filter in the code keeps tools that start with get_, list_ or search_: 158 of 303. The agent can then read orders, payments and analytics, but has no tool to create a product, send an email or delete a webhook. The chart shows what the filter keeps in the areas a reporting agent needs.
| Point | All tools | Kept by the read-only filter |
|---|---|---|
| Orders and customers | 6 | 6 |
| Payments and subscribers | 4 | 4 |
| Payouts (read only) | 4 | 4 |
| Analytics | 8 | 8 |
| Products | 6 | 2 |
| Discounts | 7 | 3 |
| Subscriptions | 6 | 2 |
Source: Pocketsflow MCP tool catalog (www.pocketsflow.com/mcp, content/mcp.ts), read November 2, 2026.
Orders keep 6 of 6 tools, and analytics keeps 8 of 8. Products keep 2 of 6, because the rest create, update or delete. Add a write tool by name later, only when the agent needs it.
Prompts for a Pocketsflow reporting agent
These Pocketsflow prompts work with the read-only tool set. The tool each one triggers is in brackets.
- "List my last 10 orders and total them." (
list_orders) - "How much recurring revenue did I collect last month?" (
list_payments) - "Are my payouts active, and how much can I withdraw?" (
get_payout_status,get_payout_balance) - "Give me my headline sales totals for this week." (
get_analytics_preview) - "Which plan am I on, and which features does it include?" (
get_entitlements)
Some Pocketsflow tools need a paid plan. On a lower plan they answer with a 403 FEATURE_LOCKED tool error. LangChain's adapter hands that error to the model as a tool message by default, so the agent can tell you to upgrade instead of crashing.
The newer langchain.mcp API with Pocketsflow
LangChain's README says langchain-mcp-adapters is no longer actively maintained, and that MCP support moved into LangChain itself as langchain.mcp (install "langchain[mcp]", version 1.4.0 or later, in beta). There, MultiServerMCPClient becomes MCPAdapter, and the Pocketsflow key goes on a FastMCP client as auth:
import os
from fastmcp.client import Client
from langchain.mcp import MCPAdapter
READ_ONLY = ("get_", "list_", "search_")
async def load_pocketsflow_tools():
client = Client(
"https://www.pocketsflow.com/mcp",
auth=os.environ["POCKETSFLOW_API_KEY"],
)
async with MCPAdapter(client) as adapter:
tools = await adapter.list_tools()
return [tool for tool in tools if tool.name.startswith(READ_ONLY)]FastMCP sends a token passed as auth as an Authorization: Bearer header, which is what Pocketsflow expects. For a script you run on your own laptop, auth="oauth" is the other option: Pocketsflow supports dynamic client registration and localhost redirects, so you sign in and click Allow access instead of creating a key.
Taking a Pocketsflow agent live
- Run your prompts on test data until the answers match the dashboard.
- Create a separate
pk_live_key for the agent and store it in your server's secret manager. - Keep the read-only filter. Add single write tools by name, and only with a human approval step in your graph.
- To cut the agent off, delete its key under Developers, API keys. Access stops on the next request.
Some Pocketsflow actions are never available to an agent: payment refunds, withdrawals and bank details stay in the dashboard. The create_refund tool sets refund policies, and the payout tools only read.
More on Pocketsflow MCP
For the full tool catalog, see the Pocketsflow MCP page and what Pocketsflow MCP can do. To decide between MCP tools and direct REST calls, read MCP vs API for selling online, and for keys and safety, read MCP server security for sellers.