Skip to main content
Glama
j-straber
by j-straber

prune_code_context

Prune source code to retain only signatures, types, interfaces, and docstrings, replacing function bodies with stubs to cut token usage and latency for LLM context.

Instructions

Reads a source file or directory (or raw string) and returns an AST-pruned version containing only signatures, types, interfaces, and docstrings. Replaces function/method bodies with stubs to drastically cut token consumption and latency. Python pruning is free; TypeScript/JavaScript pruning is a Pro feature.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
depthNoPruning depth: 'interfaces_only' (preserves docstrings) or 'minimal' (strips docstrings)
languageNoOptional language hint ('python', 'typescript', or 'javascript'). Auto-detected if target_path has an extension.
license_keyNoOptional ContextCut Pro license key (can also be set via CONTEXTCUT_LICENSE_KEY environment variable)
target_pathNoPath to the source file or directory to prune (absolute or relative to current workspace)
code_contentNoOptional raw code string to prune directly in-memory instead of reading from disk
glob_patternNoGlob filter for directory scans (default: '*.py' for Python, '*.ts' for TypeScript)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.3.0

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations, the description carries the behavioral burden. It discloses input modes, the transformation (replacing bodies with stubs), output contents, and the free/Pro licensing boundary. It could mention non-mutation of files or what happens with Pro languages without a license, but it is already substantive.

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 compact sentences: purpose and output, mechanism and benefit, and licensing constraint. Each earns its place and the most important information is front-loaded.

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?

Covers the essential context: input modes, output contents, use case, and language-specific licensing. The main remaining gap is what happens when a Pro language is requested without a license key, but overall the description is sufficient for correct invocation.

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 parameters are already well documented. The description adds minimal extra parameter meaning beyond mapping 'source file or directory (or raw string)' to target_path and code_content. 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?

States a specific verb and result: reads source and returns an AST-pruned version containing signatures, types, interfaces, and docstrings with bodies stubbed. This clearly distinguishes it from sibling tools like check_license and get_savings_report.

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 clear context for when to use the tool: to reduce token consumption and latency by pruning code. It also adds a conditional constraint (Python free, TypeScript/JavaScript Pro), but it does not explicitly name alternatives or state when not to use it.

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