get_user_identity
Fetch authenticated user details from Discogs API to access personal account information or manage music collections.
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)Defines the MCP 'get_user_identity' tool handler, which executes by creating an OAuthService instance and calling getUserIdentity(), returning the JSON stringified result.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/types/oauth.ts:6-11 (schema)Zod schema used to validate the output/response from the Discogs /oauth/identity endpoint.export const DiscogsUserIdentitySchema = z.object({ id: z.number(), username: z.string(), resource_url: z.string().url(), consumer_name: z.string(), });
- src/tools/userIdentity.ts:108-108 (registration)Registers the get_user_identity tool with the FastMCP server.server.addTool(getUserIdentityTool);
- src/services/oauth.ts:18-35 (helper)Core helper method in OAuthService that performs the authenticated request to Discogs /oauth/identity and validates the response.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)}`); } }
- src/tools/index.ts:19-19 (registration)Top-level registration call that includes adding the get_user_identity tool via registerUserIdentityTools.registerUserIdentityTools(server);