---
title: "Cursor MCP 配置教程 | Narwhal API"
description: "将 Narwhal 托管的 Streamable HTTP MCP 服务器添加到 Cursor，并使用 Narwhal 账户登录。"
url: "https://narwhalapi.com/zh/docs/mcp/cursor"
---

# Cursor MCP：连接到 Narwhal

将 Narwhal 托管的 Streamable HTTP MCP 服务器添加到 Cursor，并使用 Narwhal 账户登录。

Cursor 支持托管的 HTTP MCP 服务器，配置文件为 `.cursor/mcp.json`。添加 Narwhal 服务器，并使用 Narwhal 账户登录。

## 配置 Cursor

选择“添加到 Cursor”。Cursor 会打开，并请你确认 Narwhal 服务器。

[添加到 Cursor](https://cursor.com/en/install-mcp?name=narwhal&config=eyJ1cmwiOiJodHRwczovL2FwaS5uYXJ3aGFsYXBpLmNvbS9tY3AifQ%3D%3D)

在 Cursor 的 MCP 设置中，选择 Narwhal 服务器旁的“Connect”，使用 Narwhal 账户登录，然后在 Narwhal 授权页面上选择“Allow”。

要改为手动添加服务器，请在项目或用户配置中创建或打开 `.cursor/mcp.json`，然后添加：

.cursor/mcp.json

```
{
  "mcpServers": {
    "narwhal": {
      "url": "https://api.narwhalapi.com/mcp"
    }
  }
}
```

如果你的客户端无法登录，请改用 API 密钥。将该条目替换为以下配置：

.cursor/mcp.json

```
{
  "mcpServers": {
    "narwhal": {
      "url": "https://api.narwhalapi.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:NARWHAL_API_KEY}"
      }
    }
  }
}
```

确保启动 Cursor 的客户端可以访问该变量。保存文件后重启或重新加载 MCP 服务器。请参阅 [Cursor MCP 配置指南](https://cursor.com/help/customization/mcp) ，了解当前客户端行为。

## 验证连接

打开客户端的 MCP 服务器列表，确认 `narwhal` 已连接。 如需命令行检查，请运行 `agent mcp list`。

然后让客户端列出可用的 Narwhal 工具。工具发现不收费；每次成功的 `tools/call` 按其所属 API 的价格计一次调用费用。

使用 [主 MCP 指南](https://narwhalapi.com/zh/docs/mcp.md) ，了解公开工具列表、参数、响应结构和额度规则。

## 妥善保管密钥

如果使用 API 密钥，请通过 Cursor 或 VS Code 的安全变量/输入存储机制为占位符提供密钥。不要将真实密钥提交到 `mcp.json`，也不要将其粘贴到提示中、放入 URL 或暴露在浏览器代码中。

每个请求都需要 `Authorization: Bearer` 请求头。请参阅 [身份验证指南](https://narwhalapi.com/zh/docs/authentication.md) ，了解密钥的存储和轮换。

此页面对你有帮助吗?
