Skip to main content
Glama

Ads Manager MCP Server

by amekala
auth.middleware.ts1.3 kB
import { validateApiKey } from '../config/supabase.js'; import { AdvertiserService, AdvertiserContext } from '../services/advertiser.service.js'; export interface AuthContext extends AdvertiserContext { apiKey: string; } /** * Authenticate a connection based on provided API key * This will be used to validate connections to the MCP server */ export async function authenticate(apiKey: string): Promise<{ success: boolean; error?: string; session?: AdvertiserContext }> { try { if (!apiKey) { return { success: false, error: 'No API key provided' }; } const validation = await validateApiKey(apiKey); if (!validation.valid || !validation.advertiserId) { return { success: false, error: validation.error || 'Invalid API key' }; } const advertiser = await AdvertiserService.getAdvertiserContext(validation.advertiserId); if (!advertiser) { return { success: false, error: 'Failed to retrieve advertiser context' }; } await AdvertiserService.updateApiKeyUsage(apiKey); return { success: true, session: advertiser }; } catch (error) { console.error('Authentication error:', error); return { success: false, error: 'Authentication failed due to an internal error' }; } }

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/amekala/adspirer-mcp-server'

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