Skip to main content
Glama
NigelThorne

Firebase MCP Server

by NigelThorne

get_auth_token

Retrieve an authentication token for Firebase Auth emulator users or list available users when no UID is specified.

Instructions

Get an ID token for a user in the Auth emulator. Lists users if no uid provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidNoUser UID. If omitted, lists available users instead.

Implementation Reference

  • The handler function 'handleGetAuthToken' that executes the logic to retrieve an Auth ID token or list users if no UID is provided.
    async function handleGetAuthToken(uid?: string) {
      if (!uid) {
        // List users so the caller can pick one
        const result = await adminAuth.listUsers(20);
        return {
          message: "No uid provided. Available users:",
          users: result.users.map((u) => ({
            uid: u.uid,
            email: u.email || undefined,
            displayName: u.displayName || undefined,
          })),
        };
      }
    
      // Create a custom token and exchange it for an ID token via the emulator REST API
      const customToken = await adminAuth.createCustomToken(uid);
      const resp = await fetch(
        `http://${AUTH_EMULATOR_HOST}/identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=fake-api-key`,
        {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({ token: customToken, returnSecureToken: true }),
        }
      );
      const data = await resp.json();
      if (!data.idToken) {
        throw new Error(`Failed to get ID token: ${JSON.stringify(data)}`);
      }
      return { uid, idToken: data.idToken };
    }
  • src/index.ts:220-228 (registration)
    The registration of the 'get_auth_token' tool in the MCP tools list.
      name: "get_auth_token",
      description: "Get an ID token for a user in the Auth emulator. Lists users if no uid provided.",
      inputSchema: {
        type: "object" as const,
        properties: {
          uid: { type: "string", description: "User UID. If omitted, lists available users instead." },
        },
      },
    },
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. Adds critical context that this targets the 'Auth emulator' (not production). Reveals dual behavior (list vs get token). Missing safety profile, error conditions, or return value description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, zero waste. Front-loaded with primary purpose, second sentence handles edge case. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a single-parameter, dual-mode tool. Emulator context and conditional behavior are disclosed. Lacks output description (no output schema exists) and safety annotations, but sufficient for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, establishing baseline 3. Description mentions 'if no uid provided' which aligns with optional parameter behavior, but adds no semantic detail beyond schema's 'If omitted, lists available users instead'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Specific verb 'Get' + resource 'ID token' + scope 'Auth emulator'. The second sentence clearly distinguishes the dual mode (listing users when uid omitted), differentiating it from document-centric siblings like get_document.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Implies usage through conditional behavior ('Lists users if no uid provided'), showing when listing occurs vs token retrieval. However, lacks explicit 'when to use' guidance regarding emulator workflow or prerequisites (e.g., 'use this to impersonate users during testing').

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/NigelThorne/firebase_mcp_server'

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