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.
@@ -0,0 +1,288 @@
1
+ // Verdo MCP tool definitions and the text every tool returns, shared by both transports:
2
+ // the stdio server in this package (src/tools.ts, over the REST API) and the remote
3
+ // server at verdo.ink/api/mcp (in-process). Pure: no fetch, no environment, no imports,
4
+ // so the remote server can import it without pulling in the stdio runtime.
5
+ //
6
+ // Guardrail: the agent proposes, a person decides. No tool invites, notifies, settles,
7
+ // closes or cancels. create_decision is the only write, and it sends no participants;
8
+ // get_close_summary only reads and points the agent at a person.
9
+ // Values the API accepts (DB checks in migrations 0041 and 0042). Owner and approver
10
+ // modes need a named person, which this API cannot set, so they are not offered.
11
+ export const METHODS = ["single_choice", "ranked_choice", "approval", "dot"];
12
+ export const AUTHORITY_MODES = ["majority", "consensus"];
13
+ export const DEFAULT_DEADLINE_HOURS = 48;
14
+ export const MAX_DEADLINE_HOURS = 720;
15
+ export const MAX_TITLE_LENGTH = 140;
16
+ export const MIN_OPTIONS = 2;
17
+ export const MAX_OPTIONS = 10;
18
+ export const REMOVED_TOOLS = {
19
+ close_decision: "close_decision was removed in 1.1.0: agents cannot close decisions. Use get_close_summary to find out who makes the call.",
20
+ 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.",
21
+ request_close: "request_close was renamed get_close_summary: the same read-only tool. Use get_close_summary.",
22
+ };
23
+ export function proposedText(id, url, args) {
24
+ return [
25
+ `Decision proposed.`,
26
+ ``,
27
+ `ID: ${id}`,
28
+ `Dashboard: ${url}`,
29
+ `Title: ${args.title}`,
30
+ `Options: ${args.options.join(", ")}`,
31
+ `Method: ${args.method ?? "single_choice"}`,
32
+ `Deadline: ${args.deadline_hours ?? DEFAULT_DEADLINE_HOURS} hours from now`,
33
+ ``,
34
+ `Nobody has been invited or notified. Send the dashboard link to the person who owns this decision: they share the voter link with the team and make the call.`,
35
+ `Use check_decision with id "${id}" to see progress.`,
36
+ ].join("\n");
37
+ }
38
+ // Fields follow the API's DecisionPayload (packages/integrations-zapier/src/events/types.ts).
39
+ export function formatDecision(d) {
40
+ const lines = [`Decision: ${d.title}`, `Status: ${d.status}`, `Method: ${d.method}`, `ID: ${d.decision_id ?? d.id}`];
41
+ if (d.outcome)
42
+ lines.push(`Outcome: ${d.outcome}`);
43
+ if (d.decided_at)
44
+ lines.push(`Decided at: ${d.decided_at}`);
45
+ const owner = d.owner;
46
+ if (owner?.name || owner?.email)
47
+ lines.push(`Owner: ${owner.name ?? owner.email}`);
48
+ // Record lite (Prompt 62): present only when approved for external sharing.
49
+ if (typeof d.rationale === "string" && d.rationale)
50
+ lines.push(`Rationale: ${d.rationale}`);
51
+ const breakdown = d.vote_breakdown;
52
+ if (breakdown?.length) {
53
+ lines.push(``, `Options:`);
54
+ for (const o of breakdown) {
55
+ lines.push(` - ${o.option} (${o.votes} vote${o.votes === 1 ? "" : "s"})`);
56
+ }
57
+ }
58
+ if (d.url)
59
+ lines.push(``, `Dashboard: ${d.url}`);
60
+ return lines.join("\n");
61
+ }
62
+ export function listText(decisions, query) {
63
+ if (decisions.length === 0) {
64
+ return query ? `No decisions found matching "${query}".` : "No decisions in this workspace.";
65
+ }
66
+ const lines = [`${decisions.length} decision${decisions.length === 1 ? "" : "s"} found:`, ``];
67
+ for (const d of decisions)
68
+ lines.push(`- [${d.status}] ${d.title} (id: ${d.id})`);
69
+ return lines.join("\n");
70
+ }
71
+ // ---- Precedent (Prompt 64, I-4 + I-5): past records, never consent ----
72
+ export const PRECEDENT_NOTE = "Past records for reference. Not consent or authorization.";
73
+ export const SEARCH_LIMIT_DEFAULT = 10;
74
+ export const SEARCH_LIMIT_MAX = 50;
75
+ const day = (iso) => (iso ? String(iso).slice(0, 10) : "date unknown");
76
+ function precedentLine(p) {
77
+ const bits = [p.winner ? `outcome: ${p.winner}` : null, `decided ${day(p.settled_at)}`, p.owner_name ? `owner: ${p.owner_name}` : null];
78
+ return `- [${p.status}] ${p.title} (id: ${p.id}): ${bits.filter(Boolean).join(", ")}`;
79
+ }
80
+ /** The section create_decision appends when there are past decisions with a similar title. */
81
+ export function precedentSection(items) {
82
+ if (items.length === 0)
83
+ return "";
84
+ return ["", "", `Previously decided (${PRECEDENT_NOTE}):`, ...items.map(precedentLine)].join("\n");
85
+ }
86
+ export function searchText(items, query) {
87
+ if (items.length === 0)
88
+ return `No past decided decisions found matching "${query}". ${PRECEDENT_NOTE}`;
89
+ return [
90
+ `${items.length} past decision${items.length === 1 ? "" : "s"} matching "${query}" (newest first):`,
91
+ ``,
92
+ ...items.map(precedentLine),
93
+ ``,
94
+ `${PRECEDENT_NOTE} execution_authorized: false.`,
95
+ ].join("\n");
96
+ }
97
+ export function precedentText(d) {
98
+ const lines = [`Past decision: ${d.title}`, `Status: ${d.status}`, `ID: ${d.id}`];
99
+ if (d.winner)
100
+ lines.push(`Outcome: ${d.winner}`);
101
+ lines.push(`Decided: ${day(d.settled_at)}`);
102
+ if (d.owner_name)
103
+ lines.push(`Owner: ${d.owner_name}`);
104
+ if (d.authority_mode)
105
+ lines.push(`How it was decided: ${d.authority_mode}`);
106
+ // Only a rationale approved for external sharing is ever returned.
107
+ if (d.rationale)
108
+ lines.push(`Rationale: ${d.rationale}`);
109
+ if (d.vote_counts.length) {
110
+ lines.push(``, `Votes per option:`);
111
+ for (const o of d.vote_counts)
112
+ lines.push(` - ${o.option} (${o.votes} vote${o.votes === 1 ? "" : "s"})`);
113
+ }
114
+ if (d.related.length) {
115
+ lines.push(``, `Related decisions on the same question:`);
116
+ for (const r of d.related)
117
+ lines.push(` - [${r.status}] ${r.title} (id: ${r.id}), decided ${day(r.settled_at)}`);
118
+ }
119
+ lines.push(``, `This is a historical record, not consent or authorization to repeat the decision. execution_authorized: false.`);
120
+ return lines.join("\n");
121
+ }
122
+ export function closeSummaryText(d) {
123
+ if (d.status !== "active") {
124
+ return `This decision is no longer open (status: ${d.status}). Nothing to close.\n\n${formatDecision(d)}`;
125
+ }
126
+ const owner = d.owner;
127
+ const who = owner?.name || owner?.email
128
+ ? [owner.name, owner.email ? `<${owner.email}>` : null].filter(Boolean).join(" ")
129
+ : "the person who owns this decision in Verdo (no owner is named on it)";
130
+ return [
131
+ `Agents cannot close Verdo decisions. A person makes the call.`,
132
+ ``,
133
+ `Ask ${who} to open ${d.url} and close it there.`,
134
+ `Share the current tally below so they can decide.`,
135
+ ``,
136
+ formatDecision(d),
137
+ ].join("\n");
138
+ }
139
+ export function unknownToolText(name) {
140
+ const tools = toolDefinitions().map((t) => t.name).join(", ");
141
+ return `${REMOVED_TOOLS[name] ?? `Unknown tool: ${name}.`} Available tools: ${tools}.`;
142
+ }
143
+ export function toolDefinitions(opts = {}) {
144
+ const meta = opts.meta ? { _meta: opts.meta } : {};
145
+ return [
146
+ {
147
+ name: "create_decision",
148
+ 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, and up to 3 previously decided decisions with a similar title: past records for reference, not consent or authorization.",
149
+ annotations: {
150
+ title: "Propose Decision",
151
+ readOnlyHint: false,
152
+ destructiveHint: false,
153
+ idempotentHint: false,
154
+ openWorldHint: false,
155
+ },
156
+ inputSchema: {
157
+ type: "object",
158
+ required: ["title", "options"],
159
+ properties: {
160
+ title: { type: "string", maxLength: MAX_TITLE_LENGTH, description: "The decision question (max 140 characters)" },
161
+ options: {
162
+ type: "array",
163
+ minItems: MIN_OPTIONS,
164
+ maxItems: MAX_OPTIONS,
165
+ items: { type: "string" },
166
+ description: "2-10 options to vote on",
167
+ },
168
+ method: {
169
+ type: "string",
170
+ enum: [...METHODS],
171
+ description: "Voting method. Default: single_choice",
172
+ },
173
+ deadline_hours: {
174
+ type: "integer",
175
+ minimum: 1,
176
+ maximum: MAX_DEADLINE_HOURS,
177
+ description: "Hours until the decision closes. Default 48, max 720 (30 days).",
178
+ },
179
+ authority_mode: {
180
+ type: "string",
181
+ enum: [...AUTHORITY_MODES],
182
+ 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.",
183
+ },
184
+ anonymous: {
185
+ type: "boolean",
186
+ description: "Whether votes are anonymous. Default: false",
187
+ },
188
+ },
189
+ },
190
+ ...meta,
191
+ },
192
+ {
193
+ name: "check_decision",
194
+ 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.",
195
+ annotations: {
196
+ title: "Check Decision",
197
+ readOnlyHint: true,
198
+ destructiveHint: false,
199
+ idempotentHint: true,
200
+ openWorldHint: false,
201
+ },
202
+ inputSchema: {
203
+ type: "object",
204
+ required: ["id"],
205
+ properties: {
206
+ id: { type: "string", format: "uuid", description: "The decision ID from create_decision" },
207
+ },
208
+ },
209
+ ...meta,
210
+ },
211
+ {
212
+ name: "list_decisions",
213
+ 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.",
214
+ annotations: {
215
+ title: "List Decisions",
216
+ readOnlyHint: true,
217
+ destructiveHint: false,
218
+ idempotentHint: true,
219
+ openWorldHint: false,
220
+ },
221
+ inputSchema: {
222
+ type: "object",
223
+ properties: {
224
+ query: { type: "string", description: "Search term to filter decisions by title (optional)" },
225
+ },
226
+ },
227
+ ...meta,
228
+ },
229
+ {
230
+ name: "search_decisions",
231
+ description: "Search past decided decisions in this workspace by words in their title, newest first. Returns each decision's ID, title, status, outcome, decision date and owner. Results are records, not consent: a past decision never authorizes repeating it, and a new decision still needs the team.",
232
+ annotations: {
233
+ title: "Search Past Decisions",
234
+ readOnlyHint: true,
235
+ destructiveHint: false,
236
+ idempotentHint: true,
237
+ openWorldHint: false,
238
+ },
239
+ inputSchema: {
240
+ type: "object",
241
+ required: ["query"],
242
+ properties: {
243
+ query: { type: "string", maxLength: 140, description: "Words to look for in past decision titles" },
244
+ limit: { type: "integer", minimum: 1, maximum: SEARCH_LIMIT_MAX, description: `How many to return. Default ${SEARCH_LIMIT_DEFAULT}, max ${SEARCH_LIMIT_MAX}.` },
245
+ },
246
+ },
247
+ ...meta,
248
+ },
249
+ {
250
+ name: "get_precedent",
251
+ description: "Retrieve a past decision record: its outcome, date, owner, how it was decided, the vote count per option, the rationale if it was approved for sharing, and related decisions on the same question. This is a historical record, not consent or authorization to repeat the decision.",
252
+ annotations: {
253
+ title: "Get Past Decision Record",
254
+ readOnlyHint: true,
255
+ destructiveHint: false,
256
+ idempotentHint: true,
257
+ openWorldHint: false,
258
+ },
259
+ inputSchema: {
260
+ type: "object",
261
+ required: ["decision_id"],
262
+ properties: {
263
+ decision_id: { type: "string", format: "uuid", description: "A decided decision's ID, from search_decisions" },
264
+ },
265
+ },
266
+ ...meta,
267
+ },
268
+ {
269
+ name: "get_close_summary",
270
+ description: "Returns the owner, dashboard link and current tally for a decision, so you can ask the owner to close it. Read-only — changes nothing.",
271
+ annotations: {
272
+ title: "Get Close Summary",
273
+ readOnlyHint: true,
274
+ destructiveHint: false,
275
+ idempotentHint: true,
276
+ openWorldHint: false,
277
+ },
278
+ inputSchema: {
279
+ type: "object",
280
+ required: ["id"],
281
+ properties: {
282
+ id: { type: "string", format: "uuid", description: "The decision ID" },
283
+ },
284
+ },
285
+ ...meta,
286
+ },
287
+ ];
288
+ }
package/dist/index.js CHANGED
@@ -1,55 +1,41 @@
1
1
  #!/usr/bin/env node
2
2
  // Verdo MCP server, stdio transport, for Claude Desktop and Claude Code.
3
- // Auth: workspace API key stored at ~/.verdo-mcp/api_key (one key, no quotes).
3
+ // Auth: workspace API key from user_config (plugin.json) or ~/.verdo-mcp/api_key fallback.
4
4
  // The server wraps the Zapier REST API (verdo.ink/api/zapier/*).
5
+ // The agent proposes, a person decides: see the guardrail note in tools.ts.
5
6
  import { readFile } from "node:fs/promises";
6
7
  import { homedir } from "node:os";
7
8
  import { join } from "node:path";
8
9
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
9
10
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
10
11
  import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
11
- import { addParticipantsTool, checkDecision, closeDecision, createDecision, listDecisions, toolDefinitions, } from "./tools.js";
12
+ import { callTool, toolDefinitions } from "./tools.js";
13
+ // The API key comes from user_config (set via the plugin's sensitive config prompt) or,
14
+ // as a fallback for standalone installs, from a file at ~/.verdo-mcp/api_key.
12
15
  const KEY_FILE = join(homedir(), ".verdo-mcp", "api_key");
13
16
  const keyStore = {
14
17
  async get() {
18
+ // Prefer the env var set by Claude's user_config mechanism
19
+ const fromEnv = process.env.VERDO_API_KEY ?? process.env.verdo_api_key;
20
+ if (fromEnv && fromEnv.trim().length > 0)
21
+ return fromEnv.trim();
22
+ // Fallback: file-based key for standalone / non-plugin installs
15
23
  try {
16
24
  const key = (await readFile(KEY_FILE, "utf8")).trim();
17
25
  return key.length > 0 ? key : null;
18
26
  }
19
27
  catch {
20
- return null; // no file yet
28
+ return null;
21
29
  }
22
30
  },
23
31
  };
24
- const server = new Server({ name: "verdo-team-decisions", version: "1.0.0" }, { capabilities: { tools: {} } });
32
+ const server = new Server({ name: "verdo-team-decisions", version: "1.2.0" }, { capabilities: { tools: {} } });
25
33
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
26
34
  tools: toolDefinitions(),
27
35
  }));
28
36
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
29
37
  const { name, arguments: args } = request.params;
30
- const a = (args ?? {});
31
- switch (name) {
32
- case "create_decision":
33
- return createDecision({
34
- title: String(a.title ?? ""),
35
- options: a.options ?? [],
36
- method: a.method,
37
- deadline_hours: a.deadline_hours,
38
- authority_mode: a.authority_mode,
39
- participants: a.participants,
40
- anonymous: a.anonymous,
41
- }, keyStore);
42
- case "check_decision":
43
- return checkDecision({ id: String(a.id ?? "") }, keyStore);
44
- case "list_decisions":
45
- return listDecisions({ query: a.query }, keyStore);
46
- case "close_decision":
47
- return closeDecision({ id: String(a.id ?? ""), winner_option_id: a.winner_option_id }, keyStore);
48
- case "add_participants":
49
- return addParticipantsTool({ id: String(a.id ?? ""), emails: a.emails ?? [] }, keyStore);
50
- default:
51
- return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
52
- }
38
+ return callTool(name, (args ?? {}), keyStore);
53
39
  });
54
40
  async function main() {
55
41
  await server.connect(new StdioServerTransport());
package/dist/tools.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { AUTHORITY_MODES, METHODS, toolDefinitions } from "./definitions.js";
2
+ export { AUTHORITY_MODES, METHODS, toolDefinitions };
1
3
  export type ApiKeyStore = {
2
4
  get(): Promise<string | null>;
3
5
  };
@@ -14,219 +16,22 @@ export declare function createDecision(args: {
14
16
  method?: string;
15
17
  deadline_hours?: number;
16
18
  authority_mode?: string;
17
- participants?: string[];
18
19
  anonymous?: boolean;
19
20
  }, store: ApiKeyStore): Promise<Text>;
21
+ export declare function searchDecisions(args: {
22
+ query: string;
23
+ limit?: number;
24
+ }, store: ApiKeyStore): Promise<Text>;
25
+ export declare function getPrecedent(args: {
26
+ decision_id: string;
27
+ }, store: ApiKeyStore): Promise<Text>;
20
28
  export declare function checkDecision(args: {
21
29
  id: string;
22
30
  }, store: ApiKeyStore): Promise<Text>;
23
31
  export declare function listDecisions(args: {
24
32
  query?: string;
25
33
  }, store: ApiKeyStore): Promise<Text>;
26
- export declare function closeDecision(args: {
27
- id: string;
28
- winner_option_id?: string;
29
- }, store: ApiKeyStore): Promise<Text>;
30
- export declare function addParticipantsTool(args: {
34
+ export declare function getCloseSummary(args: {
31
35
  id: string;
32
- emails: string[];
33
36
  }, store: ApiKeyStore): Promise<Text>;
34
- export declare function toolDefinitions(): ({
35
- name: string;
36
- description: string;
37
- annotations: {
38
- title: string;
39
- readOnlyHint: boolean;
40
- destructiveHint: boolean;
41
- idempotentHint: boolean;
42
- openWorldHint: boolean;
43
- };
44
- inputSchema: {
45
- type: "object";
46
- required: string[];
47
- properties: {
48
- title: {
49
- type: string;
50
- maxLength: number;
51
- description: string;
52
- };
53
- options: {
54
- type: string;
55
- minItems: number;
56
- maxItems: number;
57
- items: {
58
- type: string;
59
- };
60
- description: string;
61
- };
62
- method: {
63
- type: string;
64
- enum: string[];
65
- description: string;
66
- };
67
- deadline_hours: {
68
- type: string;
69
- minimum: number;
70
- maximum: number;
71
- description: string;
72
- };
73
- authority_mode: {
74
- type: string;
75
- enum: string[];
76
- description: string;
77
- };
78
- participants: {
79
- type: string;
80
- items: {
81
- type: string;
82
- format: string;
83
- };
84
- description: string;
85
- };
86
- anonymous: {
87
- type: string;
88
- description: string;
89
- };
90
- id?: undefined;
91
- query?: undefined;
92
- winner_option_id?: undefined;
93
- emails?: undefined;
94
- };
95
- };
96
- } | {
97
- name: string;
98
- description: string;
99
- annotations: {
100
- title: string;
101
- readOnlyHint: boolean;
102
- destructiveHint: boolean;
103
- idempotentHint: boolean;
104
- openWorldHint: boolean;
105
- };
106
- inputSchema: {
107
- type: "object";
108
- required: string[];
109
- properties: {
110
- id: {
111
- type: string;
112
- format: string;
113
- description: string;
114
- };
115
- title?: undefined;
116
- options?: undefined;
117
- method?: undefined;
118
- deadline_hours?: undefined;
119
- authority_mode?: undefined;
120
- participants?: undefined;
121
- anonymous?: undefined;
122
- query?: undefined;
123
- winner_option_id?: undefined;
124
- emails?: undefined;
125
- };
126
- };
127
- } | {
128
- name: string;
129
- description: string;
130
- annotations: {
131
- title: string;
132
- readOnlyHint: boolean;
133
- destructiveHint: boolean;
134
- idempotentHint: boolean;
135
- openWorldHint: boolean;
136
- };
137
- inputSchema: {
138
- type: "object";
139
- properties: {
140
- query: {
141
- type: string;
142
- description: string;
143
- };
144
- title?: undefined;
145
- options?: undefined;
146
- method?: undefined;
147
- deadline_hours?: undefined;
148
- authority_mode?: undefined;
149
- participants?: undefined;
150
- anonymous?: undefined;
151
- id?: undefined;
152
- winner_option_id?: undefined;
153
- emails?: undefined;
154
- };
155
- required?: undefined;
156
- };
157
- } | {
158
- name: string;
159
- description: string;
160
- annotations: {
161
- title: string;
162
- readOnlyHint: boolean;
163
- destructiveHint: boolean;
164
- idempotentHint: boolean;
165
- openWorldHint: boolean;
166
- };
167
- inputSchema: {
168
- type: "object";
169
- required: string[];
170
- properties: {
171
- id: {
172
- type: string;
173
- format: string;
174
- description: string;
175
- };
176
- winner_option_id: {
177
- type: string;
178
- format: string;
179
- description: string;
180
- };
181
- title?: undefined;
182
- options?: undefined;
183
- method?: undefined;
184
- deadline_hours?: undefined;
185
- authority_mode?: undefined;
186
- participants?: undefined;
187
- anonymous?: undefined;
188
- query?: undefined;
189
- emails?: undefined;
190
- };
191
- };
192
- } | {
193
- name: string;
194
- description: string;
195
- annotations: {
196
- title: string;
197
- readOnlyHint: boolean;
198
- destructiveHint: boolean;
199
- idempotentHint: boolean;
200
- openWorldHint: boolean;
201
- };
202
- inputSchema: {
203
- type: "object";
204
- required: string[];
205
- properties: {
206
- id: {
207
- type: string;
208
- format: string;
209
- description: string;
210
- };
211
- emails: {
212
- type: string;
213
- minItems: number;
214
- items: {
215
- type: string;
216
- format: string;
217
- };
218
- description: string;
219
- };
220
- title?: undefined;
221
- options?: undefined;
222
- method?: undefined;
223
- deadline_hours?: undefined;
224
- authority_mode?: undefined;
225
- participants?: undefined;
226
- anonymous?: undefined;
227
- query?: undefined;
228
- winner_option_id?: undefined;
229
- };
230
- };
231
- })[];
232
- export {};
37
+ export declare function callTool(name: string, a: Record<string, unknown>, store: ApiKeyStore): Promise<Text>;