深度链接(deeplinks)
Cursor 深度链接概览
MCP 服务器安装
可通过 Cursor 深度链接安装 MCP 服务器。其配置格式基于 mcp.json,包含名称和传输配置。
链接格式
安装链接格式如下:
cursor://anysphere.cursor-deeplink/mcp/install?name=$NAME&config=$BASE64_ENCODED_CONFIG
组件 | 描述 |
---|---|
cursor:// | 协议方案 |
anysphere.cursor-deeplink | 深度链接处理器 |
/mcp/install | 路径 |
name | 服务器名称的查询参数 |
config | Base64 编码的 JSON 配置的查询参数 |
生成安装链接
- 🔧 链接生成器
- 📋 配置示例
- 📖 手动生成
JSON 配置
在下方输入您的MCP服务器配置:
✅ 检测到服务器: postgres
配置示例
以下是一些常用的MCP服务器配置示例,您可以复制使用:
PostgreSQL
PostgreSQL数据库连接
配置示例
{
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
]
}
}
SQLite
SQLite数据库连接
配置示例
{
"sqlite": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-sqlite",
"--db-path",
"./database.sqlite"
]
}
}
File System
文件系统访问
配置示例
{
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/allowed/files"
]
}
}
如果您希望手动生成安装链接,请按照以下步骤:
- 获取服务器配置:准备您的 MCP 服务器 JSON 配置
- 序列化配置:使用
JSON.stringify()
将配置对象转换为字符串 - Base64 编码:对序列化后的配置进行 base64 编码
- 构建链接:将服务器名称和编码后的配置替换到链接模板中
JavaScript 示例代码:
// 1. 准备配置对象
const serverConfig = {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
]
}
};
// 2. 获取服务器名称和配置
const serverName = Object.keys(serverConfig)[0]; // "postgres"
const config = serverConfig[serverName];
// 3. 序列化并编码
const configString = JSON.stringify(config);
const base64Config = btoa(configString);
// 4. 生成安装链接
const installLink = `cursor://anysphere.cursor-deeplink/mcp/install?name=${serverName}&config=${base64Config}`;
console.log(installLink);
Python 示例代码:
import json
import base64
# 1. 准备配置
server_config = {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
]
}
}
# 2. 获取服务器名称和配置
server_name = list(server_config.keys())[0]
config = server_config[server_name]
# 3. 序列化并编码
config_string = json.dumps(config)
base64_config = base64.b64encode(config_string.encode()).decode()
# 4. 生成安装链接
install_link = f"cursor://anysphere.cursor-deeplink/mcp/install?name={server_name}&config={base64_config}"
print(install_link)
安装服务器
使用生成的深度链接安装 MCP 服务器:
- 点击链接:点击生成的安装链接或将链接粘贴至浏览器地址栏
- 确认安装:Cursor 会弹出提示框要求您确认安装服务器
- 开始使用:安装完成后,您就可以在 Cursor 的聊天模式中使用该 MCP 服务器了
提示
安装 MCP 服务器后,您可以在 Cursor 的设置中管理和配置这些服务器。详细信息请参阅 MCP 服务器文档。
BugBot 集成
BugBot 评论中的 Fix in Cursor
链接会在 Cursor 中打开预填充了文件路径和问题描述的编辑界面。
功能特性
- 自动文件定位:直接跳转到相关的源代码文件
- 问题描述预填充:自动填入 BugBot 检测到的问题描述
- 上下文保持:保留完整的问题上下文信息
注意
此类深度链接仅在 BugBot 的评论中可用,无法手动创建。
了解更多关于 Cursor 深度链接的信息,请参阅相关文档: