Skip to main content
Glama

list_sessions

View all active Python REPL sessions to monitor and manage code execution environments within the MCP Python Interpreter.

Instructions

List all active REPL sessions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_sessions' tool. It iterates over the global _sessions dictionary and formats a string listing each session's ID, history length, and count of non-magic variables in its locals.
    @mcp.tool() def list_sessions() -> str: """List all active REPL sessions.""" if not _sessions: return "No active sessions." result = "Active REPL Sessions:\n\n" for session_id, session in _sessions.items(): result += f"- Session: {session_id}\n" result += f" History entries: {len(session.history)}\n" result += f" Variables: {len([k for k in session.locals.keys() if not k.startswith('__')])}\n\n" return result

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