Skip to main content
Glama
mrwyndham

PocketBase MCP Server

authenticate_user

Authenticate users with email and password credentials for PocketBase database access, supporting both regular user collections and admin authentication.

Instructions

Authenticate a user with email and password

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailYesUser email
passwordYesUser password
collectionNoCollection name (default: users)users
isAdminNoWhether to authenticate as an admin (uses _superusers collection)

Implementation Reference

  • The handler function that performs user authentication using PocketBase's authWithPassword method. Supports regular users and admin authentication via environment variables.
    private async authenticateUser(args: any) {
      try {
        // Use _superusers collection for admin authentication
        const collection = args.isAdmin ? '_superusers' : (args.collection || 'users');
        
        // For admin authentication, use environment variables if email/password not provided
        const email = args.isAdmin && !args.email ? process.env.POCKETBASE_ADMIN_EMAIL : args.email;
        const password = args.isAdmin && !args.password ? process.env.POCKETBASE_ADMIN_PASSWORD : args.password;
        
        if (!email || !password) {
          throw new Error('Email and password are required for authentication');
        }
        
        const authData = await this.pb
          .collection(collection)
          .authWithPassword(email, password);
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(authData, null, 2),
            },
          ],
        };
      } catch (error: unknown) {
        throw new McpError(
          ErrorCode.InternalError,
          `Authentication failed: ${pocketbaseErrorMessage(error)}`
        );
      }
    }
  • Input schema defining the parameters for the authenticate_user tool, including email, password, optional collection, and isAdmin flag.
    inputSchema: {
      type: 'object',
      properties: {
        email: {
          type: 'string',
          description: 'User email',
        },
        password: {
          type: 'string',
          description: 'User password',
        },
        collection: {
          type: 'string',
          description: 'Collection name (default: users)',
          default: 'users'
        },
        isAdmin: {
          type: 'boolean',
          description: 'Whether to authenticate as an admin (uses _superusers collection)',
          default: false
        }
      },
      required: ['email', 'password'],
    },
  • src/index.ts:304-331 (registration)
    Tool registration in the ListTools response, including name, description, and input schema.
    {
      name: 'authenticate_user',
      description: 'Authenticate a user with email and password',
      inputSchema: {
        type: 'object',
        properties: {
          email: {
            type: 'string',
            description: 'User email',
          },
          password: {
            type: 'string',
            description: 'User password',
          },
          collection: {
            type: 'string',
            description: 'Collection name (default: users)',
            default: 'users'
          },
          isAdmin: {
            type: 'boolean',
            description: 'Whether to authenticate as an admin (uses _superusers collection)',
            default: false
          }
        },
        required: ['email', 'password'],
      },
    },
  • src/index.ts:683-684 (registration)
    Dispatcher case in the CallToolRequest handler that routes calls to the authenticateUser method.
    case 'authenticate_user':
      return await this.authenticateUser(request.params.arguments);
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits such as what happens on success/failure (e.g., returns token, sets session), security implications, rate limits, or error handling. For an authentication tool with zero annotation coverage, this leaves critical gaps in understanding its operation.

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 waste. It front-loads the core purpose ('Authenticate a user') and adds necessary detail ('with email and password'). Every word earns its place, making it appropriately sized and well-structured.

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?

Given the complexity of authentication (security-sensitive, no annotations, no output schema), the description is incomplete. It lacks details on return values, error cases, side effects, and how it fits with sibling tools. For a tool with 4 parameters and significant behavioral implications, more context is needed to be fully helpful.

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. The description adds no parameter-specific information beyond implying 'email' and 'password' are used. It doesn't explain parameter interactions or provide context beyond what's in the schema, meeting the baseline for high coverage.

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 action ('authenticate') and target ('a user'), specifying the method ('with email and password'). It distinguishes from sibling tools like 'authenticate_with_oauth2' and 'authenticate_with_otp' by naming the authentication method, but doesn't explicitly contrast them. The purpose is specific but could be more differentiated.

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?

No guidance is provided on when to use this tool versus alternatives like 'authenticate_with_oauth2' or 'authenticate_with_otp'. The description implies usage for email/password authentication but doesn't mention prerequisites, error conditions, or typical scenarios. Without explicit when/when-not instructions, it offers minimal usage context.

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

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