Cursor 配置 MCP(Model Context Protocol)

官方说明

MCP - Model Context Protocol
https://modelcontextprotocol.io/introduction
https://docs.cursor.com/context/model-context-protocol
在这里插入图片描述

1、MCP Tool 的集合

https://smithery.ai/

2、一个 demo :Sequential Thinking

我们以 Sequential Thinking 这个 MCP Server 作为 demo 配置一下

2.1、搜索一个 MCP Tool 获取 command 命令

在这里插入图片描述
https://smithery.ai/server/@smithery-ai/server-sequential-thinking
在这里插入图片描述
得到:

npx -y @smithery/cli@latest install @smithery-ai/server-sequential-thinking --client cursor --key d17b0085-f937-4a71-b723-cc2671612b9a

2.2、在 Cursor 配置

Name 是自定义的
Type 选择 command
Command 直接填写上面得到的

npx -y @smithery/cli@latest install @smithery-ai/server-sequential-thinking --client cursor --key d17b0085-f937-4a71-b723-cc2671612b9a

在这里插入图片描述

2.3、配置状态检查与修正(解决网络问题)

检查

配置完毕后,如果前面的点是绿色的,表示正常,否则表示配置没有生效。
在这里插入图片描述

解决办法

npx -y @smithery/cli@latest install @smithery-ai/server-sequential-thinking --client cursor --key d17b0085-f937-4a71-b723-cc2671612b9a

中 @xxx 部分 替换为 github 开源项目中提供的原始命令
在这里插入图片描述
比如下面 https://github.com/smithery-ai/reference-servers/tree/main/src/sequentialthinking
你可以获取的命令就是

npx -y @modelcontextprotocol/server-sequential-thinking

在这里插入图片描述

npx -y @smithery/cli@latest install @smithery-ai/server-sequential-thinking --client cursor --key d17b0085-f937-4a71-b723-cc2671612b9a

=>

npx -y @modelcontextprotocol/server-sequential-thinking --client cursor --key d17b0085-f937-4a71-b723-cc2671612b9a

然后就正常了
在这里插入图片描述

2.4、json 配置格式

部分低版本的 cursor 只支持 json格式的配置,道理是一样的 ,在页面勾选即可
在这里插入图片描述

推荐直接使用 github 的内容
在这里插入图片描述

{
  "mcpServers": {
    "sequential-thinking": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sequential-thinking"
      ]
    }
  }
}

2.5、使用

  • 比如我再配置一个热点新闻
npx -y @wopal/mcp-server-hotnews --client cursor --key d17b0085-f937-4a71-b723-cc2671612b9a

在这里插入图片描述

  • 然后使用
  • 可以发现,我的指令,直接调用了查询新闻的 MCP tool
    在这里插入图片描述

3、其它 MCP

3.1、前端设计稿 → ​​Figma MCP Server​​

获取 Figma Token 的路径​​
​​登录 Figma 账户​​
访问 [Figma 官网](https://www.figma.com/) 并登录你的账户。
​​进入账号设置​​
点击右上角的个人头像或头像图标。
在下拉菜单中选择 ​​"Settings"(设置)​​。
​​找到开发者选项​​
在左侧菜单栏中,找到并点击 ​​"Account"(账户)​​ 或 ​​"Dev Mode"(开发者模式)​​(根据 Figma 版本可能略有不同)。
向下滚动到 ​​"Personal access tokens"(个人访问令牌)​​ 部分。
​​生成新 Token​​
点击 ​​"Generate new token"(生成新令牌)​​。
输入 Token 的名称(例如 "API Token"),并选择权限范围(如 file:read、team:read 等)。
点击 ​​"Create"(创建)​​。
​​复制并保存 Token​​
生成的 Token 会显示一次(请立即复制保存,关闭后无法再次查看)。
​​⚠️ 重要提示​​:Token 类似密码,请妥善保管,不要泄露。

3.2、GitHub MCP Server

GitHub MCP Server

3.3、magic-mcp Server

magic-mcp Server

### 配置 CursorMCP 的集成 为了配置 Cursor 并使其能够与 MCP (Model Context Protocol) 进行交互,需遵循特定的安装和配置流程。此过程涉及环境准备、依赖项安装以及具体参数设定。 #### 环境准备 确保本地开发环境中已安装 Python 解释器,并建议创建虚拟环境以隔离项目依赖关系[^1]: ```bash python3 -m venv mcp-env source mcp-env/bin/activate # Linux or macOS # 或者 Windows 用户使用: # .\mcp-env\Scripts\activate.bat ``` #### 安装依赖包 接着,在激活后的虚拟环境下安装必要的 Python 库,特别是 `mcp-python-sdk`,这是用于构建客户端应用程序并与 MCP 服务器通信的核心组件之一: ```bash pip install --upgrade pip setuptools wheel pip install git+https://github.com/modelcontextprotocol/python-sdk.git@main ``` 上述命令会从 GitHub 上获取最新版本的 SDK 源码并完成安装操作。 #### 初始化 Cursor 设置 Cursor 提供了一个友好的界面帮助开发者快速上手。要使 Cursor 能够访问 MCP 功能,则需要按照官方指南中的指示进行适当调整。这通常意味着编辑配置文件或通过图形化界面对接相应的 API 接口和服务地址[^2]: - 访问 [Cursor 官方网站](https://www.cursor.dev/) 获取更多关于如何针对不同平台定制化的指导; - 利用 Cursor 中内置的帮助资源,比如文档和支持论坛寻求进一步的技术支持; #### 实现基本功能调用 一旦完成了以上准备工作之后,就可以编写一段简单的 Python 程序来测试是否可以成功连接到远程 MCP 服务端点。下面给出了一段基础示例代码片段展示怎样发送请求给 LLM 处理模块并接收返回的结果: ```python from mcp import ModelContextClient, StdioTransport def main(): transport = StdioTransport() client = ModelContextClient(transport) response = client.call_llm(prompt="你好世界") print(f"LLM Response: {response}") if __name__ == "__main__": main() ``` 这段脚本定义了一个名为 `main()` 函数,该函数实例化了传输层对象 (`StdioTransport`) 和模型上下文客户端 (`ModelContextClient`) ,随后向指定的语言模型发出查询请求 ("你好世界") 并打印出收到的回答内容。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值