Skip to main content
Glama

get_recent_submissions

Retrieve detailed metadata of a user's recent LeetCode submissions, including accepted and failed attempts, by specifying their username and an optional limit.

Instructions

Retrieves a user's recent submissions on LeetCode Global, including both accepted and failed submissions with detailed metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of submissions to return (optional, defaults to server-defined limit)
usernameYesLeetCode username to retrieve recent submissions for

Implementation Reference

  • Registration of the 'get_recent_submissions' MCP tool, including input schema (username: string, limit?: number), description, and inline asynchronous handler that fetches data from LeetCode service and formats response as JSON text content or error.
    this.server.tool( "get_recent_submissions", "Retrieves a user's recent submissions on LeetCode Global, including both accepted and failed submissions with detailed metadata", { username: z .string() .describe( "LeetCode username to retrieve recent submissions for" ), limit: z .number() .optional() .default(10) .describe( "Maximum number of submissions to return (optional, defaults to server-defined limit)" ) }, async ({ username, limit }) => { try { const data = await this.leetcodeService.fetchUserRecentSubmissions( username, limit ); return { content: [ { type: "text", text: JSON.stringify({ username, submissions: data }) } ] }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify({ error: "Failed to fetch recent submissions", message: error.message }) } ] }; } } );
  • Inline handler function for the get_recent_submissions tool. Calls leetcodeService.fetchUserRecentSubmissions, returns structured JSON response with submissions or error message.
    async ({ username, limit }) => { try { const data = await this.leetcodeService.fetchUserRecentSubmissions( username, limit ); return { content: [ { type: "text", text: JSON.stringify({ username, submissions: data }) } ] }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify({ error: "Failed to fetch recent submissions", message: error.message }) } ] }; } }
  • Zod input schema definition for the tool parameters: required 'username' (string) and optional 'limit' (number, default 10).
    { username: z .string() .describe( "LeetCode username to retrieve recent submissions for" ), limit: z .number() .optional() .default(10) .describe( "Maximum number of submissions to return (optional, defaults to server-defined limit)" ) },
  • Helper method in LeetCodeGlobalService implementing the core API call to retrieve recent submissions via the leetcode-query library's LeetCode instance.
    async fetchUserRecentSubmissions( username: string, limit?: number ): Promise<any> { return await this.leetCodeApi.recent_submissions(username, limit); }

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

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