OpsMateAgent is a FastAPI-based microservice with an embedded MCP agent. The agent communicates with its MCP server over stdio for extra security.
- FastAPI endpoints for chat and agent interaction (
/chat,/docs) - Agent initialization at startup with secrets injected via YAML
- MCP server vendored as a local module (
mcp_server_brassin) - Dockerized deployment, optimized for Fly.io
FastAPI (api/main.py) <---> MCP Agent <---> MCP Server (mcp_server_brassin)
- FastAPI exposes REST endpoints and orchestrates requests.
- MCP Agent manages lifecycle and interaction with the MCP server.
- MCP Server (
mcp_server_brassin) is installed as a vendored tool and runs under the agent’s supervision.
Make sure you are in the project root directory i.e. OpsMateAgent.
You should see folders like configs/, tests/ and files like .python-version, README.md when running ls (mac/Linux) or dir (Windows).
# Create virtual environment
uv venv
# Activate virtual environment
source .venv/bin/activate # Linux/macOS
.venv\Scripts\activate # Windows
# Install dependencies
uv syncuv tool install --from ./mcp_server_brassin mcp-server-brassin
# Verify installation
mcp-server-brassinCreate a YAML file in the configs/ folder and name it: mcp_agent.secrets.yaml.
Example: mcp_agent.secrets.yaml
openai:
api_key: "sk-your-openai-key"
# anthropic:
# api_key: "sk-your-anthropic-key"
# Optional: Azure OpenAI
# azure:
# api_key: "..."
# endpoint: "https://<your-endpoint>.openai.azure.com"
# Optional: Google
# google:
# api_key: "..."
# vertexai: true
# project: your-gcp-project-id
# location: us-central1
# Optional: AWS / Bedrock
# bedrock:
# aws_access_key_id: "..."
# aws_secret_access_key: "..."
# aws_region: "us-east-1"uv run main.pyAccess the API at:
- Swagger docs → http://localhost:9000/docs
- Chat endpoint →
POST http://localhost:9000/chat
If you make changes to mcp_server_brassin:
# Uninstall old version
uv tool uninstall mcp-server-brassin
# Install updated version
uv tool install --from ./mcp_server_brassin mcp-server-brassin
# Verify
uv tool list
# Run agent again
uv run main.pyBuild and run locally:
# Build image
docker build -t opsmate-agent .
# Run container (map host port 9000 to container port 9000)
docker run -d -p 9000:9000 --env-file .env opsmate-agentAccess the app at:
- Swagger docs → http://localhost:8000/docs
- Chat endpoint →
POST http://localhost:8000/chat
-
Install Fly.io CLI
curl -L https://fly.io/install.sh | sh -
Initialize app
flyctl launch
- Choose Docker deployment
- Set internal port to
9000
-
Check
fly.toml[http_service] internal_port = 9000 force_https = true auto_stop_machines = true auto_start_machines = true min_machines_running = 0 #set to 1 or higher if you are on paid version
-
Deploy
flyctl deploy --remote-only
-
Access Your app will be available at:
https://<your-app-name>.fly.dev/docs
- Ensure the app always binds to
0.0.0.0:9000inside Docker/Fly.io. - Cold starts may add latency if
auto_stop_machines = true. Usemin_machines_running = 1to keep one warm instance. - MCP server must be reinstalled (
uv tool install) after updates.