get_userinfo
Retrieve PayPal user account details by providing an identity token to access profile information and account data.
Instructions
Get user info from identity token
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| access_token | Yes |
Implementation Reference
- src/index.ts:1306-1323 (handler)The implementation of the get_userinfo tool handler within the CallToolRequestSchema switch statement. It validates the access_token argument, calls the PayPal userinfo API, and returns the response.case 'get_userinfo': { const args = this.validateTokenParams(request.params.arguments); const response = await axios.get<PayPalIdentityTokenInfo>( 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo', { headers: { Authorization: `Bearer ${args.access_token}`, 'Content-Type': 'application/json' } } ); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }] }; }
- src/index.ts:1096-1106 (registration)Registration of the 'get_userinfo' tool in the ListTools response, defining its name, description, and input schema.{ name: 'get_userinfo', description: 'Get user info from identity token', inputSchema: { type: 'object', properties: { access_token: { type: 'string' } }, required: ['access_token'] } },
- src/index.ts:706-711 (helper)Helper function to validate the arguments for the get_userinfo tool, ensuring access_token is provided as a string.private validateTokenParams(args: unknown): { access_token: string } { if (typeof args !== 'object' || !args || typeof (args as any).access_token !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid access token'); } return { access_token: (args as any).access_token }; }
- src/index.ts:236-240 (schema)TypeScript interface defining the structure of the PayPal userinfo API response.interface PayPalIdentityTokenInfo { client_id: string; user_id: string; scopes: string[]; }