get_profile
Retrieve your Gmail account profile details such as name and email address to verify identity and access user information.
Instructions
Get the current user's Gmail profile
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1289-1298 (registration)Registers the MCP tool 'get_profile'. Includes empty input schema and inline handler that uses shared 'handleTool' to authenticate and call Gmail API's users.getProfile to retrieve the current user's profile information.server.tool("get_profile", "Get the current user's Gmail profile", {}, async () => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.getProfile({ userId: 'me' }) return formatResponse(data) }) } )
- src/index.ts:1292-1297 (handler)Inline handler function for the 'get_profile' tool, which invokes the shared handleTool utility with the specific Gmail API call to fetch the user's profile.async () => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.getProfile({ userId: 'me' }) return formatResponse(data) }) }
- src/index.ts:50-66 (helper)Shared helper function used by get_profile (and other tools) to handle OAuth2 authentication, validate credentials, create Gmail client, and execute the provided API callback.const handleTool = async (queryConfig: Record<string, any> | undefined, apiCall: (gmail: gmail_v1.Gmail) => Promise<any>) => { try { const oauth2Client = queryConfig ? createOAuth2Client(queryConfig) : defaultOAuth2Client if (!oauth2Client) throw new Error('OAuth2 client could not be created, please check your credentials') const credentialsAreValid = await validateCredentials(oauth2Client) if (!credentialsAreValid) throw new Error('OAuth2 credentials are invalid, please re-authenticate') const gmailClient = queryConfig ? google.gmail({ version: 'v1', auth: oauth2Client }) : defaultGmailClient if (!gmailClient) throw new Error('Gmail client could not be created, please check your credentials') const result = await apiCall(gmailClient) return result } catch (error: any) { return `Tool execution failed: ${error.message}` } }
- src/index.ts:48-48 (helper)Helper function to format API responses into MCP content structure by JSON stringifying the response.const formatResponse = (response: any) => ({ content: [{ type: "text", text: JSON.stringify(response) }] })