Skip to main content
Glama
Pavilion-devs

Saros MCP Server

get_farm_positions

Retrieve farming positions and staking rewards for a Solana wallet, including staked LP tokens and claimable rewards.

Instructions

Get all farming positions and staking rewards for a wallet. Shows staked LP tokens and claimable rewards.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletYesSolana wallet address

Implementation Reference

  • Primary handler function that executes the get_farm_positions tool logic: validates wallet input, fetches positions from farmService, formats output as formatted text response, handles empty results and errors.
    async function getFarmPositionsTool(args, farmService) {
      const { wallet } = args;
    
      if (!wallet) {
        throw new Error("Wallet address is required");
      }
    
      try {
        const positions = await farmService.getFarmPositions(wallet);
    
        if (positions.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: `No farm positions found for wallet: ${wallet}`,
              },
            ],
          };
        }
    
        // Format positions
        let positionsText = `**Farm Positions for ${wallet}**\n\n`;
        positionsText += `Total Farms: ${positions.length}\n\n`;
    
        positions.forEach((pos, idx) => {
          positionsText +=
            `**Position ${idx + 1}:**\n` +
            `- Farm: ${pos.farmAddress}\n` +
            `- LP Token: ${pos.lpAddress}\n` +
            `- Staked Amount: ${pos.stakedAmount}\n` +
            `- Pool: ${pos.token0} / ${pos.token1}\n`;
    
          if (pos.pendingRewards && pos.pendingRewards.length > 0) {
            positionsText += `- Pending Rewards:\n`;
            pos.pendingRewards.forEach((reward) => {
              positionsText += `  • ${reward.amount} ${reward.symbol}\n`;
            });
          }
    
          positionsText += `\n`;
        });
    
        return {
          content: [
            {
              type: "text",
              text: positionsText,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get farm positions: ${error.message}`);
      }
    }
  • Schema definition for the get_farm_positions tool, including input schema (wallet address required), provided in the ListTools response for tool discovery.
      name: "get_farm_positions",
      description:
        "Get all farming positions and staking rewards for a wallet. Shows staked LP tokens and claimable rewards.",
      inputSchema: {
        type: "object",
        properties: {
          wallet: {
            type: "string",
            description: "Solana wallet address",
          },
        },
        required: ["wallet"],
      },
    },
  • src/index.js:165-166 (registration)
    Tool registration in the central CallToolRequestSchema handler: dispatches calls to get_farm_positions to the specific getFarmPositionsTool function with farmService.
    case "get_farm_positions":
      return await getFarmPositionsTool(args, this.farmService);
  • src/index.js:19-19 (registration)
    Import of the getFarmPositionsTool handler from its dedicated tool module.
    const { getFarmPositionsTool } = require("./tools/get-farm-positions.js");
  • Supporting service method called by the tool handler to retrieve farm positions data (currently a stub implementation).
    async getFarmPositions(walletAddress) {
      // Return empty for demo
      return [];
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Pavilion-devs/saros-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server