Environment Variables
Environment variables for custom functions can be configured at the tool level. This allows function reusability across multiple MCP servers while maintaining different configurations for each server. In addition, this also allows composing different logic branches within the same function and executing the relevant one based on the environment variable values.
Variables can be accessed using process.env.VARIABLE_NAME syntax.
For example, you might have a function that connects to different databases based on an environment variable:
const dbHost = process.env.DB_HOST;const dbUser = process.env.DB_USER;const dbPassword = process.env.DB_PASSWORD;export async function handler(request: Request): Promise<Response> { // Use dbHost, dbUser, and dbPassword to connect to the database}When configuring the tool in the Infragate Console, you can set the values for DB_HOST, DB_USER, and DB_PASSWORD specific to that MCP server.