A production-ready Model Context Protocol (MCP) server that exposes the FORUS Cortex Agent's tools and capabilities to external LLM applications.
- Memory Search: Semantic search across agent's FAISS vector database
- Knowledge Base: Query Master Services Agreement documents
- Code Execution: Safe Python and shell command execution
- System Monitoring: Real-time server and resource status
- MCP Compliance: Full JSON-RPC 2.0 protocol implementation
- Security Ready: Authentication hooks and input validation
- Python 3.9+
- Access to FORUS Cortex Agent memory database
- Network access for HTTP server
# Clone the repository
git clone https://github.com/SingularityAI-Dev/FORUS-Cortex-MCP-Server.git
cd FORUS-Cortex-MCP-Server
# Install dependencies
pip install -r requirements.txt
# Start the server
python server.py# Build and run with Docker Compose
docker-compose up -d
# Or run directly
docker build -t forus-mcp-server .
docker run -p 8083:8083 forus-mcp-servercurl http://localhost:8083/curl -X POST http://localhost:8083/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}'curl -X POST http://localhost:8083/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "memory_search",
"arguments": {
"query": "FORUS business model",
"limit": 5
}
}
}'| Tool | Description | Parameters |
|---|---|---|
memory_search |
Search agent memory using semantic similarity | query, limit, area |
query_msa |
Query Master Services Agreement documents | query |
execute_python |
Execute Python code safely | code, timeout |
execute_shell |
Execute whitelisted shell commands | command, timeout |
get_system_status |
Get server and system status | None |
list_mcp_tools |
List all available tools | None |
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"forus-cortex": {
"command": "python",
"args": ["/path/to/server.py", "--stdio"]
}
}
}Create .vscode/mcp.json:
{
"mcpServers": {
"forus-cortex": {
"url": "http://localhost:8083/mcp"
}
}
}import requests
import json
def call_mcp_tool(tool_name, **kwargs):
response = requests.post('http://localhost:8083/mcp', json={
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": tool_name,
"arguments": kwargs
}
})
return response.json()
# Usage
result = call_mcp_tool("memory_search", query="FORUS", limit=3)
print(json.dumps(result, indent=2))βββββββββββββββββββββββββββββββββββββββββββββββ
β External LLM Applications β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β MCP Protocol (JSON-RPC)
β
βββββββββββββββββββββββββββββββββββββββββββββββ
β FORUS MCP Server β
β βββββββββββββββββββββββββββββββββββββββ β
β β JSON-RPC Handler β β
β βββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββ β
β β Tool Registry & Router β β
β βββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββ β
β β Agent Context Manager β β
β βββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β
ββββββββββββββββ΄βββββββββββββββ
β β
βββββββββββββββββ βββββββββββββββββ
β Memory Tools β β Knowledge DB β
β - FAISS β β - Qdrant β
β - Embeddingsβ β - MSA Docs β
βββββββββββββββββ βββββββββββββββββ
β β
βββββββββββββββββ βββββββββββββββββ
β Code Execute β β System Tools β
β - Python β β - Scheduler β
β - Shell β β - Browser β
βββββββββββββββββ βββββββββββββββββ
- Input validation on all tools
- Whitelisted shell commands only
- Sandboxed code execution
- Request timeout protection
- CORS support
- Enable API key authentication
- Add rate limiting per client
- Use HTTPS with SSL certificates
- Implement request logging and monitoring
- Set up firewall rules
# Add bearer token authentication
headers = {"Authorization": "Bearer your-api-token"}
response = requests.post(
"https://your-server.com/mcp",
headers=headers,
json=request_data
)| Variable | Description | Default |
|---|---|---|
MCP_HOST |
Server bind address | 0.0.0.0 |
MCP_PORT |
Server port | 8083 |
MEMORY_PATH |
Path to memory index | ./memory/default/index.pkl |
LOG_LEVEL |
Logging level | INFO |
AUTH_ENABLED |
Enable authentication | false |
Create config.yaml:
server:
host: "0.0.0.0"
port: 8083
security:
auth_enabled: false
rate_limit: 100
allowed_origins:
- "http://localhost:*"
tools:
memory:
enabled: true
index_path: "./memory/default/index.pkl"
execution:
python_timeout: 30
shell_timeout: 10
allowed_commands:
- ls
- pwd
- echo
- cat
- head
- tailpython -m pytest tests/# Test server health
python examples/test_server.py
# Test with MCP Inspector
npx @modelcontextprotocol/inspector http://localhost:8083/mcp# Install artillery
npm install -g artillery
# Run load test
artillery run load-test.yml-
Set up SSL certificate:
sudo certbot --nginx -d mcp.yourdomain.com
-
Configure reverse proxy (Nginx):
server { listen 443 ssl; server_name mcp.yourdomain.com; location / { proxy_pass http://localhost:8083; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }
-
Run with process manager:
# With PM2 pm2 start server.py --name mcp-server --interpreter python3 # With systemd sudo systemctl enable mcp-server sudo systemctl start mcp-server
gcloud run deploy mcp-server \
--source . \
--platform managed \
--region us-central1 \
--allow-unauthenticated# Package and deploy with Serverless
serverless deploy# Deploy with Vercel CLI
vercel deploy- Request/response latency
- Tool execution times
- Error rates and types
- Memory usage patterns
- Concurrent connection counts
# Basic health check
curl -f http://localhost:8083/ || exit 1
# Tool availability check
curl -X POST http://localhost:8083/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'- Structured JSON logging
- Request/response logging
- Error tracking with stack traces
- Performance metrics logging
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
python -m pytest
# Run linting
flake8 .
# Format code
black .This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check the examples directory
- Issues: Report bugs or request features via GitHub Issues
- Discussions: Join the conversation in GitHub Discussions
- Email: Contact rain.singlesource@gmail.com
- Built for the FORUS Cortex Agent ecosystem
- Implements the official Model Context Protocol
- Inspired by the MCP community and best practices
- Special thanks to the open-source MCP tools and examples
π Star this repo if you find it useful!