Skip to main content
Glama
jinzcdev

LeetCode MCP Server

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
NameRequiredDescriptionDefault
usernameYesLeetCode username to retrieve recent submissions for
limitNoMaximum number of submissions to return (optional, defaults to server-defined limit)

Implementation Reference

  • 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
                            })
                        }
                    ]
                };
            }
        }
    );
  • 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
                        })
                    }
                ]
            };
        }
    }
  • 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);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions retrieval of submissions with metadata but lacks behavioral details such as rate limits, authentication requirements, pagination behavior, error conditions, or data freshness. This is inadequate for a tool with potential external API calls and user data access.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary details. It could be slightly improved by structuring usage context, but it avoids redundancy and waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It doesn't explain return values (e.g., submission structure, metadata fields), error handling, or behavioral traits like rate limits. For a tool retrieving user data from an external service, this leaves significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters ('username' and 'limit'). The description adds no additional parameter semantics beyond what's in the schema, such as format constraints or usage examples, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('retrieves') and resource ('user's recent submissions on LeetCode Global'), specifying scope ('including both accepted and failed submissions with detailed metadata'). However, it doesn't explicitly differentiate from sibling tools like 'get_recent_ac_submissions' (which likely only returns accepted submissions), missing full sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_recent_ac_submissions' (for only accepted submissions) or 'get_user_profile' (for broader user data), nor does it specify prerequisites or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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