Skip to main content
Glama
ahonn

Google Search Console MCP Server

by ahonn

get_sitemap

Retrieve sitemap data from Google Search Console to analyze website structure and improve search engine visibility.

Instructions

Get a sitemap for a site in Google Search Console

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
feedpathNoThe URL of the actual sitemap. For example: http://www.example.com/sitemap.xml
siteUrlNoThe site's URL, including protocol. For example: http://www.example.com/

Implementation Reference

  • Main handler for the 'get_sitemap' MCP tool: parses arguments using GetSitemapSchema, constructs requestBody, calls SearchConsoleService.getSitemap, formats and returns the API response as text content.
    case 'get_sitemap': {
      const args = GetSitemapSchema.parse(request.params.arguments);
      const requestBody = {
        siteUrl: args.siteUrl,
        feedpath: args.feedpath,
      };
      const response = await searchConsole.getSitemap(requestBody);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(response.data, null, 2),
          },
        ],
      };
    }
  • Zod schema defining input parameters for get_sitemap: siteUrl and feedpath (both optional strings with descriptions).
    export const GetSitemapSchema = z.object({
      feedpath: z
        .string()
        .optional()
        .describe('The URL of the actual sitemap. For example: http://www.example.com/sitemap.xml'),
      siteUrl: z
        .string()
        .optional()
        .describe("The site's URL, including protocol. For example: http://www.example.com/"),
    });
  • src/index.ts:73-77 (registration)
    Registration of the 'get_sitemap' tool in the ListToolsRequestHandler: specifies name, description, and converts GetSitemapSchema to JSON schema for input.
    {
      name: 'get_sitemap',
      description: 'Get a sitemap for a site in Google Search Console',
      inputSchema: zodToJsonSchema(GetSitemapSchema),
    },
  • Helper method in SearchConsoleService that performs the actual Google Webmasters API call to webmasters.sitemaps.get, with permission error handling and URL normalization fallback.
    async getSitemap(requestBody: GetSitemapRequest) {
      const webmasters = await this.getWebmasters();
      return this.handlePermissionError(
        () => webmasters.sitemaps.get(requestBody),
        () =>
          webmasters.sitemaps.get({
            ...requestBody,
            siteUrl: this.normalizeUrl(requestBody.siteUrl!),
          }),
      );
    }

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/ahonn/mcp-server-gsc'

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