# Environment-aware Credentials (/typescript-sdk/credentials/env-aware-credentials)





Environment-aware credentials enable automatic loading of environment-specific credentials (development, production, etc.) while keeping them cleanly separated and easily switchable via the CLI's --env flag.

Credentials are referenced in the TypeScript SDK using the `envSettings` object. Creating environment-aware credentials is a two step process:

### Step 1: Define environment configurations

<Tabs>
  <Tab title="Development Config">
    ```typescript title="projects/my-project/environments/development.env.ts"
    import { registerEnvironmentSettings } from '@inkeep/agents-sdk';
    import { CredentialStoreType } from '@inkeep/agents-core';

    // How credentials are referenced depends on how the credential was created, in this case this credential was created as an environment variable
    export const development = registerEnvironmentSettings({
    credentials: {
    'stripe_api_key': {
      id: 'stripe-api-key',
      name: 'Stripe API Key',
      type: CredentialStoreType.memory,
      credentialStoreId: 'memory-default',
      retrievalParams: {
        key: 'STRIPE_API_KEY_DEV',
      },
    }
    },
    });
    ```
  </Tab>

  <Tab title="Production Config">
    ```typescript title="projects/my-project/environments/production.env.ts"
    import { registerEnvironmentSettings } from '@inkeep/agents-sdk';
    import { CredentialStoreType } from '@inkeep/agents-core';

    // How credentials are referenced depends on how the credential was created, in this case this credential was created as an environment variable
    export const production = registerEnvironmentSettings({
    credentials: {
    'stripe_api_key': {
      id: 'stripe-api-key',
      name: 'Stripe API Key',
      type: CredentialStoreType.memory,
      credentialStoreId: 'memory-default',
      retrievalParams: {
        key: 'STRIPE_API_KEY_PROD',
      },
    }
    },
    });
    ```
  </Tab>

  <Tab title="Index File">
    ```typescript title="projects/my-project/environments/index.ts"
    import { createEnvironmentSettings } from '@inkeep/agents-sdk';
    import { development } from './development.env';
    import { production } from './production.env';

    export const envSettings = createEnvironmentSettings({
    development,
    production,
    });
    ```
  </Tab>
</Tabs>

### Step 2: Use the credentials in tools

```typescript title="<your-project-name>/tools/stripe-tool.ts"
import { mcpTool } from "@inkeep/agents-sdk";
import { envSettings } from "../environments";

export const stripeTool = mcpTool({
  id: 'stripe-tool',
  name: 'Stripe',
  serverUrl: 'https://mcp.stripe.com/mcp',
  credential: envSettings.getEnvironmentCredential('stripe_api_key'),
});
```

This pattern is useful if you want to keep track of different credentials for different environments. When you push your project using the [Inkeep CLI](/typescript-sdk/cli-reference#inkeep-push) `inkeep push` command with the `--env` flag, the credentials will be loaded from the appropriate environment file. For example, if you run `inkeep push --env development`, the credentials will be loaded from the `environments/development.env.ts` file.

### CLI Environment Variables

The CLI respects these environment variables when using the `--env` flag:

```bash