Skip to main content
Glama
arpitbatra123

Google Tasks MCP Server

set-auth-code

Configure Google Tasks access by entering the OAuth authorization code to authenticate with Google's API.

Instructions

Set the authentication code received from Google OAuth flow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe authentication code received from Google

Implementation Reference

  • The handler function for the 'set-auth-code' tool. It exchanges the provided OAuth code for access and refresh tokens using Google OAuth2Client, stores the credentials in memory, closes the temporary auth server, and returns a success message or an error if token retrieval fails.
    async ({ code }) => { try { const { tokens } = await oauth2Client.getToken(code); oauth2Client.setCredentials(tokens); // Store tokens in memory only credentials = tokens; // Close auth server if it's still running if (authServer) { try { authServer.close(); } catch (error) { console.error('Error closing auth server:', error); } authServer = null; } return { content: [ { type: "text", text: "Authentication successful! You can now use the Google Tasks tools.", }, ], }; } catch (error) { console.error('Error retrieving access token:', error); return { isError: true, content: [ { type: "text", text: `Authentication failed: ${error}`, }, ], }; } }
  • Input schema for the 'set-auth-code' tool, defining a required 'code' parameter as a string using Zod.
    { code: z.string().describe("The authentication code received from Google"), },
  • src/index.ts:139-184 (registration)
    Registration of the 'set-auth-code' tool using server.tool(), including name, description, input schema, and inline handler function.
    server.tool( "set-auth-code", "Set the authentication code received from Google OAuth flow", { code: z.string().describe("The authentication code received from Google"), }, async ({ code }) => { try { const { tokens } = await oauth2Client.getToken(code); oauth2Client.setCredentials(tokens); // Store tokens in memory only credentials = tokens; // Close auth server if it's still running if (authServer) { try { authServer.close(); } catch (error) { console.error('Error closing auth server:', error); } authServer = null; } return { content: [ { type: "text", text: "Authentication successful! You can now use the Google Tasks tools.", }, ], }; } catch (error) { console.error('Error retrieving access token:', error); return { isError: true, content: [ { type: "text", text: `Authentication failed: ${error}`, }, ], }; } } );

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