MCPcopy
hub / github.com/simstudioai/sim / getClientEnvVars

Function getClientEnvVars

apps/sim/tools/utils.ts:228–249  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

226 * Get environment variables from React Query cache (client-side only)
227 */
228export function getClientEnvVars(): Record<string, string> {
229 if (typeof window === 'undefined') return {}
230
231 try {
232 const allEnvVars =
233 getQueryClient().getQueryData<Record<string, EnvironmentVariable>>(
234 environmentKeys.personal()
235 ) ?? {}
236
237 // Convert environment variables to a simple key-value object
238 return Object.entries(allEnvVars).reduce(
239 (acc, [key, variable]) => {
240 acc[key] = variable.value
241 return acc
242 },
243 {} as Record<string, string>
244 )
245 } catch (_error) {
246 // In case of any errors (like in testing), return empty object
247 return {}
248 }
249}
250
251/**
252 * Creates the request body configuration for custom tools

Callers 2

utils.test.tsFile · 0.90

Calls 1

getQueryClientFunction · 0.90

Tested by

no test coverage detected