Skip to main content
Glama

get-user-profile

Retrieve detailed LeetCode user information by inputting a valid username. This tool enables AI assistants to access user profiles for analysis or integration purposes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesLeetCode username

Implementation Reference

  • The async handler function for the 'get-user-profile' tool. It fetches the user's LeetCode profile using LeetCodeService, stringifies the data as JSON, and returns it as text content. Handles errors by returning an error message.
    async ({ username }) => { try { const data = await leetcodeService.fetchUserProfile(username); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error: ${errorMessage}` }], isError: true }; } } );
  • Input schema for the 'get-user-profile' tool, validating the 'username' as a required string.
    { username: z.string().describe("LeetCode username") },
  • Registration of the 'get-user-profile' tool using server.tool(), including the name, input schema, and inline handler function.
    "get-user-profile", { username: z.string().describe("LeetCode username") }, async ({ username }) => { try { const data = await leetcodeService.fetchUserProfile(username); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error: ${errorMessage}` }], isError: true }; } } );
  • Supporting helper method in LeetCodeService that executes the GraphQL userProfileQuery to retrieve the profile data.
    async fetchUserProfile(username: string) { return this.executeQuery(userProfileQuery, { username }); }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/doggybee/mcp-server-leetcode'

If you have feedback or need assistance with the MCP directory API, please join our Discord server