Skip to main content
Glama

extract_code_blocks

Read-onlyIdempotent

Extract code blocks from Markdown documents to parse AI responses and technical docs. Returns JSON arrays containing programming languages, source code, and start/end line numbers.

Instructions

Extract all code blocks from a Markdown document. Returns a JSON array of code blocks, each with language, code content, and start/end line numbers. Useful for extracting code snippets from LLM responses or documentation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
markdownYesThe Markdown text to extract code blocks from.
Behavior4/5

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

Annotations declare read-only/idempotent nature. Description adds valuable output structure details beyond annotations: JSON array format with specific fields (language, code content, start/end line numbers) and the 'all' scope indicator.

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 zero waste: first sentence covers function + return format, second covers use case. Information-dense and front-loaded.

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

Completeness5/5

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

No output schema exists, but description fully compensates by detailing the JSON array structure and constituent fields (language, line numbers). Complete for a single-parameter extraction tool with good annotations.

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 coverage is 100% ('The Markdown text to extract code blocks from'). Description references 'Markdown document' but does not supplement schema with additional format constraints, validation rules, or examples. Baseline 3 appropriate for high-coverage schemas.

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?

Specific verb 'Extract' with clear resource 'code blocks' and scope 'from a Markdown document'. Distinctly positioned against sibling 'extract_structure' (general structure) and 'extract_links' (URLs) by targeting fenced code blocks specifically.

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?

Provides concrete usage contexts ('LLM responses or documentation') indicating when to use. Lacks explicit exclusions or sibling comparisons (e.g., vs extract_structure), but clear enough for selection.

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

Install Server

Other 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/XJTLUmedia/MCP_Markdown_Formatter'

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