# pm_user_tool
{{< tier level="sovereign" note="Let agents use your installed user tools directly, without creating a workflow." >}}

Your build helpers, reporting scripts, and CLI adapters can serve both workflows and everyday agent requests. With `pm_user_tool`, an agent finds an installed action, reads the inputs it needs, and runs it through the same Valdr MCP connection it already uses.

This guide covers finding an action, running it, and handling a repeat request. To write or install a tool first, start with [Build User Tools](/valdr/docs/workflows/user-tools/).

## Before you start

Import a user-tool pack and make sure its runtime or CLI is installed on the machine running Valdr. Your agent's MCP permissions must allow `pm_user_tool`; inspecting tools and running them can be permitted separately.

The examples below use the Node text summary from the [starter pack](/valdr/docs/workflows/user-tools/starters/). It counts text without reading files or accessing the network.

For the current call reference and examples:

```text
pm_user_tool { action: "help" }
```

If your MCP connection does not expose `pm_user_tool`, check your Valdr version, Sovereign access, and the tools enabled for that session.

## Find and inspect an action

Search by what you want to do:

```text
pm_user_tool { action: "search", query: "text summary" }
```

Omit `query` to browse. Use `toolId` to narrow the results to one installed tool, or pass `data.nextOffset` as `offset` for the next page; `null` means there are no more pages. `limit` defaults to 20 and accepts 1–100. Results in `data.hits` identify the tool, action, selected revision, side effects, retry policy, and availability.

Read the action's inputs and outputs before running it:

```text
pm_user_tool {
  action: "describe",
  toolId: "valdr-tools.user.node",
  toolAction: "summarize"
}
```

`describe` returns the input and output schemas and execution limits in `data`. Searching and inspecting do not run the tool. `availability: available` means the installed action is supported; its runtime, credentials, and working directory must still be available when you run it.

## Run it

Generate a fresh request ID with `pm_generate_ulid {}`, then supply the action's input and an existing absolute working directory on the Valdr host:

```text
pm_user_tool {
  action: "run",
  toolId: "valdr-tools.user.node",
  toolAction: "summarize",
  input: { text: "Hello Valdr" },
  cwd: "/absolute/path/to/your/project",
  clientRequestId: "<fresh ULID>"
}
```

Replace the directory and request ID before calling. `toolAction` selects the installed action; `input` contains that action's own fields, including `{}` for actions with no inputs. Keep the generated `clientRequestId` for retries of this same request.

A successful call has `action: run` and `ok: true`. Read `data.result` for the action's output—here, `{"characters":11,"words":2,"lines":1}`. Other fields in `data` identify the selected revision, working directory, time limit, and whether a saved result was returned. Use the accompanying diagnostics to investigate execution problems.

The call waits for the tool to finish. Optional `timeoutSeconds` can shorten its configured time limit, up to the host maximum of 300 seconds; it cannot extend that limit. Configure your MCP client's request timeout to allow the expected run time plus startup and cleanup.

Tools run as your user on the machine running Valdr, using their configured environment and that machine's CLI sign-ins. The `run` call uses the installed tool's program and configuration; it accepts the action inputs described by `describe`. Review an action's effects before running it. See [Requests and Execution](/valdr/docs/workflows/user-tools/runtime/) for environment setup and sensitive-output guidance.

## Handle a failed call

A failed call has `ok: false` and an `error` with `code` and `message`. Inspect `error.started` to see whether execution began and `error.needsAttention` to see whether you need to check the outcome before retrying. Some failures also include execution diagnostics in `data`.

| Error | What to do |
| --- | --- |
| `tool_not_found`, `version_not_found`, or `action_not_found` | Search the installed catalog again and describe the selected action. Valdr does not fall back to another revision's action. |
| `invalid_request`, `invalid_input`, or `invalid_cwd` | Correct the call shape, action inputs, or host directory. Inputs must satisfy the schema returned by `describe`. |
| `runtime_unavailable` or `snapshot_unavailable` | Check the runtime and declared environment, or the installed tool's source, in **Workflows > Tools**. |
| `domain_error` | The program returned a handled failure. Read its message and check `needsAttention` before deciding to invoke it again. |
| `timed_out` or `cancelled` | Execution was interrupted. Check for completed external effects; interruption cannot undo them. |
| `request_conflict`, `tool_removed`, or `outcome_unknown` | Follow the repeat-request guidance below. Don't automatically generate a new ID to bypass the failure. |

## Choose a revision

By default, each call selects the most recently installed visible revision, rather than the highest version number. Pass an optional `revision` to `search`, `describe`, or `run` to select a particular installed version. Describe and run fail if that revision or action is missing, instead of falling back to an older one.

When adding a new workflow step, the Builder prefers the highest semantic version. Its default can therefore differ from a direct MCP call. Check the selected revision in either path.

Use the revision returned by `describe` when you want the same version label for `run`. An approved pack overwrite can replace the contents under that label, so publish changed tools with a new revision.

## If a response is lost

Repeat the same call with the **same `clientRequestId`**. Once Valdr has recorded the invocation, a completed result—success or failure—is returned with `data.replayed: true`, without starting the action again. Keep the tool, action, input, directory, revision selection, and timeout unchanged. Conflicting requests receive `request_conflict`.

The recorded invocation keeps its original tool content and effective timeout even after a newer revision is installed. If its original tool revision was removed from the visible catalog or replaced, replay returns `tool_removed`. Calls rejected before an invocation is recorded, such as invalid input, have no saved result to replay.

If the response says `outcome_unknown` or `error.needsAttention: true`, check what happened before making a new request. A duplicate call while the original is still running can also return `outcome_unknown`; it does not start a second process. After the original finishes, repeating its exact request can retrieve the saved result. Use a fresh ID only when you deliberately intend a new invocation.

## Use it in a workflow

For a reusable process, add the installed tool from the Builder's **User tools** group. The Builder records the selected revision, exact tool contents, and input/output schemas for the step. Use this route to add a workflow step; `pm_user_tool` is for direct agent calls. See [User Tool steps](/valdr/docs/workflows/steps/user-tool/).

## Try it with your agent

{{< prompts intro="With the starter pack imported, ask your agent:" >}}
Find the installed Node text summary tool, inspect its inputs, and summarize “Hello Valdr” using my project directory.
{{< /prompts >}}

