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
| Name | Required | Description | Default |
|---|---|---|---|
| titleSlug | Yes | The URL slug/identifier of the problem (e.g., 'two-sum', 'add-two-numbers') as it appears in the LeetCode URL |
Implementation Reference
- src/mcp/tools/problem-tools.ts:35-62 (registration)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 }) } ] }; } );
- src/mcp/tools/problem-tools.ts:45-61 (handler)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 }) } ] }; }
- src/mcp/tools/problem-tools.ts:38-44 (schema)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);