Skip to main content
Glama

get-search-terms

Analyze search terms used to find a WordPress site by specifying the site URL, credentials, and time period. Retrieve up to 100 terms for insights into visitor search behavior.

Instructions

View search terms used to find the site

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of search terms to return
passwordYesWordPress application password
periodNoTime period for stats
siteIdYesWordPress site ID
siteUrlYesWordPress site URL
usernameYesWordPress username

Implementation Reference

  • Handler function that makes an API request to the WordPress site's Jetpack stats endpoint for search terms, processes the response data, formats it into a readable text output, and returns it as MCP content or an error message.
    async ({ siteUrl, username, password, siteId, period = "week", limit = 10 }) => { try { const searchData = await makeWPRequest<any>({ siteUrl, endpoint: `sites/${siteId}/stats/search-terms`, auth: { username, password }, params: { period, limit } }); const searchTermsText = Array.isArray(searchData.search_terms) && searchData.search_terms.length > 0 ? searchData.search_terms.map((term: any) => `"${term.term || "Unknown"}" Views: ${term.views || 0} ---` ).join("\n") : "No search terms found or search terms are encrypted"; return { content: [ { type: "text", text: `Search Terms for site #${siteId} (${period}):\n\n${searchTermsText}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error retrieving search terms: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
  • Zod schema defining the input parameters for the get-search-terms tool, including required credentials, site details, and optional period and limit for the stats query.
    { siteUrl: z.string().url().describe("WordPress site URL"), username: z.string().describe("WordPress username"), password: z.string().describe("WordPress application password"), siteId: z.number().describe("WordPress site ID"), period: z.enum(["day", "week", "month", "year"]).optional().describe("Time period for stats"), limit: z.number().min(1).max(100).optional().describe("Maximum number of search terms to return"), },
  • src/index.ts:1653-1700 (registration)
    Registration of the 'get-search-terms' tool using McpServer.tool(), including the tool name, description, input schema, and handler function reference.
    server.tool( "get-search-terms", "View search terms used to find the site", { siteUrl: z.string().url().describe("WordPress site URL"), username: z.string().describe("WordPress username"), password: z.string().describe("WordPress application password"), siteId: z.number().describe("WordPress site ID"), period: z.enum(["day", "week", "month", "year"]).optional().describe("Time period for stats"), limit: z.number().min(1).max(100).optional().describe("Maximum number of search terms to return"), }, async ({ siteUrl, username, password, siteId, period = "week", limit = 10 }) => { try { const searchData = await makeWPRequest<any>({ siteUrl, endpoint: `sites/${siteId}/stats/search-terms`, auth: { username, password }, params: { period, limit } }); const searchTermsText = Array.isArray(searchData.search_terms) && searchData.search_terms.length > 0 ? searchData.search_terms.map((term: any) => `"${term.term || "Unknown"}" Views: ${term.views || 0} ---` ).join("\n") : "No search terms found or search terms are encrypted"; return { content: [ { type: "text", text: `Search Terms for site #${siteId} (${period}):\n\n${searchTermsText}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error retrieving search terms: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );

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

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