Skip to main content
Glama

evaluate_strategy

Assess trading strategies against current market conditions to identify optimal approaches for risk management and performance.

Instructions

Evaluate a trading strategy against current market conditions. Built-in strategies: conservative_dca, momentum_rider, macro_aligned, fear_accumulator, full_defensive. Also evaluates custom strategies created with set_custom_strategy.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
strategyYesStrategy name (e.g. "conservative_dca", "momentum_rider", "full_defensive", or a custom name)

Implementation Reference

  • The MCP tool handler for 'evaluate_strategy'. It resolves the strategy definition (builtin or custom) and calls the strategy engine to evaluate it against current values.
    export async function evaluateStrategyTool(cache: CacheService, strategyName: string): Promise<StrategyEvaluation | ErrorOutput> {
      // Find strategy — check builtins first, then custom
      let strategy: StrategyDefinition | null = BUILTIN_STRATEGIES.find(s => s.name === strategyName) ?? null;
    
      if (!strategy) {
        const custom = getStrategy(AGENT_ID, strategyName);
        if (custom) {
          strategy = {
            name: custom.name,
            description: `Custom strategy: ${custom.name}`,
            conditions: custom.conditions,
            action_when_met: 'execute',
            action_when_not_met: 'wait',
          };
        }
      }
    
      if (!strategy) {
        const available = BUILTIN_STRATEGIES.map(s => s.name).join(', ');
        return {
          error: true, error_source: 'evaluate_strategy',
          agent_guidance: `Strategy "${strategyName}" not found. Available built-in strategies: ${available}. You can also create custom strategies with set_custom_strategy.`,
          last_known_data: null, data_warnings: [`Unknown strategy: ${strategyName}`],
        };
      }
    
      try {
        const reality = await getRealityCheck(cache);
        const currentValues = extractCurrentValues(reality as unknown as Record<string, unknown>);
        return evaluateStrategy(strategy, currentValues);
      } catch {
        return {
          error: true, error_source: 'evaluate_strategy',
          agent_guidance: 'Strategy evaluation temporarily unavailable. Retry shortly.',
          last_known_data: null, data_warnings: ['Strategy evaluation service temporarily unavailable.'],
        };
      }
    }
  • The core engine logic that evaluates a StrategyDefinition against current values to determine if conditions are met and what action to take.
    export function evaluateStrategy(
      strategy: StrategyDefinition,
      currentValues: Record<string, string | number | null>,
    ): StrategyEvaluation {
      const details: ConditionResult[] = [];
      let allMet = true;
    
      for (const condition of strategy.conditions) {
        const result = evaluateCondition(condition, currentValues);
        details.push(result);
        if (!result.met) allMet = false;
      }
    
      const action = allMet ? strategy.action_when_met : strategy.action_when_not_met;
    
      let guidance = `Strategy "${strategy.name}": `;
      if (allMet) {
        guidance += `ALL conditions met. Action: ${action.toUpperCase()}. `;
        if (action === 'execute') guidance += 'Conditions are favorable for this strategy. Proceed with position sizing appropriate to your risk tolerance.';
        else if (action === 'exit') guidance += 'Exit conditions triggered. Reduce or close positions immediately.';
      } else {
        const unmet = details.filter(d => !d.met);
        guidance += `${unmet.length} condition${unmet.length === 1 ? '' : 's'} not met. Action: WAIT. `;
        guidance += `Unmet: ${unmet.map(u => `${u.field} is ${u.current_value} (need ${u.operator} ${u.threshold})`).join('; ')}.`;
      }
    
      return {
        strategy_name: strategy.name,
        description: strategy.description,
        conditions_met: allMet,
        conditions_detail: details,
        action,
        agent_guidance: guidance,
      };
    }
Behavior2/5

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

No annotations provided, so description carries full burden. States 'evaluate' but fails to clarify if this is read-only simulation, modifies state, or incurs costs/rate limits. Critical behavioral gaps remain.

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?

Two efficient sentences with zero waste. Front-loaded with action and scope, followed by valid inputs and their source. Excellent information density.

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?

Appropriate for a single-parameter tool with complete schema coverage, but gaps remain: no output schema exists yet description omits what evaluation returns, and behavioral safety is undisclosed.

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

Parameters4/5

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

Schema coverage is 100%, but description adds significant value by enumerating all five valid built-in strategy names (completing the partial list in schema) and clarifying custom strategy provenance from 'set_custom_strategy'.

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?

Provides specific verb (Evaluate), resource (trading strategy), and scope (against current market conditions). Lists all five built-in strategies, clearly positioning it relative to the data-retrieval 'get_' siblings.

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?

Explicitly references sibling tool 'set_custom_strategy' as the prerequisite for evaluating custom strategies, clarifying the workflow. However, lacks explicit 'when not to use' guidance relative to analysis tools like 'get_portfolio_analysis'.

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/0xHashy/fathom-fyi'

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