Skip to main content
Glama
pixxelboy
by pixxelboy
auth.ts1.82 kB
/** * Authentication Utility for IRCAM Amplify API */ import { MCPError } from '../types/mcp-tools.js'; /** * Environment variable name for the API key */ export const API_KEY_ENV_VAR = 'IRCAM_AMPLIFY_API_KEY'; /** * Get the IRCAM Amplify API key from environment * @throws MCPError if the API key is not set */ export function getApiKey(): string { const apiKey = process.env[API_KEY_ENV_VAR]; if (!apiKey || apiKey.trim() === '') { const error: MCPError = { code: 'MISSING_API_KEY', message: `Missing API key. Set ${API_KEY_ENV_VAR} environment variable.`, suggestion: `Get your API key from https://app.ircamamplify.io and set it with: export ${API_KEY_ENV_VAR}="your-key-here"`, }; throw error; } return apiKey.trim(); } /** * Check if the API key is configured (without throwing) */ export function hasApiKey(): boolean { const apiKey = process.env[API_KEY_ENV_VAR]; return !!apiKey && apiKey.trim() !== ''; } /** * Create authentication headers for IRCAM API requests * @throws MCPError if the API key is not set */ export function createAuthHeaders(): Record<string, string> { const apiKey = getApiKey(); return { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json', }; } /** * Create headers with custom content type * @throws MCPError if the API key is not set */ export function createAuthHeadersWithContentType(contentType: string): Record<string, string> { const apiKey = getApiKey(); return { Authorization: `Bearer ${apiKey}`, 'Content-Type': contentType, }; } /** * Mask API key for logging (show only first and last 4 chars) */ export function maskApiKey(apiKey: string): string { if (apiKey.length <= 8) { return '***'; } return `${apiKey.slice(0, 4)}...${apiKey.slice(-4)}`; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pixxelboy/amplify-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server