Skip to main content
Glama

t2000_invest

Manage investment assets by buying, selling, or earning yield through lending. Automatically handles insufficient balances by withdrawing from savings.

Instructions

Buy, sell, earn yield, or stop earning on investment assets. Actions: buy (invest USD), sell (convert to USDC), earn (deposit into best-rate lending for yield), unearn (withdraw from lending, keep in portfolio). Amount required for buy/sell only. If checking balance is insufficient for a buy, the SDK will auto-withdraw from savings — no manual withdraw needed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes'buy' to invest, 'sell' to liquidate, 'earn' to deposit into lending for yield, 'unearn' to withdraw from lending
assetYesAsset to invest in
amountNoUSD amount (required for buy/sell, ignored for earn/unearn)
slippageNoMax slippage percent (default: 3, for buy/sell only)
dryRunNoPreview without signing (default: false)

Implementation Reference

  • The handler function for t2000_invest, which processes actions: buy, sell, earn, and unearn. It interacts with the agent to perform these actions and optionally supports a dry run.
    async ({ action, asset, amount, slippage, dryRun }) => {
      try {
        if (dryRun) {
          agent.enforcer.assertNotLocked();
          const balance = await agent.balance();
          const portfolio = await agent.getPortfolio();
          const position = portfolio.positions.find(p => p.asset === asset);
    
          if (action === 'sell' && amount === 'all' && !position) {
            return {
              content: [{ type: 'text', text: JSON.stringify({ preview: true, error: `No ${asset} position to sell` }) }],
            };
          }
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                preview: true,
                action,
                asset,
                amount: amount === 'all' ? position?.currentValue ?? 0 : amount ?? position?.totalAmount ?? 0,
                currentBalance: balance.available,
                currentPosition: position ?? null,
                earning: position?.earning ?? false,
                earningProtocol: position?.earningProtocol ?? null,
                earningApy: position?.earningApy ?? null,
              }),
            }],
          };
        }
    
        const maxSlippage = slippage ? slippage / 100 : undefined;
        if (action === 'buy') {
          if (typeof amount !== 'number') throw new Error('Buy amount must be a number');
          const result = await mutex.run(() => agent.investBuy({ asset: asset as InvestmentAsset, usdAmount: amount, maxSlippage }));
          return { content: [{ type: 'text', text: JSON.stringify(result) }] };
        } else if (action === 'sell') {
          const usdAmount = amount === 'all' ? 'all' as const : amount as number;
          const result = await mutex.run(() => agent.investSell({ asset: asset as InvestmentAsset, usdAmount, maxSlippage }));
          return { content: [{ type: 'text', text: JSON.stringify(result) }] };
        } else if (action === 'earn') {
          const result = await mutex.run(() => agent.investEarn({ asset: asset as InvestmentAsset }));
          return { content: [{ type: 'text', text: JSON.stringify(result) }] };
        } else {
          const result = await mutex.run(() => agent.investUnearn({ asset: asset as InvestmentAsset }));
          return { content: [{ type: 'text', text: JSON.stringify(result) }] };
        }
      } catch (err) {
        return errorResult(err);
      }
    },
  • Registration of the t2000_invest tool with the MCP server, defining its schema and tool description.
    server.tool(
      't2000_invest',
      'Buy, sell, earn yield, or stop earning on investment assets. Actions: buy (invest USD), sell (convert to USDC), earn (deposit into best-rate lending for yield), unearn (withdraw from lending, keep in portfolio). Amount required for buy/sell only. If checking balance is insufficient for a buy, the SDK will auto-withdraw from savings — no manual withdraw needed.',
      {
        action: z.enum(['buy', 'sell', 'earn', 'unearn']).describe("'buy' to invest, 'sell' to liquidate, 'earn' to deposit into lending for yield, 'unearn' to withdraw from lending"),
        asset: z.enum(investAssets).describe('Asset to invest in'),
        amount: z.union([z.number(), z.literal('all')]).optional().describe('USD amount (required for buy/sell, ignored for earn/unearn)'),
        slippage: z.number().optional().describe('Max slippage percent (default: 3, for buy/sell only)'),
        dryRun: z.boolean().optional().describe('Preview without signing (default: false)'),
      },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: the auto-withdraw feature for insufficient checking balances during buys, and that amount is required only for buy/sell actions. However, it lacks details on error handling, rate limits, or authentication needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in two sentences, front-loading the core actions and following with important behavioral details. Every sentence adds value without redundancy, making it easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 5 parameters, no annotations, and no output schema, the description is adequate but has gaps. It covers the main actions and some behavioral traits, but does not explain return values, error conditions, or dependencies on other tools, leaving room for improvement in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema, such as clarifying that amount is 'ignored for earn/unearn' and mentioning the auto-withdraw behavior, but does not provide additional syntax or format details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs (buy, sell, earn, unearn) and resources (investment assets), distinguishing it from siblings like t2000_balance or t2000_portfolio by focusing on transactional operations rather than querying.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use each action (e.g., 'buy to invest USD', 'sell to convert to USDC'), but does not explicitly state when to use this tool versus alternatives like t2000_exchange or t2000_save, nor does it mention prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/mission69b/t2000'

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