# 模型上下文协议 (MCP)

该 **模型上下文协议 (MCP)** 与……的集成 [**Oxylabs 的网页爬虫API**](https://oxylabs.io/products/scraper-api/web) 能够交付结构化、适用于 AI 的数据，并针对大语言模型（LLM）工作流进行了优化。

MCP 确保上下文、元数据和指令格式正确，从而使 Anthropic 的 Claude 等 LLM 能够有效地解释并利用这些数据。

{% hint style="success" %}
请访问 Oxylabs GitHub 仓库，查看一个完整可运行的示例： [MCP 与网页爬虫API的集成](https://github.com/oxylabs/oxylabs-mcp).
{% endhint %}

## **Claude Desktop 的设置**

{% hint style="warning" %}
在开始之前，请确保你已 [**Claude Desktop**](https://claude.ai/download) 安装。&#x20;
{% endhint %}

### 使用 Smithery.ai

安装 [**Node.js 和 npm**](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) 命令行界面。如果你已经安装了它们，请运行以下命令将 npm 更新到最新版本：

```
npm install -g npm
```

要通过 [Smithery](https://smithery.ai/server/@oxylabs/oxylabs-mcp)自动为 Claude Desktop 安装 Oxylabs MCP 服务器，请运行以下命令：

```
npx -y @smithery/cli install @oxylabs/oxylabs-mcp --client claude
```

在安装过程中，系统会提示你输入 API 用户名和密码。请在要求时输入这些凭据。

安装完成后，打开 Claude Desktop 并配置爬虫，以开始使用 MCP 增强输出。

### &#x20;**使用 UV**

安装 [**uv**](https://docs.astral.sh/uv/getting-started/installation/)，作为 npm 的替代方案。请参阅 [**Model Context Protocol 快速入门指南**](https://modelcontextprotocol.io/quickstart/user) 以了解配置过程。

要将 MCP 服务器与 **Claude Desktop**集成，请按如下方式更新 `claude_desktop_config.json` 文件：

```json
{
  "mcpServers": {
    "oxylabs_mcp": {
      "command": "uvx",
      "args": ["oxylabs-mcp"],
      "env": {
        "OXYLABS_USERNAME": "your_username",
        "OXYLABS_PASSWORD": "your_password"
      }
    }
  }
}
```

将 `your_username` 和 `your_password` 替换为你的 API 用户用户名和密码。

将更改保存到配置文件中，并重启 Claude Desktop，以确保更新后的设置生效。

## **在 Cursor 上运行**

配置 Cursor 注意：需要 Cursor 0.46+ 版本

在 Cursor 中配置 Oxylabs：<br>

1. 选择 Cursor → 设置 → Cursor 设置 → MCP Tools
2. 点击“Add Custom MCP”
3. 添加以下配置：

```
{
  "mcpServers": {
    "oxylabs": {
      "command": "uvx",
      "args": ["oxylabs-mcp"],
      "env": {
        "OXYLABS_USERNAME": "your_username",
        "OXYLABS_PASSWORD": "your_password",
        "OXYLABS_AI_STUDIO_API_KEY": "your_ai_studio_api_key"
      }
    }
  }
}
```

将 `your_username` 和 `your_password` 替换为你的 API 用户用户名和密码。还请将 `your_ai_studio_api_key` 替换为你的 Oxylabs AI Studio API 密钥。

添加配置后，刷新 MCP 服务器列表以查看新工具。Composer Agent 会在适当的时候自动使用 Oxylabs，但你也可以通过描述你的网页爬取需求来明确请求它。可通过 Command+L（Mac）进入 Composer，在提交按钮旁选择“Agent”，然后输入你的查询。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.oxylabs.io/products/cn/web-scraper-api/solutions-for-ai-workflows/model-context-protocol-mcp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
