verdo-mcp 1.0.0 → 1.2.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/LICENSE +21 -0
- package/README.md +19 -10
- package/dist/definitions.d.ts +424 -0
- package/dist/definitions.js +288 -0
- package/dist/index.js +13 -27
- package/dist/tools.d.ts +11 -206
- package/dist/tools.js +84 -212
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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.
|
|
5
|
+
//
|
|
6
|
+
// Guardrail: the agent proposes, a person decides. No tool here invites, notifies,
|
|
7
|
+
// settles, closes or cancels. create_decision is the only write, and it sends no
|
|
8
|
+
// participants; get_close_summary only reads and points the agent at a person.
|
|
9
|
+
import { AUTHORITY_MODES, DEFAULT_DEADLINE_HOURS, METHODS, formatDecision, listText, proposedText, closeSummaryText, toolDefinitions, unknownToolText, precedentSection, precedentText, searchText, } from "./definitions.js";
|
|
10
|
+
export { AUTHORITY_MODES, METHODS, toolDefinitions };
|
|
3
11
|
const VERDO_API = process.env.VERDO_API_URL ?? "https://verdo.ink/api";
|
|
4
12
|
const text = (t, isError = false) => ({
|
|
5
13
|
content: [{ type: "text", text: t }],
|
|
@@ -39,35 +47,59 @@ export async function createDecision(args, store) {
|
|
|
39
47
|
const apiKey = await store.get();
|
|
40
48
|
if (!apiKey)
|
|
41
49
|
return noKeyError();
|
|
50
|
+
// Never send participants: inviting people is a person's call, made in the dashboard.
|
|
42
51
|
const { ok, status, data } = await verdoFetch("/zapier/decisions", apiKey, {
|
|
43
52
|
method: "POST",
|
|
44
53
|
body: JSON.stringify({
|
|
45
54
|
title: args.title,
|
|
46
55
|
options: args.options,
|
|
47
56
|
method: args.method ?? "single_choice",
|
|
48
|
-
deadline_hours: args.deadline_hours ??
|
|
57
|
+
deadline_hours: args.deadline_hours ?? DEFAULT_DEADLINE_HOURS,
|
|
49
58
|
authority_mode: args.authority_mode ?? "majority",
|
|
50
|
-
participants: args.participants ?? [],
|
|
51
59
|
anonymous: args.anonymous ?? false,
|
|
52
60
|
}),
|
|
53
61
|
});
|
|
54
62
|
if (!ok)
|
|
55
63
|
return agentError("create the decision", status, data);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
`Method: ${args.method ?? "single_choice"}`,
|
|
64
|
-
`Deadline: ${args.deadline_hours ?? 48} hours from now`,
|
|
65
|
-
];
|
|
66
|
-
if (args.participants?.length) {
|
|
67
|
-
lines.push(`Participants: ${args.participants.join(", ")}`);
|
|
64
|
+
// Prompt 64: up to 3 previously decided decisions with a similar title (reference only;
|
|
65
|
+
// a failed lookup never fails the create).
|
|
66
|
+
let precedent = [];
|
|
67
|
+
try {
|
|
68
|
+
const found = await verdoFetch(`/zapier/decisions/precedent?query=${encodeURIComponent(args.title)}&limit=4`, apiKey);
|
|
69
|
+
if (found.ok)
|
|
70
|
+
precedent = (found.data.decisions ?? []).filter((p) => p.id !== String(data.id)).slice(0, 3);
|
|
68
71
|
}
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
catch {
|
|
73
|
+
precedent = [];
|
|
74
|
+
}
|
|
75
|
+
return text(proposedText(String(data.id), String(data.url), args) + precedentSection(precedent));
|
|
76
|
+
}
|
|
77
|
+
// Read-only. Past decided decisions, newest first: records, never consent.
|
|
78
|
+
export async function searchDecisions(args, store) {
|
|
79
|
+
const apiKey = await store.get();
|
|
80
|
+
if (!apiKey)
|
|
81
|
+
return noKeyError();
|
|
82
|
+
const query = args.query.trim();
|
|
83
|
+
if (!query)
|
|
84
|
+
return text("Could not search decisions: query is required (words to look for in past decision titles).", true);
|
|
85
|
+
const qs = `?query=${encodeURIComponent(query)}${args.limit !== undefined ? `&limit=${encodeURIComponent(String(args.limit))}` : ""}`;
|
|
86
|
+
const { ok, status, data } = await verdoFetch(`/zapier/decisions/precedent${qs}`, apiKey);
|
|
87
|
+
if (!ok)
|
|
88
|
+
return agentError("search decisions", status, data);
|
|
89
|
+
return text(searchText((data.decisions ?? []), query));
|
|
90
|
+
}
|
|
91
|
+
// Read-only. One past decision's record: a historical record, not consent.
|
|
92
|
+
export async function getPrecedent(args, store) {
|
|
93
|
+
const apiKey = await store.get();
|
|
94
|
+
if (!apiKey)
|
|
95
|
+
return noKeyError();
|
|
96
|
+
const { ok, status, data } = await verdoFetch(`/zapier/decisions/${encodeURIComponent(args.decision_id)}/precedent`, apiKey);
|
|
97
|
+
if (!ok)
|
|
98
|
+
return agentError("read the past decision", status, data);
|
|
99
|
+
const d = data.precedent;
|
|
100
|
+
if (!d)
|
|
101
|
+
return text("Past decision data not available.", true);
|
|
102
|
+
return text(precedentText(d));
|
|
71
103
|
}
|
|
72
104
|
export async function checkDecision(args, store) {
|
|
73
105
|
const apiKey = await store.get();
|
|
@@ -89,215 +121,55 @@ export async function listDecisions(args, store) {
|
|
|
89
121
|
const { ok, status, data } = await verdoFetch(`/zapier/decisions/search${qs}`, apiKey);
|
|
90
122
|
if (!ok)
|
|
91
123
|
return agentError("list decisions", status, data);
|
|
92
|
-
|
|
93
|
-
if (decisions.length === 0) {
|
|
94
|
-
return text(args.query ? `No decisions found matching "${args.query}".` : "No decisions in this workspace.");
|
|
95
|
-
}
|
|
96
|
-
const lines = [`${decisions.length} decision${decisions.length === 1 ? "" : "s"} found:`, ``];
|
|
97
|
-
for (const d of decisions) {
|
|
98
|
-
lines.push(`- [${d.status}] ${d.title} (id: ${d.id})`);
|
|
99
|
-
}
|
|
100
|
-
return text(lines.join("\n"));
|
|
124
|
+
return text(listText((data.decisions ?? []), args.query));
|
|
101
125
|
}
|
|
102
|
-
|
|
126
|
+
// Read-only. An agent never closes a decision: this tells it who makes the call and
|
|
127
|
+
// where. It only GETs the decision; no mutating route is called.
|
|
128
|
+
export async function getCloseSummary(args, store) {
|
|
103
129
|
const apiKey = await store.get();
|
|
104
130
|
if (!apiKey)
|
|
105
131
|
return noKeyError();
|
|
106
|
-
const { ok, status, data } = await verdoFetch(`/zapier/decisions/${encodeURIComponent(args.id)}
|
|
107
|
-
method: "POST",
|
|
108
|
-
body: JSON.stringify(args.winner_option_id ? { winner_option_id: args.winner_option_id } : {}),
|
|
109
|
-
});
|
|
132
|
+
const { ok, status, data } = await verdoFetch(`/zapier/decisions/${encodeURIComponent(args.id)}`, apiKey);
|
|
110
133
|
if (!ok)
|
|
111
|
-
return agentError("
|
|
134
|
+
return agentError("read the decision", status, data);
|
|
112
135
|
const d = data.decision;
|
|
113
136
|
if (!d)
|
|
114
|
-
return text("Decision
|
|
115
|
-
return text(
|
|
116
|
-
}
|
|
117
|
-
export async function addParticipantsTool(args, store) {
|
|
118
|
-
const apiKey = await store.get();
|
|
119
|
-
if (!apiKey)
|
|
120
|
-
return noKeyError();
|
|
121
|
-
const { ok, status, data } = await verdoFetch(`/zapier/decisions/${encodeURIComponent(args.id)}/participants`, apiKey, { method: "POST", body: JSON.stringify({ emails: args.emails }) });
|
|
122
|
-
if (!ok)
|
|
123
|
-
return agentError("add participants", status, data);
|
|
124
|
-
return text(`Added ${data.added ?? args.emails.length} participant${data.added === 1 ? "" : "s"} to the decision.`);
|
|
137
|
+
return text("Decision data not available.", true);
|
|
138
|
+
return text(closeSummaryText(d));
|
|
125
139
|
}
|
|
126
|
-
// ----
|
|
127
|
-
function
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
// ---- Dispatch ----
|
|
141
|
+
export async function callTool(name, a, store) {
|
|
142
|
+
switch (name) {
|
|
143
|
+
case "create_decision":
|
|
144
|
+
return createDecision({
|
|
145
|
+
title: String(a.title ?? ""),
|
|
146
|
+
options: a.options ?? [],
|
|
147
|
+
method: a.method,
|
|
148
|
+
deadline_hours: a.deadline_hours,
|
|
149
|
+
authority_mode: a.authority_mode,
|
|
150
|
+
anonymous: a.anonymous,
|
|
151
|
+
}, store);
|
|
152
|
+
case "check_decision":
|
|
153
|
+
return checkDecision({ id: String(a.id ?? "") }, store);
|
|
154
|
+
case "list_decisions":
|
|
155
|
+
return listDecisions({ query: a.query }, store);
|
|
156
|
+
case "get_close_summary":
|
|
157
|
+
return getCloseSummary({ id: String(a.id ?? "") }, store);
|
|
158
|
+
case "search_decisions":
|
|
159
|
+
return searchDecisions({ query: String(a.query ?? ""), limit: a.limit }, store);
|
|
160
|
+
case "get_precedent":
|
|
161
|
+
return getPrecedent({ decision_id: String(a.decision_id ?? "") }, store);
|
|
162
|
+
default:
|
|
163
|
+
return text(unknownToolText(name), true);
|
|
147
164
|
}
|
|
148
|
-
const participants = d.participants;
|
|
149
|
-
if (participants?.length) {
|
|
150
|
-
lines.push(``, `Participants: ${participants.map((p) => p.email ?? p.name).join(", ")}`);
|
|
151
|
-
}
|
|
152
|
-
if (d.url)
|
|
153
|
-
lines.push(``, `Dashboard: ${d.url}`);
|
|
154
|
-
return lines.join("\n");
|
|
155
165
|
}
|
|
166
|
+
// ---- Helpers ----
|
|
156
167
|
function noKeyError() {
|
|
157
168
|
return text([
|
|
158
|
-
"No Verdo API key found.
|
|
169
|
+
"No Verdo API key found.",
|
|
159
170
|
"",
|
|
160
|
-
"
|
|
161
|
-
"2. Copy the key (shown once)",
|
|
162
|
-
"3. Save it to ~/.verdo-mcp/api_key",
|
|
171
|
+
"Set your Verdo API key in the plugin settings (verdo_api_key), or set VERDO_API_KEY, or save it to ~/.verdo-mcp/api_key.",
|
|
163
172
|
"",
|
|
164
|
-
"
|
|
173
|
+
"To get a key: verdo.ink/dashboard/settings > API Keys > Create (the key is shown once).",
|
|
165
174
|
].join("\n"), true);
|
|
166
175
|
}
|
|
167
|
-
// ---- Tool definitions ----
|
|
168
|
-
export function toolDefinitions() {
|
|
169
|
-
return [
|
|
170
|
-
{
|
|
171
|
-
name: "create_decision",
|
|
172
|
-
description: "Create a Verdo team decision. Returns a dashboard link and decision ID. Participants receive email notifications to vote. Supports single-choice, ranked-choice, approval, and dot voting methods.",
|
|
173
|
-
annotations: {
|
|
174
|
-
title: "Create Decision",
|
|
175
|
-
readOnlyHint: false,
|
|
176
|
-
destructiveHint: false,
|
|
177
|
-
idempotentHint: false,
|
|
178
|
-
openWorldHint: true,
|
|
179
|
-
},
|
|
180
|
-
inputSchema: {
|
|
181
|
-
type: "object",
|
|
182
|
-
required: ["title", "options"],
|
|
183
|
-
properties: {
|
|
184
|
-
title: { type: "string", maxLength: 140, description: "The decision question (max 140 characters)" },
|
|
185
|
-
options: {
|
|
186
|
-
type: "array",
|
|
187
|
-
minItems: 2,
|
|
188
|
-
maxItems: 10,
|
|
189
|
-
items: { type: "string" },
|
|
190
|
-
description: "2-10 options to vote on",
|
|
191
|
-
},
|
|
192
|
-
method: {
|
|
193
|
-
type: "string",
|
|
194
|
-
enum: ["single_choice", "ranked_choice", "approval", "dot_voting"],
|
|
195
|
-
description: "Voting method. Default: single_choice",
|
|
196
|
-
},
|
|
197
|
-
deadline_hours: {
|
|
198
|
-
type: "integer",
|
|
199
|
-
minimum: 1,
|
|
200
|
-
maximum: 720,
|
|
201
|
-
description: "Hours until the decision closes. Default 48, max 720 (30 days).",
|
|
202
|
-
},
|
|
203
|
-
authority_mode: {
|
|
204
|
-
type: "string",
|
|
205
|
-
enum: ["majority", "unanimous", "owner_decides", "approver"],
|
|
206
|
-
description: "How the winner is determined. Default: majority",
|
|
207
|
-
},
|
|
208
|
-
participants: {
|
|
209
|
-
type: "array",
|
|
210
|
-
items: { type: "string", format: "email" },
|
|
211
|
-
description: "Email addresses of people who should vote. They receive an email notification.",
|
|
212
|
-
},
|
|
213
|
-
anonymous: {
|
|
214
|
-
type: "boolean",
|
|
215
|
-
description: "Whether votes are anonymous. Default: false",
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
name: "check_decision",
|
|
222
|
-
description: "Check the status, votes, and outcome of a Verdo decision. Returns the full decision state including vote counts per option, participants, and winner (if decided).",
|
|
223
|
-
annotations: {
|
|
224
|
-
title: "Check Decision",
|
|
225
|
-
readOnlyHint: true,
|
|
226
|
-
destructiveHint: false,
|
|
227
|
-
idempotentHint: true,
|
|
228
|
-
openWorldHint: false,
|
|
229
|
-
},
|
|
230
|
-
inputSchema: {
|
|
231
|
-
type: "object",
|
|
232
|
-
required: ["id"],
|
|
233
|
-
properties: {
|
|
234
|
-
id: { type: "string", format: "uuid", description: "The decision ID from create_decision" },
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
name: "list_decisions",
|
|
240
|
-
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.",
|
|
241
|
-
annotations: {
|
|
242
|
-
title: "List Decisions",
|
|
243
|
-
readOnlyHint: true,
|
|
244
|
-
destructiveHint: false,
|
|
245
|
-
idempotentHint: true,
|
|
246
|
-
openWorldHint: false,
|
|
247
|
-
},
|
|
248
|
-
inputSchema: {
|
|
249
|
-
type: "object",
|
|
250
|
-
properties: {
|
|
251
|
-
query: { type: "string", description: "Search term to filter decisions by title (optional)" },
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
name: "close_decision",
|
|
257
|
-
description: "Close a Verdo decision now, before its deadline. Optionally override the winner with a specific option ID. The decision transitions to 'decided' and participants are notified.",
|
|
258
|
-
annotations: {
|
|
259
|
-
title: "Close Decision",
|
|
260
|
-
readOnlyHint: false,
|
|
261
|
-
destructiveHint: true,
|
|
262
|
-
idempotentHint: true,
|
|
263
|
-
openWorldHint: false,
|
|
264
|
-
},
|
|
265
|
-
inputSchema: {
|
|
266
|
-
type: "object",
|
|
267
|
-
required: ["id"],
|
|
268
|
-
properties: {
|
|
269
|
-
id: { type: "string", format: "uuid", description: "The decision ID to close" },
|
|
270
|
-
winner_option_id: {
|
|
271
|
-
type: "string",
|
|
272
|
-
format: "uuid",
|
|
273
|
-
description: "Override the winner with this option ID (from check_decision). Omit to use the leading option.",
|
|
274
|
-
},
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
name: "add_participants",
|
|
280
|
-
description: "Add voters to an active Verdo decision by email. New participants receive an email notification to vote. Cannot add to a closed decision.",
|
|
281
|
-
annotations: {
|
|
282
|
-
title: "Add Participants",
|
|
283
|
-
readOnlyHint: false,
|
|
284
|
-
destructiveHint: false,
|
|
285
|
-
idempotentHint: true,
|
|
286
|
-
openWorldHint: true,
|
|
287
|
-
},
|
|
288
|
-
inputSchema: {
|
|
289
|
-
type: "object",
|
|
290
|
-
required: ["id", "emails"],
|
|
291
|
-
properties: {
|
|
292
|
-
id: { type: "string", format: "uuid", description: "The decision ID" },
|
|
293
|
-
emails: {
|
|
294
|
-
type: "array",
|
|
295
|
-
minItems: 1,
|
|
296
|
-
items: { type: "string", format: "email" },
|
|
297
|
-
description: "Email addresses of people to add as voters",
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
];
|
|
303
|
-
}
|