Skip to main content
Glama

webview_execute_js

[Tauri Apps Only] Execute JavaScript in a Tauri app's webview context. Requires active driver_session. Has access to window.TAURI. If you need a return value, it must be JSON-serializable.

Instructions

[Tauri Apps Only] Execute JavaScript in a Tauri app's webview context. Requires active driver_session. Has access to window.TAURI. If you need a return value, it must be JSON-serializable. For functions that return values, use an IIFE: "(() => { return 5; })()" not "() => { return 5; }". Accepts an optional timeout parameter (milliseconds) for long-running scripts. Timeout errors will identify which layer timed out (transport, script self-race, or Rust eval). Targets the only connected app, or the default app if multiple are connected. Specify appIdentifier (port or bundle ID) to target a specific app. For browser JS execution, use Chrome DevTools MCP instead.

Input Schema

NameRequiredDescriptionDefault
argsNoArguments to pass to the script
scriptYesJavaScript code to execute in the webview context. If returning a value, it must be JSON-serializable. For functions that return values, use IIFE syntax: "(() => { return value; })()" not "() => { return value; }"
timeoutNoExecution timeout in milliseconds
windowIdNoWindow label to target (defaults to "main")
appIdentifierNoApp port or bundle ID to target. Defaults to the only connected app or the default app if multiple are connected.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.0.1
    • addedInput schema / properties / timeout
      Added value: +{
      +  "description": "Execution timeout in milliseconds",
      +  "exclusiveMinimum": 0,
      +  "type": "integer"
      +}
  2. Addedv0.11.1

TDQS

A4.5/5.0
Behavior5/5

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

Annotations only supply safety hints (readOnlyHint=false, destructiveHint=false, openWorldHint=false); the description carries the real behavioral load. It discloses the auth/session prerequisite, the execution environment ('Has access to window.__TAURI__'), return-value constraints (JSON-serializable, IIFE requirement), and error semantics (timeouts identify the failing layer: transport, script self-race, or Rust eval). This is substantial context beyond structured fields.

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-loaded with the scope tag and core action, and nearly every sentence earns its place (prerequisite, IIFE, timeout, targeting, alternative). It is somewhat dense at nine sentences in one block, and the IIFE example is repeated verbatim from the schema description, a minor redundancy.

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

Completeness5/5

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

There is no output schema, so the description correctly covers return handling (JSON-serializable values, IIFE for functions), timeout behavior, prerequisites, and app targeting. An agent has everything needed to invoke this correctly without opening other tools.

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 baseline is 3, but the description adds semantics the schema lacks: it explains timeout error behavior (which layer timed out) and the default targeting logic for appIdentifier when multiple apps are connected. The IIFE note duplicates the script field's schema description rather than extending it.

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?

States a specific verb and resource ('Execute JavaScript in a Tauri app's webview context') with an explicit scope qualifier ('[Tauri Apps Only]'), so the domain is unambiguous. It does not, however, explicitly contrast with the sibling ipc_execute_command, which is the nearest adjacent capability; the only alternative named (Chrome DevTools MCP) is not a sibling tool.

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?

Gives a prerequisite ('Requires active driver_session'), targeting rules ('Targets the only connected app, or the default app if multiple are connected', plus appIdentifier for a specific app), and an explicit exclusion/alternative ('For browser JS execution, use Chrome DevTools MCP instead'). All routing decisions an agent needs are stated.

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