get_trends
Retrieve AI-detected trending topics in tech, science, patents, or funding events. Specify category and time window to get trends with relevance weights.
Instructions
Return AI-detected trending topics in tech & science, patents, or funding events. Use when the user asks 'what's trending in tech' or 'show me patent trends'. Returns { category, count, trends: [{date, topic, weight}] } where weight is 0-1. Tier: Pro only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Trend category | techscience |
| days | No | Lookback window | |
| latest | No | If true, only return most recent day | |
| date | No | Exact date lookup |
Implementation Reference
- src/tools/trends.ts:42-55 (handler)The actual handler function for the get_trends tool. Parses input via GetTrendsInputSchema, builds a cache key, and calls ctx.apiClient.get('/trends', ...) with the category, days, latest, and date parameters.
export async function handleGetTrends(ctx: McpContext, rawArgs: unknown): Promise<unknown> { const args = GetTrendsInputSchema.parse(rawArgs); const category = args.category ?? "techscience"; const days = args.days ?? 10; const key = `trends:${category}:${days}:${args.latest ? "latest" : args.date || "range"}`; return ctx.cache.wrap(key, 1_800_000, () => ctx.apiClient.get("/trends", { category, days, latest: args.latest ? 1 : undefined, date: args.date, }) ); } - src/tools/trends.ts:8-17 (schema)Zod schema defining the input for get_trends: optional category enum (techscience/patents/fundingevents, default techscience), days (1-180, default 10), latest boolean, and date regex string.
export const GetTrendsInputSchema = z.object({ category: z .enum(["techscience", "patents", "fundingevents"]) .default("techscience") .optional() .describe("Trend category"), days: z.number().int().min(1).max(180).default(10).optional().describe("Lookback window"), latest: z.boolean().default(false).optional().describe("If true, only return most recent day"), date: z.string().regex(dateRegex).optional().describe("Exact date lookup"), }); - src/tools/index.ts:93-96 (registration)The registerAllTools function registers the get_trends tool by spreading trendsTools into ALL_TOOLS and mapping the handler in HANDLERS: get_trends: (ctx, args) => handleGetTrends(ctx, args).
export function registerAllTools(server: Server, ctx: McpContext): void { server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: ALL_TOOLS, })); - src/tools/trends.ts:25-32 (registration)The Tool definition object for get_trends, including the name, description, inputSchema (from GetTrendsInputSchema), and read-only annotations.
export const trendsTools: Tool[] = [ { name: "get_trends", description: "Return AI-detected trending topics in tech & science, patents, or funding events. Use when the user asks 'what's trending in tech' or 'show me patent trends'. Returns { category, count, trends: [{date, topic, weight}] } where weight is 0-1. Tier: Pro only.", inputSchema: z.toJSONSchema(GetTrendsInputSchema) as Tool["inputSchema"], annotations: READ_ONLY_ANNOTATIONS, }, - src/tools/index.ts:51-61 (registration)ALL_TOOLS array that includes trendsTools (spread), which contains the get_trends tool definition.
const ALL_TOOLS: Tool[] = [ PING_TOOL, ...screenersTools, ...patternsTools, ...optionsFlowTools, ...stockTools, ...compositeTools, ...marketMomentumTools, ...trendsTools, ...educationTools, ];