Skip to main content
Glama

Purge Knowledge Base

ctx_purge

Permanently delete indexed content for a single session or entire project. Confirmation is required to prevent irreversible data loss.

Instructions

DESTRUCTIVE: permanently delete indexed content. Cannot be undone. Requires confirm:true and exactly one scope.

WHEN:

  • User explicitly asks to clear a specific session ('purge this session', 'wipe this conversation')

  • User explicitly asks to reset the whole project ('reset everything', 'wipe the knowledge base')

WHEN NOT:

  • User says 'reset', 'clear', or 'wipe' without naming a scope -> ask which scope before calling

  • User wants to free memory or improve performance -> recommend ctx_stats first, do not purge

SCOPES (pass exactly one):

  • Per-session: ctx_purge(confirm: true, sessionId: "") deletes that session's events (auto-captured decisions, errors, plans, user prompts, rejected approaches, etc.) and per-session FTS5 chunks; sibling sessions and stats file are preserved.

  • Per-project: ctx_purge(confirm: true, scope: "project") wipes FTS5 knowledge base, every session DB row, events markdown, and resets the stats file. Use ctx_stats first to preview category counts before purging.

CONTRACT:

  • confirm:true is required; confirm:false returns 'purge cancelled'.

  • sessionId and scope:'project' together return 'ambiguous - pick one'.

  • scope:'session' without sessionId throws (sessionId required).

  • Bare {confirm:true} is deprecated: maps to scope:'project' with a stderr warning; will hard-error in a future major.

RETURNS: A summary of removed rows + the resolved scope.

EXAMPLE: ctx_purge(confirm: true, sessionId: "7c8a-1234-5678-9abc-def012345678") EXAMPLE: ctx_purge(confirm: true, scope: "project")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
confirmYesMUST be true. Destructive operation; false returns 'purge cancelled'.
sessionIdNoUUID of a single session. Pairs with confirm:true to wipe only that session's events + per-session FTS5 chunks. Sibling sessions and the stats file are preserved. MUST NOT be combined with scope:'project'.
scopeNoExplicit scope selector. 'session' REQUIRES sessionId. 'project' wipes the entire project (FTS5 + every session + stats). Omit only for the deprecated bare-{confirm:true} back-compat path.
Behavior5/5

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

No annotations provided, so description carries full burden. It discloses destructive nature, irreversibility, required confirm:true, error conditions, deprecation path, and return value. No contradiction with annotations (none exist).

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?

Well-structured with headers, WHEN blocks, SCOPES, CONTRACT, RETURNS, and examples. Some verbosity is justified by complexity, but could be slightly more concise.

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 destructive tool with 3 parameters and no output schema, the description covers all necessary aspects: usage context, side effects, error handling, return summary, and deprecation. Complete and thorough.

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 coverage is 100%, but description adds significant value beyond schema by providing exact contract details, examples, and deprecation behavior. Baseline 3 plus extra clarity justifies 4.

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?

Clearly states it is a destructive tool that permanently deletes indexed content. The verb 'purge' and resource 'knowledge base' are specific, and it distinguishes itself from sibling tools like ctx_stats by noting when not to use it.

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

Usage Guidelines5/5

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

Explicitly lists WHEN to use (user asking to clear a specific session or reset the project) and WHEN NOT to use (ambiguous requests, performance needs). Provides alternative tool ctx_stats for non-destructive scenarios.

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/mksglu/context-mode'

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