parse_sitemap_content
Extract and process sitemap data from XML or text content to retrieve structured information, with optional inclusion of page details for comprehensive analysis.
Instructions
Parse a sitemap directly from its XML or text content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The content of the sitemap (XML, text, etc.) | |
| include_pages | No | Whether to include page details in the response |
Implementation Reference
- src/sitemap_mcp_server/server.py:511-533 (handler)The main handler function for the 'parse_sitemap_content' tool. It is decorated with @mcp.tool, defining the tool schema inline via Pydantic Field annotations. Parses sitemap content using sitemap_from_str from the usp library and returns a JSON-serialized dictionary representation of the sitemap.@mcp.tool(description="Parse a sitemap directly from its XML or text content") async def parse_sitemap_content( ctx: Context, content: str = Field( ..., description="The content of the sitemap (XML, text, etc.)" ), include_pages: bool = Field( False, description="Whether to include page details in the response" ), ) -> str: """Parse a sitemap from its content. This tool parses a sitemap directly from its XML or text content and returns a structured representation. """ try: logger.info("Parsing sitemap from content") parsed_sitemap = sitemap_from_str(content) return safe_json_dumps(parsed_sitemap.to_dict(with_pages=include_pages)) except Exception as e: error_msg = f"Error parsing sitemap content: {str(e)}" logger.error(error_msg) return safe_json_dumps({"error": error_msg})