get_recent_submissions
Retrieve recent LeetCode submissions for a user, including accepted and failed attempts with detailed metadata, to track coding progress and analyze problem-solving patterns.
Instructions
Retrieves a user's recent submissions on LeetCode Global, including both accepted and failed submissions with detailed metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | LeetCode username to retrieve recent submissions for | |
| limit | No | Maximum number of submissions to return (optional, defaults to server-defined limit) |
Implementation Reference
- src/mcp/tools/user-tools.ts:45-93 (registration)Registration of the MCP tool 'get_recent_submissions' including description, Zod input schema, and inline async handler function that calls leetcodeService and formats response as MCP content."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 }) } ] }; } } );
- src/mcp/tools/user-tools.ts:61-92 (handler)The core handler function for the tool that executes the logic: fetches recent submissions from LeetCode service and returns formatted JSON response.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 }) } ] }; } }
- src/mcp/tools/user-tools.ts:47-60 (schema)Zod schema defining input parameters: username (required string) and limit (optional 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)" ) },
- Supporting method in LeetCodeGlobalService that implements fetching recent submissions by delegating to the leetcode-query library's recent_submissions API.async fetchUserRecentSubmissions( username: string, limit?: number ): Promise<any> { return await this.leetCodeApi.recent_submissions(username, limit); }