Skip to content

Commit 5a26217

Browse files
[Docs] Add MCP tool filtering, agent examples, and available tools list (#8188)
1 parent 938c1e2 commit 5a26217

File tree

3 files changed

+204
-25
lines changed

3 files changed

+204
-25
lines changed

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

Lines changed: 113 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,76 @@ https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>
1717

1818
Make sure to keep your secret key safe and never share it with anyone.
1919

20+
By default, all tools are available. You can filter the tools available by passing multiple `tool` query parameter.
21+
22+
```http
23+
https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>&tool=fetchWithPayment&tool=getWalletBalance
24+
```
25+
26+
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.
31+
32+
#### Example usage with langchain:
33+
34+
<Tabs defaultValue="typescript">
35+
36+
<TabsList>
37+
<TabsTrigger value="typescript">TypeScript</TabsTrigger>
38+
<TabsTrigger value="python">Python</TabsTrigger>
39+
</TabsList>
40+
41+
<TabsContent value="typescript">
42+
43+
```typescript
44+
import { createReactAgent } from "@langchain/langgraph/prebuilt";
45+
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
46+
47+
const mcpServers = {
48+
thirdweb: {
49+
url: `https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>`
50+
}
51+
};
52+
53+
// Connect to MCP servers and get tools
54+
const client = new MultiServerMCPClient(mcpServers);
55+
const tools = await client.getTools();
56+
57+
const agent = createReactAgent({
58+
llm: model,
59+
tools: tools,
60+
});
61+
await agent.invoke({messages: [{ role: "user", content: "create a server wallet called 'my-wallet'" }]})
62+
```
63+
64+
</TabsContent>
65+
66+
<TabsContent value="python">
67+
68+
```python
69+
from langchain_mcp_adapters.client import MultiServerMCPClient
70+
from langgraph.prebuilt import create_react_agent
71+
72+
client = MultiServerMCPClient(
73+
{
74+
"thirdweb": {
75+
"url": "https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>",
76+
}
77+
}
78+
)
79+
tools = await client.get_tools()
80+
agent = create_react_agent("openai:gpt-4.1", tools)
81+
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+
2090
## Usage with LLM clients
2191

2292
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.
@@ -112,31 +182,6 @@ claude mcp add --transport http "thirdweb-api" "https://api.thirdweb.com/mcp?sec
112182

113183
</Tabs>
114184

115-
## Usage with agents
116-
117-
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
123-
from langgraph.prebuilt import create_react_agent
124-
125-
client = MultiServerMCPClient(
126-
{
127-
"thirdweb-api": {
128-
"transport": "streamable_http",
129-
"url": "https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>",
130-
}
131-
}
132-
)
133-
tools = await client.get_tools()
134-
agent = create_react_agent("openai:gpt-4.1", tools)
135-
response = await agent.ainvoke({"messages": "create a server wallet called 'my-wallet'"})
136-
```
137-
138-
Once installed, you can use the entire thirdweb API with natural language.
139-
140185
## Example prompts
141186

142187
#### Managing server wallets
@@ -164,3 +209,46 @@ List my contracts
164209
```
165210
approve 100 USDC from treasury wallet to executor wallet
166211
```
212+
213+
## Available tools
214+
215+
Currently, the following tools are available:
216+
217+
- `initiateAuthentication`
218+
- `completeAuthentication`
219+
- `linkAuthentication`
220+
- `unlinkAuthentication`
221+
- `getMyWallet`
222+
- `listUserWallets`
223+
- `createUserWallet`
224+
- `listServerWallets`
225+
- `createServerWallet`
226+
- `getWalletBalance`
227+
- `getWalletTransactions`
228+
- `getWalletTokens`
229+
- `getWalletNFTs`
230+
- `signMessage`
231+
- `signTypedData`
232+
- `sendTokens`
233+
- `listContracts`
234+
- `deployContract`
235+
- `readContract`
236+
- `writeContract`
237+
- `getContractTransactions`
238+
- `getContractEvents`
239+
- `getContractMetadata`
240+
- `getContractSignatures`
241+
- `getTransactionById`
242+
- `listTransactions`
243+
- `sendTransactions`
244+
- `createPayment`
245+
- `paymentsPurchase`
246+
- `getPaymentHistory`
247+
- `fetchWithPayment`
248+
- `createToken`
249+
- `listTokens`
250+
- `getTokenOwners`
251+
- `getBridgeChains`
252+
- `convertFiatToCrypto`
253+
- `bridgeSwap`
254+
- `chat`

apps/portal/src/app/payments/sidebar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ export const sidebar: SideBar = {
8080
href: `${paymentsSlug}/x402/server`,
8181
name: "Server Side",
8282
},
83+
{
84+
href: `${paymentsSlug}/x402/agents`,
85+
name: "Agents",
86+
},
8387
{
8488
href: `${paymentsSlug}/x402/facilitator`,
8589
name: "Facilitator",
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
2+
import { OpenApiEndpoint } from "@doc";
3+
4+
# Agents
5+
6+
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).
15+
16+
<Tabs defaultValue="typescript">
17+
18+
<TabsList>
19+
<TabsTrigger value="typescript">TypeScript</TabsTrigger>
20+
<TabsTrigger value="python">Python</TabsTrigger>
21+
</TabsList>
22+
23+
<TabsContent value="typescript">
24+
25+
```typescript
26+
import { createReactAgent } from "@langchain/langgraph/prebuilt";
27+
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
28+
import { ChatOpenAI } from "@langchain/openai";
29+
30+
const model = new ChatOpenAI({
31+
model: "gpt-4.1",
32+
});
33+
34+
const mcpServers = {
35+
thirdweb: {
36+
url: `https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>&tool=fetchWithPayment&tool=getWalletBalance`
37+
}
38+
};
39+
40+
// Connect to MCP servers and get tools
41+
const client = new MultiServerMCPClient(mcpServers);
42+
const tools = await client.getTools();
43+
44+
const agent = createReactAgent({
45+
llm: model,
46+
tools: tools,
47+
prompt: "Use the fetchWithPayment tool to fetch any endpoint. Always pay in {{tokenAddress}}. Your wallet address is {{walletAddress}}."
48+
});
49+
```
50+
51+
</TabsContent>
52+
53+
<TabsContent value="python">
54+
55+
```python
56+
from langchain_mcp_adapters.client import MultiServerMCPClient
57+
from langgraph.prebuilt import create_react_agent
58+
59+
client = MultiServerMCPClient(
60+
{
61+
"thirdweb": {
62+
"url": "https://api.thirdweb.com/mcp?secretKey=<your-project-secret-key>&tool=fetchWithPayment&tool=getWalletBalance",
63+
}
64+
}
65+
)
66+
tools = await client.get_tools()
67+
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.
84+
```
85+
86+
<OpenApiEndpoint path="/v1/payments/x402/fetch" method="POST" />
87+

0 commit comments

Comments
 (0)