返回市场
风帆-MCP集成服务器

风帆-MCP集成服务器

作者:rohanbanda-TRT2 星标更新:2025-04-05

项目介绍

MCP Server for Windsurf

用于扩展Windsurf代理IDE功能的主控程序(MCP)服务器。

概述

此MCP服务器旨在通过提供未内置到Windsurf中的额外工具来扩展Windsurf的功能。它使用FastAPI创建一个支持WebSocket的健壮API服务器,以实现与Windsurf的实时通信。

特性

  • FastAPI后端:高性能且易于使用的框架
  • WebSocket支持:实时双向通信
  • 可扩展工具系统:轻松添加新工具以扩展Windsurf
  • RESTful API:用于工具执行的HTTP端点
  • Windsurf集成:无缝集成到Windsurf IDE

项目结构

MCP_servers/
├── main.py                 # 主FastAPI应用程序
├── tools.py                # 自定义工具实现
├── windsurf_integration.py # Windsurf集成模块
├── requirements.txt        # 项目依赖
└── README.md               # 文档

内置工具

MCP服务器自带几个内置工具:

  1. 文件搜索:在目录中按模式匹配搜索文件
  2. 代码分析:分析代码文件的语法、复杂度和依赖关系
  3. 网络请求:对外部API进行HTTP请求

安装

  1. 克隆仓库
  2. 创建虚拟环境:
    python -m venv venv
    source venv/bin/activate  # 在Windows上:venv\Scripts\activate
    
  3. 安装依赖项:
    pip install -r requirements.txt
    

使用

  1. 启动MCP服务器:

    python main.py
    

    这将在http://localhost:8089启动服务器

  2. 配置WebSocket连接以连接Windsurf到MCP服务器:

    ws://localhost:8089/ws
    
  3. 访问API文档:http://localhost:8089/docs

添加自定义工具

要向MCP服务器添加新工具:

  1. 打开tools.py
  2. 使用@register_tool装饰器注册您的工具:
@register_tool(
    name="my_custom_tool",
    description="描述该工具的作用",
    parameters={
        "param1": {"type": "string", "description": "参数1的描述"},
        "param2": {"type": "integer", "description": "参数2的描述"}
    }
)
async def my_custom_tool_handler(params: Dict[str, Any]) -> Any:
    # 工具实现
    param1 = params.get("param1", "")
    param2 = params.get("param2", 0)
    
    # 对参数进行处理
    result = f"处理了{param1},值为{param2}"
    
    return {"output": result}

API端点

  • GET /:服务器信息
  • GET /tools:列出所有可用工具
  • POST /tools/{tool_name}:执行特定工具
  • WebSocket /ws:用于实时通信的WebSocket端点

许可证

MIT

</中文翻译>