Skip to main content
Glama

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
NameRequiredDescriptionDefault
contestSlugYesThe URL slug of the contest

Implementation Reference

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

Other Tools

Related 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/doggybee/mcp-server-leetcode'

If you have feedback or need assistance with the MCP directory API, please join our Discord server