REST API Reference¶
Complete reference for all REST API endpoints exposed by MCP Hangar in HTTP mode.
Base URL: http://localhost:8000/api
All responses are JSON. Error responses return:
MCP servers¶
List MCP servers¶
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
state | query | string | No | Filter: cold, ready, degraded, dead |
Response 200:
{
"mcp_servers": [
{
"mcp_server": "math",
"state": "ready",
"mode": "subprocess",
"alive": true,
"tools_count": 5,
"health_status": "healthy",
"tools_predefined": false,
"description": "Math computation mcp_server"
}
]
}
Create MCP Server¶
Request body:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
mcp_server_id | string | Yes | -- | Unique identifier |
mode | string | Yes | -- | subprocess, docker, or remote |
command | list[string] | For subprocess | -- | Command to run |
image | string | For docker | -- | Docker image |
endpoint | string | For remote | -- | HTTP endpoint URL |
env | dict | No | {} | Environment variables |
idle_ttl_s | int | No | 300 | Idle timeout in seconds |
health_check_interval_s | int | No | 60 | Health check interval |
description | string | No | -- | Human-readable description |
volumes | list[string] | No | [] | Docker volume mounts |
network | string | No | "none" | Docker network mode |
read_only | bool | No | true | Read-only filesystem (docker) |
Response 201:
Get MCP Server¶
Response 200: MCP Server detail object with tools, health, and configuration.
Response 404: MCP Server not found.
Update MCP Server¶
Request body (all fields optional):
| Field | Type | Description |
|---|---|---|
description | string | New description |
env | dict | New environment variables (replaces existing) |
idle_ttl_s | int | New idle timeout |
health_check_interval_s | int | New health check interval |
Response 200:
Delete MCP Server¶
Stops the MCP server if running, then removes it from the registry.
Response 200:
Start MCP Server¶
Response 200: Start result object.
Stop MCP Server¶
Request body (optional):
| Field | Type | Default | Description |
|---|---|---|---|
reason | string | "user_request" | Reason for stopping |
Response 200: Stop result object.
Get MCP Server Tools¶
Response 200:
Get MCP Server Health¶
Response 200: Health status object with check history.
Get MCP Server Logs¶
| Parameter | In | Type | Default | Range | Description |
|---|---|---|---|---|---|
lines | query | int | 100 | 1--1000 | Number of recent lines |
Response 200:
{
"logs": [
{"timestamp": "2026-03-23T10:15:30", "line": "...", "mcp_server_id": "math", "stream": "stderr"}
],
"mcp_server_id": "math",
"count": 42
}
Get Tool Invocation History¶
| Parameter | In | Type | Default | Range | Description |
|---|---|---|---|---|---|
limit | query | int | 100 | 1--500 | Max records |
from_position | query | int | 0 | -- | Event store version offset |
Response 200:
Groups¶
List Groups¶
Response 200:
{
"groups": [
{
"group_id": "llm-pool",
"state": "healthy",
"strategy": "round_robin",
"members": [...],
"circuit_breaker_state": "closed"
}
]
}
Create Group¶
Request body:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
group_id | string | Yes | -- | Unique identifier |
strategy | string | No | "round_robin" | Load balancing strategy |
min_healthy | int | No | 1 | Minimum healthy members |
description | string | No | -- | Description |
Response 201:
Get Group¶
Response 200: Group detail with members and circuit breaker state.
Update Group¶
Request body (all optional):
| Field | Type | Description |
|---|---|---|
strategy | string | New strategy |
min_healthy | int | New minimum healthy count |
description | string | New description |
Response 200:
Delete Group¶
Response 200:
Rebalance Group¶
Re-checks member health and resets circuit breaker if applicable.
Response 200:
Add Group Member¶
Request body:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
member_id | string | Yes | -- | MCP Server ID to add |
weight | int | No | 1 | Routing weight |
priority | int | No | 1 | Routing priority |
Response 201:
Remove Group Member¶
Response 200:
Discovery¶
List Sources¶
Response 200:
{"sources": [{"source_id": "...", "type": "docker", "mode": "additive", "enabled": true, "last_scan": "..."}]}
Register Source¶
Request body:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
source_type | string | Yes | -- | docker, filesystem, kubernetes, entrypoint |
mode | string | Yes | -- | additive or authoritative |
enabled | bool | No | true | Activate immediately |
config | dict | No | {} | Source-specific configuration |
Response 201:
Update Source¶
Request body (all optional): mode, enabled, config.
Response 200:
Delete Source¶
Response 200:
Trigger Scan¶
Response 200:
Enable/Disable Source¶
Request body:
Response 200:
List Pending MCP servers¶
Response 200:
List Quarantined MCP servers¶
Response 200:
Approve MCP Server¶
Response 200: Approval result.
Reject MCP Server¶
Response 200: Rejection result.
Configuration¶
Get Config¶
Returns the current server configuration with sensitive fields stripped.
Response 200:
Reload Config¶
Request body (optional):
| Field | Type | Default | Description |
|---|---|---|---|
config_path | string | server default | Path to config file |
graceful | bool | true | Graceful reload |
Response 200:
Export Config¶
Serializes current in-memory state to YAML.
Response 200:
Backup Config¶
Creates a rotating backup of the current configuration.
Response 200:
Config Diff¶
Compares on-disk configuration with current in-memory state.
Response 200:
System¶
Get System Info¶
Response 200:
{
"system": {
"total_mcp_servers": 5,
"mcp_servers_by_state": {"ready": 3, "cold": 2},
"total_tools": 15,
"total_tool_calls": 42,
"uptime_seconds": 3600.5,
"version": "1.1.0"
}
}
Auth Management¶
Create API Key¶
Request body:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
principal_id | string | Yes | -- | Principal this key authenticates as |
name | string | Yes | -- | Human-readable key name |
created_by | string | No | "system" | Creator principal |
expires_at | string | No | -- | ISO8601 expiry datetime |
Response 201:
Warning
The raw_key is returned only once. Store it securely.
Revoke API Key¶
Request body (optional):
| Field | Type | Default | Description |
|---|---|---|---|
revoked_by | string | "system" | Revoking principal |
reason | string | "" | Revocation reason |
List API Keys¶
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
principal_id | query | string | Yes | Principal whose keys to list |
include_revoked | query | bool | No | Include revoked keys (default true) |
List All Roles¶
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
include_builtin | query | bool | No | Include built-in roles (default true) |
List Built-in Roles¶
Get Role¶
Create Custom Role¶
Update Custom Role¶
Delete Custom Role¶
Assign Role¶
Request body:
Revoke Role¶
Request body:
List Principals¶
List Roles for Principal¶
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
principal_id | query | string | Yes | Principal whose roles to list |
scope | query | string | No | Scope filter (default * = all) |
Check Permission¶
Request body:
Get Tool Access Policy¶
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
scope | path | string | Yes | provider, group, or member |
target_id | path | string | Yes | Identifier of the provider, group, or member |
Set Tool Access Policy¶
Request body:
Clear Tool Access Policy¶
WebSocket Endpoints¶
Events Stream¶
Streams all domain events as JSON frames.
See the WebSockets guide for connection details.