SEO站点地图提取工具

一个用于从robots.txt文件中提取和分析站点地图URL的SEO工具服务器。

  • by dalebertrand
  • Python
  • 本地部署
  • 4 星标
  • 更新于
在 GitHub 查看 dalebertrand/seo-mcp-tools

使用说明

SEO MCP工具

一种模型上下文协议(MCP)服务器,提供用于分析robots.txt文件的SEO工具。此服务器实现了一组专门的工具,可以帮助从网络上的robots.txt文件中提取和分析站点地图信息。

特性

SEO MCP Tools服务器提供两个主要工具:

  1. 获取第一个网站地图URL:从robots.txt文件中提取第一个站点地图URL。
  2. 获取所有网站地图URL:从robots.txt文件中提取所有站点地图URL。

需求

  • Python 3.8+
  • FastMCP
  • 广告工具
  • 请求:
  • 熊猫

安装

  1. 克隆此存储库:

    git clone https://github.com/yourusername/seo-mcp-tools.git
    cd seo-mcp-tools
    
  2. 安装所需的依赖项:

    pip install fastmcp advertools requests pandas
    

用法

运行服务器

使用以下命令启动MCP服务器:

python mcp_server.py

或者,使用FastMCP开发工具进行交互式测试环境:

fastmcp dev mcp_server.py

MCP工具调用

获取第一个网站地图URL

from mcp_client import MCP_Client  # Assuming you're using an MCP client

client = MCP_Client("http://localhost:8000")

# Extract the first sitemap URL from a robots.txt file
first_sitemap = client.call("get_sitemap_url_from_robots_txt", {
    "robots_txt_url": "https://example.com/robots.txt"
})
print(f"First sitemap URL: {first_sitemap}")

获取所有网站地图URL

# Extract all sitemap URLs from a robots.txt file
all_sitemaps = client.call("get_all_sitemap_urls_from_robots_txt", {
    "robots_txt_url": "https://example.com/robots.txt"
})
print(f"All sitemap URLs: {all_sitemaps}")

Claude桌面集成

  1. 创建最小MCP配置文件:

    {
      "version": "v1",
      "endpoints": [{
        "name": "SEO Tools",
        "transport": {
          "type": "stdio",
          "command": {
            "path": "/path/to/python",
            "args": ["/path/to/mcp_server.py"]
          }
        },
        "input_format": "json",
        "output_format": "json"
      }]
    }
    
  2. 在Claude Desktop中安装:

    fastmcp install mcp_server.py
    

对于开发/测试模式,请使用: fastmcp dev mcp_server.py

测试

运行测试以验证服务器功能:

pytests

该测试套件包括对真实网站的robots.txt文件进行验证,以确保这些工具能够正确地处理各种robots.txt结构。

运作原理

服务器使用直接HTTP请求从URL中获取robots.txt文件,然后应用正则表达式模式来提取相关指令。这种方法确保了对来自各种网站的robots.txt文件的可靠解析,而不管格式差异如何。

许可证

麻省理工学院