使用说明
MCP服务器演示(幽默版)
用Python实现的简化模型上下文协议(MCP)服务器。此版本从标准输入中读取纯文本,并以幽默的消息进行响应。它是Docker和Azure可部署的。
项目结构
.
├── infrastructure/ # Infrastructure and deployment related files
│ ├── azure/ # Azure deployment files
│ │ ├── deploy.ps1 # PowerShell deployment script
│ │ ├── deploy.sh # Bash deployment script
│ │ └── main.bicep # Azure Bicep deployment template
│ └── docker/ # Docker deployment files
│ ├── Dockerfile # Container definition
│ └── docker-compose.yml # Docker Compose configuration
├── main.py main.py # MCP server implementation (reads text, returns funny responses)
└── requirements.txt # Python dependencies
发展
要在本地运行MCP服务器:
python main.py
使用Docker运行:
cd infrastructure/docker
docker compose up --build # Build and start the container
docker compose down # Stop and remove the container
要测试MCP服务器,请发送一条消息:
echo '{"type": "prompt", "content": "Hello MCP Server!", "metadata": {}}' | docker compose exec -T mcp-server-demo python -u main.py
部署
要部署到Azure,请执行以下操作:
cd infrastructure/azure
./deploy.ps1
在部署之前,请确保已安装Azure CLI并登录。