Skip to content

Commit 2779afc

Browse files
[Docs] Update X402 agent example to use listDiscoveryResources (#8265)
1 parent fe50abd commit 2779afc

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

apps/portal/src/app/ai/mcp/page.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ Currently, the following tools are available:
245245
- `paymentsPurchase`
246246
- `getPaymentHistory`
247247
- `fetchWithPayment`
248+
- `listDiscoveryResources`
248249
- `createToken`
249250
- `listTokens`
250251
- `getTokenOwners`

apps/portal/src/app/payments/x402/agents/page.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The easiest way to equip your agents with the ability to pay for API calls is to
2020

2121
The MCP server comes with all the tools by default, but you can filter the tools available by passing a comma-separated list of tools as a query parameter.
2222

23-
In this example, we create a ReAct agent using LangChain and filter the MCP tools to `fetchWithPayment` and `getWalletBalance` as the only 2 tools we give our agent. You can view the full list of available tools [here](/ai/mcp#available-tools).
23+
In this example, we create a ReAct agent using LangChain and filter the MCP tools to `fetchWithPayment` and `listDiscoveryResources` as the only 2 tools we give our agent. You can view the full list of available tools [here](/ai/mcp#available-tools).
2424

2525
<Tabs defaultValue="typescript">
2626

@@ -42,7 +42,7 @@ const model = new ChatOpenAI({
4242

4343
const mcpServers = {
4444
thirdweb: {
45-
url: `https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>&tools=fetchWithPayment,getWalletBalance`
45+
url: `https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>&tools=fetchWithPayment,listDiscoveryResources`
4646
}
4747
};
4848

@@ -53,7 +53,7 @@ const tools = await client.getTools();
5353
const agent = createReactAgent({
5454
llm: model,
5555
tools: tools,
56-
prompt: "Use the fetchWithPayment tool to fetch any endpoint. Always pay in {{tokenAddress}}. Your wallet address is {{walletAddress}}."
56+
prompt: "Use the fetchWithPayment tool to fetch any endpoint. Discover the available endpoints with the listDiscoveryResources tool."
5757
});
5858
```
5959

@@ -68,12 +68,12 @@ from langgraph.prebuilt import create_react_agent
6868
client = MultiServerMCPClient(
6969
{
7070
"thirdweb": {
71-
"url": "https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>&tools=fetchWithPayment,getWalletBalance",
71+
"url": "https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>&tools=fetchWithPayment,listDiscoveryResources",
7272
}
7373
}
7474
)
7575
tools = await client.get_tools()
76-
agent = create_react_agent("openai:gpt-4.1", tools, prompt="Use the fetchWithPayment tool to fetch any endpoint. Always pay in {{tokenAddress}}. Your wallet address is {{walletAddress}}.")
76+
agent = create_react_agent("openai:gpt-4.1", tools, prompt="Use the fetchWithPayment tool to fetch any endpoint. Discover the available endpoints with the listDiscoveryResources tool.")
7777
```
7878

7979
</TabsContent>
@@ -83,10 +83,10 @@ agent = create_react_agent("openai:gpt-4.1", tools, prompt="Use the fetchWithPay
8383

8484
You can also create your own MCP tool or wrap all external calls with the `/v1/x402/fetchWithPayment` endpoint to automatically handle payment flows when APIs return a `402 Payment Required` response.
8585

86-
Pass the target `url`, `method` and optional `from` wallet address to the endpoint that will complete the payment. The address should be one of your [user wallets](/wallets/users) or [server wallets](/wallets/server).
86+
Pass the target `url`, `method`. By default, it will use your default project wallet for payments, but you can also pass an optional `from` wallet address to the endpoint that will complete the payment. The address should be one of your [user wallets](/wallets/users) or [server wallets](/wallets/server).
8787

8888
```bash
89-
curl -X POST https://api.thirdweb.com/v1/payments/x402/fetch?url=https://api.example.com/premium&method=GET&from=0x1234... \
89+
curl -X POST https://api.thirdweb.com/v1/payments/x402/fetch?url=https://api.example.com/premium&method=GET \
9090
-H "Content-Type: application/json" \
9191
-H "x-secret-key: <your-project-secret-key>" \
9292
-d '{ ... }' # optional request body passed through to the url called.

0 commit comments

Comments
 (0)