Skip to main content
Glama

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);

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