Skip to main content
Glama
fadlee

PocketBase MCP Server

by fadlee

authenticate_user

Verify user credentials and generate authentication tokens for accessing PocketBase database resources. Provide email and password to obtain secure session tokens with configurable auto-refresh settings.

Instructions

Authenticate a user and get auth token

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
autoRefreshThresholdNoTime in seconds that will trigger token auto refresh before its expiration (default: 30 minutes)
collectionNoAuth collection name (default: 'users')
emailYesUser email or identity field value
passwordYesUser password

Implementation Reference

  • Creates the ToolHandler for 'authenticate_user' which authenticates a user using PocketBase's authWithPassword method, handles errors, and returns a JSON response.
    export function createAuthenticateUserHandler(pb: PocketBase): ToolHandler {
      return async (args: AuthenticateUserArgs) => {
        try {
          const collection = args.collection || "users";
          const autoRefreshThreshold = args.autoRefreshThreshold || 1800; // 30 minutes
          
          const result = await pb
            .collection(collection)
            .authWithPassword(args.email, args.password, {
              autoRefreshThreshold,
            });
          
          return createJsonResponse(result);
        } catch (error: unknown) {
          throw handlePocketBaseError("authenticate user", error);
        }
      };
    }
  • src/server.ts:152-156 (registration)
    Registers the 'authenticate_user' tool in the MCP server with its name, description, input schema, and handler.
      name: "authenticate_user",
      description: "Authenticate a user and get auth token",
      inputSchema: authenticateUserSchema,
      handler: createAuthenticateUserHandler(pb),
    },
  • Defines the JSON input schema for the 'authenticate_user' tool, specifying properties like email, password, and optional collection and autoRefreshThreshold.
    export const authenticateUserSchema = {
      type: "object",
      properties: {
        collection: {
          type: "string",
          description: "Auth collection name (default: 'users')",
        },
        email: {
          type: "string",
          description: "User email or identity field value",
        },
        password: {
          type: "string",
          description: "User password",
        },
        autoRefreshThreshold: {
          type: "number",
          description: "Time in seconds that will trigger token auto refresh before its expiration (default: 30 minutes)",
        },
      },
      required: ["email", "password"],
    };
  • TypeScript interface defining the input arguments for the authenticate_user handler.
    export interface AuthenticateUserArgs {
      collection?: string;
      email: string;
      password: string;
      autoRefreshThreshold?: number;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states the action ('authenticate') and outcome ('get auth token'), but lacks critical details: authentication method (e.g., password-based), error handling (e.g., invalid credentials), token properties (e.g., expiration), security implications, or rate limits. For a security-sensitive tool with zero annotation coverage, this is a significant gap.

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?

The description is a single, efficient sentence with zero wasted words. It front-loads the core purpose ('authenticate a user') and immediately states the outcome ('get auth token'). Every word earns its place, making it easy for an agent to parse quickly.

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

Completeness2/5

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

For an authentication tool with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects (security, errors, token usage), output details (token format, expiration), or integration context (how the token is used in subsequent calls). Given the complexity and security sensitivity, more guidance is needed for safe and effective use.

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 description coverage is 100%, so the schema fully documents all 4 parameters (email, password, collection, autoRefreshThreshold). The description adds no parameter-specific information beyond what's in the schema—it doesn't explain parameter relationships (e.g., email/password as credentials) or usage context. Baseline 3 is appropriate when the schema does all the work.

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

Purpose4/5

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

The description clearly states the verb ('authenticate') and resource ('user'), and specifies the outcome ('get auth token'). It distinguishes from siblings like 'create_user' by focusing on authentication rather than user creation. However, it doesn't explicitly differentiate from potential login/credential-checking tools that might exist in other contexts.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., user must exist), when not to use it (e.g., for token refresh vs. initial auth), or how it relates to sibling tools like 'create_user' for user management workflows. Usage is implied only through the tool name and description.

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/fadlee/dynamic-pocketbase-mcp'

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