Skip to main content

Overview

Duplicates an existing environment in Dokploy with optional service selection. Creates a new environment with the same configuration and optionally the same services.
This tool duplicates environments, not projects. The source and target are environment IDs.

Annotations

destructiveHint
boolean
default:"false"
This operation creates a new resource and is non-destructive.
idempotentHint
boolean
default:"false"
This operation is not idempotent - calling it multiple times will create multiple environments.
openWorldHint
boolean
default:"true"
This operation interacts with the external Dokploy API.

Input Schema

sourceEnvironmentId
string
required
The ID of the source environment to duplicate. Must be a valid existing environment ID.
name
string
required
The name for the new duplicated environment. Must be at least 1 character long.
description
string
An optional description for the duplicated environment.
includeServices
boolean
default:"true"
Whether to include services in the duplication. Defaults to true.
selectedServices
array
Array of specific services to include. When includeServices is true and this is not provided, you MUST first retrieve all services from the source environment and include ALL of them in this array. Services are not automatically included - you must explicitly list each service with its ID and type.Each service object should contain:
  • id (string): The ID of the service
  • type (string): The type of the service (application, postgres, mariadb, mongo, mysql, redis, compose)
duplicateInSameProject
boolean
default:"false"
Whether to duplicate the environment within the same project. Defaults to false.

Response Schema

Returns the newly created environment object:
environmentId
string
Unique identifier for the newly created environment
name
string
Name of the duplicated environment
description
string | null
Description of the environment
projectId
string
ID of the project containing this environment
createdAt
string
ISO 8601 timestamp of when the environment was created
services
object
Object containing all duplicated services (applications, databases, compose services)

Usage Example

// Duplicate an environment without services
const result = await mcp.useTool("project-duplicate", {
  sourceEnvironmentId: "env_abc123",
  name: "Staging Environment Copy",
  description: "Duplicate of production for testing",
  includeServices: false
});

// Duplicate an environment with all services
// First, get the source environment to retrieve all services
const sourceEnv = await mcp.useTool("project-one", {
  projectId: "proj_456"
});

// Extract services from the environment
const services = [];
const env = sourceEnv.data.environments.find(e => e.environmentId === "env_abc123");

if (env.applications) {
  env.applications.forEach(app => {
    services.push({ id: app.applicationId, type: "application" });
  });
}
if (env.postgres) {
  env.postgres.forEach(db => {
    services.push({ id: db.postgresId, type: "postgres" });
  });
}
if (env.mysql) {
  env.mysql.forEach(db => {
    services.push({ id: db.mysqlId, type: "mysql" });
  });
}

// Now duplicate with services
const resultWithServices = await mcp.useTool("project-duplicate", {
  sourceEnvironmentId: "env_abc123",
  name: "Complete Environment Copy",
  description: "Full duplicate including all services",
  includeServices: true,
  selectedServices: services,
  duplicateInSameProject: true
});

console.log(resultWithServices);
// Output:
// {
//   "message": "Environment \"Complete Environment Copy\" duplicated successfully from source environment \"env_abc123\"",
//   "data": {
//     "environmentId": "env_xyz789",
//     "name": "Complete Environment Copy",
//     "description": "Full duplicate including all services",
//     "projectId": "proj_456",
//     "createdAt": "2024-03-04T15:30:00Z",
//     "services": {
//       "applications": [...],
//       "postgres": [...],
//       "mysql": [...]
//     }
//   }
// }

Error Handling

If the environment duplication fails, an error response will be returned:
{
  "error": "Failed to duplicate environment",
  "details": "Source environment with ID \"env_abc123\" not found"
}

Notes

  • This operation duplicates environments, not entire projects
  • When includeServices is true, you must explicitly provide the list of services to duplicate
  • Services are not automatically included - retrieve them first using project-one and build the selectedServices array
  • Each service in selectedServices must have both id and type properties
  • Supported service types: application, postgres, mariadb, mongo, mysql, redis, compose
  • Use duplicateInSameProject: true to create the duplicate in the same project as the source
  • The new environment will have the same configuration as the source but with a new ID and name

Build docs developers (and LLMs) love