get-env-var
Retrieve specific environment variables from MCP servers using profile IDs and variable keys for precise configuration management in the MCP Environment & Installation Manager.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Environment variable key | |
| profileId | Yes | Profile ID to get environment variable from |
Implementation Reference
- src/tools/environment-tools.ts:60-95 (handler)Handler function that validates the profileId and key, retrieves the profile and specific environment variable using ConfigService, masks the value if sensitive, and returns a structured text response with the details.async ({ profileId, key }, extra) => { if (!profileId.trim()) { throw new Error("Profile ID cannot be empty"); } if (!key.trim()) { throw new Error("Environment variable key cannot be empty"); } const profile = configService.getProfile(profileId); if (!profile) { throw new Error(`Profile not found: ${profileId}`); } const envVar = configService.getEnvVar(profileId, key); if (!envVar) { throw new Error(`Environment variable not found: ${key}`); } return { content: [ { type: "text", text: JSON.stringify({ profileId, profileName: profile.name, key, value: envVar.sensitive ? '********' : envVar.value, sensitive: envVar.sensitive, description: envVar.description }, null, 2) } ] }; } );
- src/tools/environment-tools.ts:56-59 (schema)Input schema using Zod for the get-env-var tool, defining required string parameters profileId and key with descriptions.{ profileId: z.string().describe("Profile ID to get environment variable from"), key: z.string().describe("Environment variable key") },
- src/tools/environment-tools.ts:54-95 (registration)Direct registration of the get-env-var tool on the MCP server, including input schema and handler implementation.server.tool( "get-env-var", { profileId: z.string().describe("Profile ID to get environment variable from"), key: z.string().describe("Environment variable key") }, async ({ profileId, key }, extra) => { if (!profileId.trim()) { throw new Error("Profile ID cannot be empty"); } if (!key.trim()) { throw new Error("Environment variable key cannot be empty"); } const profile = configService.getProfile(profileId); if (!profile) { throw new Error(`Profile not found: ${profileId}`); } const envVar = configService.getEnvVar(profileId, key); if (!envVar) { throw new Error(`Environment variable not found: ${key}`); } return { content: [ { type: "text", text: JSON.stringify({ profileId, profileName: profile.name, key, value: envVar.sensitive ? '********' : envVar.value, sensitive: envVar.sensitive, description: envVar.description }, null, 2) } ] }; } );
- src/server.ts:31-31 (registration)High-level registration call that invokes the environment tools module registration, which includes the get-env-var tool.registerEnvironmentTools(server, configService);