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
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of submissions to return (optional, defaults to server-defined limit) | |
| username | Yes | LeetCode username to retrieve recent submissions for |
Implementation Reference
- src/mcp/tools/user-tools.ts:44-93 (registration)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 }) } ] }; } } );
- src/mcp/tools/user-tools.ts:61-92 (handler)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 }) } ] }; } }
- src/mcp/tools/user-tools.ts:47-60 (schema)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); }