Windsurf扩展工具服务器

MCP服务器为Windsurf代理IDE提供额外的工具扩展,包括文件搜索、代码分析和Web请求等功能,通过FastAPI和WebSocket实现高效通信。

  • by rohanbanda-TRT
  • Python
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 rohanbanda-trt/windsurf-mcp-integration

使用说明

用于Windsurf的MCP服务器

主控制程序(MCP)服务器,为Windsurf代理IDE提供额外工具。

概述

此MCP服务器旨在通过提供Windsurf中未内置的其他工具来扩展Windsurf的功能。它使用FastAPI创建一个强大的API服务器,并支持WebSocket与Windsurf进行实时通信。

特性

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

项目结构

MCP_servers/
├── main.py                 # Main FastAPI application
├── tools.py                # Custom tool implementations
├── windsurf_integration.py # Windsurf integration module
├── requirements.txt        # Project dependencies
└── README.md               # Documentation

内置工具

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

  1. 文件搜索:在具有模式匹配的目录中搜索文件
  2. 代码分析:分析代码文件的语法、复杂性和依赖关系
  3. web请求:向外部API发出HTTP请求

安装

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

用法

  1. 启动MCP服务器:

    python main.py
    

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

  2. 通过将WebSocket连接配置为:

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

添加自定义工具

要向MCP服务器添加新工具,请执行以下操作:

  1. 打开 tools.py
  2. 使用 @register_tool decorator来注册你的工具:
@register_tool(
    name="my_custom_tool",
    description="Description of what the tool does",
    parameters={
        "param1": {"type": "string", "description": "Description of parameter 1"},
        "param2": {"type": "integer", "description": "Description of parameter 2"}
    }
)
async def my_custom_tool_handler(params: Dict[str, Any]) -> Any:
    # Tool implementation
    param1 = params.get("param1", "")
    param2 = params.get("param2", 0)
    
    # Do something with the parameters
    result = f"Processed {param1} with value {param2}"
    
    return {"output": result}

API终点

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

许可证

麻省理工学院