用于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服务器附带了几个内置工具:
- 文件搜索:在具有模式匹配的目录中搜索文件
- 代码分析:分析代码文件的语法、复杂性和依赖关系
- web请求:向外部API发出HTTP请求
安装
- 克隆存储库
- 创建虚拟环境:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- 安装依赖项:
pip install -r requirements.txt用法
- 启动MCP服务器:
python main.py这将启动服务器http://localhost:8089
- 通过将WebSocket连接配置为:
ws://localhost:8089/ws- 访问API文档:http://localhost:8089/docs
添加自定义工具
要向MCP服务器添加新工具,请执行以下操作:
- 打开
tools.py - 使用
@register_tooldecorator来注册你的工具:
@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端点
许可证
麻省理工学院
