Skip to main content
Glama

list_problem_solutions

Retrieve metadata for community solutions to a specific LeetCode problem, including topic IDs for accessing full solution content.

Instructions

Retrieves a list of community solutions for a specific LeetCode problem, including only metadata like topicId. To view the full content of a solution, use the 'get_problem_solution' tool with the topicId returned by this tool.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
questionSlugYesThe URL slug/identifier of the problem to retrieve solutions for (e.g., 'two-sum', 'add-two-numbers'). This is the same string that appears in the LeetCode problem URL after '/problems/'
limitNoMaximum number of solutions to return per request. Used for pagination and controlling response size. Default is 20 if not specified. Must be a positive integer.
skipNoNumber of solutions to skip before starting to collect results. Used in conjunction with 'limit' for implementing pagination. Default is 0 if not specified. Must be a non-negative integer.
orderByNoSorting criteria for the returned solutions. 'DEFAULT' sorts by LeetCode's default algorithm (typically a combination of recency and popularity), 'MOST_VOTES' sorts by the number of upvotes (highest first), and 'MOST_RECENT' sorts by publication date (newest first).HOT
userInputNoSearch term to filter solutions by title, content, or author name. Case insensitive. Useful for finding specific approaches or algorithms mentioned in solutions.
tagSlugsNoArray of tag identifiers to filter solutions by programming languages (e.g., 'python', 'java') or problem algorithm/data-structure tags (e.g., 'dynamic-programming', 'recursion'). Only solutions tagged with at least one of the specified tags will be returned.

Implementation Reference

  • Global variant of the 'list_problem_solutions' tool handler: an inline async function that constructs options from input params, calls leetcodeService.fetchQuestionSolutionArticles(questionSlug, options), and returns structured JSON content with solutionArticles list or error details.
    async ({ questionSlug, limit, skip, orderBy, userInput, tagSlugs }) => { try { const options = { limit, skip, orderBy, userInput, tagSlugs }; const data = await this.leetcodeService.fetchQuestionSolutionArticles( questionSlug, options ); return { content: [ { type: "text", text: JSON.stringify({ questionSlug, solutionArticles: data }) } ] }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify({ error: "Failed to fetch solutions", message: error.message }) } ] }; } }
  • China variant of the 'list_problem_solutions' tool handler: an inline async function identical in logic to the global version, calling leetcodeService.fetchQuestionSolutionArticles with the same options structure.
    async ({ questionSlug, limit, skip, orderBy, userInput, tagSlugs }) => { try { const options = { limit, skip, orderBy, userInput, tagSlugs }; const data = await this.leetcodeService.fetchQuestionSolutionArticles( questionSlug, options ); return { content: [ { type: "text", text: JSON.stringify({ questionSlug, solutionArticles: data }) } ] }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify({ error: "Failed to fetch solutions", message: error.message }) } ] }; } }
  • Zod schema definition for the 'list_problem_solutions' tool inputs in global mode, including questionSlug (required), limit/skip (optional pagination), orderBy (HOT/MOST_RECENT/MOST_VOTES), userInput (search), tagSlugs (filter).
    { questionSlug: z .string() .describe( "The URL slug/identifier of the problem to retrieve solutions for (e.g., 'two-sum', 'add-two-numbers'). This is the same string that appears in the LeetCode problem URL after '/problems/'" ), limit: z .number() .optional() .default(10) .describe( "Maximum number of solutions to return per request. Used for pagination and controlling response size. Default is 20 if not specified. Must be a positive integer." ), skip: z .number() .optional() .describe( "Number of solutions to skip before starting to collect results. Used in conjunction with 'limit' for implementing pagination. Default is 0 if not specified. Must be a non-negative integer." ), orderBy: z .enum(["HOT", " MOST_RECENT", "MOST_VOTES"]) .default("HOT") .optional() .describe( "Sorting criteria for the returned solutions. 'DEFAULT' sorts by LeetCode's default algorithm (typically a combination of recency and popularity), 'MOST_VOTES' sorts by the number of upvotes (highest first), and 'MOST_RECENT' sorts by publication date (newest first)." ), userInput: z .string() .optional() .describe( "Search term to filter solutions by title, content, or author name. Case insensitive. Useful for finding specific approaches or algorithms mentioned in solutions." ), tagSlugs: z .array(z.string()) .optional() .default([]) .describe( "Array of tag identifiers to filter solutions by programming languages (e.g., 'python', 'java') or problem algorithm/data-structure tags (e.g., 'dynamic-programming', 'recursion'). Only solutions tagged with at least one of the specified tags will be returned." ) },
  • Zod schema definition for the 'list_problem_solutions' tool inputs in China mode, similar to global but with expanded orderBy enum (DEFAULT/MOST_UPVOTE/HOT/NEWEST_TO_OLDEST/OLDEST_TO_NEWEST).
    { questionSlug: z .string() .describe( "The URL slug/identifier of the problem to retrieve solutions for (e.g., 'two-sum', 'add-two-numbers'). This is the same string that appears in the LeetCode problem URL after '/problems/'" ), limit: z .number() .min(1) .optional() .default(10) .describe( "Maximum number of solutions to return per request. Used for pagination and controlling response size. Default is 20 if not specified. Must be a positive integer. If not provided or set to a very large number, the system may still apply internal limits." ), skip: z .number() .optional() .describe( "Number of solutions to skip before starting to collect results. Used in conjunction with 'limit' for implementing pagination. Default is 0 if not specified. Must be a non-negative integer." ), orderBy: z .enum([ "DEFAULT", "MOST_UPVOTE", "HOT", "NEWEST_TO_OLDEST", "OLDEST_TO_NEWEST" ]) .default("DEFAULT") .optional() .describe( "Sorting criteria for the returned solutions. 'DEFAULT' uses the default algorithm, 'MOST_UPVOTE' sorts by the number of upvotes (highest first), 'HOT' prioritizes trending solutions with recent engagement, 'NEWEST_TO_OLDEST' sorts by publication date (newest first), and 'OLDEST_TO_NEWEST' sorts by publication date (oldest first)." ), userInput: z .string() .optional() .describe( "Search term to filter solutions by title, content, or author name. Case insensitive. Useful for finding specific approaches or algorithms mentioned in solutions." ), tagSlugs: z .array(z.string()) .optional() .default([]) .describe( "Array of tag identifiers to filter solutions by programming languages (e.g., 'python', 'java') or problem algorithm/data-structure approaches (e.g., 'dynamic-programming', 'recursion'). Only solutions tagged with at least one of the specified tags will be returned." )
  • Top-level function registerSolutionTools that instantiates SolutionToolRegistry with server and leetcodeService, and calls registry.registerTools() to register both global and CN variants of the tool.
    export function registerSolutionTools( server: McpServer, leetcodeService: LeetCodeBaseService ): void { const registry = new SolutionToolRegistry(server, leetcodeService); registry.registerTools(); }
  • src/index.ts:96-96 (registration)
    Invocation of registerSolutionTools(server, leetcodeService) in the main entrypoint, which triggers the registration of the list_problem_solutions tool.
    registerSolutionTools(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