Skip to main content
Glama

Refine Prompt

refine_prompt

Improve prompts for AI agents by selecting or creating optimized versions based on agent type, language, and project context. Use scoping options to focus the agent on relevant files, directories, and priorities.

Instructions

Refine a prompt before sending to an agent.

Given an original prompt and context, either selects an existing refined prompt or creates a new one optimized for the agent type and language.

Scoping Options (Optional but Recommended): To improve focus and reduce context overload, include in the context dict:

  • target_dirs: List of directories the agent should focus on (e.g., ["src/", "tests/"])

  • target_files: Specific files to modify (e.g., ["src/main.py", "src/config.py"])

  • exclude_paths: Paths to ignore (e.g., [".venv/", "node_modules/"])

  • scope: High-level scope description (e.g., "backend API layer only")

  • focus: Priority aspects (e.g., ["performance", "security", "error-handling"])

Note: A project_id is required. If not provided, the response will include a list of existing projects or instructions to create one. The agent should:

  1. Call list_projects to see available projects, or

  2. Call create_project to create a new one, then

  3. Resubmit the refine_prompt request with the project_id

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestYesRefinement request with prompt details

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
sourceYes
prompt_keyYes
usage_countNo
average_scoreNo
refined_promptYes
confidence_scoreNo
similar_prompts_foundNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden and does well: it discloses that the tool either selects an existing refined prompt or creates a new one, explains what happens when project_id is absent, and documents how context keys like target_dirs and focus affect behavior. This is substantial behavioral context beyond the schema.

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

Conciseness4/5

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

The description is front-loaded with a crisp one-line purpose and uses markdown headings, bullets, and numbered steps effectively. It is longer than average, but the added detail is functional rather than filler, especially given the nested request object and the project_id fallback workflow.

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?

For a tool with a nested request object, no annotations, and an output schema, the description is remarkably complete. It covers the main use case, optional scoping keys, required workflow around project_id, and sibling-tool handoffs. Nothing essential for invoking the tool correctly appears to be missing.

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

Parameters4/5

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

Schema description coverage is 100%, so the baseline is 3, but the description adds meaning by documenting the recommended shape of the context object and clarifying that project_id is important for the workflow. It explains the intended use of agent_type and language more concretely than the schema alone, though it does not discuss every nested field.

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?

The description opens with a specific verb and resource: 'Refine a prompt before sending to an agent.' It clearly states the tool selects an existing refined prompt or creates a new one, distinguishing it from sibling tools like activate_prompt, deactivate_prompt, and project-management tools.

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 description gives clear context for when to use the tool ('before sending to an agent') and provides recommended scoping options to improve focus. It also gives an explicit fallback workflow when project_id is missing, directing the agent to list_projects or create_project before resubmitting, though it does not explicitly contrast against non-project siblings.

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