Skip to main content
Glama
jinzcdev

LeetCode MCP Server

get_user_profile

Retrieve LeetCode user profile data including stats, solved problems, and profile details by providing a username.

Instructions

Retrieves profile information about a LeetCode user, including user stats, solved problems, and profile details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesLeetCode username to retrieve profile information for

Implementation Reference

  • The inline async handler function for the get_user_profile tool. It takes a username, fetches the profile data from the LeetCode service, and returns it as a text content block containing JSON with the username and profile data.
    async ({ username }) => {
        const data =
            await this.leetcodeService.fetchUserProfile(username);
        return {
            content: [
                {
                    type: "text",
                    text: JSON.stringify({
                        username: username,
                        profile: data
                    })
                }
            ]
        };
    }
  • Zod input schema defining the required 'username' parameter as a string with description.
    {
        username: z
            .string()
            .describe(
                "LeetCode username to retrieve profile information for"
            )
    },
  • Registration of the 'get_user_profile' tool using server.tool(), including the tool name, description, input schema, and inline handler function within the UserToolRegistry's registerCommon method.
    this.server.tool(
        "get_user_profile",
        "Retrieves profile information about a LeetCode user, including user stats, solved problems, and profile details",
        {
            username: z
                .string()
                .describe(
                    "LeetCode username to retrieve profile information for"
                )
        },
        async ({ username }) => {
            const data =
                await this.leetcodeService.fetchUserProfile(username);
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify({
                            username: username,
                            profile: data
                        })
                    }
                ]
            };
        }
    );

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/jinzcdev/leetcode-mcp-server'

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