Skip to main content
Glama
hdresearch

Python REPL MCP Server

by hdresearch

list_variables

View all variables currently defined in the Python REPL session to track and manage your workspace.

Instructions

List all variables in the current session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler implementation for the 'list_variables' tool. It filters and lists variables from the global namespace, excluding builtins and private variables, formatting them for output.
    elif name == "list_variables":
        # Filter out builtins and private variables
        vars_dict = {
            k: repr(v) for k, v in self.global_namespace.items() 
            if not k.startswith('_') and k != '__builtins__'
        }
        
        if not vars_dict:
            return [
                types.TextContent(
                    type="text",
                    text="No variables in current session."
                )
            ]
        
        # Format variables list
        var_list = "\n".join(f"{k} = {v}" for k, v in vars_dict.items())
        return [
            types.TextContent(
                type="text",
                text=f"Current session variables:\n\n{var_list}"
            )
        ]
  • Registration of the 'list_variables' tool in the list_tools handler, including its name, description, and empty input schema.
    types.Tool(
        name="list_variables",
        description="List all variables in the current session",
        inputSchema={
            "type": "object",
            "properties": {},
        },
    ),
  • Input schema for the 'list_variables' tool, which requires no parameters.
    inputSchema={
        "type": "object",
        "properties": {},
    },

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.4/5.0
Behavior2/5

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

With no annotations, the description must convey behavioral traits. It implies a read-only listing but does not state whether values are included, how the result is returned, or if there are side effects. 'Current session' is ambiguous and not elaborated.

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

Conciseness5/5

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

The description is a single, direct sentence with no wasted words. It is front-loaded and appropriately sized for a zero-parameter tool.

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

Completeness2/5

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

There is no output schema and no annotations, so the description should explain what the output looks like. It only says 'list all variables', leaving unclear whether the output is names only or names with values, and what format is used. For a simple tool this might be sufficient, but it lacks completeness.

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?

The tool has zero parameters, so the schema is trivially complete. The description does not need to explain parameter details; the baseline of 4 applies because there is nothing to clarify.

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 uses a specific verb 'List' and a clear resource 'variables', scoped to 'current session'. It obviously differs from sibling tools like execute_python and install_package, so purpose is unambiguous.

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?

No guidance is provided about when to use this tool versus alternatives. There is no mention of prerequisites, exclusions, or comparison with execute_python or install_package. The description only states the action, not the context of use.

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