Skip to main content
Glama

get-country-views

Analyze a WordPress site's traffic by country to gain geographic insights. Specify the site URL, credentials, and time period to retrieve detailed view statistics.

Instructions

View a site's views by country

Input Schema

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

Implementation Reference

  • The handler function that executes the 'get-country-views' tool. It makes an authenticated API request to the WordPress Jetpack Stats endpoint `/sites/{siteId}/stats/country-views`, processes the response data typed as WPCountryView[], formats it into a readable text summary, and returns it in the MCP content format. Handles errors gracefully.
      async ({ siteUrl, username, password, siteId, period = "week", limit = 10 }) => {
        try {
          const countryData = await makeWPRequest<{country_views: WPCountryView[]}>({
            siteUrl,
            endpoint: `sites/${siteId}/stats/country-views`,
            auth: { username, password },
            params: { period, limit }
          });
          
          const countriesText = Array.isArray(countryData.country_views) && countryData.country_views.length > 0
            ? countryData.country_views.map((country) => 
                `${country.country_name || "Unknown"} (${country.country_code || "??"})
    Views: ${country.views || 0}
    Percentage: ${country.views_percent ? Math.round(country.views_percent * 100) / 100 + '%' : "0%"}
    ---`
              ).join("\n")
            : "No country data found";
          
          return {
            content: [
              {
                type: "text",
                text: `Views by Country for site #${siteId} (${period}):\n\n${countriesText}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error retrieving country views: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
  • Zod input schema defining parameters for the 'get-country-views' tool: siteUrl (required URL), username and password (auth), siteId (required number), optional period (enum: day/week/month/year), and limit (1-100).
    {
      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 countries to return"),
    },
  • src/index.ts:1332-1334 (registration)
    Registration of the 'get-country-views' tool using McpServer.tool() method, specifying the tool name, description, input schema, and handler function.
    server.tool(
      "get-country-views",
      "View a site's views by country",
  • TypeScript interface WPCountryView used to type the country views data returned from the API in the handler.
    interface WPCountryView {
      country_code: string;
      country_name: string;
      views: number;
      views_percent: number;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states 'view' which implies a read-only operation, but doesn't clarify authentication requirements, rate limits, data freshness, or what 'views' specifically means (e.g., page views, unique visitors). The description lacks crucial context about what this tool actually returns and how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with zero waste. It's appropriately sized for a tool with good schema documentation and is perfectly front-loaded with the core functionality. Every word earns its place in this concise statement.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for this 6-parameter tool. While the schema covers parameters well, the description doesn't address authentication needs (implied by username/password parameters), doesn't explain what 'views' means, and provides no information about return format or data structure. For a tool that requires authentication and returns statistical data, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema - it doesn't explain relationships between parameters or provide usage examples. Baseline 3 is appropriate when schema does the heavy lifting, though the description could have added value by explaining parameter interactions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'View a site's views by country' clearly states the action (view) and resource (site's views by country), making the purpose immediately understandable. It distinguishes from siblings like 'get-site-stats' or 'get-stats-summary' by specifying country-level view data. However, it doesn't explicitly contrast with 'get-clicks' or 'get-referrers' which might also involve geographic data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when this tool is appropriate compared to siblings like 'get-site-stats' (which might include country data) or 'get-stats-summary'. There's no context about prerequisites or typical use cases beyond the basic action stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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