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": {},
    },
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the action without behavioral details. It doesn't disclose if this is a read-only operation, what format the output takes (e.g., list of names vs. values), or any constraints like session dependencies. More context is needed for a mutation-aware agent.

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, clear sentence with no wasted words. It's front-loaded with the core action and scope, making it easy to parse quickly. Every part of the sentence contributes directly to understanding the tool's purpose.

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 simplicity (0 parameters, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks details on output format or behavioral context, which could be important for an agent. It meets basic needs but leaves gaps in 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 0 parameters, and schema description coverage is 100%, so no parameter documentation is needed. The description appropriately doesn't add param info, aligning with the schema. A baseline of 4 is given as it handles the zero-param case correctly without redundancy.

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 verb ('list') and resource ('variables'), specifying scope ('in the current session'). It's specific enough to understand the action, though it doesn't explicitly differentiate from sibling tools like execute_python or install_package, which perform different functions.

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 on when to use this tool versus alternatives. The description lacks context on prerequisites, such as whether a session must be active, or comparisons to other tools for variable management. It's a basic statement without usage instructions.

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

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