Skip to main content
Glama
@yawlabs/electron-mcp

@yawlabs/electron-mcp

Official
by YawLabs

electron_generate_preload_bridge

Read-onlyIdempotent

Generate a secure preload.ts and TypeScript window declarations to expose multiple main-process APIs via contextBridge.exposeInMainWorld, with security guidance.

Instructions

Generate a complete, secure preload.ts with contextBridge.exposeInMainWorld for multiple API methods. Produces the preload script, TypeScript declarations for window.electronAPI, and security best practices. Use this when you need to expose several main-process APIs to the renderer at once.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "methods": "<methods>"
    },
    "name": "electron_generate_preload_bridge"
  }
}

Input Schema

NameRequiredDescriptionDefault
methodsYesArray of methods to expose through the preload bridge
namespaceNoThe property name on window, e.g. 'electronAPI'. Defaults to 'electronAPI'.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.7.2
    • removedInput schema / additionalProperties
      Removed value: -false
    • removedInput schema / properties / methods / items / additionalProperties
      Removed value: -false
  2. Changed4 schema fields changedv1.2.15
    • addedInput schema / properties / methods / items / properties / args / pattern
      Added value: +"^[^`\\r\\n]*$"
    • addedInput schema / properties / methods / items / properties / name / pattern
      Added value: +"^[a-zA-Z_$][\\w$]*$"
    • addedInput schema / properties / methods / items / properties / returnType / pattern
      Added value: +"^[^`\\r\\n]*$"
    • addedInput schema / properties / namespace / pattern
      Added value: +"^[a-zA-Z_$][\\w$]*$"
  3. First observedv1.2.13

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, and idempotentHint=true, so the safety profile is covered. The description adds what the output contains (preload script, TypeScript declarations, security guidance), which is useful given no output schema. However, it never says whether files are written to disk or code is returned as text, nor any limits on method count — a meaningful gap for a generator.

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?

Three short sentences, front-loaded with the core action and artifact, followed by output contents and a usage trigger. Every sentence carries information; no filler or restatement of the tool name.

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?

For a two-parameter generator with no output schema, the description adequately says what is produced. It leaves open the delivery form (returned code versus written files), the 50-method cap, and whether existing preload files are touched — details an agent would want before invoking.

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 100%, with per-field descriptions and examples for name, channel, type, args, and returnType, so the schema carries parameter meaning. The description adds only the hint that 'window.electronAPI' is the exposed namespace, duplicating what the namespace parameter already documents. Baseline 3 applies.

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 artifact: 'Generate a complete, secure preload.ts with contextBridge.exposeInMainWorld.' The emphasis on 'multiple API methods' implicitly distinguishes it from single-channel scaffolding siblings, though it never names one. An agent knows exactly what artifact comes out.

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?

'Use this when you need to expose several main-process APIs to the renderer at once' gives a clear trigger condition, and 'at once' signals the batch-oriented case versus per-channel tools. No explicit when-not or named alternative is given, so it falls short of a 5.

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