Skip to main content
Glama
arpitbatra123

Google Tasks MCP Server

authenticate

Generate a Google authentication URL to connect the Google Tasks MCP Server with your Google account for task management through Claude.

Instructions

Get URL to authenticate with Google Tasks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'authenticate' tool. It sets up a temporary HTTP server on port 3000 to handle the OAuth callback, generates the Google authorization URL, starts the server, and returns the URL with instructions to the user.
    async () => {
      // Make sure any previous server is closed
      if (authServer) {
        try {
          authServer.close();
        } catch (error) {
          console.error('Error closing existing auth server:', error);
        }
        authServer = null;
      }
    
      // Create the temporary HTTP server for OAuth callback
      authServer = http.createServer(async (req, res) => {
        try {
          // Parse the URL to get the authorization code
          const queryParams = url.parse(req.url || '', true).query;
          const code = queryParams.code;
          
          if (code) {
            console.error('✅ Authorization code received');
            
            // Send success response with the code
            res.writeHead(200, { 'Content-Type': 'text/html' });
            res.end(`
              <h1>Authorization Code Received</h1>
              <p>Please copy this code and use it with the 'set-auth-code' tool in Claude:</p>
              <div style="padding: 10px; background-color: #f0f0f0; border: 1px solid #ccc; margin: 20px 0;">
                <code>${code}</code>
              </div>
              <p>You can close this window after copying the code.</p>
            `);
            
            // Close the server after a short delay
            setTimeout(() => {
              if (authServer) {
                authServer.close();
                authServer = null;
              }
            }, 60000); // Keep the server alive for 1 minute
          } else {
            res.writeHead(400, { 'Content-Type': 'text/html' });
            res.end(`
              <h1>Authentication Failed</h1>
              <p>No authorization code received.</p>
              <p>Please try again.</p>
            `);
          }
        } catch (error) {
          console.error('Error during authentication:', error);
          res.writeHead(500, { 'Content-Type': 'text/html' });
          res.end(`
            <h1>Authentication Error</h1>
            <p>${error instanceof Error ? error.message : String(error)}</p>
          `);
        }
      });
    
      // Start the server
      authServer.listen(REDIRECT_PORT, () => {
        console.error(`Temporary authentication server running at http://localhost:${REDIRECT_PORT}/`);
        console.error('Waiting for authentication...');
      });
    
      // Generate the auth URL
      const authUrl = oauth2Client.generateAuthUrl({
        access_type: 'offline',
        scope: SCOPES,
        // Force approval prompt to always get a refresh token
        prompt: 'consent'
      });
    
      return {
        content: [
          {
            type: "text",
            text: `Please visit this URL to authenticate with Google Tasks:\n\n${authUrl}\n\nAfter authenticating, you'll receive a code. Use the 'set-auth-code' tool with that code.`,
          },
        ],
      };
    }
  • src/index.ts:52-136 (registration)
    Registration of the 'authenticate' tool via server.tool call. It has no input parameters (empty schema) and provides a description.
    server.tool(
      "authenticate",
      "Get URL to authenticate with Google Tasks",
      {},
      async () => {
        // Make sure any previous server is closed
        if (authServer) {
          try {
            authServer.close();
          } catch (error) {
            console.error('Error closing existing auth server:', error);
          }
          authServer = null;
        }
    
        // Create the temporary HTTP server for OAuth callback
        authServer = http.createServer(async (req, res) => {
          try {
            // Parse the URL to get the authorization code
            const queryParams = url.parse(req.url || '', true).query;
            const code = queryParams.code;
            
            if (code) {
              console.error('✅ Authorization code received');
              
              // Send success response with the code
              res.writeHead(200, { 'Content-Type': 'text/html' });
              res.end(`
                <h1>Authorization Code Received</h1>
                <p>Please copy this code and use it with the 'set-auth-code' tool in Claude:</p>
                <div style="padding: 10px; background-color: #f0f0f0; border: 1px solid #ccc; margin: 20px 0;">
                  <code>${code}</code>
                </div>
                <p>You can close this window after copying the code.</p>
              `);
              
              // Close the server after a short delay
              setTimeout(() => {
                if (authServer) {
                  authServer.close();
                  authServer = null;
                }
              }, 60000); // Keep the server alive for 1 minute
            } else {
              res.writeHead(400, { 'Content-Type': 'text/html' });
              res.end(`
                <h1>Authentication Failed</h1>
                <p>No authorization code received.</p>
                <p>Please try again.</p>
              `);
            }
          } catch (error) {
            console.error('Error during authentication:', error);
            res.writeHead(500, { 'Content-Type': 'text/html' });
            res.end(`
              <h1>Authentication Error</h1>
              <p>${error instanceof Error ? error.message : String(error)}</p>
            `);
          }
        });
    
        // Start the server
        authServer.listen(REDIRECT_PORT, () => {
          console.error(`Temporary authentication server running at http://localhost:${REDIRECT_PORT}/`);
          console.error('Waiting for authentication...');
        });
    
        // Generate the auth URL
        const authUrl = oauth2Client.generateAuthUrl({
          access_type: 'offline',
          scope: SCOPES,
          // Force approval prompt to always get a refresh token
          prompt: 'consent'
        });
    
        return {
          content: [
            {
              type: "text",
              text: `Please visit this URL to authenticate with Google Tasks:\n\n${authUrl}\n\nAfter authenticating, you'll receive a code. Use the 'set-auth-code' tool with that code.`,
            },
          ],
        };
      }
    );
  • Helper function used by multiple tools to check if authentication credentials are set before allowing access to Google Tasks API.
    function isAuthenticated() {
      return credentials !== null;
    }
  • Empty input schema for the 'authenticate' tool, indicating it takes no parameters.
    {},
  • Comment and helper function declaration for authentication status check, used extensively in other tools.
    // Helper function to check if authenticated
    function isAuthenticated() {
      return credentials !== null;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions getting a URL but doesn't explain what happens next (e.g., whether this initiates OAuth flow, if user interaction is required, what the URL is used for, or any rate limits). This leaves significant gaps in understanding the tool's behavior.

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, clear sentence that gets straight to the point with no wasted words. It's appropriately sized for a simple tool and front-loads the essential information efficiently.

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 insufficient. It doesn't explain what the returned URL is for, how it should be used, what authentication flow it enables, or what happens after authentication. This leaves critical gaps in understanding the tool's role in the broader authentication process.

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

Parameters4/5

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

The tool has zero parameters with 100% schema description coverage, so the schema already fully documents the parameter situation. The description doesn't need to add parameter information, and it appropriately doesn't mention any parameters. This meets the baseline expectation for a zero-parameter tool.

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 ('Get URL') and target resource ('authenticate with Google Tasks'), making the purpose immediately understandable. However, it doesn't distinguish this from sibling tools like 'set-auth-code' which also relates to authentication, leaving some ambiguity about when to use each.

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 like 'set-auth-code', nor does it mention prerequisites or context for authentication. It simply states what the tool does without indicating when it should be invoked.

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/arpitbatra123/mcp-googletasks'

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