---
title: "Wrenches"
description: "Reusable code snippets that let your assistant invoke MCP tools directly — write once, run many times."
updated: 2026-06-09
---

# Wrenches

## What are Wrenches?

Wrenches are reusable JavaScript functions stored in your organization. When your assistant needs to perform a multi-step operation — like pulling data from GitHub, transforming it, and posting a summary to Slack — you can package that logic into a Wrench instead of relying on the LLM to improvise it every time.

Think of a Wrench as a saved, versioned tool: the assistant writes it once, and can call it reliably in any future conversation.

> **Note:** Wrenches are organization-scoped. They belong to your assistant and respect its permissions. You can also share Wrenches across organizations in your organization.



---
## Why use Wrenches?

Without Wrenches, every time your assistant needs to perform a complex workflow it has to reason through each step from scratch — which is slower, less consistent, and harder to debug.

Wrenches solve this by:

- **Reducing repetition** — common workflows run from a single call
- **Improving reliability** — the logic is fixed and versioned, not regenerated
- **Enabling reuse** — share Wrenches across your organization's organizations
- **Supporting auditability** — every execution is logged with inputs, outputs, and console logs

---
## How Wrenches work

A Wrench is a JavaScript file that defines an `async function run(inputs)`. When executed, it runs in a sandboxed Node.js VM — no filesystem, no network access — but with full access to your connected MCP tools via two built-in helpers:

| Helper | Description |
|---|---|
| `callTool(serverId, toolName, params)` | Invoke any tool on a connected MCP server |
| `listTools(serverId)` | Discover available tools on a server |
| `console.log()` | Write to the execution log |

The function receives an `inputs` object and returns any value you choose.

### Example Wrench


```javascript
async function run(inputs) {
  // List available GitHub tools
  const tools = await listTools('github');
  console.log('Available tools:', tools);

  // Get contents of a file
  const result = await callTool('github', 'get_file_contents', {
    repository: inputs.repo,
    path: inputs.filePath,
  });

  return result;
}
```


---
## Versioning

Every time a Wrench is updated, a new version is created. You can:

- View version history
- Roll back to a previous version
- Set any version as the active one

This makes it safe to iterate — you can update a Wrench without losing your working baseline.

---
## Execution history

Every Wrench execution is recorded with:

- The inputs passed
- The output returned
- All `console.log()` output
- Timestamp and duration

Use the execution history to debug unexpected behavior or audit what ran and when.

---
## Creating a Wrench

Ask your assistant to create a Wrench. Provide:

1. A **name** — unique within your organization
2. A **description** — what the Wrench does
3. The **script** — the `async function run(inputs)` body
4. An optional **input schema** — describes the expected inputs (JSON Schema)
5. An optional **output schema** — describes the expected return value

The assistant will call `listTools` on your connected services first to confirm exact tool names before writing the script.

> **Warning:** Always have the assistant call `listTools(serverId)` within the Wrench script to confirm tool names at runtime. Tool names can change when services are updated.



---
## Sharing across organizations

Wrenches can be shared with other organizations in your organization. Shared Wrenches are read-only in the receiving organization — they run the active version from the owning organization.

---
## Security

Wrench scripts run in a sandboxed VM with restricted access:

- ❌ No filesystem access
- ❌ No direct network requests
- ❌ No access to environment variables or process
- ✅ MCP tool calls via `callTool()` only

This ensures Wrenches can only interact with services your organization has explicitly connected.
