search_patterns
Search across multiple screeners to find stocks with specific chart patterns like head and shoulders or cup and handle. Returns matches with pattern details.
Instructions
Find all stocks across one or more screeners that currently exhibit specific chart patterns. Much faster than calling get_chart_patterns in a loop. Use when the user asks 'which stocks have a cup and handle' or 'find me hot prospects with bullish reversal patterns'. Returns { screeners_queried, patterns_queried, interval, count, matches: [...] }.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| screener_slugs | Yes | Screener slugs to search within | |
| pattern_ids | No | Pattern ids to filter by (e.g. 'head_shoulders', 'cup_handle'). Empty = all patterns. | |
| interval | No | Chart interval | 1d |
Implementation Reference
- src/tools/patterns.ts:61-73 (handler)Handler function for search_patterns tool. Parses input args (screener_slugs, pattern_ids, interval) and POSTs to the /patterns API endpoint.
export async function handleSearchPatterns( ctx: McpContext, rawArgs: unknown ): Promise<unknown> { const args = SearchPatternsInputSchema.parse(rawArgs); const interval = args.interval ?? "1d"; const patternIds = args.pattern_ids ?? []; return ctx.apiClient.post("/patterns", { screeners: args.screener_slugs, patterns: patternIds, interval, }); } - src/tools/patterns.ts:16-28 (schema)Zod input schema for search_patterns tool defining screener_slugs (required array 1-24), pattern_ids (optional array defaulting to []), and interval (optional '1d' or '1wk', defaults to '1d').
export const SearchPatternsInputSchema = z.object({ screener_slugs: z .array(z.string()) .min(1) .max(24) .describe("Screener slugs to search within"), pattern_ids: z .array(z.string()) .default([]) .optional() .describe("Pattern ids to filter by (e.g. 'head_shoulders', 'cup_handle'). Empty = all patterns."), interval: z.enum(["1d", "1wk"]).default("1d").optional().describe("Chart interval"), }); - src/tools/patterns.ts:38-44 (registration)Tool definition registration: name 'search_patterns', description, inputSchema using z.toJSONSchema(SearchPatternsInputSchema), and READ_ONLY_ANNOTATIONS.
{ name: "search_patterns", description: "Find all stocks across one or more screeners that currently exhibit specific chart patterns. Much faster than calling get_chart_patterns in a loop. Use when the user asks 'which stocks have a cup and handle' or 'find me hot prospects with bullish reversal patterns'. Returns { screeners_queried, patterns_queried, interval, count, matches: [...] }.", inputSchema: z.toJSONSchema(SearchPatternsInputSchema) as Tool["inputSchema"], annotations: READ_ONLY_ANNOTATIONS, }, - src/tools/index.ts:76-76 (registration)Handler mapping in the HANDLERS record connecting the 'search_patterns' string to the imported handleSearchPatterns function.
search_patterns: (ctx, args) => handleSearchPatterns(ctx, args), - src/tools/index.ts:54-54 (registration)ALL_TOOLS array spreading patternsTools (which includes search_patterns tool definition) into the full tool list for ListToolsRequestSchema.
...patternsTools,