Skip to main content
Glama

get-user-contest-ranking

Retrieve a LeetCode user's contest ranking by submitting their username. This tool enables access to contest data through the MCP server for LeetCode.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesLeetCode username

Implementation Reference

  • The handler function that implements the core logic of the 'get-user-contest-ranking' tool. It calls LeetCodeService.fetchUserContestRanking, formats the result as JSON, or returns an error response.
    async ({ username }) => { try { const data = await leetcodeService.fetchUserContestRanking(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 using Zod for validating the 'username' parameter of the tool.
    { username: z.string().describe("LeetCode username") },
  • The server.tool() registration call that defines and registers the 'get-user-contest-ranking' MCP tool, including its name, input schema, and handler.
    server.tool( "get-user-contest-ranking", { username: z.string().describe("LeetCode username") }, async ({ username }) => { try { const data = await leetcodeService.fetchUserContestRanking(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 }; } } );
  • Helper utility method in LeetCodeService that executes the GraphQL query to fetch the user's contest ranking data.
    async fetchUserContestRanking(username: string) { return this.executeQuery(userContestRankingQuery, { username }); }
  • src/index.ts:24-24 (registration)
    Top-level call to registerContestTools, which includes registration of the 'get-user-contest-ranking' tool.
    registerContestTools(server, leetcodeService);

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