list-env-vars
Retrieve environment variables for a specific profile ID to manage configurations and automate installations in the MCP server environment.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| profileId | Yes | Profile ID to list environment variables from |
Implementation Reference
- src/tools/environment-tools.ts:18-50 (handler)The handler function implementing the core logic of the 'list-env-vars' tool: validates input, fetches profile and environment variables via ConfigService, masks sensitive values, formats as JSON, and returns as text content.async ({ profileId }, extra) => { if (!profileId.trim()) { throw new Error("Profile ID cannot be empty"); } const profile = configService.getProfile(profileId); if (!profile) { throw new Error(`Profile not found: ${profileId}`); } const envVars = configService.getEnvVars(profileId); // Transform to array and mask sensitive values const result = Object.entries(envVars).map(([key, envVar]) => ({ key, value: envVar.sensitive ? '********' : envVar.value, sensitive: envVar.sensitive, description: envVar.description })); return { content: [ { type: "text", text: JSON.stringify({ profileId, profileName: profile.name, variables: result }, null, 2) } ] }; }
- src/tools/environment-tools.ts:15-17 (schema)Input schema definition for the 'list-env-vars' tool using Zod, specifying the required 'profileId' parameter.{ profileId: z.string().describe("Profile ID to list environment variables from") },
- src/tools/environment-tools.ts:13-51 (registration)Direct registration of the 'list-env-vars' tool on the MCP server using server.tool(), including name, schema, and handler.server.tool( "list-env-vars", { profileId: z.string().describe("Profile ID to list environment variables from") }, async ({ profileId }, extra) => { if (!profileId.trim()) { throw new Error("Profile ID cannot be empty"); } const profile = configService.getProfile(profileId); if (!profile) { throw new Error(`Profile not found: ${profileId}`); } const envVars = configService.getEnvVars(profileId); // Transform to array and mask sensitive values const result = Object.entries(envVars).map(([key, envVar]) => ({ key, value: envVar.sensitive ? '********' : envVar.value, sensitive: envVar.sensitive, description: envVar.description })); return { content: [ { type: "text", text: JSON.stringify({ profileId, profileName: profile.name, variables: result }, null, 2) } ] }; } );
- src/server.ts:31-31 (registration)Top-level registration call for the environment tools module (containing list-env-vars) during server initialization.registerEnvironmentTools(server, configService);