vice-agent-tools
README.md
# Agent Tools for Vice
A [Vice Terminal](https://github.com/OxygenButBeta/vice) module that gives AI coding CLIs (**Claude Code**,
**OpenAI Codex** and **Antigravity** `agy`) extra tools that come from Vice and from other Vice
modules, over [MCP](https://modelcontextprotocol.io).
- Agents can notify you (also on your phone), ask you a question and wait for the answer, open a
file in a Vice preview tab or open Vice's git review for a folder.
- Any Vice module can offer its own tools to agents with a few lines of code (see
[For module authors](#for-module-authors)).
- The **Activity** tab shows what agents do with these tools live, per agent and extension, and
lets you **stop** a run at any time.
No npm dependencies: the module installs instantly.
## How it works
```
Claude Code / Codex / agy ──stdio (MCP)──▶ mcp/server.js ──named pipe──▶ Agent Tools (in Vice) ──▶ Vice / modules
```
The CLI starts `mcp/server.js` with Vice's own executable as plain Node (`ELECTRON_RUN_AS_NODE=1`).
The server forwards `tools/list` and `tools/call` to the Agent Tools hub running inside Vice.
**Tools are only offered while Vice is running.** If Vice is closed, the server answers with an
empty tool list (and tool calls return an error), so it never breaks the CLI.
## Enable it per agent
Open **Agent Tools → Agents** and switch on the agents you want. This adds one MCP server entry
named `vice-agent-tools` to the CLI's config — nothing else in the file is changed, and a
timestamped backup (`<file>.vice-agent-tools-backup-<time>`) is made next to the file before the
first edit:
| Agent | File | Entry |
| --- | --- | --- |
| Claude Code | `~/.claude.json` and `<profile>/.claude.json` of every Claude profile Vice manages | `mcpServers["vice-agent-tools"]` |
| Codex | `~/.codex/config.toml` | `[mcp_servers.vice-agent-tools]` (+ `.env`) |
| Antigravity | `~/.gemini/antigravity/mcp_config.json` | `mcpServers["vice-agent-tools"]` |
Nothing is registered by default. **Restart running agent sessions** after (un)registering — CLIs
load MCP servers at start. Uninstalling the module removes all entries again.
## Token cost
Every tool an agent can use is described to it in **every session** (name, description and input
schema), which costs context tokens even when the tool is never called. The **Tools** tab shows an
estimate per tool and the total (≈ characters / 4). Switch off what you don't need — per tool or
per extension. Disabled tools are not offered to agents at all.
The four built-ins cost about 330 tokens together.
## Built-in tools
| Tool | What it does |
| --- | --- |
| `vice_notify` | `{ title, message, phone? }` — desktop notification; `phone: true` also sends it to your Vice webhook (Discord / Slack / Telegram → phone). |
| `vice_ask_user` | `{ question, options? }` — shows the question in the Agent Tools tab (and notifies you), waits up to 10 minutes and returns `{ answer }` (or `{ timedOut: true }` / `{ dismissed: true }`). |
| `vice_open_preview` | `{ path, line? }` — opens a file in a Vice preview tab (image, video, PDF, markdown, code). Relative paths are resolved against the agent's working folder. |
| `vice_open_diff` | `{ folder }` — opens Vice's git diff / review tab for a repository. |
## Activity and Stop
When an agent starts calling tools of an extension (a module, or Vice for the built-ins), Agent
Tools starts a **sequence** for that agent session and extension and shows it in the Activity tab
(and opens the tab — "Open when an agent uses tools", on by default). Each card shows the calls in
order with their arguments summary, status, duration and the result (click a call). Questions from
`vice_ask_user` are answered right in the card.
A sequence ends after 2 minutes without calls or when the agent session ends. **Stop** aborts the
running calls of a sequence (the agent gets the tool error *"Stopped by the user in Vice"*) and
refuses further calls from that agent session to that extension until you click **Allow again** or
the session ends. **Stop all** does this for every running sequence.
## For module authors
Your module can offer tools to agents without depending on Agent Tools: if it is not installed,
your module simply works without them.
**1. Declare the optional dependency** in `vice-module.json` (shown as "Works with Agent Tools"):
```json
{ "uses": ["agent-tools"], "backgroundStart": true }
```
`backgroundStart` is only needed if your tools should be registered right after Vice starts
(otherwise they are registered when your backend first runs; Agent Tools remembers registered tools
and Vice starts your backend when one is called).
**2. Implement each tool** as an export named `tool:<name>`, and **register** the specs:
```js
const vice = require('vice');
const TOOLS = [
{
name: 'upload_build', // agents see it as "<your module id>_upload_build"
description: 'Upload the latest build to Steam.', // keep it short: it costs tokens in every session
inputSchema: { // JSON Schema of the arguments
type: 'object',
properties: { branch: { type: 'string' } },
required: ['branch'],
},
timeoutMs: 10 * 60_000, // optional, default 60 s, max 30 min
openUi: true, // optional: also open your tab when an agent starts using it
},
];
// args = the agent's arguments; meta = { callId, agent, sessionId }
vice.exports.handle('tool:upload_build', async (ctx, args, meta) => {
// ctx.from === 'agent-tools'
return { uploaded: true, branch: args.branch }; // string, any JSON value, or MCP { content: [...] }
});
// Optional: called (best effort) when the user presses Stop while a call is running.
vice.exports.handle('tool:$cancel', (ctx, { callId }) => { /* abort the work of callId */ });
async function registerTools() {
if (!vice.modules.isAvailable('agent-tools')) return;
await vice.modules.call('agent-tools', 'registerTools', [TOOLS]); // -> { registered, rejected }
}
registerTools();
vice.on('modules-change', registerTools); // Agent Tools installed / enabled later
```
Rules:
- Tool names are namespaced as `<moduleId>_<name>` (characters outside `a-zA-Z0-9_-` become `_`,
max 64). Calling `registerTools` again **replaces** your module's set; `unregisterTools` removes it.
- A tool call runs `vice.modules.call('<your id>', 'tool:<name>', [args, meta], { timeoutMs })`.
Throwing an error returns it to the agent as a tool error.
- Return a string, any JSON value (sent as JSON text) or `{ content: [...], isError? }` with MCP
content blocks (e.g. images).
- Tools of disabled or uninstalled modules are hidden automatically.
Other exports of Agent Tools:
| Export | Who may call | Result |
| --- | --- | --- |
| `registerTools(specs)` / `unregisterTools()` | any module (for itself) | `{ registered, rejected }` / `boolean` |
| `getSourceState(id)` | any module | `{ enabled, toolCount, tokens }` of a module's tools |
| `setSourceEnabled(id, on)` | only the module `id` itself | switch all of your tools on/off |
A complete example lives in [`examples/demo-tools`](examples/demo-tools).
## Security notes
- A tool call runs module code (or Vice actions) **with your Windows user's rights** — the same as
everything a module does. Only install modules you trust.
- The agents' own permission prompts still apply: Claude Code / Codex / agy ask before calling MCP
tools according to their settings.
- The pipe is local to your machine; every connection must present a random token that Agent
Tools writes to its private data folder (`hub.json`) at start.
- The activity log keeps only a short, secret-redacted summary of arguments, in memory.
## Development
`npm test` (or `node --test`) runs the unit tests: the targeted `.claude.json` editor (it never
re-serializes the whole file, which keeps duplicate keys and formatting intact), the TOML editor,
the Antigravity editor, the MCP server against a fake hub, the registry, token estimates and
sequences. Tests that use copies of your real config files are skipped when those files don't exist.
To test registration without touching your real configs, set the storage key `devConfigHome` in
`%APPDATA%\Vice Terminal\module-data\agent-tools\vice-storage.json` to a folder that contains copies
(`.claude.json`, `.codex\config.toml`, `.gemini\antigravity\mcp_config.json`).
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues