JavaScript has no equivalent of pytrends - there is no widely-used unofficial Google Trends library for Node.js that has maintained community trust. Trends MCP fills the gap directly: it is accessible via standard fetch from any JavaScript environment (Node.js, browser, edge runtime, serverless function) and returns structured JSON with normalized values and absolute volume estimates from 15+ sources.
Python developers have pytrends. JavaScript developers have a gap. The few npm packages that attempt Google Trends scraping have poor maintenance records and no community consensus around reliability. The standard approach for JavaScript projects that need trend data has been to either use a Python microservice for data collection or to accept Google Trends' manual interface and not automate it.
Trends MCP is a managed HTTP API that works from any JavaScript environment via fetch. The response is structured JSON with a consistent schema, which makes it straightforward to use in web apps, API routes, serverless functions, or AI agent tools.
The API accepts standard HTTPS POST requests with JSON-RPC bodies. Node.js v18+ includes native fetch, so no additional HTTP library is required:
const API_KEY = process.env.TRENDS_MCP_API_KEY;
const ENDPOINT = "https://api.trendsmcp.ai/mcp";
async function callTrendsMCP(toolName, params) {
const response = await fetch(ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`,
},
body: JSON.stringify({
jsonrpc: "2.0",
method: "tools/call",
params: {
name: toolName,
arguments: params,
},
id: 1,
}),
});
const data = await response.json();
// The trend data is in the MCP response content
return JSON.parse(data.result.content[0].text);
}
// Get weekly Google Search trend for any keyword
const trendData = await callTrendsMCP("get_trends", {
keyword: "electric vehicles",
source: "google",
data_mode: "weekly",
});
The returned trendData object contains the time series array with date, normalized_value, absolute_volume_estimate, and data_quality_score per data point. Pipe it directly into a chart library.
For Next.js applications, the cleanest pattern is a route handler that proxies requests to Trends MCP, keeping the API key server-side:
// app/api/trends/route.js
export async function POST(request) {
const { keyword, source } = await request.json();
const trendData = await callTrendsMCP("get_growth", {
keyword,
source: source || "google, tiktok, reddit",
percent_growth: ["1M", "3M", "1Y"],
});
return Response.json(trendData);
}
Your frontend components then call /api/trends and never touch the Trends MCP API key directly.
For apps that surface what is trending right now, get_top_trends requires no keyword and returns a live list of trending topics on any platform:
const trendingNow = await callTrendsMCP("get_top_trends", {
type: "TikTok Trending Hashtags",
limit: 20,
});
// Map the results directly to UI components
const feed = trendingNow.trends.map((item) => ({
name: item.name,
value: item.normalized_value,
growth: item.growth_rate,
}));
This works in serverless functions that run on a cron schedule to populate a cached trending feed, or in real-time API routes that serve a live feed component.
JavaScript AI frameworks can use Trends MCP as a tool definition. For Vercel AI SDK:
import { tool } from "ai";
import { z } from "zod";
const getTrends = tool({
description: "Get trend data for a keyword across multiple platforms",
parameters: z.object({
keyword: z.string(),
source: z.string().optional().default("google"),
data_mode: z.enum(["weekly", "daily"]).optional().default("weekly"),
}),
execute: async ({ keyword, source, data_mode }) => {
return await callTrendsMCP("get_trends", { keyword, source, data_mode });
},
});
The tool is then passed to the AI model alongside other tools, and the model calls it automatically when a user asks about trends.
For direct MCP protocol support in Node.js, the MCP TypeScript SDK (@modelcontextprotocol/sdk) can connect to Trends MCP via HTTP transport at https://api.trendsmcp.ai/mcp. This is the most direct integration path for custom MCP clients built in TypeScript.
Trends MCP works in edge runtimes (Cloudflare Workers, Vercel Edge Functions) with no modifications. The API uses standard HTTPS and JSON - no Node.js-specific APIs, no streaming that requires special handling. Call it with the standard fetch API and parse the response.
One edge consideration: API key management. Environment variables on Cloudflare Workers and Vercel Edge Functions work the same way as in Node.js. Store the key as a secret, reference it in the handler.
Tools for this workflow
get_trendsRetrieve a full historical time series for any keyword - returns a JSON array of date/value/volume objects usable directly in chart libraries like Chart.js, D3, or Recharts.
get_trends(keyword='artificial intelligence', source='google', data_mode='weekly')
get_growthGet cross-platform growth rates for scorecard or badge components - one call returns all sources with period-over-period growth percentages.
get_growth(keyword='artificial intelligence', source='google, tiktok, reddit', percent_growth=['1M', '3M', '1Y'])
get_ranked_trendsPower discovery UIs or trend feeds - returns ranked lists of fastest-growing keywords on any platform without a seed keyword.
get_ranked_trends(source='tiktok', sort='wow_pct_change', limit=20)
get_top_trendsBuild real-time trending feeds - what is trending right now on any platform, no keyword required, ready for display.
get_top_trends(type='Google Trending Hashtags', limit=15)
FAQ