get-contest-details
Retrieve contest details, including problem sets and metadata, by specifying the contest's URL slug on the LeetCode platform.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contestSlug | Yes | The URL slug of the contest |
Implementation Reference
- src/tools/contest-tools.ts:7-29 (registration)Registration of the 'get-contest-details' MCP tool, including inline schema and handler function.server.tool( "get-contest-details", { contestSlug: z.string().describe("The URL slug of the contest") }, async ({ contestSlug }) => { try { const data = await leetcodeService.fetchContestDetails(contestSlug); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error: ${errorMessage}` }], isError: true }; } } );
- src/tools/contest-tools.ts:12-28 (handler)Executes the tool logic: fetches contest details using LeetCodeService and returns JSON-formatted response or error.async ({ contestSlug }) => { try { const data = await leetcodeService.fetchContestDetails(contestSlug); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error: ${errorMessage}` }], isError: true }; } }
- src/tools/contest-tools.ts:9-11 (schema)Zod schema defining the input parameter 'contestSlug'.{ contestSlug: z.string().describe("The URL slug of the contest") },
- Service helper method that performs the GraphQL query to retrieve contest details.*/ async fetchContestDetails(contestSlug: string) { return this.executeQuery(contestDetailsQuery, { contestSlug }); }
- src/index.ts:24-24 (registration)Top-level registration call that invokes registerContestTools to add the tool to the main MCP server.registerContestTools(server, leetcodeService);