Skip to main content
Glama
jinzcdev

LeetCode MCP Server

get_problem

Retrieve LeetCode problem details including description, examples, constraints, and related information using the problem's URL slug identifier.

Instructions

Retrieves details about a specific LeetCode problem, including its description, examples, constraints, and related information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleSlugYesThe URL slug/identifier of the problem (e.g., 'two-sum', 'add-two-numbers') as it appears in the LeetCode URL

Implementation Reference

  • Registration of the 'get_problem' tool including description, input schema, and handler function.
    this.server.tool(
        "get_problem",
        "Retrieves details about a specific LeetCode problem, including its description, examples, constraints, and related information",
        {
            titleSlug: z
                .string()
                .describe(
                    "The URL slug/identifier of the problem (e.g., 'two-sum', 'add-two-numbers') as it appears in the LeetCode URL"
                )
        },
        async ({ titleSlug }) => {
            const data =
                await this.leetcodeService.fetchProblemSimplified(
                    titleSlug
                );
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify({
                            titleSlug,
                            problem: data
                        })
                    }
                ]
            };
        }
    );
  • The handler function that executes the tool logic: fetches simplified problem data from LeetCode service and returns it as JSON in a structured content response.
    async ({ titleSlug }) => {
        const data =
            await this.leetcodeService.fetchProblemSimplified(
                titleSlug
            );
        return {
            content: [
                {
                    type: "text",
                    text: JSON.stringify({
                        titleSlug,
                        problem: data
                    })
                }
            ]
        };
    }
  • Input schema definition using Zod for the 'titleSlug' parameter.
    {
        titleSlug: z
            .string()
            .describe(
                "The URL slug/identifier of the problem (e.g., 'two-sum', 'add-two-numbers') as it appears in the LeetCode URL"
            )
    },
  • src/index.ts:93-93 (registration)
    Top-level call to register all problem tools, including 'get_problem', on the MCP server instance.
    registerProblemTools(server, leetcodeService);
Behavior2/5

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

With no annotations provided, the description carries full burden but only states what information is retrieved without disclosing behavioral traits. It doesn't mention whether this is a read-only operation (implied by 'retrieves' but not explicit), error handling for invalid slugs, rate limits, authentication needs, or response format. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness5/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 ('retrieves details about a specific LeetCode problem') and lists key returned information. There is no wasted verbiage, and every phrase adds value by specifying the resource and data types.

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

Completeness3/5

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

Given the tool's low complexity (1 parameter, no nested objects) and 100% schema coverage, the description is minimally adequate but incomplete. Without annotations or an output schema, it should ideally mention the read-only nature, error cases, or response structure to fully inform usage. It covers the 'what' but lacks operational context needed for robust agent invocation.

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?

The input schema has 100% description coverage, with the single parameter 'titleSlug' well-documented in the schema. The description adds no additional parameter semantics beyond what the schema provides, such as examples of valid slugs or format constraints. With high schema coverage, the baseline is 3, as the description doesn't compensate but doesn't need to heavily.

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 details') and resource ('specific LeetCode problem'), specifying the type of information returned (description, examples, constraints, related information). It distinguishes this from siblings like 'get_daily_challenge' or 'search_problems' by focusing on a single problem's details rather than lists or challenges. However, it doesn't explicitly contrast with 'get_problem_solution' which might retrieve solution-specific details.

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

Usage Guidelines3/5

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

The description implies usage when detailed problem information is needed, but provides no explicit guidance on when to choose this over alternatives like 'search_problems' for finding problems or 'get_problem_solution' for solution-focused data. It lacks any 'when-not' scenarios or prerequisites, such as requiring a valid titleSlug.

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