You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can find all available tools at the bottom of this page.
27
+
28
+
## Usage with agents
29
+
30
+
Use your favorite agent framework to plug in the MCP server as a collection of tools for your agent. Refer to your agent framework's documentation for more information.
response =await agent.invoke({"messages": "create a server wallet called 'my-wallet'"})
82
+
```
83
+
84
+
</TabsContent>
85
+
86
+
</Tabs>
87
+
88
+
Once installed, you can use the entire thirdweb API with natural language.
89
+
20
90
## Usage with LLM clients
21
91
22
92
You can also use the MCP server on your own LLM client, like cursor, claude code and more. Refer to your LLM client's documentation for more information.
Use your favorite agent framework to plug in the MCP server as a collection of tools for your agent. Refer to your agent framework's documentation for more information.
118
-
119
-
#### Example usage with langchain:
120
-
121
-
```python
122
-
from langchain_mcp_adapters.client import MultiServerMCPClient
Easily create AI agents that can pay for any x402-compatible API calls.
7
+
8
+
## Using the MCP Server
9
+
10
+
The easiest way to equip your agents with the ability to pay for API calls is to use the [remote MCP server](/ai/mcp) and provide the tools to your agent.
11
+
12
+
The MCP server comes with all the tools by default, but you can filter the tools available by passing multiple `tool` query parameter.
13
+
14
+
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).
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}}.")
68
+
```
69
+
70
+
</TabsContent>
71
+
</Tabs>
72
+
73
+
## Using the API directly
74
+
75
+
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.
76
+
77
+
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).
78
+
79
+
```bash
80
+
curl -X POST https://api.thirdweb.com/v1/payments/x402/fetch?url=https://api.example.com/premium&method=GET&from=0x1234... \
81
+
-H "Content-Type: application/json" \
82
+
-H "x-secret-key: <your-project-secret-key>" \
83
+
-d '{ ... }'# optional request body passed through to the url called.
0 commit comments