get_chart_patterns
Return all chart patterns currently detected for a stock symbol, including head and shoulders, cup and handle, triangles, and harmonic patterns.
Instructions
Return all chart patterns currently detected for a single stock symbol. Covers 25+ patterns including head_shoulders, cup_handle, wedge_rising/falling, asc/desc/sym_triangle, double_top/bottom, channel_up/down, cup_handle, harmonic patterns (gartley, butterfly, bat, crab). Use when the user asks 'what patterns does X have' or 'is X forming a head and shoulders'. Returns { symbol, interval, computedAt, candleCount, patterns: [...] }. Empty patterns array if none detected.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock ticker, e.g. AAPL, TSLA, MSFT | |
| interval | No | Chart interval | 1d |
Implementation Reference
- src/tools/patterns.ts:47-59 (handler)The main handler function for get_chart_patterns. It parses the input schema, extracts symbol and interval, builds a cache key, and fetches chart patterns from the API client at /patterns/{symbol} with caching for 600 seconds.
export async function handleGetChartPatterns( ctx: McpContext, rawArgs: unknown ): Promise<unknown> { const args = GetChartPatternsInputSchema.parse(rawArgs); const interval = args.interval ?? "1d"; const key = `patterns:${args.symbol.toUpperCase()}:${interval}`; return ctx.cache.wrap(key, 600_000, () => ctx.apiClient.get(`/patterns/${encodeURIComponent(args.symbol.toUpperCase())}`, { interval, }) ); } - src/tools/patterns.ts:8-14 (schema)Input schema for get_chart_patterns using Zod. Validates `symbol` (uppercase regex) and optional `interval` (1d or 1wk, default 1d).
export const GetChartPatternsInputSchema = z.object({ symbol: z .string() .regex(symbolRegex, "Invalid symbol — use uppercase like AAPL") .describe("Stock ticker, e.g. AAPL, TSLA, MSFT"), interval: z.enum(["1d", "1wk"]).default("1d").optional().describe("Chart interval"), }); - src/tools/patterns.ts:30-37 (registration)Tool definition and registration in the patternsTools array. Defines name 'get_chart_patterns', description, inputSchema derived from GetChartPatternsInputSchema, and read-only annotations.
export const patternsTools: Tool[] = [ { name: "get_chart_patterns", description: "Return all chart patterns currently detected for a single stock symbol. Covers 25+ patterns including head_shoulders, cup_handle, wedge_rising/falling, asc/desc/sym_triangle, double_top/bottom, channel_up/down, cup_handle, harmonic patterns (gartley, butterfly, bat, crab). Use when the user asks 'what patterns does X have' or 'is X forming a head and shoulders'. Returns { symbol, interval, computedAt, candleCount, patterns: [...] }. Empty patterns array if none detected.", inputSchema: z.toJSONSchema(GetChartPatternsInputSchema) as Tool["inputSchema"], annotations: READ_ONLY_ANNOTATIONS, }, - src/tools/index.ts:75-76 (registration)Handler registration in the HANDLERS record mapping the tool name 'get_chart_patterns' to its handler function handleGetChartPatterns.
get_chart_patterns: (ctx, args) => handleGetChartPatterns(ctx, args), search_patterns: (ctx, args) => handleSearchPatterns(ctx, args), - src/tools/index.ts:53-54 (registration)Patterns tools are included in the ALL_TOOLS array via spread of patternsTools.
...screenersTools, ...patternsTools,