Skip to content

Commit fab1b13

Browse files
committed
feat: add token filter to get_opportunities MCP tools
Allow filtering reserves by token symbol or address in aave_get_opportunities and spark_get_opportunities.
1 parent 6385ef3 commit fab1b13

6 files changed

Lines changed: 12 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ npx @bootnodedev/defi-mcp-server --http --port 3000
9797

9898
The `*_get_opportunities` tools return the top 10 reserves per network by default, with slim fields to minimize token usage. Optional parameters:
9999

100+
- `token` — filter by token symbol (e.g. `USDC`) or contract address (case-insensitive)
100101
- `limit` — max reserves per network (default: 10)
101102
- `detailed` — include all fields like `availableLiquidity`, `liquidationThreshold`, `canBeCollateral` (default: false)
102103

commands/aave.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Parse the following arguments: $ARGUMENTS
1515
| `repay` | `--network --asset --amount --wallet` (amount can be "max") |
1616
| `withdraw` | `--network --asset --amount --wallet` (amount can be "max") |
1717
| `position` | `--network --wallet` |
18-
| `opportunities` | `--network` (can be "all") |
18+
| `opportunities` | `--network` (can be "all"), optional `--token` to filter by symbol or address |
1919
| `grant-permissions` | `--network --wallet --token --limit` |
2020

2121
## Instructions

commands/spark.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Parse the following arguments: $ARGUMENTS
1515
| `repay` | `--network --asset --amount --wallet` (amount can be "max") |
1616
| `withdraw` | `--network --asset --amount --wallet` (amount can be "max") |
1717
| `position` | `--network --wallet` |
18-
| `opportunities` | `--network` (can be "all") |
18+
| `opportunities` | `--network` (can be "all"), optional `--token` to filter by symbol or address |
1919
| `grant-permissions` | `--network --wallet --token --limit` |
2020

2121
## Instructions

mcp-server/tools/aave.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ export function registerAaveTools(server: McpServer) {
2323
description: "Aave V3 supply/borrow APY rates. Top reserves ranked by supply APY. Use detailed=true for all fields.",
2424
inputSchema: z.object({
2525
network: networkAll,
26+
token: z.string().optional().describe("Filter by token symbol (e.g. 'USDC') or address (0x...). Case-insensitive."),
2627
limit: z.number().optional().describe("Max reserves per network (default: 10)"),
2728
detailed: z.boolean().optional().describe("Include all reserve fields"),
2829
}),
2930
},
30-
async ({ network: net, limit, detailed }) => {
31+
async ({ network: net, token, limit, detailed }) => {
3132
const results = await getOpportunities(net as NetworkName | "all");
3233
const maxReserves = limit ?? DEFAULT_LIMIT;
34+
const tokenFilter = token?.toLowerCase();
3335

3436
const slimmed = results.map(({ network: n, reserves }) => ({
3537
network: n,
3638
reserves: reserves
3739
.filter((r) => r.supplyAPY >= MIN_APY || r.borrowAPY >= MIN_APY)
40+
.filter((r) => !tokenFilter || r.symbol.toLowerCase() === tokenFilter || r.asset.toLowerCase() === tokenFilter)
3841
.slice(0, maxReserves)
3942
.map((r) =>
4043
detailed

mcp-server/tools/spark.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ export function registerSparkTools(server: McpServer) {
2323
description: "SparkLend supply/borrow APY rates. Top reserves ranked by supply APY. Use detailed=true for all fields.",
2424
inputSchema: z.object({
2525
network: networkAll,
26+
token: z.string().optional().describe("Filter by token symbol (e.g. 'DAI') or address (0x...). Case-insensitive."),
2627
limit: z.number().optional().describe("Max reserves per network (default: 10)"),
2728
detailed: z.boolean().optional().describe("Include all reserve fields"),
2829
}),
2930
},
30-
async ({ network: net, limit, detailed }) => {
31+
async ({ network: net, token, limit, detailed }) => {
3132
const results = await getOpportunities(net as NetworkName | "all");
3233
const maxReserves = limit ?? DEFAULT_LIMIT;
34+
const tokenFilter = token?.toLowerCase();
3335

3436
const slimmed = results.map(({ network: n, reserves }) => ({
3537
network: n,
3638
reserves: reserves
3739
.filter((r) => r.supplyAPY >= MIN_APY || r.borrowAPY >= MIN_APY)
40+
.filter((r) => !tokenFilter || r.symbol.toLowerCase() === tokenFilter || r.asset.toLowerCase() === tokenFilter)
3841
.slice(0, maxReserves)
3942
.map((r) =>
4043
detailed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bootnodedev/defi-mcp-server",
3-
"version": "0.1.0-beta.2",
3+
"version": "0.1.0-beta.3",
44
"description": "DeFi for Agents",
55
"license": "ISC",
66
"author": "BootNode",

0 commit comments

Comments
 (0)