Skip to main content
Glama

run_script

Execute JavaScript scripts in LibreSprite to automate pixel art creation and retrieve console output.

Instructions

        Run a JavaScript script inside Libresprite.

        IMPORTANT: Make sure you are well versed with the documentation and examples provided in the resources `docs:reference` and `docs:examples`.

        Args:
            script: The script to execute

        Returns:
            Console output
        

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scriptYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Registers the 'run_script' tool via the FastMCP 'tool' decorator. This is where the tool is declared as an MCP tool with its name, schema (script: str), and handler delegation.
    @self.mcp.tool()
    def run_script(script: str, ctx: Context) -> str:
        """
        Run a JavaScript script inside Libresprite.
    
        IMPORTANT: Make sure you are well versed with the documentation and examples provided in the resources `docs:reference` and `docs:examples`.
    
        Args:
            script: The script to execute
    
        Returns:
            Console output
        """
        return self._libresprite_proxy.run_script(script, ctx)
  • Handler function that receives the script string and context, delegates execution to the proxy's run_script method.
    @self.mcp.tool()
    def run_script(script: str, ctx: Context) -> str:
        """
        Run a JavaScript script inside Libresprite.
    
        IMPORTANT: Make sure you are well versed with the documentation and examples provided in the resources `docs:reference` and `docs:examples`.
    
        Args:
            script: The script to execute
    
        Returns:
            Console output
        """
        return self._libresprite_proxy.run_script(script, ctx)
  • Helper/proxy method that sends the script via an HTTP relay server (Flask), blocks waiting for the output from the remote Libresprite instance, and returns the result.
    def run_script(self, script: str, ctx: Context) -> str:
        """
        Run a script in the execution context.
    
        WARNING: This method is synchronous and blocking.
    
        Args:
            script: The script to execute
        """
        # This proxy only allows one script to be executed at a time
        if self._lock:
            ctx.error("Script execution is already in progress...")
            raise RuntimeError("Script execution is already in progress.")
    
        # Sending the script
        ctx.info("Sending script to libresprite...")
        self._lock = True
        self._script = script
        self._script_event.set()
    
        # Waiting for execution
        if not self._output_event.wait(timeout=15):
            ctx.warning("This is taking longer than usual, make sure the user has the Libresprite application with the remote script running?")
        self._output_event.wait()
        self._output_event.clear()
    
        # Return the output
        ctx.info("Script execution completed, checking the logs...")
        output = self._output
        self._output = None
        self._lock = False
        return output
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It only mentions executing a script and returning console output, omitting critical details like potential data mutation, security risks, or error handling. For a tool that runs arbitrary code, this is insufficient.

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 concise at 5 lines. It is front-loaded with the purpose, followed by an important warning, then parameter and return sections. Every part serves a purpose, though the warning could be shortened.

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?

Given the potential complexity of running scripts, the description lacks context on failure modes, timeouts, or permissions. The existence of an output schema reduces the need to explain return values, but behavioral gaps remain, making it incomplete.

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 input schema has 0% description coverage, so the parameter 'script' is clarified only in the description as 'The script to execute.' This adds meaning but is minimal and does not provide constraints or examples.

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 clearly states 'Run a JavaScript script inside Libresprite,' which is a specific verb-resource combination. There are no sibling tools, so differentiation is not required.

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

Usage Guidelines3/5

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

The description includes an IMPORTANT note about consulting documentation, which implies a prerequisite but does not explicitly state when to use the tool or when to avoid it. No alternatives exist, so the guidance is minimal.

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/Snehil-Shah/libresprite-mcp'

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