Skip to main content
Glama
dragosroua

addTaskManager MCP Server

by dragosroua

authenticate_user

Verify user identity using Apple ID to enable access to addTaskManager task data and features.

Instructions

Authenticate user with Apple ID to access their addTaskManager data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
webAuthTokenYesCloudKit web auth token from Apple Sign-In

Implementation Reference

  • Primary handler function for the 'authenticate_user' tool. Manages both production (delegates to UserAuthService) and mock authentication modes, sets user session/token.
    private async authenticateUser(webAuthToken: string) {
      if (this.productionMode && this.authService) {
        // Production CloudKit authentication
        try {
          const authResult = await this.authService.authenticateUser(webAuthToken);
          
          if (authResult.success) {
            this.currentSession = await this.authService.validateSession(authResult.sessionId!);
            this.userToken = {
              cloudKitWebAuthToken: webAuthToken,
              userIdentity: { 
                userRecordName: authResult.userRecordName, 
                lookupInfo: { sessionId: authResult.sessionId } 
              }
            };
            
            return { 
              content: [{ 
                type: 'text', 
                text: `โœ… Successfully authenticated with iCloud as ${authResult.userRecordName}. Session expires: ${authResult.expiresAt?.toLocaleString()}` 
              }] 
            };
          } else if (authResult.redirectToSignIn) {
            return { 
              content: [{ 
                type: 'text', 
                text: `๐Ÿ” Please authenticate with your Apple ID: ${authResult.authUrl}\n\nAfter signing in, provide your web auth token to complete authentication.` 
              }] 
            };
          } else {
            throw new Error(authResult.message || 'Authentication failed');
          }
        } catch (error) {
          console.error('Production CloudKit authentication failed:', error);
          throw new McpError(ErrorCode.InvalidParams, `CloudKit authentication failed: ${error instanceof Error ? error.message : String(error)}`);
        }
      } else {
        // Mock authentication for development
        this.userToken = {
          cloudKitWebAuthToken: webAuthToken,
          userIdentity: { userRecordName: `mock_user_${uuidv4()}`, lookupInfo: {} }
        };
        return { content: [{ type: 'text', text: '๐Ÿงช Mock authentication successful. You can now access addTaskManager data (development mode).' }] };
      }
    }
  • Input schema definition for the 'authenticate_user' tool, specifying required webAuthToken.
    {
      name: 'authenticate_user',
      description: 'Authenticate user with Apple ID to access their addTaskManager data',
      inputSchema: {
        type: 'object',
        properties: {
          webAuthToken: { type: 'string', description: 'CloudKit web auth token from Apple Sign-In' }
        },
        required: ['webAuthToken']
      }
    },
  • src/index.ts:652-657 (registration)
    Tool dispatch/registration in the CallToolRequestSchema handler switch statement.
    case 'authenticate_user':
      if (!args || typeof args.webAuthToken !== 'string') {
        throw new McpError(ErrorCode.InvalidRequest, 'Invalid or missing webAuthToken.');
      }
      return await this.authenticateUser(args.webAuthToken);
  • Core production authentication logic in UserAuthService. Validates token via CloudKitService, creates and manages user sessions with rate limiting.
    async authenticateUser(webAuthToken?: string): Promise<AuthResult> {
      try {
        // Check rate limiting
        if (this.securityConfig?.rateLimiting && !this.checkRateLimit('auth')) {
          return {
            success: false,
            message: 'Rate limit exceeded. Please try again later.'
          };
        }
    
        // If no token provided, initiate authentication flow
        if (!webAuthToken) {
          return {
            success: false,
            authUrl: this.generateAuthUrl(),
            message: 'User authentication required. Please visit the provided URL to sign in with your Apple ID.',
            redirectToSignIn: true
          };
        }
    
        // Validate the provided token with CloudKit
        const isValid = await this.validateWebAuthToken(webAuthToken);
        if (!isValid) {
          return {
            success: false,
            message: 'Invalid or expired authentication token. Please authenticate again.'
          };
        }
    
        // Get user identity from CloudKit
        const userIdentity = await this.getUserIdentityFromToken(webAuthToken);
        if (!userIdentity) {
          return {
            success: false,
            message: 'Failed to retrieve user identity from token'
          };
        }
    
        // Create user session
        const sessionId = this.generateSessionId();
        const session: UserSession = {
          sessionId,
          webAuthToken,
          userId: this.generateUserId(userIdentity.userRecordName),
          userRecordName: userIdentity.userRecordName,
          createdAt: new Date(),
          expiresAt: new Date(Date.now() + (this.securityConfig?.sessionTimeout || 24 * 60 * 60 * 1000)), // Default 24 hours
          containerID: userIdentity.containerID || 'unknown'
        };
    
        this.sessions.set(sessionId, session);
    
        console.log(`User authenticated: ${session.userRecordName} (session: ${sessionId})`);
    
        return {
          success: true,
          sessionId,
          userId: session.userId,
          userRecordName: session.userRecordName,
          expiresAt: session.expiresAt
        };
      } catch (error) {
        console.error('Authentication failed:', error);
        return {
          success: false,
          message: `Authentication failed: ${error instanceof Error ? error.message : String(error)}`
        };
      }
    }
  • Low-level CloudKit authentication using CloudKit JS SDK's setUpAuth with webAuthToken.
    async authenticateUser(webAuthToken?: string): Promise<boolean> {
      if (this.config.authMethod !== 'user') {
        throw new Error('User authentication not available in server-to-server mode');
      }
    
      try {
        if (webAuthToken) {
          // Use provided web auth token
          this.userIdentity = await this.ck.setUpAuth(webAuthToken);
        } else {
          // Request user authentication flow
          this.userIdentity = await this.ck.setUpAuth();
        }
    
        if (this.userIdentity) {
          this.authenticated = true;
          console.log('User authenticated:', this.userIdentity.userRecordName);
          return true;
        } else {
          this.authenticated = false;
          return false;
        }
      } catch (error) {
        console.error('User authentication failed:', error);
        this.authenticated = false;
        return false;
      }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions authentication but fails to describe critical traits such as what happens on success/failure, whether it returns a session token, if it's idempotent, or any rate limits/errors. This leaves significant gaps for a mutation-like operation.

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

Conciseness4/5

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

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, though it could be slightly more structured by separating usage context.

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 tool's complexity (authentication with potential side effects), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects, return values, or error handling, making it inadequate for safe and effective use by an agent.

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?

The input schema has 100% description coverage, so the schema already documents the 'webAuthToken' parameter fully. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't explain how to obtain the token or its format), meeting the baseline for high schema 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 user') and the resource ('Apple ID to access their addTaskManager data'), providing a specific purpose. However, it doesn't explicitly differentiate this authentication tool from potential alternatives or explain why Apple ID is used over other methods, which prevents a perfect score.

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 minimal guidance by implying this tool is used for authentication to access data, but it lacks explicit instructions on when to use it (e.g., before other operations), when not to use it, or alternatives. No context or prerequisites are mentioned, leaving usage unclear.

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/dragosroua/addtaskmanager-mcp-server'

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