Skip to main content
Glama
mrwyndham

PocketBase MCP Server

authenticate_user

Verify user identity by authenticating with email and password in PocketBase MCP Server, supporting admin access and custom collection checks.

Instructions

Authenticate a user with email and password

Input Schema

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

Implementation Reference

  • The handler function that authenticates a user using PocketBase's authWithPassword method. Supports admin auth via env vars or regular users. Returns JSON auth data.
    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 for the authenticate_user tool, defining required email/password and optional collection/isAdmin.
    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 setTools call, 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'], }, },

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