get_user_identity
Retrieve authenticated user information from Discogs to manage music collections and catalog operations.
Instructions
Retrieve basic information about the authenticated user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/userIdentity.ts:14-28 (handler)MCP tool definition for 'get_user_identity', including name, description, empty input schema (z.object({})), and execute handler that fetches user identity via OAuthService and returns JSON string.export const getUserIdentityTool: Tool<FastMCPSessionAuth, ToolParameters> = { name: 'get_user_identity', description: 'Retrieve basic information about the authenticated user', parameters: z.object({}), execute: async () => { try { const oauthService = new OAuthService(); const identity = await oauthService.getUserIdentity(); return JSON.stringify(identity); } catch (error) { throw formatDiscogsError(error); } }, };
- src/tools/userIdentity.ts:107-113 (registration)Registration function that adds the 'get_user_identity' tool (and related user tools) to the FastMCP server.export function registerUserIdentityTools(server: FastMCP): void { server.addTool(getUserIdentityTool); server.addTool(getUserProfileTool); server.addTool(editUserProfileTool); server.addTool(getUserSubmissionsTool); server.addTool(getUserContributionsTool); }
- src/tools/userIdentity.ts:17-17 (schema)Input schema for the tool: empty object (no parameters required).parameters: z.object({}),
- src/services/oauth.ts:18-35 (helper)OAuthService method called by the tool handler to retrieve the authenticated user's identity from Discogs API (/oauth/identity), with Zod validation.async getUserIdentity(): Promise<DiscogsUserIdentity> { try { // Call the identity endpoint relative to the OAuth base path const response = await this.request<DiscogsUserIdentity>('/identity'); // Validate the response using Zod schema const validatedResponse = DiscogsUserIdentitySchema.parse(response); return validatedResponse; } catch (error) { // If it's already a Discogs error, just rethrow it if (isDiscogsError(error)) { throw error; } // For validation errors or other unexpected errors, wrap them throw new Error(`Failed to get identity: ${String(error)}`); } }