Admin API

Administrative API for managing MCP servers, monitoring operations, and system configuration

The MCP Admin API provides administrative capabilities for managing MCP servers through Compozy's HTTP proxy architecture. This API enables operational teams to register, monitor, and manage MCP server deployments using a simple REST interface.

API Overview

The Admin API is built on top of Compozy's MCP proxy service, providing a simple HTTP interface for managing MCP servers. The architecture follows a straightforward client-proxy-server pattern:

Loading diagram...

The admin API provides essential MCP management capabilities through simple HTTP endpoints. Unlike complex enterprise systems, Compozy's admin API focuses on practical operational needs with a lightweight implementation.

Core Admin Capabilities

Server Registration

Register and manage MCP servers with the proxy

Tool Execution

Execute tools on registered MCP servers

Health Monitoring

Basic health checks and server status

Configuration Management

Update proxy and server configurations

Authentication

Token-based authentication for admin access

Proxy Management

Control proxy service operations

Implementation Overview

Compozy's admin API is implemented using the existing MCP proxy infrastructure. The core components work together to provide a simple but effective management interface.

MCP Client Implementation

The foundation of the admin API is the MCP client, which provides HTTP communication with the proxy service:

// From engine/mcp/client.go - The actual MCP client implementation
type Client struct {
    baseURL   string
    http      *http.Client
    adminTok  string
    retryConf RetryConfig
}

// Core operations available through the client
func (c *Client) Register(ctx context.Context, def *Definition) error
func (c *Client) Deregister(ctx context.Context, name string) error
func (c *Client) ListMCPs(ctx context.Context) ([]Definition, error)
func (c *Client) CallTool(ctx context.Context, mcpName, toolName string, arguments map[string]any) (any, error)

Why this implementation matters:

  • Simple HTTP operations: Direct communication with the proxy service
  • Token-based authentication: Basic but secure admin token system
  • Retry logic: Built-in retry configuration for reliability
  • Context support: Proper cancellation and timeout handling

Tool Execution

Execute tools on registered MCP servers:

// Execute tool on specific server
func (h *AdminHandler) ExecuteTool(c *gin.Context) {
    ctx := c.Request.Context()
    log := logger.FromContext(ctx)

    var request ToolCallRequest
    if err := c.ShouldBindJSON(&request); err != nil {
        c.JSON(400, gin.H{"error": err.Error()})
        return
    }

    // Execute tool via proxy
    response, err := h.mcpClient.CallTool(ctx, request.MCPName, request.ToolName, request.Arguments)
    if err != nil {
        log.Error("tool execution failed", "error", err, "mcp", request.MCPName, "tool", request.ToolName)
        c.JSON(500, gin.H{"error": "Tool execution failed"})
        return
    }

    c.JSON(200, gin.H{"result": response})
}

API Usage Examples

Basic Server Operations

Here are practical examples of using the admin API:

# List all registered MCP servers
curl -X GET http://localhost:6001/admin/mcps \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

# Register a new MCP server
curl -X POST http://localhost:6001/admin/mcps \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -d '{
    "name": "filesystem_server",
    "transport": "stdio",
    "command": "mcp-server-filesystem",
    "args": ["--root", "/workspace"]
  }'

Tool Management

Execute tools on registered servers:

# List available tools for all servers
curl -X GET http://localhost:6001/admin/tools \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

# Execute a tool with arguments
curl -X POST http://localhost:6001/admin/tools/call \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -d '{
    "mcpName": "filesystem_server",
    "toolName": "read_file",
    "arguments": {
      "path": "/workspace/README.md"
    }
  }'

CLI Management

Compozy provides comprehensive CLI commands for managing the system:

Authentication Commands

# Generate a new API key
compozy auth generate --name "admin-key" --description "Admin API access"

# List all API keys
compozy auth list --format table

# Revoke an API key
compozy auth revoke [key-id] --force

# User management
compozy auth create-user --email "admin@example.com" --name "Admin User" --role "admin"
compozy auth list-users --role admin
compozy auth update-user [user-id] --role "user"
compozy auth delete-user [user-id] --force

Configuration Commands

# Show current configuration
compozy config show --format yaml

# Run configuration diagnostics
compozy config diagnostics --verbose

# Validate configuration file
compozy config validate

MCP Proxy Commands

# Start MCP proxy server
compozy mcp-proxy \
  --mcp-host 0.0.0.0 \
  --mcp-port 6001 \
  --mcp-admin-tokens "your-admin-token" \
  --debug

# With environment variables
MCP_PROXY_HOST=0.0.0.0 \
MCP_PROXY_PORT=6001 \
compozy mcp-proxy --debug

Workflow Commands

# List all workflows
compozy workflow list --format table

# Get specific workflow details
compozy workflow get [workflow-id] --format yaml

# Execute a workflow
compozy workflow execute [workflow-id] --json='{"key": "value"}'

Development Commands

# Initialize new project
compozy init [project-name]

# Start development server
compozy dev --port 8080 --reload

# Start production server
compozy start --config production.yaml

MCP Configuration Reference

Complete Config Structure

// From engine/mcp/config.go - Complete Config struct
type Config struct {
    // Resource reference for the MCP server (optional)
    Resource string `yaml:"resource,omitempty" json:"resource,omitempty"`

    // ID is the unique identifier for this MCP server configuration
    ID string `yaml:"id" json:"id"`

    // URL is the endpoint for remote MCP servers
    URL string `yaml:"url" json:"url"`

    // Command is the executable command to spawn a local MCP server process
    Command string `yaml:"command,omitempty" json:"command,omitempty"`

    // Env contains environment variables to pass to the MCP server process
    Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`

    // Proto specifies the MCP protocol version to use (YYYY-MM-DD format)
    Proto string `yaml:"proto,omitempty" json:"proto,omitempty"`

    // Transport defines the communication transport mechanism
    // Supported: "sse", "streamable-http", "stdio"
    Transport mcpproxy.TransportType `yaml:"transport,omitempty" json:"transport,omitempty"`

    // StartTimeout is the maximum time to wait for the MCP server to start
    StartTimeout time.Duration `yaml:"start_timeout,omitempty" json:"start_timeout,omitempty"`

    // MaxSessions defines the maximum number of concurrent sessions allowed
    MaxSessions int `yaml:"max_sessions,omitempty" json:"max_sessions,omitempty"`
}

Configuration Examples

# Local MCP server configuration
mcps:
  - id: filesystem
    command: "mcp-server-filesystem"
    args: ["--root", "/workspace"]
    transport: stdio
    env:
      LOG_LEVEL: "debug"
    start_timeout: 30s
    max_sessions: 10

# Remote MCP server configuration
  - id: github-api
    url: "https://api.github.com/mcp/v1"
    transport: sse
    proto: "2025-03-26"
    env:
      GITHUB_TOKEN: "{{ .env.GITHUB_TOKEN }}"

Best Practices

Security Best Practices

  • Generate strong admin tokens with sufficient entropy
  • Use HTTPS for all admin API communications
  • Implement proper permission validation for admin operations
  • Log all administrative actions for audit purposes

Next Steps