Skip to main content
Glama

Get Code Examples

get_code_examples

Retrieve working code examples for any library feature from official documentation, returning formatted fenced code blocks ready for immediate use.

Instructions

Fetch working code examples for a specific library feature from official docs.

Unlike get_docs(), this tool specifically hunts for pages rich in code samples, extracting and formatting fenced code blocks for immediate use.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesFeature or pattern you need code for, e.g. "streaming chat completion", "async vector upsert", "RAG pipeline".
libraryYesLibrary key (e.g. "openai", "langchain", "pinecone").
languageNoExpected language for syntax context. Default: "python".python
serper_api_keyNoOptional. Overrides server SERPER_API_KEY env var (BYOK).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4/5.0
Behavior3/5

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

With no annotations, the description carries the burden of behavioral disclosure. It explains that the tool hunts for code-rich pages and extracts/format fenced code blocks, which is useful. However, it does not disclose whether results are verified, whether network/rate-limit behavior applies, or any caveats about 'working' examples.

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?

Two sentences with no filler. The core purpose is front-loaded, and the second sentence earns its place by differentiating from a sibling tool.

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?

The schema covers all parameters, an output schema exists, and the description covers purpose, behavior, and the main alternative. Given this is a read-oriented retrieval tool, the description is largely complete. Minor gaps like rate limits or validation expectations prevent a 5.

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%, so the schema fully documents all four parameters. The description adds context about the tool's overall behavior but does not add meaning to individual parameters beyond what the schema already provides. Baseline 3 is appropriate.

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?

Description uses a specific verb and resource: 'Fetch working code examples for a specific library feature from official docs.' It clearly distinguishes itself from the sibling get_docs() by emphasizing code-rich pages and fenced code block extraction.

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?

The 'Unlike get_docs()' sentence explicitly tells the agent when to prefer this tool over a key alternative. It implies use when code examples are needed rather than general documentation. It does not describe conditions for other siblings like search_docs_multi, but the primary routing decision is clear.

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