get_profile
Retrieve the authenticated user's Gmail profile information, including email address and account details, for identity verification and personalized email management.
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)Registration of the 'get_profile' MCP tool, including inline handler that calls Gmail API's users.getProfile via the shared handleTool wrapper.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 logic for executing the 'get_profile' tool: authenticates via handleTool, fetches user profile from Gmail API, and formats response.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, client creation, and API call execution.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 used to format the API response for MCP tools, including 'get_profile'.const formatResponse = (response: any) => ({ content: [{ type: "text", text: JSON.stringify(response) }] })