Skip to main content
Glama

get-user-submissions

Fetch and analyze user submissions from LeetCode by entering a username and submission limit. Retrieve up to 100 recent submissions for insights or evaluation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of submissions to return
usernameYesLeetCode username

Implementation Reference

  • Executes the tool logic: fetches user submissions using LeetCodeService and returns JSON-formatted response or error message.
    async ({ username, limit }) => { try { const data = await leetcodeService.fetchUserSubmissions(username, limit); 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: username (string), limit (number, optional, default 20, range 1-100).
    { username: z.string().describe("LeetCode username"), limit: z.number().min(1).max(100).optional().default(20).describe("Maximum number of submissions to return") },
  • Registers the get-user-submissions tool on the MCP server with schema and handler.
    server.tool( "get-user-submissions", { username: z.string().describe("LeetCode username"), limit: z.number().min(1).max(100).optional().default(20).describe("Maximum number of submissions to return") }, async ({ username, limit }) => { try { const data = await leetcodeService.fetchUserSubmissions(username, limit); 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 }; } } );
  • Service method that executes the GraphQL query to fetch recent user submissions.
    async fetchUserSubmissions(username: string, limit: number = 20) { return this.executeQuery(userSubmissionsQuery, { username, limit }); }
  • GraphQL query for retrieving a user's recent submissions with fields: id, title, titleSlug, timestamp, statusDisplay, lang.
    export const userSubmissionsQuery = ` query recentSubmissions($username: String!, $limit: Int!) { recentSubmissionList(username: $username, limit: $limit) { id title titleSlug timestamp statusDisplay lang __typename } } `;

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