Skip to main content
Glama
yzfly

MCP Python Interpreter

by yzfly

clear_session

Clear a Python REPL session's state and history to reset the execution environment and remove previous code outputs.

Instructions

Clear a REPL session's state and history.

Args:
    session_id: Session ID to clear

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idNodefault

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The clear_session tool handler: deletes the REPL session for the given session_id from the global _sessions dictionary and returns a confirmation message.
    def clear_session(session_id: str = "default") -> str:
        """
        Clear a REPL session's state and history.
        
        Args:
            session_id: Session ID to clear
        """
        if session_id in _sessions:
            del _sessions[session_id]
            return f"Session '{session_id}' cleared."
        else:
            return f"Session '{session_id}' not found."
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool clears 'state and history,' implying a destructive operation, but doesn't specify whether this is irreversible, what 'state' includes (e.g., variables, outputs), or if it affects other sessions. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 appropriately sized and front-loaded, with the core purpose stated first ('Clear a REPL session's state and history.') and parameter details following. It avoids unnecessary elaboration, but the 'Args' section could be more integrated. Overall, it's efficient with minimal waste.

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

Completeness3/5

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

Given the tool's complexity (destructive operation with one parameter), no annotations, and an output schema (which reduces need to explain returns), the description is partially complete. It covers the basic action and parameter, but lacks critical context like irreversible effects, session existence checks, or error handling. For a mutation tool, this is a moderate gap in completeness.

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?

The description adds minimal parameter semantics beyond the input schema. It includes an 'Args' section listing 'session_id: Session ID to clear,' which provides basic meaning (identifying which session to clear). However, with 0% schema description coverage and only one parameter, this is adequate but not detailed (e.g., no format or default value explanation). The baseline is 4 for 0 parameters, but here it's 3 due to the single parameter being partially documented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('clear') and resource ('a REPL session's state and history'). It distinguishes the tool from siblings like 'list_sessions' or 'run_python_code' by focusing on cleanup rather than listing or execution. However, it doesn't explicitly differentiate from all siblings (e.g., it's clear but not maximally specific about sibling relationships).

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether a session must exist), exclusions (e.g., not for active sessions), or suggest alternatives among siblings like 'list_sessions' for checking sessions first. The tool's purpose is clear, but usage context is missing.

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/yzfly/mcp-python-interpreter'

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