Skip to main content
Glama

report-referrer-spam

Identify and report spam referrer domains to clean up traffic analytics and enhance website security on WordPress sites. Submit domain details securely via REST API.

Instructions

Report a referrer as spam

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesDomain to report as spam
passwordYesWordPress application password
siteIdYesWordPress site ID
siteUrlYesWordPress site URL
usernameYesWordPress username

Implementation Reference

  • src/index.ts:1517-1557 (registration)
    Registration of the 'report-referrer-spam' MCP tool, including description, input schema using Zod, and inline handler function.
    server.tool( "report-referrer-spam", "Report a referrer as spam", { 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"), domain: z.string().describe("Domain to report as spam"), }, async ({ siteUrl, username, password, siteId, domain }) => { try { const response = await makeWPRequest<any>({ siteUrl, endpoint: `sites/${siteId}/stats/referrers/spam/new`, method: "POST", auth: { username, password }, data: { domain } }); return { content: [ { type: "text", text: `Successfully reported domain "${domain}" as spam.`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error reporting referrer as spam: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );
  • The handler function executes a POST request to the WordPress stats API endpoint `/sites/{siteId}/stats/referrers/spam/new` with the domain, using the shared makeWPRequest helper, and returns success or error message.
    async ({ siteUrl, username, password, siteId, domain }) => { try { const response = await makeWPRequest<any>({ siteUrl, endpoint: `sites/${siteId}/stats/referrers/spam/new`, method: "POST", auth: { username, password }, data: { domain } }); return { content: [ { type: "text", text: `Successfully reported domain "${domain}" as spam.`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error reporting referrer as spam: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
  • Zod schema for input parameters required by the tool.
    { 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"), domain: z.string().describe("Domain to report as spam"), },
  • Shared helper function used by the tool (and all others) to make authenticated requests to WordPress REST API.
    async function makeWPRequest<T>({ siteUrl, endpoint, method = 'GET', auth, data = null, params = null }: { siteUrl: string; endpoint: string; method?: 'GET' | 'POST' | 'PUT' | 'DELETE'; auth: { username: string; password: string }; data?: any; params?: any; }): Promise<T> { const authString = Buffer.from(`${auth.username}:${auth.password}`).toString('base64'); try { const response = await axios({ method, url: `${siteUrl}/wp-json/wp/v2/${endpoint}`, headers: { 'Authorization': `Basic ${authString}`, 'Content-Type': 'application/json', }, data: data, params: params }); return response.data as T; } catch (error) { if (axios.isAxiosError(error) && error.response) { throw new Error(`WordPress API error: ${error.response.data?.message || error.message}`); } throw 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