How It Works
An external client calls the launched endpoint, and the agent runs the request before returning the response.Choose a Protocol
Pick the launch protocol that matches the caller.Quick Start
Launch Methods
HTTP API Server
The most common deployment method is as an HTTP API server using FastAPI:MCP Server
For Model Context Protocol integration:API Usage
When launched as an HTTP API, agents expose a single endpoint that accepts POST requests:HTTP API Endpoint
POST /path
Send messages to the agent and receive responses.
Complete Examples
Example 1: Single Agent HTTP API
Example 2: Multi-Agent HTTP API System
Example 3: MCP Server with Tools
Example 4: Multiple Endpoints on Same Port
Multiple
Agent / Agents instances may call .launch(port=N) concurrently from different threads — registration is atomic. If two launch calls use the same path on the same port, the second gets an auto-suffixed path (/path_abc123) and a warning is logged. Server readiness is signalled deterministically (no fixed sleep); .launch() returns only after the port is accepting connections. The wait defaults to 5 seconds and is configurable via the PRAISONAI_SERVER_READY_TIMEOUT environment variable. If the server doesn’t become ready in time, .launch() still returns and a warning is logged — check server logs for startup errors.Example 5: Debug Mode for Development
Launch Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
protocol | str | Launch protocol: “http” or “mcp" | "http” |
host | str | Host to bind to | ”0.0.0.0” |
port | int | Port number | 8000 |
path | str | API endpoint path (HTTP) or base path (MCP) | ”/“ |
debug | bool | Enable debug mode with auto-reload | False |
Environment Variables
| Variable | Default | Description |
|---|---|---|
PRAISONAI_SERVER_READY_TIMEOUT | 5.0 | Seconds .launch() waits for the HTTP server to be ready. On timeout, a warning is logged and execution continues. |
Client Integration
Python Client
JavaScript Client
MCP Client Integration
For MCP servers, use an MCP-compatible client:Deployment Best Practices
Performance
- Use appropriate worker processes
- Enable connection pooling
- Monitor resource usage
- Consider horizontal scaling for high load
Security
- Deploy behind a reverse proxy (nginx, Apache)
- Implement authentication at proxy level
- Use HTTPS in production
- Validate and sanitize inputs
- Set up rate limiting
Production Deployment
Docker Deployment
Systemd Service
Nginx Reverse Proxy
Important Notes
- Threading: The launch() method uses threading to run servers in the background
- Blocking: The last launch() call in your script will block the main thread
- Multiple Agents: You can run multiple agents on the same port with different paths (HTTP mode only)
- Dependencies: HTTP mode requires FastAPI and uvicorn, MCP mode requires praison-mcp
- API Documentation: HTTP APIs automatically get FastAPI documentation at
/docs
Troubleshooting
Port already in use
Port already in use
- Check if another process is using the port:
lsof -i :8000 - Kill the process or use a different port
- Ensure previous agent instances are properly stopped
Missing dependencies
Missing dependencies
- For HTTP:
pip install fastapi uvicorn - For MCP:
pip install praison-mcp mcp - Check error messages for specific missing packages
Agent not responding
Agent not responding
- Check console for error messages
- Verify API key is set correctly
- Test with debug=True for more detailed logs
- Ensure agent initialization is successful
Connection refused
Connection refused
- Verify the host and port settings
- Check firewall rules
- Ensure the agent is actually running
- Try connecting from localhost first
Agent server slow to start
Agent server slow to start
If you see Common causes: slow imports, cold-start on resource-constrained machines, blocking startup hooks.
Agent server on port N did not become ready within 5.0s in the logs, the FastAPI server took longer than the default 5s to come up. This is usually safe (.launch() still returns and the server keeps starting), but you can raise the wait:Next Steps
API Reference
Detailed Agent API documentation
MCP Integration
Learn more about Model Context Protocol
Best Practices
Pick the protocol that matches your caller
Pick the protocol that matches your caller
Use
protocol="http" for web apps, cURL, and microservices that speak REST, and protocol="mcp" when the caller is an MCP-compatible agent host. HTTP is the default, so agent.launch(port=8000) gives you a POST endpoint with automatic FastAPI docs at /docs. Switch only when the consumer requires MCP tools.Tune the readiness timeout for slow cold starts
Tune the readiness timeout for slow cold starts
.launch() returns only after the port accepts connections, waiting up to 5 seconds by default. On resource-constrained machines or with heavy imports, raise the wait so startup logs aren’t misread as failures:Terminate TLS and auth at the edge
Terminate TLS and auth at the edge
The launch server is intentionally minimal. In production, place it behind a reverse proxy (nginx) that handles HTTPS, authentication, and rate limiting rather than exposing
0.0.0.0:8000 directly. Bind to 127.0.0.1 when the proxy runs on the same host.Related
Run a persistent multi-agent server with richer routing and lifecycle control.
Connect agents to Model Context Protocol tools and servers.

