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

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."

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