MCP Web Tools Server

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Converts scraped web content into markdown format for easier processing by Claude

  • Explicitly mentioned as an example website whose content can be fetched and summarized using the web_scrape tool

  • Provides a UI for connecting to and testing MCP servers, including viewing available tools and executing them

MCP Web 工具服务器

模型上下文协议 (MCP) 服务器,提供与 Web 相关的操作工具。该服务器允许 LLM 通过标准化工具与 Web 内容进行交互。

当前工具

  • web_scrape :将 URL 转换为使用 r.jina.ai 作为前缀并返回 markdown 内容

安装

  1. 克隆此存储库:
    git clone <repository-url> cd MCP
  2. 安装所需的依赖项:
    pip install -r requirements.txt
    或者,您可以使用uv进行更快的安装:
    uv pip install -r requirements.txt

运行服务器和 UI

该存储库包含运行 MCP 服务器或 Streamlit UI 的便捷脚本。

使用运行脚本

在 macOS/Linux 上:

# Run the server with stdio transport (default) ./run.sh server # Run the server with SSE transport ./run.sh server --transport sse --host localhost --port 5000 # Run the Streamlit UI ./run.sh ui

在 Windows 上:

# Run the server with stdio transport (default) run.bat server # Run the server with SSE transport run.bat server --transport sse --host localhost --port 5000 # Run the Streamlit UI run.bat ui

手动运行

或者,您可以直接运行服务器:

使用 stdio(默认)

python server.py

使用 SSE

python server.py --transport sse --host localhost --port 5000

这将在localhost:5000上启动一个接受 MCP 连接的 HTTP 服务器。

并手动运行 Streamlit UI:

streamlit run streamlit_app.py

使用 MCP Inspector 进行测试

MCP 检查器是一款用于测试和调试 MCP 服务器的工具。您可以使用它来与您的服务器进行交互:

  1. 安装 MCP 检查器:
    npm install -g @modelcontextprotocol/inspector
  2. 使用您的服务器运行检查器:
    npx @modelcontextprotocol/inspector python server.py
  3. 使用 Inspector 界面通过提供类似example.com URL 并查看返回的 markdown 内容来测试web_scrape工具。

与 Claude 桌面版集成

要将此服务器与 Claude for Desktop 一起使用:

  1. 确保您已安装Claude for Desktop
  2. 打开 Claude for Desktop 配置文件:
    • Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  3. 添加以下配置(根据需要调整路径):
{ "mcpServers": { "web-tools": { "command": "python", "args": [ "/absolute/path/to/MCP/server.py" ] } } }
  1. 重新启动 Claude 桌面版。
  2. 现在您应该可以在 Claude 的界面中看到 web_scrape 工具了。您可以让 Claude 从网站抓取内容,它会使用该工具。

示例用法

与 Claude 集成后,您可以提出以下问题:

  • “example.com 的主页上有什么?”
  • “您能从 mozilla.org 获取并总结内容吗?”
  • “从 wikipedia.org/wiki/Model_Context_Protocol 获取内容并向我解释。”

Claude 将使用 web_scrape 工具来获取内容并在其响应中提供。

添加更多工具

要向此服务器添加更多工具:

  1. tools/目录中创建一个新的 Python 文件,例如tools/new_tool.py
  2. 按照与现有工具类似的模式实现您的工具功能。
  3. server.py中导入您的工具并将其注册到 MCP 服务器:
# Import your new tool from tools.new_tool import new_tool_function # Register the tool with the MCP server @mcp.tool() async def new_tool(param1: str, param2: int) -> str: """ Description of what your tool does. Args: param1: Description of param1 param2: Description of param2 Returns: Description of return value """ return await new_tool_function(param1, param2)
  1. 重新启动服务器以应用更改。

Streamlit UI

该存储库包含一个 Streamlit 应用程序,允许您连接并测试在 Claude for Desktop 中配置的所有 MCP 服务器。

运行 Streamlit UI

streamlit run streamlit_app.py

这将启动 Streamlit 服务器并打开带有 UI 的 Web 浏览器。

特征

  • 加载并解析 Claude for Desktop 配置文件
  • 查看所有已配置的 MCP 服务器
  • 连接到任何服务器并查看其可用工具
  • 通过提供输入参数和查看结果来测试工具
  • 查看可用资源和提示

用法

  1. 启动 Streamlit 应用
  2. 输入 Claude for Desktop 配置文件的路径(默认路径已预填)
  3. 点击“加载服务器”查看所有可用的 MCP 服务器
  4. 选择一个服务器选项卡并单击“连接”以加载其工具
  5. 选择工具并提供所需参数
  6. 单击“执行”运行该工具并查看结果

故障排除

  • 缺少依赖项:确保requirements.txt中的所有依赖项都已安装。
  • 连接问题:检查服务器是否正在运行以及 Claude for Desktop 中的配置是否指向正确的路径。
  • 工具执行错误:在服务器输出中查找错误消息。
  • Streamlit UI 问题:确保 Streamlit 已正确安装并且配置文件路径正确。

执照

本项目遵循 MIT 许可证。更多详情请参阅许可证文件。

-
security - not tested
A
license - permissive license
-
quality - not tested

模型上下文协议服务器允许 LLM 通过标准化工具与 Web 内容进行交互,目前支持 Web 抓取功能。

  1. Current Tools
    1. Installation
      1. Running the Server and UI
        1. Using the Run Scripts
        2. Running Manually
      2. Testing with MCP Inspector
        1. Integrating with Claude for Desktop
          1. Example Usage
            1. Adding More Tools
              1. Streamlit UI
                1. Running the Streamlit UI
                2. Features
                3. Usage
              2. Troubleshooting
                1. License
                  ID: cn5q63wd5r