Skip to main content
Glama

Execute Code

rlm_execute_code

Execute JavaScript code to manipulate and aggregate data, access context, retrieve metadata, manage variables, and format output.

Instructions

Execute JavaScript code in the session's REPL environment.

Available functions:

  • print(...args) - Output text

  • getContext(id) - Get context content

  • getContextMetadata(id) - Get context metadata

  • len(str), slice(str,s,e), split(str,sep), join(arr,sep)

  • search(pattern,text,flags), findAll(pattern,text), replace(text,pattern,repl)

  • range(start,end,step), map(arr,fn), filter(arr,fn), reduce(arr,fn,init)

  • setVar(name,value), getVar(name), listVars()

  • setAnswer(content,ready), getAnswer()

  • JSON.parse(), JSON.stringify()

Use this for custom data manipulation and aggregation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesJavaScript code to execute
session_idNoSession ID
Behavior3/5

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

Annotations indicate the tool is not read-only, idempotent, or destructive, which sets a basic expected behavior. The description adds a list of available functions, but does not elaborate on side effects (e.g., modifying session state via setVar) or execution semantics. It does not contradict the annotations, but more detail would improve transparency.

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 front-loaded with the core purpose and includes a structured list of available functions. The function list is lengthy but relevant, and there is no redundant text. It could be slightly more concise but is well-organized.

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?

The tool has no output schema, so the description should ideally explain what the execution returns. It does not. It also omits information about state mutation effects. The function list and use case are helpful, but the lack of return behavior and side-effect disclosure leaves gaps for a code execution tool.

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?

Schema coverage is 100%, so the schema documents both parameters. The description adds value by listing helper functions and emphasizing custom data manipulation, giving the agent a sense of what the 'code' parameter should contain and what is possible, beyond the schema's simple 'JavaScript code to execute'.

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 'Execute JavaScript code in the session's REPL environment' with a specific verb and resource. It also includes a use case ('custom data manipulation and aggregation') that differentiates it from sibling tools which perform more specific operations like searching or variable management.

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

Usage Guidelines4/5

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

The description explicitly says 'Use this for custom data manipulation and aggregation,' giving clear guidance on when to use this tool. It does not explicitly mention when not to use it or name alternative tools, but the use case is specific enough, earning a 4 rather than 5.

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/win10ogod/RLM-MCP'

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