Skip to main content
Glama

Run Code in Browser

run_code_in_browser
Destructive

Run a TypeScript snippet inside the running app's preview document in the user's open Floot editor and return the string it returns. document and window are the app's own DOM: measure elements, read computed styles and rendered output, or click a button and read the result. Runs at the project root, so project files import by relative path. The same _floot helpers as run_code_in_vm are available. Needs the project open in the editor (fails fast otherwise); prefer run_code_in_vm when the DOM is not needed. Typed text input and long multi-step flows are unreliable here: leave those to the user.

Input Schema

NameRequiredDescriptionDefault
codeYesA TypeScript module that exports a default async function returning a string; that string is the tool result. Runs at the project root, so import other files by relative path. No top-level `return` (it's a module, not a function body) and no React hooks (not a component). Example: export default async function () { const el = document.querySelector("main"); return JSON.stringify({ width: el?.clientWidth ?? null }); }
projectIdYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations declare readOnly=false, destructive=true, openWorld=true, so the description must add the safety context: it discloses that code runs live in the user's open editor, can click buttons and mutate the page, fails fast if the project isn't open, and that input/long flows are unreliable. It doesn't spell out whether mutations are undoable, but the interaction constraints are unusually well surfaced for a live-execution tool.

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?

Front-loads what the tool does, then context, then the sibling preference and the reliability caveat. Dense but every sentence carries a distinct point. Slight awkwardness in 'return the string it returns' but overall tight.

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

Completeness4/5

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

For a 2-param live-execution tool with no output schema and no destructive-safety annotation detail, the description covers execution environment, preconditions, failure mode, sibling choice, and known unreliabilities. Only gap: what exactly projectId addresses given the editor is already open and how the returned string is surfaced.

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?

Schema coverage is 50%: code is well documented in-schema (module shape, no top-level return, example), but projectId has no description anywhere. The description compensates partially by explaining the execution context ('runs at the project root, so project files import by relative path') which gives meaning to projectId implicitly. Baseline 3 is right.

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?

States a specific verb (run TypeScript) and resource (the app's preview document in the editor) and contrasts it with the sibling run_code_in_vm by scope ('document and window are the app's own DOM' vs VM). An agent can select between them without opening the schema.

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

Usage Guidelines5/5

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

Explicit when-to-use (measure DOM, read computed styles, click and read result), explicit precondition ('needs the project open in the editor (fails fast otherwise)'), explicit alternative ('prefer run_code_in_vm when the DOM is not needed'), and explicit exclusions ('typed text input and long multi-step flows are unreliable here').

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources