Skip to main content
Glama
stockmarketscan

stockmarketscan/mcp-server

Official

search_setups

Read-onlyIdempotent

Identifies the strongest trading setups by merging options flow signals with screener confluence. Returns a ranked list of top bullish or bearish plays for the day.

Instructions

Find the strongest trading setups today by combining options flow signals and screener confluence into a ranked list. Use when the user asks 'what should I trade today', 'best setups', 'top bullish plays'. Returns a ranked list with a composite score (signal strength + screener confluence + streak length). Present the top 3-5 to the user with narrative context, don't dump the raw JSON. Use get_stock_report if the user wants to dig deeper into any specific result. Returns { side, date, count, setups: [{symbol, score, signal, screeners_hit, ...}] }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sideNoSide of setups to returnbullish
limitNoMax setups to return

Implementation Reference

  • The main handler function for the search_setups tool. It parses input (side, limit), fetches options flow signals, filters by side and latest date, scores each signal based on strength, streak bonus, and premium size, sorts descending, and returns the top N ranked setups.
    export async function handleSearchSetups(
      ctx: McpContext,
      rawArgs: unknown
    ): Promise<unknown> {
      const args = SearchSetupsInputSchema.parse(rawArgs);
      const side = args.side ?? "bullish";
      const limit = args.limit ?? 20;
    
      // Pull today's signals (all sides)
      const signalsRes = await safeCall(() =>
        ctx.cache.wrap("options-flow:signals:default", 300_000, () =>
          ctx.apiClient.get<{ signals?: SignalRow[] }>("/options-flow/signals")
        )
      );
    
      if ("error" in signalsRes) {
        throw new McpError(
          `Could not load signals: ${signalsRes.error}`,
          (signalsRes as { code?: string }).code === "TIER_UPGRADE_REQUIRED"
            ? "TIER_UPGRADE_REQUIRED"
            : "UPSTREAM_ERROR",
          "search_setups"
        );
      }
    
      const allSignals = (signalsRes as { signals?: SignalRow[] }).signals || [];
      if (allSignals.length === 0) {
        return { side, date: null, count: 0, setups: [], note: "No signals available yet." };
      }
    
      // Get the most recent signal date
      const latestDate = allSignals
        .map((s) => (s.signal_date || "").slice(0, 10))
        .sort()
        .pop() || "";
      const todaysSignals = allSignals.filter(
        (s) => (s.signal_date || "").slice(0, 10) === latestDate && s.side === side
      );
    
      if (todaysSignals.length === 0) {
        return { side, date: latestDate, count: 0, setups: [] };
      }
    
      // Score each signal
      const setups = todaysSignals.map((s) => {
        const strength = s.strength_score || 0;
        const streakBonus = (s.consecutive_days || 0) >= 5 ? 1 : 0;
        const premiumBonus = toNum(s.total_premium) >= 10_000_000 ? 0.5 : 0;
        const score = strength + streakBonus + premiumBonus;
        return {
          symbol: s.symbol,
          score: Number(score.toFixed(1)),
          signal: {
            type: s.signal_type,
            strength: strength,
            consecutive_days: s.consecutive_days,
            call_put_ratio: s.call_put_ratio,
            total_premium: toNum(s.total_premium),
          },
        };
      });
    
      setups.sort((a, b) => b.score - a.score);
    
      return {
        side,
        date: latestDate,
        count: setups.length,
        setups: setups.slice(0, limit),
        note:
          "Scores combine signal strength, streak length, and premium size. This is a ranking hint, not financial advice.",
      };
    }
  • Zod schema defining input validation for search_setups: side ('bullish'|'bearish', default bullish) and limit (1-100, default 20).
    export const SearchSetupsInputSchema = z.object({
      side: z
        .enum(["bullish", "bearish"])
        .default("bullish")
        .optional()
        .describe("Side of setups to return"),
      limit: z
        .number()
        .int()
        .min(1)
        .max(100)
        .default(20)
        .optional()
        .describe("Max setups to return"),
    });
  • Tool metadata registration in the compositeTools array. Defines name 'search_setups', description, inputSchema (converted from Zod), and read-only annotations.
      {
        name: "search_setups",
        description:
          "Find the strongest trading setups today by combining options flow signals and screener confluence into a ranked list. Use when the user asks 'what should I trade today', 'best setups', 'top bullish plays'. Returns a ranked list with a composite score (signal strength + screener confluence + streak length). Present the top 3-5 to the user with narrative context, don't dump the raw JSON. Use get_stock_report if the user wants to dig deeper into any specific result. Returns { side, date, count, setups: [{symbol, score, signal, screeners_hit, ...}] }.",
        inputSchema: z.toJSONSchema(SearchSetupsInputSchema) as Tool["inputSchema"],
        annotations: READ_ONLY_ANNOTATIONS,
      },
    ];
  • Handler mapping in the HANDLERS record: maps string 'search_setups' to handleSearchSetups function. This is where the tool name is bound to its implementation at runtime.
      search_setups: (ctx, args) => handleSearchSetups(ctx, args),
      get_market_momentum: (ctx, args) => handleGetMarketMomentum(ctx, args),
      get_trends: (ctx, args) => handleGetTrends(ctx, args),
      get_trend_connections: (ctx, args) => handleGetTrendConnections(ctx, args),
      explain_concept: (ctx, args) => handleExplainConcept(ctx, args),
    };
  • Aggregation of ALL_TOOLS array which includes compositeTools (containing search_setups) along with all other tool definitions, registered with the MCP server.
    const ALL_TOOLS: Tool[] = [
      PING_TOOL,
      ...screenersTools,
      ...patternsTools,
      ...optionsFlowTools,
      ...stockTools,
      ...compositeTools,
      ...marketMomentumTools,
      ...trendsTools,
      ...educationTools,
    ];
Behavior4/5

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

Annotations already indicate readOnlyHint=true, idempotentHint=true, so the tool is safe and repeatable. The description adds value by detailing the composite score components (signal strength, screener confluence, streak length) and the return structure, but does not discuss potential edge cases or performance characteristics.

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 four sentences, front-loaded with purpose, then usage, presentation instruction, alternative tool, and output structure. Every sentence adds distinct value without redundancy or fluff.

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

Completeness4/5

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

The description provides the return structure and explains the composite score, which compensates for the lack of an output schema. It also specifies presentation guidelines. However, it does not mention handling of empty results or errors, leaving a minor gap.

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?

Input schema coverage is 100%, so parameters are fully defined. The description does not add new context beyond the schema, only implicitly hinting at 'side' via 'top bullish plays'. Baseline score of 3 is appropriate as the schema carries the full burden.

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 finds the strongest trading setups by combining options flow signals and screener confluence into a ranked list. It uses a specific verb 'Find' and resource 'trading setups', distinguishing it from siblings like get_options_flow_signals and get_screener_data.

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?

The description explicitly specifies when to use the tool (e.g., 'what should I trade today', 'best setups', 'top bullish plays') and provides an alternative (get_stock_report for deeper analysis). It also instructs the agent to present top 3-5 results with narrative context.

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/stockmarketscan/mcp-server'

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