create-secret
Add a new secret to a specified project and environment in Infisical, defining its name, value, and path for secure storage and management.
Instructions
Create a new secret in Infisical
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| environmentSlug | Yes | The slug of the environment to create the secret in (required) | |
| projectId | Yes | The ID of the project to create the secret in (required) | |
| secretName | Yes | The name of the secret to create (required) | |
| secretPath | No | The path of the secret to create (Defaults to /) | |
| secretValue | No | The value of the secret to create |
Implementation Reference
- src/index.ts:475-493 (handler)Handler logic for the 'create-secret' tool: parses arguments using Zod, invokes Infisical SDK's createSecret method, and returns a success response with the created secret details.if (name === AvailableTools.CreateSecret) { const data = createSecretSchema.zod.parse(args); const { secret } = await infisicalSdk.secrets().createSecret(data.secretName, { environment: data.environmentSlug, projectId: data.projectId, secretPath: data.secretPath, secretValue: data.secretValue ?? "" }); return { content: [ { type: "text", text: `Secret created successfully: ${JSON.stringify(secret, null, 3)}` } ] }; }
- src/index.ts:70-108 (schema)Input schema definition using Zod and MCP capability spec for the 'create-secret' tool.const createSecretSchema = { zod: z.object({ projectId: z.string(), environmentSlug: z.string(), secretName: z.string(), secretValue: z.string().optional(), secretPath: z.string().default("/") }), capability: { name: AvailableTools.CreateSecret, description: "Create a new secret in Infisical", inputSchema: { type: "object", properties: { projectId: { type: "string", description: "The ID of the project to create the secret in (required)" }, environmentSlug: { type: "string", description: "The slug of the environment to create the secret in (required)" }, secretName: { type: "string", description: "The name of the secret to create (required)" }, secretValue: { type: "string", description: "The value of the secret to create" }, secretPath: { type: "string", description: "The path of the secret to create (Defaults to /)" } }, required: ["projectId", "environmentSlug", "secretName"] } } };
- src/index.ts:452-467 (registration)Registration of the 'create-secret' tool (via its capability) in the list of available tools returned by ListToolsRequestSchema handler.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ createSecretSchema.capability, deleteSecretSchema.capability, updateSecretSchema.capability, listSecretsSchema.capability, getSecretSchema.capability, createProjectSchema.capability, createEnvironmentSchema.capability, createFolderSchema.capability, inviteMembersToProjectSchema.capability, listProjectsSchema.capability ] }; });
- src/index.ts:57-68 (registration)Enum defining the tool name constant 'create-secret' used throughout the implementation.enum AvailableTools { CreateSecret = "create-secret", DeleteSecret = "delete-secret", UpdateSecret = "update-secret", ListSecrets = "list-secrets", GetSecret = "get-secret", CreateProject = "create-project", CreateEnvironment = "create-environment", CreateFolder = "create-folder", InviteMembersToProject = "invite-members-to-project", ListProjects = "list-projects" }