Spaces:
Sleeping
Sleeping
File size: 6,278 Bytes
a6bd8c1 7e7f9f2 a6bd8c1 7e7f9f2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | ---
title: Coral Server
emoji: π»
colorFrom: green
colorTo: yellow
sdk: docker
app_port: 5555
pinned: false
---
```markdown
---
title: Coral Protocol MCP Server
emoji: πͺΈ
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
pinned: false
license: apache-2.0
tags:
- mcp
- multi-agent
- coral-protocol
- ai-agents
---
# πͺΈ Coral Protocol MCP Server
This Space hosts a **Coral Protocol MCP (Model Context Protocol) Server** that enables multi-agent communication and coordination.
## π Features
- **MCP-compliant server** with SSE (Server-Sent Events) transport
- **Multi-agent communication** through thread-based messaging
- **RESTful API** for agent management
- **Real-time event streaming** for agent interactions
- **Production-ready** nginx reverse proxy setup
## π‘ Endpoints
### Status Check
- **GET** `/` - Server status page
- **GET** `/health` - Health check endpoint
### MCP SSE Endpoint
- **GET** `/devmode/exampleApplication/privkey/session1/sse` - Main SSE endpoint for MCP communication
### API Endpoints
- **POST** `/api/agents` - Register new agent
- **GET** `/api/agents` - List all agents
- **POST** `/api/threads` - Create new thread
- **POST** `/api/messages` - Send message
## π§ Technical Details
- **Framework**: Coral Server (Kotlin/Gradle)
- **Transport**: Server-Sent Events (SSE)
- **Proxy**: Nginx reverse proxy
- **Port**: 7860 (proxied from internal port 5555)
## π Documentation
For detailed documentation, visit:
- [Coral Protocol Documentation](https://docs.coralprotocol.org)
- [Quickstart Guide](https://docs.coralprotocol.org/setup/quickstart)
- [Server Applications](https://docs.coralprotocol.org/setup/coral-server-applications)
## π€ Integration
### Using with MCP Clients
```python
import requests
import sseclient
# Connect to SSE endpoint
url = "https://[your-space-name].hf.space/devmode/exampleApplication/privkey/session1/sse"
response = requests.get(url, stream=True)
client = sseclient.SSEClient(response)
# Listen for events
for event in client.events():
print(f"Event: {event.event}")
print(f"Data: {event.data}")
```
### Using with Coral SDK
```javascript
const CoralClient = require('@coral-protocol/sdk');
const client = new CoralClient({
serverUrl: 'https://[your-space-name].hf.space',
transport: 'sse'
});
await client.connect();
```
## π About Coral Protocol
Coral Protocol is an open and decentralized infrastructure designed to enable:
- **Communication** between AI agents
- **Coordination** of multi-agent tasks
- **Trust** mechanisms for agent interactions
- **Payments** for agent services
## π License
This project is licensed under the Apache License 2.0.
## π Links
- [GitHub Repository](https://github.com/Coral-Protocol/coral-server)
- [Coral Protocol Website](https://coralprotocol.org)
- [Discord Community](https://discord.gg/coral-protocol)
## π‘ Status
Current Status: **π’ Active**
Last Updated: 2024
```
## 3. **.gitignore** (Optional but recommended)
```gitignore
# Gradle
.gradle/
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
# IDE
.idea/
*.iml
*.ipr
*.iws
.vscode/
*.swp
*.swo
# OS
.DS_Store
Thumbs.db
# Logs
logs/
*.log
# Temporary files
tmp/
temp/
*.tmp
# Environment variables
.env
.env.local
# Node (if using any JS tools)
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Python (if using any Python tools)
__pycache__/
*.py[cod]
*$py.class
.Python
venv/
ENV/
# Hugging Face
.huggingface/
```
## 4. **docker-compose.yml** (Optional - for local testing)
```yaml
version: '3.8'
services:
coral-server:
build: .
ports:
- "7860:7860"
environment:
- CONFIG_PATH=/app/coral-config/
- GRADLE_USER_HOME=/home/user/.gradle
volumes:
- ./coral-config:/app/coral-config
- gradle-cache:/home/user/.gradle
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7860/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
volumes:
gradle-cache:
```
## 5. **test.sh** (Optional - Test script)
```bash
#!/bin/bash
# Test script for Coral Server endpoints
SERVER_URL="${1:-http://localhost:7860}"
echo "πͺΈ Testing Coral Server at: $SERVER_URL"
echo "================================"
# Test 1: Health check
echo -n "Testing health endpoint... "
if curl -s -f "$SERVER_URL/health" > /dev/null; then
echo "β
OK"
else
echo "β FAILED"
fi
# Test 2: Root endpoint
echo -n "Testing root endpoint... "
if curl -s "$SERVER_URL/" | grep -q "Coral Server"; then
echo "β
OK"
else
echo "β FAILED"
fi
# Test 3: SSE endpoint (just check if it connects)
echo -n "Testing SSE endpoint... "
if curl -s -N --max-time 2 "$SERVER_URL/devmode/exampleApplication/privkey/session1/sse" 2>/dev/null; then
echo "β
OK (Connected)"
else
echo "β οΈ Timeout (Expected for SSE)"
fi
echo "================================"
echo "Test complete!"
```
## Deployment Instructions:
1. **Create a new Space on Hugging Face**:
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Choose "Docker" as the SDK
- Set visibility (public/private)
2. **Upload the files**:
- Upload the `Dockerfile` to the root of your Space
- Upload the `README.md` to the root of your Space
- Optionally upload `.gitignore` and other files
3. **Wait for build**:
- Hugging Face will automatically build and deploy your Space
- Check the logs for any errors
- The build process might take 5-10 minutes
4. **Access your server**:
- Once deployed, access at: `https://[your-username]-[space-name].hf.space/`
- Test the SSE endpoint: `https://[your-username]-[space-name].hf.space/devmode/exampleApplication/privkey/session1/sse`
5. **Monitor logs**:
- Use the "Logs" tab in your Space to monitor both build and runtime logs
- Check for any startup errors or connection issues
This complete setup should work properly on Hugging Face Spaces. The key improvements include:
- Proper supervisor configuration for managing multiple processes
- Correct nginx configuration for SSE/MCP protocol
- Better error handling and logging
- Health checks and status endpoints
- Proper permissions for non-root user execution
|