Typescript sdkCredentials

Environment Variables

Copy page

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.

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

ParameterTypeRequiredDescription
idstringYesUnique identifier for the credential
typeCredentialStoreTypeYesType of credential store (memory, nango, or keychain)
credentialStoreIdstringYesIdentifier for the specific credential store instance
retrievalParamsobjectYesParameters for retrieving the credential from the store.