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
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of submissions to return | |
| username | Yes | LeetCode username |
Implementation Reference
- src/tools/user-tools.ts:38-54 (handler)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 }; } }
- src/tools/user-tools.ts:34-37 (schema)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") },
- src/tools/user-tools.ts:32-55 (registration)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 }); }
- src/graphql/queries.ts:51-63 (helper)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 } } `;