verdo-mcp 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -8
- package/dist/definitions.d.ts +781 -0
- package/dist/definitions.js +389 -0
- package/dist/index.js +1 -1
- package/dist/tools.d.ts +27 -112
- package/dist/tools.js +125 -188
- package/package.json +3 -1
package/dist/tools.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
// Verdo MCP tools — wraps the Zapier REST API (apps/verdo-web/app/api/zapier/*)
|
|
2
2
|
// with agent-friendly descriptions and error messages that help agents self-remedy.
|
|
3
|
+
// The definitions and the text each tool returns live in definitions.ts, shared with
|
|
4
|
+
// the remote server at verdo.ink/api/mcp.
|
|
3
5
|
//
|
|
4
|
-
// Guardrail: the agent proposes, a person decides. No tool here invites, notifies,
|
|
5
|
-
//
|
|
6
|
-
//
|
|
6
|
+
// Guardrail: the agent proposes, a person decides. No tool here invites, notifies, settles
|
|
7
|
+
// or picks an outcome. Writes (2.0.0): create_decision (sends no participants), and, for the
|
|
8
|
+
// caller's own request, cancel_decision and edit_decision (/api/v1/decisions/{id}/...). There
|
|
9
|
+
// is no reject tool: rejecting is the human approver's call. get_close_summary only reads.
|
|
10
|
+
import { AUTHORITY_MODES, DEFAULT_DEADLINE_HOURS, METHODS, formatDecision, listText, proposedText, cancelledText, editedText, closeSummaryText, toolDefinitions, unknownToolText, precedentSection, precedentText, searchText, } from "./definitions.js";
|
|
11
|
+
export { AUTHORITY_MODES, METHODS, toolDefinitions };
|
|
7
12
|
const VERDO_API = process.env.VERDO_API_URL ?? "https://verdo.ink/api";
|
|
8
13
|
const text = (t, isError = false) => ({
|
|
9
14
|
content: [{ type: "text", text: t }],
|
|
@@ -39,10 +44,6 @@ function agentError(action, status, data) {
|
|
|
39
44
|
return text(`Could not ${action}: ${enriched}${retry}`, true);
|
|
40
45
|
}
|
|
41
46
|
// ---- Tool implementations ----
|
|
42
|
-
// Values the API accepts (DB checks in migrations 0041 and 0042). Owner and approver
|
|
43
|
-
// modes need a named person, which this API cannot set, so they are not offered.
|
|
44
|
-
export const METHODS = ["single_choice", "ranked_choice", "approval", "dot"];
|
|
45
|
-
export const AUTHORITY_MODES = ["majority", "consensus"];
|
|
46
47
|
export async function createDecision(args, store) {
|
|
47
48
|
const apiKey = await store.get();
|
|
48
49
|
if (!apiKey)
|
|
@@ -54,27 +55,59 @@ export async function createDecision(args, store) {
|
|
|
54
55
|
title: args.title,
|
|
55
56
|
options: args.options,
|
|
56
57
|
method: args.method ?? "single_choice",
|
|
57
|
-
deadline_hours: args.deadline_hours ??
|
|
58
|
+
deadline_hours: args.deadline_hours ?? DEFAULT_DEADLINE_HOURS,
|
|
58
59
|
authority_mode: args.authority_mode ?? "majority",
|
|
59
60
|
anonymous: args.anonymous ?? false,
|
|
61
|
+
...(args.idempotency_key !== undefined ? { idempotency_key: args.idempotency_key } : {}),
|
|
62
|
+
...(args.tags !== undefined ? { tags: args.tags } : {}),
|
|
63
|
+
...(args.source_agent !== undefined ? { source_agent: args.source_agent } : {}),
|
|
60
64
|
}),
|
|
61
65
|
});
|
|
62
66
|
if (!ok)
|
|
63
67
|
return agentError("create the decision", status, data);
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
const meta = { created: data.created !== false, requestFingerprint: typeof data.request_fingerprint === "string" ? data.request_fingerprint : null };
|
|
69
|
+
// A replay (same idempotency_key, decision still open): nothing new to look up.
|
|
70
|
+
if (!meta.created)
|
|
71
|
+
return text(proposedText(String(data.id), String(data.url), args, meta));
|
|
72
|
+
// Prompt 64: up to 3 previously decided decisions with a similar title (reference only;
|
|
73
|
+
// a failed lookup never fails the create).
|
|
74
|
+
let precedent = [];
|
|
75
|
+
try {
|
|
76
|
+
const found = await verdoFetch(`/zapier/decisions/precedent?query=${encodeURIComponent(args.title)}&limit=4`, apiKey);
|
|
77
|
+
if (found.ok)
|
|
78
|
+
precedent = (found.data.decisions ?? []).filter((p) => p.id !== String(data.id)).slice(0, 3);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
precedent = [];
|
|
82
|
+
}
|
|
83
|
+
return text(proposedText(String(data.id), String(data.url), args, meta) + precedentSection(precedent));
|
|
84
|
+
}
|
|
85
|
+
// Read-only. Past decided decisions, newest first: records, never consent.
|
|
86
|
+
export async function searchDecisions(args, store) {
|
|
87
|
+
const apiKey = await store.get();
|
|
88
|
+
if (!apiKey)
|
|
89
|
+
return noKeyError();
|
|
90
|
+
const query = args.query.trim();
|
|
91
|
+
if (!query)
|
|
92
|
+
return text("Could not search decisions: query is required (words to look for in past decision titles).", true);
|
|
93
|
+
const qs = `?query=${encodeURIComponent(query)}${args.limit !== undefined ? `&limit=${encodeURIComponent(String(args.limit))}` : ""}`;
|
|
94
|
+
const { ok, status, data } = await verdoFetch(`/zapier/decisions/precedent${qs}`, apiKey);
|
|
95
|
+
if (!ok)
|
|
96
|
+
return agentError("search decisions", status, data);
|
|
97
|
+
return text(searchText((data.decisions ?? []), query));
|
|
98
|
+
}
|
|
99
|
+
// Read-only. One past decision's record: a historical record, not consent.
|
|
100
|
+
export async function getPrecedent(args, store) {
|
|
101
|
+
const apiKey = await store.get();
|
|
102
|
+
if (!apiKey)
|
|
103
|
+
return noKeyError();
|
|
104
|
+
const { ok, status, data } = await verdoFetch(`/zapier/decisions/${encodeURIComponent(args.decision_id)}/precedent`, apiKey);
|
|
105
|
+
if (!ok)
|
|
106
|
+
return agentError("read the past decision", status, data);
|
|
107
|
+
const d = data.precedent;
|
|
108
|
+
if (!d)
|
|
109
|
+
return text("Past decision data not available.", true);
|
|
110
|
+
return text(precedentText(d));
|
|
78
111
|
}
|
|
79
112
|
export async function checkDecision(args, store) {
|
|
80
113
|
const apiKey = await store.get();
|
|
@@ -92,23 +125,26 @@ export async function listDecisions(args, store) {
|
|
|
92
125
|
const apiKey = await store.get();
|
|
93
126
|
if (!apiKey)
|
|
94
127
|
return noKeyError();
|
|
95
|
-
const
|
|
128
|
+
const params = new URLSearchParams();
|
|
129
|
+
if (args.query)
|
|
130
|
+
params.set("query", args.query);
|
|
131
|
+
if (args.lifecycle_status?.length)
|
|
132
|
+
params.set("lifecycle_status", args.lifecycle_status.join(","));
|
|
133
|
+
if (args.tags?.length)
|
|
134
|
+
params.set("tags", args.tags.join(","));
|
|
135
|
+
if (args.source_agent)
|
|
136
|
+
params.set("source_agent", args.source_agent);
|
|
137
|
+
if (args.notification_status)
|
|
138
|
+
params.set("notification_status", args.notification_status);
|
|
139
|
+
const qs = params.toString() ? `?${params.toString()}` : "";
|
|
96
140
|
const { ok, status, data } = await verdoFetch(`/zapier/decisions/search${qs}`, apiKey);
|
|
97
141
|
if (!ok)
|
|
98
142
|
return agentError("list decisions", status, data);
|
|
99
|
-
|
|
100
|
-
if (decisions.length === 0) {
|
|
101
|
-
return text(args.query ? `No decisions found matching "${args.query}".` : "No decisions in this workspace.");
|
|
102
|
-
}
|
|
103
|
-
const lines = [`${decisions.length} decision${decisions.length === 1 ? "" : "s"} found:`, ``];
|
|
104
|
-
for (const d of decisions) {
|
|
105
|
-
lines.push(`- [${d.status}] ${d.title} (id: ${d.id})`);
|
|
106
|
-
}
|
|
107
|
-
return text(lines.join("\n"));
|
|
143
|
+
return text(listText((data.decisions ?? []), args.query));
|
|
108
144
|
}
|
|
109
145
|
// Read-only. An agent never closes a decision: this tells it who makes the call and
|
|
110
146
|
// where. It only GETs the decision; no mutating route is called.
|
|
111
|
-
export async function
|
|
147
|
+
export async function getCloseSummary(args, store) {
|
|
112
148
|
const apiKey = await store.get();
|
|
113
149
|
if (!apiKey)
|
|
114
150
|
return noKeyError();
|
|
@@ -118,27 +154,37 @@ export async function requestClose(args, store) {
|
|
|
118
154
|
const d = data.decision;
|
|
119
155
|
if (!d)
|
|
120
156
|
return text("Decision data not available.", true);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
157
|
+
return text(closeSummaryText(d));
|
|
158
|
+
}
|
|
159
|
+
// 2.0.0. Withdraw the caller's own draft or open decision. Full-access keys only.
|
|
160
|
+
export async function cancelDecision(args, store) {
|
|
161
|
+
const apiKey = await store.get();
|
|
162
|
+
if (!apiKey)
|
|
163
|
+
return noKeyError();
|
|
164
|
+
const { ok, status, data } = await verdoFetch(`/v1/decisions/${encodeURIComponent(args.decision_id)}/cancel`, apiKey, {
|
|
165
|
+
method: "POST",
|
|
166
|
+
body: JSON.stringify(args.reason !== undefined ? { reason: args.reason } : {}),
|
|
167
|
+
});
|
|
168
|
+
if (!ok)
|
|
169
|
+
return agentError("cancel the decision", status, data);
|
|
170
|
+
return text(cancelledText(args.decision_id, `${VERDO_API.replace(/\/api$/, "")}/dashboard/d/${args.decision_id}`));
|
|
171
|
+
}
|
|
172
|
+
// 2.0.0. Revise the caller's own draft or open decision. A change voids the votes cast so far.
|
|
173
|
+
export async function editDecision(args, store) {
|
|
174
|
+
const apiKey = await store.get();
|
|
175
|
+
if (!apiKey)
|
|
176
|
+
return noKeyError();
|
|
177
|
+
const { decision_id, ...edit } = args;
|
|
178
|
+
const { ok, status, data } = await verdoFetch(`/v1/decisions/${encodeURIComponent(decision_id)}/edit`, apiKey, { method: "POST", body: JSON.stringify(edit) });
|
|
179
|
+
if (!ok)
|
|
180
|
+
return agentError("edit the decision", status, data);
|
|
181
|
+
return text(editedText(decision_id, {
|
|
182
|
+
changed: data.changed === true,
|
|
183
|
+
votesVoided: typeof data.votes_voided === "number" ? data.votes_voided : 0,
|
|
184
|
+
requestFingerprint: typeof data.request_fingerprint === "string" ? data.request_fingerprint : null,
|
|
185
|
+
}));
|
|
136
186
|
}
|
|
137
187
|
// ---- Dispatch ----
|
|
138
|
-
const REMOVED_TOOLS = {
|
|
139
|
-
close_decision: "close_decision was removed in 1.1.0: agents cannot close decisions. Use request_close to find out who makes the call.",
|
|
140
|
-
add_participants: "add_participants was removed in 1.1.0: agents cannot invite people. Send the dashboard link to the decision's owner; they share the voter link.",
|
|
141
|
-
};
|
|
142
188
|
export async function callTool(name, a, store) {
|
|
143
189
|
switch (name) {
|
|
144
190
|
case "create_decision":
|
|
@@ -149,46 +195,40 @@ export async function callTool(name, a, store) {
|
|
|
149
195
|
deadline_hours: a.deadline_hours,
|
|
150
196
|
authority_mode: a.authority_mode,
|
|
151
197
|
anonymous: a.anonymous,
|
|
198
|
+
idempotency_key: a.idempotency_key,
|
|
199
|
+
tags: a.tags,
|
|
200
|
+
source_agent: a.source_agent,
|
|
152
201
|
}, store);
|
|
153
202
|
case "check_decision":
|
|
154
203
|
return checkDecision({ id: String(a.id ?? "") }, store);
|
|
155
204
|
case "list_decisions":
|
|
156
|
-
return listDecisions({
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
205
|
+
return listDecisions({
|
|
206
|
+
query: a.query,
|
|
207
|
+
lifecycle_status: a.lifecycle_status,
|
|
208
|
+
tags: a.tags,
|
|
209
|
+
source_agent: a.source_agent,
|
|
210
|
+
notification_status: a.notification_status,
|
|
211
|
+
}, store);
|
|
212
|
+
case "get_close_summary":
|
|
213
|
+
return getCloseSummary({ id: String(a.id ?? "") }, store);
|
|
214
|
+
case "search_decisions":
|
|
215
|
+
return searchDecisions({ query: String(a.query ?? ""), limit: a.limit }, store);
|
|
216
|
+
case "get_precedent":
|
|
217
|
+
return getPrecedent({ decision_id: String(a.decision_id ?? "") }, store);
|
|
218
|
+
case "cancel_decision":
|
|
219
|
+
return cancelDecision({ decision_id: String(a.decision_id ?? ""), reason: a.reason }, store);
|
|
220
|
+
case "edit_decision":
|
|
221
|
+
return editDecision({
|
|
222
|
+
decision_id: String(a.decision_id ?? ""),
|
|
223
|
+
title: a.title,
|
|
224
|
+
description: a.description,
|
|
225
|
+
options: a.options,
|
|
226
|
+
}, store);
|
|
227
|
+
default:
|
|
228
|
+
return text(unknownToolText(name), true);
|
|
163
229
|
}
|
|
164
230
|
}
|
|
165
231
|
// ---- Helpers ----
|
|
166
|
-
// Fields follow the API's DecisionPayload (packages/integrations-zapier/src/events/types.ts).
|
|
167
|
-
function formatDecision(d) {
|
|
168
|
-
const lines = [
|
|
169
|
-
`Decision: ${d.title}`,
|
|
170
|
-
`Status: ${d.status}`,
|
|
171
|
-
`Method: ${d.method}`,
|
|
172
|
-
`ID: ${d.decision_id ?? d.id}`,
|
|
173
|
-
];
|
|
174
|
-
if (d.outcome)
|
|
175
|
-
lines.push(`Outcome: ${d.outcome}`);
|
|
176
|
-
if (d.decided_at)
|
|
177
|
-
lines.push(`Decided at: ${d.decided_at}`);
|
|
178
|
-
const owner = d.owner;
|
|
179
|
-
if (owner?.name || owner?.email)
|
|
180
|
-
lines.push(`Owner: ${owner.name ?? owner.email}`);
|
|
181
|
-
const breakdown = d.vote_breakdown;
|
|
182
|
-
if (breakdown?.length) {
|
|
183
|
-
lines.push(``, `Options:`);
|
|
184
|
-
for (const o of breakdown) {
|
|
185
|
-
lines.push(` - ${o.option} (${o.votes} vote${o.votes === 1 ? "" : "s"})`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
if (d.url)
|
|
189
|
-
lines.push(``, `Dashboard: ${d.url}`);
|
|
190
|
-
return lines.join("\n");
|
|
191
|
-
}
|
|
192
232
|
function noKeyError() {
|
|
193
233
|
return text([
|
|
194
234
|
"No Verdo API key found.",
|
|
@@ -198,106 +238,3 @@ function noKeyError() {
|
|
|
198
238
|
"To get a key: verdo.ink/dashboard/settings > API Keys > Create (the key is shown once).",
|
|
199
239
|
].join("\n"), true);
|
|
200
240
|
}
|
|
201
|
-
// ---- Tool definitions ----
|
|
202
|
-
export function toolDefinitions() {
|
|
203
|
-
return [
|
|
204
|
-
{
|
|
205
|
-
name: "create_decision",
|
|
206
|
-
description: "Propose a team decision in the user's Verdo workspace. The agent proposes; a person decides. Nobody is invited or notified: the decision opens in the workspace's dashboard, where its owner shares the voter link and makes the call. The deadline starts counting when it is created. Returns the decision ID and the dashboard link to send to that person.",
|
|
207
|
-
annotations: {
|
|
208
|
-
title: "Propose Decision",
|
|
209
|
-
readOnlyHint: false,
|
|
210
|
-
destructiveHint: false,
|
|
211
|
-
idempotentHint: false,
|
|
212
|
-
openWorldHint: false,
|
|
213
|
-
},
|
|
214
|
-
inputSchema: {
|
|
215
|
-
type: "object",
|
|
216
|
-
required: ["title", "options"],
|
|
217
|
-
properties: {
|
|
218
|
-
title: { type: "string", maxLength: 140, description: "The decision question (max 140 characters)" },
|
|
219
|
-
options: {
|
|
220
|
-
type: "array",
|
|
221
|
-
minItems: 2,
|
|
222
|
-
maxItems: 10,
|
|
223
|
-
items: { type: "string" },
|
|
224
|
-
description: "2-10 options to vote on",
|
|
225
|
-
},
|
|
226
|
-
method: {
|
|
227
|
-
type: "string",
|
|
228
|
-
enum: [...METHODS],
|
|
229
|
-
description: "Voting method. Default: single_choice",
|
|
230
|
-
},
|
|
231
|
-
deadline_hours: {
|
|
232
|
-
type: "integer",
|
|
233
|
-
minimum: 1,
|
|
234
|
-
maximum: 720,
|
|
235
|
-
description: "Hours until the decision closes. Default 48, max 720 (30 days).",
|
|
236
|
-
},
|
|
237
|
-
authority_mode: {
|
|
238
|
-
type: "string",
|
|
239
|
-
enum: [...AUTHORITY_MODES],
|
|
240
|
-
description: "How the result is reached: majority (most votes) or consensus (everyone agrees). Default: majority. Owner and approver modes need a named person and are set up in Verdo, not here.",
|
|
241
|
-
},
|
|
242
|
-
anonymous: {
|
|
243
|
-
type: "boolean",
|
|
244
|
-
description: "Whether votes are anonymous. Default: false",
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
name: "check_decision",
|
|
251
|
-
description: "Check the status, votes and outcome of a Verdo decision. Returns the status, the vote count per option, the owner if one is named, the outcome once a person has decided, and the dashboard link.",
|
|
252
|
-
annotations: {
|
|
253
|
-
title: "Check Decision",
|
|
254
|
-
readOnlyHint: true,
|
|
255
|
-
destructiveHint: false,
|
|
256
|
-
idempotentHint: true,
|
|
257
|
-
openWorldHint: false,
|
|
258
|
-
},
|
|
259
|
-
inputSchema: {
|
|
260
|
-
type: "object",
|
|
261
|
-
required: ["id"],
|
|
262
|
-
properties: {
|
|
263
|
-
id: { type: "string", format: "uuid", description: "The decision ID from create_decision" },
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
name: "list_decisions",
|
|
269
|
-
description: "List or search decisions in the workspace. Returns up to 25 decisions with their status and title. Use the query parameter to search by title.",
|
|
270
|
-
annotations: {
|
|
271
|
-
title: "List Decisions",
|
|
272
|
-
readOnlyHint: true,
|
|
273
|
-
destructiveHint: false,
|
|
274
|
-
idempotentHint: true,
|
|
275
|
-
openWorldHint: false,
|
|
276
|
-
},
|
|
277
|
-
inputSchema: {
|
|
278
|
-
type: "object",
|
|
279
|
-
properties: {
|
|
280
|
-
query: { type: "string", description: "Search term to filter decisions by title (optional)" },
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
name: "request_close",
|
|
286
|
-
description: "Use when the user wants a Verdo decision closed or settled. Agents cannot close decisions; a person makes the call. Returns who owns the decision, its dashboard link and the current tally, so you can ask that person to decide. Changes nothing.",
|
|
287
|
-
annotations: {
|
|
288
|
-
title: "Request Close",
|
|
289
|
-
readOnlyHint: true,
|
|
290
|
-
destructiveHint: false,
|
|
291
|
-
idempotentHint: true,
|
|
292
|
-
openWorldHint: false,
|
|
293
|
-
},
|
|
294
|
-
inputSchema: {
|
|
295
|
-
type: "object",
|
|
296
|
-
required: ["id"],
|
|
297
|
-
properties: {
|
|
298
|
-
id: { type: "string", format: "uuid", description: "The decision ID" },
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
];
|
|
303
|
-
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "verdo-mcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Claude MCP server for Verdo team decisions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
7
8
|
"bin": {
|
|
8
9
|
"verdo-mcp": "dist/index.js"
|
|
9
10
|
},
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
},
|
|
16
17
|
"scripts": {
|
|
17
18
|
"build": "tsc",
|
|
19
|
+
"prepack": "npm run build",
|
|
18
20
|
"start": "node dist/index.js",
|
|
19
21
|
"test": "vitest run"
|
|
20
22
|
},
|