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
| Name | Required | Description | Default |
|---|---|---|---|
| feedpath | No | The URL of the actual sitemap. For example: http://www.example.com/sitemap.xml | |
| siteUrl | No | The site's URL, including protocol. For example: http://www.example.com/ |
Implementation Reference
- src/index.ts:326-341 (handler)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), }, ], }; }
- src/schemas.ts:73-82 (schema)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), },
- src/search-console.ts:206-216 (helper)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!), }), ); }