# Use Environment Variables as Credentials (/typescript-sdk/credentials/environment-variables)





Environment variables are a simple way to store credentials in your environment. They are stored in the environment variables in your `.env` file.

## Referencing credentials in SDK

Here is an example of how to reference a credential in the TypeScript SDK for Bearer Authentication.

```typescript
import { agent, subAgent, mcpTool, credential } from "@inkeep/agents-sdk";
import { CredentialStoreType } from "@inkeep/agents-core";

// Step 1: Reference the credential created in the environment file
const stripeCredential = credential({
  id: 'stripe-credential',
  name: 'Stripe Credential',
  type: CredentialStoreType.memory,
  credentialStoreId: 'memory-default',
  retrievalParams: {
    "key": "<environment-variable-name>", // where <environment-variable-name> is the name of the environment variable that contains the credential value, for example, STRIPE_API_KEY
  },
});

// Step 2: Use credential in MCP tool
const stripeTool = mcpTool({
  id: 'stripe-tool',
  name: 'Stripe Tool',
  description: 'Access Stripe payment services',
  serverUrl: 'https://mcp.stripe.com/mcp',
  credential: stripeCredential,
});
```

### Credential Configuration

| Parameter           | Type                | Required | Description                                              |
| ------------------- | ------------------- | -------- | -------------------------------------------------------- |
| `id`                | string              | Yes      | Unique identifier for the credential                     |
| `type`              | CredentialStoreType | Yes      | Type of credential store (memory, nango, or keychain)    |
| `credentialStoreId` | string              | Yes      | Identifier for the specific credential store instance    |
| `retrievalParams`   | object              | Yes      | Parameters for retrieving the credential from the store. |