Skip to main content
Glama

get_code_snippet

Retrieves starter boilerplate code for a LeetCode problem in a specified language, returning the snippet, language, and method signatures as JSON for coding without the full problem description.

Instructions

Retrieves starter boilerplate code for a problem in a specified programming language (read-only, no auth). Returns snippet, language, and method signatures as JSON. Use this when writing a solution and needing the exact starter template without fetching the full problem description.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "titleSlug": "<titleSlug>",
      "lang": "<lang>"
    },
    "name": "get_code_snippet"
  }
}

Input Schema

NameRequiredDescriptionDefault
langYesLanguage slug or name (e.g., 'python3', 'javascript', 'cpp', 'java', 'typescript', 'rust', 'golang')
titleSlugYesProblem URL slug (e.g., 'two-sum')

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.5.1

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations supplied, the description carries the burden and mostly meets it: it declares read-only behavior, that no auth is required, and what the payload contains (snippet, language, method signatures). It omits failure behavior for unknown slugs or unsupported languages, and any rate-limit or caching context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, front-loaded with the core action, with the return shape and usage condition each earning their place. No redundant restatement of the name or padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-parameter read tool with no output schema, the description covers purpose, safety profile, return contents, and usage condition, which is nearly everything an agent needs. Only edge-case behavior for invalid slugs or unsupported languages is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the schema already gives slugs and examples for both parameters, so the baseline is 3. The description only restates that a problem and a language are supplied, adding no format or constraint detail beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Retrieves starter boilerplate code for a problem in a specified programming language') and scopes it against the broader problem fetch, so an agent can distinguish it from get_problem without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit when-to-use guidance ('Use this when writing a solution and needing the exact starter template without fetching the full problem description'), which implicitly routes the agent away from get_problem. It does not name that alternative outright or state a when-not condition, so it falls short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.