Skip to main content
Glama

Firebase MCP

authClient.ts1.68 kB
/** * Firebase Authentication Client * * This module provides functions for interacting with Firebase Authentication. * It includes operations for user management and verification. * * @module firebase-mcp/auth */ import * as admin from 'firebase-admin'; interface AuthResponse { content: Array<{ type: string; text: string }>; isError?: boolean; } /** * Retrieves user information from Firebase Authentication using either a user ID or email address. * The function automatically detects whether the identifier is an email address (contains '@') * or a user ID and uses the appropriate Firebase Auth method. * * @param {string} identifier - The user ID or email address to look up * @returns {Promise<AuthResponse>} A formatted response object containing the user information * @throws {Error} If the user cannot be found or if there's an authentication error * * @example * // Get user by email * const userInfo = await getUserByIdOrEmail('user@example.com'); * * @example * // Get user by ID * const userInfo = await getUserByIdOrEmail('abc123xyz456'); */ export async function getUserByIdOrEmail(identifier: string): Promise<AuthResponse> { try { let user: admin.auth.UserRecord; // Try to get user by email first if (identifier.includes('@')) { user = await admin.auth().getUserByEmail(identifier); } else { // If not an email, try by UID user = await admin.auth().getUser(identifier); } return { content: [{ type: 'json', text: JSON.stringify(user) }], }; } catch { return { content: [{ type: 'error', text: `User not found: ${identifier}` }], isError: true, }; } }

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/gannonh/firebase-mcp'

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