Skip to main content
Glama

set_custom_strategy

Define custom trading strategies with specific conditions to evaluate against market data for financial decision-making.

Instructions

Create a custom trading strategy with your own conditions. Then use evaluate_strategy to test it against current market conditions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName for your strategy
conditionsYesArray of conditions that must ALL be met

Implementation Reference

  • The handler function that processes the set_custom_strategy tool call.
    export function setCustomStrategyTool(input: SetStrategyInput): SetStrategyResult {
      const validated = input.conditions
        .filter(c => c.field && c.operator && c.threshold !== undefined)
        .map(c => ({
          field: c.field,
          operator: c.operator as ConditionOperator,
          threshold: c.threshold,
        }));
    
      setStrategy(AGENT_ID, {
        name: input.name,
        conditions: validated,
        created_at: new Date().toISOString(),
      });
    
      return {
        success: true,
        agent_id: AGENT_ID,
        strategy_name: input.name,
        conditions_count: validated.length,
        agent_guidance: `Custom strategy "${input.name}" saved with ${validated.length} conditions. Call evaluate_strategy with strategy: "${input.name}" to evaluate against current market conditions.`,
      };
    }
  • Input and Output type definitions for the set_custom_strategy tool.
    export interface SetStrategyInput {
      name: string;
      conditions: Array<{ field: string; operator: string; threshold: string | number }>;
    }
    
    export interface SetStrategyResult {
      success: boolean;
      agent_id: string;
      strategy_name: string;
      conditions_count: number;
      agent_guidance: string;
    }
  • src/index.ts:342-361 (registration)
    Registration of the set_custom_strategy tool in the MCP server.
    // ─── Tool: set_custom_strategy ───
    server.tool(
      'set_custom_strategy',
      'Create a custom trading strategy with your own conditions. Then use evaluate_strategy to test it against current market conditions.',
      {
        name: z.string().describe('Name for your strategy'),
        conditions: z.array(z.object({
          field: z.string().describe('Condition field (fear_greed, risk_score, regime, posture, etc.)'),
          operator: z.string().describe('Comparison operator: <, >, <=, >=, ==, !='),
          threshold: z.union([z.string(), z.number()]).describe('Threshold value'),
        })).describe('Array of conditions that must ALL be met'),
      },
      async ({ name, conditions }) => {
        const gateError = gateTool('set_custom_strategy');
        if (gateError) return { content: [{ type: 'text' as const, text: gateError }] };
    
        const result = setCustomStrategyTool({ name, conditions });
        return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };
      },
    );
Behavior3/5

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

No annotations provided, so description carries full burden. States 'Create' implying mutation/persistence, and mentions workflow with evaluate_strategy. However, lacks details on idempotency (duplicate names?), return values, or side effects (does it activate immediately?).

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 sentences, zero waste. Front-loaded with purpose, second sentence earns its place by providing critical workflow context. No redundancy with structured fields.

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?

Creation tool with no annotations and no output schema. Description provides adequate workflow context (use evaluate_strategy next) but omits what this returns (strategy ID?), persistence behavior, or error conditions. Adequate but gaps remain for a state-mutating operation.

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 has 100% description coverage, establishing baseline 3. Description references 'conditions' generally but adds no syntax details, examples, or format guidance beyond what the schema already provides for the nested field/operator/threshold structure.

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?

Clear specific verb (Create) + resource (custom trading strategy) + scope (with conditions). Explicitly distinguishes from sibling evaluate_strategy by stating this tool creates while that one tests.

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

Usage Guidelines5/5

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

Excellent workflow guidance: explicitly directs user to 'use evaluate_strategy to test it against current market conditions' after creation. Clear sequencing between create and evaluation phases.

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