cursor 安装 cline 调试 mcp

1、用uv安装环境

  1. 新建目录 mcp-server-demo-2
  2. 用cursor打开mcp-server-demo-2
  3. 新建终端
bash 复制代码
d.uv init   初始化
uv init   #初始化
uv venv   #建环境
source .venv/bin/activate   #启动环境
uv add "mcp[cli]"           #加mcp扩展

2.写个demo

  1. 新建文件 server.py
python 复制代码
# server.py
from mcp.server.fastmcp import FastMCP

# Create an MCP server
mcp = FastMCP("Demo")


# Add an addition tool
@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b


# Add a dynamic greeting resource
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
    """Get a personalized greeting"""
    return f"Hello, {name}!"

if __name__ == "__main__":
    mcp.run()

3.mcp 测试

bash 复制代码
mcp dev server.py
  1. 访问 http://127.0.0.1:6274/#resources 如下图

4.cursor 安装 cline



配置服务

5.cline 配置文件

json 复制代码
{
  "mcpServers": {
    "你的名字": {
      "autoApprove": [],
      "disabled": false,
      "timeout": 60,
      "command": "/项目路径/mcp-server-demo-2/.venv/bin/python",
      "args": [
        "/项目路径/mcp-server-demo-2/server.py"
      ],
      "env": {},
      "transportType": "stdio"
    }
  }
}

配置好后可以看到对应的工具和资源

6.测试



7、参考资料

https://github.com/modelcontextprotocol/python-sdk
https://modelcontextprotocol.io/introduction

相关推荐
啊湘19 小时前
vscode 使用 github (适用CURSOR等使用)
ide·vscode·github·cursor·mcp
小小呱呱蛙19 小时前
Claude Code 自下而上分析(Slash/Sub Agents/Skills/MCP)带来的启发
agent·claude·mcp
wangruofeng19 小时前
Flutter AI Coding 实战手册:可落地场景拆解 + 代码级实操方案
aigc·ai编程·cursor
callJJ20 小时前
MCP配置与实战:深入理解现代开发工具链
javascript·node.js·vue·mcp·windsurf
乘风gg1 天前
Skill 真香!5 分钟帮女友制作一款塔罗牌 APP
人工智能·ai编程·cursor
谷哥的小弟1 天前
Brave Search MCP服务器安装以及客户端连接配置
搜索引擎·大模型·spring ai·mcp·brave search
太空眼睛1 天前
【MCP】使用SpringBoot基于Streamable-HTTP构建MCP-Client
spring boot·ai·llm·sse·mcp·mcp-client·streamable
kaizq1 天前
AI-MCP-SQLite-SSE本地服务及CherryStudio便捷应用
python·sqlite·llm·sse·mcp·cherry studio·fastmcp
太空眼睛2 天前
【MCP】使用SpringBoot基于Streamable-HTTP构建MCP-Server
spring boot·sse·curl·mcp·mcp-server·spring-ai·streamable
啊湘2 天前
VSCODE英文界面切换为中文(适用CURSOR等使用)
ide·vscode·编辑器·bug·cursor