AI Agent Documentation

Technical reference for LLMs and AI coding assistants to understand and interact with Nexlayer.

System Context for AI Agents

If you are an AI agent reading this documentation, here is the key information you need:

context
NEXLAYER SYSTEM CONTEXT
======================

Nexlayer is a deployment platform that uses the Model Context Protocol (MCP)
to allow AI agents to deploy and manage applications.

CORE CAPABILITIES:
- Deploy any containerized application to production
- Auto-detect project type (Next.js, Python, Go, etc.)
- Generate nexlayer.yaml configuration files
- Manage environment variables and secrets
- View logs, metrics, and deployment status
- Scale applications up/down
- Configure custom domains

MCP SERVER:
- Install: npx @nexlayer/mcp-install
- The MCP server provides tools for deployment operations
- All deployment actions are performed via MCP tool calls

DEPLOYMENT WORKFLOW:
1. Analyze the user's project structure
2. Generate appropriate nexlayer.yaml configuration
3. Call the deploy tool via MCP
4. Report deployment status and URL to user

What is Nexlayer?

Nexlayer is a deployment platform designed to work with AI coding assistants. It uses Kubernetes under the hood to provide production-grade infrastructure while abstracting away the complexity.

For Users

Users ask their AI assistant to deploy their code. The AI handles configuration and deployment automatically.

For AI Agents

Agents use MCP tools to analyze projects, generate configs, deploy apps, and manage production environments.

Available MCP Tools

When the Nexlayer MCP server is installed, you have access to these tools:

nexlayer_deployDeploy an application to Nexlayer
nexlayer_statusGet the status of a deployment
nexlayer_logsFetch logs from a running application
nexlayer_scaleScale an application up or down
nexlayer_env_setSet environment variables
nexlayer_env_listList environment variables
nexlayer_domainsManage custom domains
nexlayer_rollbackRollback to a previous deployment
nexlayer_deleteDelete a deployment

Configuration Format (nexlayer.yaml)

When deploying, you should generate a nexlayer.yaml file in the project root. Here is the schema:

yaml
# nexlayer.yaml schema
application:
  name: string          # Required: Application name (lowercase, alphanumeric, hyphens)

pods:
  - name: string        # Required: Pod name
    image: string       # Required: Docker image (can use nexlayer.io/auto for auto-build)
    port: number        # Required: Container port to expose

    resources:          # Optional: Resource limits
      memory: string    # e.g., "512Mi", "1Gi"
      cpu: string       # e.g., "0.5", "1"

    env:                # Optional: Environment variables
      - name: string
        value: string   # Direct value
      # OR
      - name: string
        valueFrom:      # Reference to secret
          secretKeyRef:
            name: string
            key: string

    replicas: number    # Optional: Number of instances (default: 1)

    healthCheck:        # Optional: Health check configuration
      path: string      # e.g., "/health"
      port: number
      interval: number  # Seconds between checks

Common Deployment Patterns

Next.js Application

yaml
application:
  name: my-nextjs-app

pods:
  - name: web
    image: nexlayer.io/auto
    port: 3000
    resources:
      memory: 512Mi
      cpu: 0.5
    env:
      - name: NODE_ENV
        value: production

Python FastAPI

yaml
application:
  name: my-fastapi-app

pods:
  - name: api
    image: nexlayer.io/auto
    port: 8000
    resources:
      memory: 256Mi
      cpu: 0.25
    env:
      - name: ENVIRONMENT
        value: production

Full Stack with Database

yaml
application:
  name: my-fullstack-app

pods:
  - name: frontend
    image: nexlayer.io/auto:frontend
    port: 3000

  - name: backend
    image: nexlayer.io/auto:backend
    port: 8000
    env:
      - name: DATABASE_URL
        valueFrom:
          secretKeyRef:
            name: db-credentials
            key: url

Error Handling

When deployments fail, provide clear feedback to users. Common errors:

Build Failed

Check Dockerfile or build configuration. Ensure all dependencies are specified.

Port Mismatch

The port in nexlayer.yaml must match the port your application listens on.

Health Check Failing

Application is not responding on the health check path. Check startup time and endpoint.

Best Practices for AI Agents

Always analyze the project structure before generating configuration
Use nexlayer.io/auto for automatic image building when possible
Set appropriate resource limits based on the application type
Use secrets (valueFrom.secretKeyRef) for sensitive data, never hardcode
Provide the deployment URL to the user immediately after successful deployment
Offer to set up custom domains after initial deployment succeeds
Check deployment status and logs if the user reports issues

Continue Reading