Skip to content

Commit 5a37fb9

Browse files
chrischallclaude
andauthored
fix(deps): require @chrischall/mcp-utils 2.15.0 so confirmed writes work in opencode v2 (#196)
## Problem In opencode v2, `tempo_approve_timesheet` (and every other confirm-gated write) hangs. opencode says it can show confirmation prompts, but it files them under a hard-coded `"global"` owner that the chat view never displays (anomalyco/opencode#51856). The server waits for an answer that never comes. ## Change - Requires `@chrischall/mcp-utils` **2.15.0**, which adds `MCP_CONFIRM_ELICITATION=off` (chrischall/mcp-utils#356). With it set, no prompt is sent. Every client gets the existing two-step flow: a preview plus `confirmToken`, then the repeat call carrying the token. - README: documents the variable, with an opencode `environment` config example. The skill notes it too. - Test: for each of the five timesheet actions, a client that *declares* elicitation, with `MCP_CONFIRM_ELICITATION=off`, gets the preview and no request; the token call then makes exactly one POST. These tests fail on 2.14.0 and pass on 2.15.0. ## Verification - `npm test` (tsc typecheck + vitest): 224/224. - End-to-end in the real opencode 2.0.11 TUI against this branch's build, with a stubbed Tempo API and `"environment": {"MCP_CONFIRM_ELICITATION": "off"}`: - no `elicitation/create` was sent; - the first call returned `confirmation-required`; - the token call made exactly one `POST /4/timesheet-approvals/user/…/approve`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01BcWMYdb6qKyL8FUbmZjg52 Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 0164a38 commit 5a37fb9

6 files changed

Lines changed: 54 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ Every write (create/update/delete, and the timesheet submit/approve/reject/reope
1212

1313
| variable | default | |
1414
|---|---|---|
15-
| `MCP_CONFIRM_MODE` | `ask-user` | What a write does on a client that cannot show a confirmation prompt (claude.ai, Claude Desktop). `ask-user`: two steps — the first call does nothing and returns a preview plus a token, and the model must get your approval in chat before calling again with it. `auto`: the same two steps, but the model may use the token after reviewing the preview itself. `refuse`: writes are refused on such clients. A client that can show prompts (Claude Code) always gets the real prompt. An unrecognised value is treated as `refuse`. |
15+
| `MCP_CONFIRM_MODE` | `ask-user` | What a write does on a client that cannot show a confirmation prompt (claude.ai, Claude Desktop). `ask-user`: two steps — the first call does nothing and returns a preview plus a token, and the model must get your approval in chat before calling again with it. `auto`: the same two steps, but the model may use the token after reviewing the preview itself. `refuse`: writes are refused on such clients. A client that can show prompts (Claude Code) gets the real prompt unless `MCP_CONFIRM_ELICITATION=off`. An unrecognised value is treated as `refuse`. |
16+
| `MCP_CONFIRM_ELICITATION` | `on` | `off` never shows a confirmation prompt, so every client gets the `MCP_CONFIRM_MODE` two-step flow. **Set it for opencode v2**: it claims to support prompts but never displays them, so writes (including timesheet approvals) hang. Any other value stays `on`. |
1617
| `MCP_CONFIRM_TTL_SECONDS` | `600` | How long a token stays valid. |
1718
| `MCP_CONFIRM_SECRET` | random per process | Signing key; set it only if tokens must survive a server restart. |
19+
20+
In opencode, set it in the server's `environment` block:
21+
22+
```json
23+
{
24+
"mcp": {
25+
"servers": {
26+
"tempo": {
27+
"type": "local",
28+
"command": ["npx", "-y", "tempo-api-mcp"],
29+
"environment": { "TEMPO_API_TOKEN": "…", "MCP_CONFIRM_ELICITATION": "off" }
30+
}
31+
}
32+
}
33+
}
34+
```

‎package-lock.json‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"typecheck": "tsc -p tsconfig.json --noEmit"
3333
},
3434
"dependencies": {
35-
"@chrischall/mcp-utils": "^2.14.0",
35+
"@chrischall/mcp-utils": "^2.15.0",
3636
"@modelcontextprotocol/server": "^2.3.0",
3737
"dotenv": "^18.0.2",
3838
"zod": "^4.6.5"

‎skills/tempo-api-mcp/SKILL.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ Desktop) gets two steps instead: the first call does nothing and returns
234234
`status: "confirmation-required"`, a `preview` of exactly what would be sent
235235
(method, path, `willSend` body, `willSendQuery`), and a `confirmToken`; only a
236236
repeat call with the same arguments plus that `confirmToken` performs the write.
237+
With `MCP_CONFIRM_ELICITATION=off` (needed on opencode v2, which never shows
238+
the prompt) every client gets the two steps.
237239

238240
- Under the default `MCP_CONFIRM_MODE=ask-user`, show the user the preview and
239241
get their approval in chat before making the second call.

‎tests/tools/_confirm-helpers.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ export const NO_ELICIT_CTX = {
1010
mcpReq: { envelope: { 'io.modelcontextprotocol/clientCapabilities': {} } },
1111
};
1212

13+
/** A ServerContext for a caller that declares form elicitation (it can be prompted). */
14+
export const ELICIT_CTX = {
15+
mcpReq: { envelope: { 'io.modelcontextprotocol/clientCapabilities': { elicitation: { form: {} } } } },
16+
};
17+
1318
type Cb = (args: Record<string, unknown>, ctx: unknown) => Promise<CallToolResult>;
1419

1520
/** Phase 1 only: the preview a gated tool returns without writing. */

‎tests/tools/projects.test.ts‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect, vi } from 'vitest';
22
import { register } from '../../src/tools/projects.js';
3-
import { callConfirmed, callPreview } from './_confirm-helpers.js';
3+
import { callConfirmed, callPreview, ELICIT_CTX } from './_confirm-helpers.js';
44
import type { TempoClient } from '../../src/client.js';
55
import type { McpServer } from '@modelcontextprotocol/server';
66

@@ -317,6 +317,29 @@ describe.each(TIMESHEET_ACTION_TOOLS)('%s', (toolName, action) => {
317317
expect(parsed.willSendQuery).toEqual({ from: '2024-01-01' });
318318
});
319319

320+
// opencode 2.0.x declares form elicitation but never renders the prompt, so
321+
// the call hangs; MCP_CONFIRM_ELICITATION=off puts it on the token flow.
322+
it('with MCP_CONFIRM_ELICITATION=off, a client that declares elicitation gets the token flow', async () => {
323+
vi.stubEnv('MCP_CONFIRM_ELICITATION', 'off');
324+
try {
325+
const client = makeClient({ status: { key: 'APPROVED' } });
326+
const { server, tools } = makeMockServer();
327+
register(server, client);
328+
const cb = findTool(tools, toolName).cb as (a: Record<string, unknown>, c: unknown) => Promise<{ content: { text: string }[] }>;
329+
const args = { accountId: 'user123', from: '2024-01-01' };
330+
const phase1 = JSON.parse((await cb(args, ELICIT_CTX)).content[0].text);
331+
expect(phase1.status).toBe('confirmation-required');
332+
expect(client.request).not.toHaveBeenCalled();
333+
await cb({ ...args, confirmToken: phase1.confirmToken }, ELICIT_CTX);
334+
expect(client.request).toHaveBeenCalledTimes(1);
335+
expect(client.request).toHaveBeenCalledWith(
336+
'POST', `/4/timesheet-approvals/user/user123/${action}`, undefined, { from: '2024-01-01', to: undefined },
337+
);
338+
} finally {
339+
vi.unstubAllEnvs();
340+
}
341+
});
342+
320343
it('is marked as a mutating tool', () => {
321344
const { server, tools } = makeMockServer();
322345
register(server, makeClient());

0 commit comments

Comments
 (0)