list-secrets
Retrieve and display all secrets within a specified project and environment in Infisical. Supports custom paths, expanded references, and included imports for comprehensive secret management.
Instructions
List all secrets in a given Infisical project and environment
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| environmentSlug | Yes | The slug of the environment to list the secrets from (required) | |
| expandSecretReferences | No | Whether to expand secret references (Defaults to true) | |
| includeImports | No | Whether to include secret imports (Defaults to true) | |
| projectId | Yes | The ID of the project to list the secrets from (required) | |
| secretPath | No | The path of the secrets to list (Defaults to /) |
Implementation Reference
- src/index.ts:534-573 (handler)Handler for the 'list-secrets' tool. Parses input, calls infisicalSdk.secrets().listSecrets(), processes secrets and imports, and returns formatted JSON response.if (name === AvailableTools.ListSecrets) { const data = listSecretsSchema.zod.parse(args); const secrets = await infisicalSdk.secrets().listSecrets({ environment: data.environmentSlug, projectId: data.projectId, secretPath: data.secretPath, expandSecretReferences: data.expandSecretReferences, includeImports: data.includeImports }); const response = { secrets: secrets.secrets.map(secret => ({ secretKey: secret.secretKey, secretValue: secret.secretValue })), ...(secrets.imports && { imports: secrets.imports?.map(imp => { const parsedImportSecrets = imp.secrets.map(secret => ({ secretKey: secret.secretKey, secretValue: secret.secretValue })); return { ...imp, secrets: parsedImportSecrets }; }) }) }; return { content: [ { type: "text", text: `${JSON.stringify(response)}` } ] }; }
- src/index.ts:190-228 (schema)Schema definition for 'list-secrets' tool, including Zod validator and capability metadata with inputSchema.const listSecretsSchema = { zod: z.object({ projectId: z.string(), environmentSlug: z.string(), secretPath: z.string().default("/"), expandSecretReferences: z.boolean().default(true), includeImports: z.boolean().default(true) }), capability: { name: AvailableTools.ListSecrets, description: "List all secrets in a given Infisical project and environment", inputSchema: { type: "object", properties: { projectId: { type: "string", description: "The ID of the project to list the secrets from (required)" }, environmentSlug: { type: "string", description: "The slug of the environment to list the secrets from (required)" }, secretPath: { type: "string", description: "The path of the secrets to list (Defaults to /)" }, expandSecretReferences: { type: "boolean", description: "Whether to expand secret references (Defaults to true)" }, includeImports: { type: "boolean", description: "Whether to include secret imports (Defaults to true)" } }, required: ["projectId", "environmentSlug"] } } };
- src/index.ts:452-467 (registration)Registration of all tools including 'list-secrets' via the ListToolsRequestSchema handler, where listSecretsSchema.capability is included in the tools array.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 tool names, including ListSecrets = "list-secrets" used throughout for matching.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" }