使用说明
MCP服务器集合
用于AI助手集成的模型上下文协议(MCP)服务器。该存储库提供两个生产就绪的MCP服务器:天气查询和稳定扩散图像生成。
特性
天气查询服务器
- 地点:
weather_mcp/ - 全球城市实时天气数据检索
- API终点:
get_weather - 数据来源:wttr.in
稳定的扩散服务器
- 地点:
sd_mcp/ - 本地稳定扩散WebUI集成
- 文本到图像和图像到图像生成
- 模型和LoRA管理
- 智能提示优化
- API端点:
generate_image,img2img,list_models,switch_model等等。
先决条件
- Python 3.8+
- 带有GitHub Copilot扩展的VS代码
- 对于SD服务器:本地运行稳定的Diffusion WebUI
安装
- 克隆存储库
git clone <repository-url>
cd MCP
- 为每台服务器安装依赖项
cd weather_mcp
pip install -r requirements.txt
cd ../sd_mcp
pip install -r requirements.txt
配置
VS代码集成
添加到您的VS代码设置(.vscode/settings.json):
{
"languageModels.mcpServers": {
"weather-server": {
"command": "python",
"args": ["main.py"],
"cwd": "${workspaceFolder}/weather_mcp"
},
"sd-painter": {
"command": "python",
"args": ["sd_mcp_server.py"],
"cwd": "${workspaceFolder}/sd_mcp"
}
}
}
稳定的扩散配置
编辑 sd_mcp/sd_mcp_server.py 配置:
SD_API_URL:稳定扩散API端点(默认值:http://127.0.0.1:7860)SD_LAUNCHER_PATH:SD启动器可执行文件的路径OUTPUT_DIR:生成的图像输出目录
用法
天气查询
Get current weather for Beijing
What's the temperature in London?
图像生成
Generate an image: beautiful landscape at sunset
Create a portrait using realistic model
项目结构
MCP/
├── weather_mcp/
│ ├── main.py
│ ├── requirements.txt
│ └── README.md
├── sd_mcp/
│ ├── sd_mcp_server.py
│ ├── requirements.txt
│ ├── README.md
│ ├── SD_MCP_GUIDE.md
│ └── generated_images/
└── README.md
API文档
天气服务器工具
get_weather(city: str):检索天气信息
SD服务器工具
generate_image(prompt: str, ...):文本到图像生成img2img(image_path: str, prompt: str, ...):图像到图像转换list_models():列出可用的SD型号switch_model(model_name: str):切换活动模型smart_generate(description: str, ...):人工智能驱动的自动发电- 更多(完整列表请参见SD_MCP_GUIDE.md)
技术细节
天气服务器
- 基于MCP协议构建
- 使用wttr.in免费天气API
- 支持中英文城市名称
- 返回结构化JSON数据
SD服务器
- 与稳定扩散WebUI API的接口
- 支持多种型号和LoRA
- 自动模型切换
- 智能提示翻译和优化
- 可配置的发电参数
许可证
麻省理工学院
贡献
欢迎捐款。请提交pull请求或bug和功能请求的开放问题。
