> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leanmcp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy MCP Server

> Deploy your MCP server to production

Deploy your tested MCP server to production environments.

## Request

<ParamField body="mcp_id" type="string" required>
  ID of the MCP server to deploy
</ParamField>

<ParamField body="environment" type="string" required>
  Deployment environment. Options: `production`, `staging`, `development`
</ParamField>

<ParamField body="config" type="object">
  Deployment configuration

  <Expandable title="Config Object">
    <ParamField body="domain" type="string">
      Custom domain for your MCP (optional)
    </ParamField>

    <ParamField body="scaling" type="object">
      Auto-scaling configuration

      <Expandable title="Scaling Options">
        <ParamField body="min_instances" type="number">
          Minimum number of instances (default: 1)
        </ParamField>

        <ParamField body="max_instances" type="number">
          Maximum number of instances (default: 10)
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="env_vars" type="object">
      Environment variables for your MCP
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the deployment succeeded
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="Deployment Data">
    <ResponseField name="deployment_id" type="string">
      Unique deployment ID
    </ResponseField>

    <ResponseField name="status" type="string">
      Deployment status: "deploying", "deployed", "failed"
    </ResponseField>

    <ResponseField name="url" type="string">
      Production URL of your MCP
    </ResponseField>

    <ResponseField name="deploy_time" type="number">
      Deployment time in seconds
    </ResponseField>

    <ResponseField name="health_check" type="string">
      Health check endpoint URL
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash Production Deploy theme={null}
  curl -X POST https://api.leanmcp.com/v1/deploy \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "mcp_id": "mcp_abc123def456",
      "environment": "production",
      "config": {
        "domain": "my-mcp.example.com",
        "scaling": {
          "min_instances": 2,
          "max_instances": 20
        },
        "env_vars": {
          "API_KEY": "your-api-key",
          "DEBUG": "false"
        }
      }
    }'
  ```

  ```bash Staging Deploy theme={null}
  curl -X POST https://api.leanmcp.com/v1/deploy \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "mcp_id": "mcp_abc123def456",
      "environment": "staging"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "success": true,
    "data": {
      "deployment_id": "deploy_xyz789abc",
      "status": "deployed",
      "url": "https://my-mcp.example.com",
      "deploy_time": 45.2,
      "health_check": "https://my-mcp.example.com/health"
    },
    "meta": {
      "request_id": "req_deploy_456", 
      "timestamp": "2023-12-01T12:00:00Z"
    }
  }
  ```
</ResponseExample>

## Deployment Environments

### Production

* **High availability** - Multiple instances across regions
* **Auto-scaling** - Scales based on demand
* **Monitoring** - Full observability and alerting
* **Custom domains** - Use your own domain
* **SSL certificates** - Automatic HTTPS

### Staging

* **Pre-production testing** - Test before going live
* **Shared resources** - Lower cost than production
* **Limited scaling** - Fewer instances
* **Temporary URLs** - Auto-generated domains

### Development

* **Quick iterations** - Fast deploy cycles
* **Single instance** - Minimal resources
* **Debug mode** - Enhanced logging
* **Auto-cleanup** - Removes old deployments

## Deployment Status

Check deployment status:

```bash theme={null}
GET https://api.leanmcp.com/v1/deploy/deploy_xyz789abc/status
```

Possible statuses:

* **deploying**: Deployment in progress
* **deployed**: Successfully deployed and running
* **failed**: Deployment failed
* **stopped**: Deployment manually stopped

## Best Practices

### Before Deploying

1. **Test thoroughly** - Use `/v1/test` endpoint
2. **Check performance** - Monitor response times
3. **Validate tools** - Ensure all tools work correctly
4. **Review logs** - Check for errors in development

### Production Checklist

* [ ] All tools tested with AI
* [ ] Resource access permissions configured
* [ ] Environment variables set
* [ ] Custom domain configured (if needed)
* [ ] Monitoring alerts configured
* [ ] Backup strategy planned

### Rollback Plan

If deployment fails:

1. Check deployment logs
2. Fix issues in development
3. Redeploy with fixes
4. Or rollback to previous version

## Monitoring

Once deployed, monitor your MCP:

* **Health checks** - Automatic uptime monitoring
* **Performance metrics** - Response times and throughput
* **Error rates** - Track failed tool calls
* **Usage analytics** - See how AI agents use your MCP
