@otskit/mcp 0.2.1 → 0.3.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.
@@ -1,17 +0,0 @@
1
- // src/scheduler/remove.ts
2
- import { execFileSync } from "child_process";
3
- async function removeScheduler() {
4
- if (process.platform === "win32") {
5
- try {
6
- execFileSync("schtasks", ["/delete", "/tn", "ots-mcp-check-pending", "/f"]);
7
- process.stdout.write("Scheduler task removed\n");
8
- } catch {
9
- process.stderr.write("Task not found or could not be removed\n");
10
- }
11
- } else {
12
- process.stdout.write("Remove the ots-mcp entry from crontab: crontab -e\n");
13
- }
14
- }
15
- export {
16
- removeScheduler
17
- };
@@ -1,27 +0,0 @@
1
- // src/scheduler/index.ts
2
- async function runScheduler(args) {
3
- const [sub, ...rest] = args;
4
- switch (sub) {
5
- case "install": {
6
- const { installScheduler } = await import("./install-BUSOMBB2.js");
7
- await installScheduler(rest);
8
- break;
9
- }
10
- case "remove": {
11
- const { removeScheduler } = await import("./remove-BGFQRDX3.js");
12
- await removeScheduler();
13
- break;
14
- }
15
- case "status": {
16
- const { statusScheduler } = await import("./status-M6A2RG7G.js");
17
- await statusScheduler();
18
- break;
19
- }
20
- default:
21
- process.stderr.write("Usage: ots-mcp scheduler install [--interval N] | remove | status\n");
22
- process.exit(1);
23
- }
24
- }
25
- export {
26
- runScheduler
27
- };
@@ -1,221 +0,0 @@
1
- import {
2
- createTimestamp,
3
- getStamp,
4
- listPending,
5
- upgradeTimestamp,
6
- verifyTimestamp
7
- } from "./chunk-OMNHFTJW.js";
8
- import {
9
- getDb,
10
- loadConfig
11
- } from "./chunk-4ZDPWS7C.js";
12
- import "./chunk-YFSUDT24.js";
13
-
14
- // src/server.ts
15
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
16
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
17
- import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
18
-
19
- // src/tools/inspect-timestamp.ts
20
- import { readFileSync, statSync } from "fs";
21
- import { DetachedTimestampFile } from "@otskit/core";
22
- function inspectTimestamp(input, db, _config) {
23
- const record = getStamp(db, input.id);
24
- if (!record) return { error: "not_found", details: `No stamp with id ${input.id}` };
25
- if (!record.proof_path) return { error: "proof_missing", details: "No proof file on record" };
26
- let proofBytes;
27
- let proofSize;
28
- try {
29
- proofSize = statSync(record.proof_path).size;
30
- proofBytes = readFileSync(record.proof_path);
31
- } catch {
32
- return { error: "proof_missing", details: `Cannot read proof: ${record.proof_path}` };
33
- }
34
- let calendarAttestations = 0;
35
- let bitcoinAttestations = 0;
36
- let bitcoinBlock = null;
37
- try {
38
- const proof = DetachedTimestampFile.deserialize(new Uint8Array(proofBytes));
39
- const attestations = proof.timestamp.getAttestations();
40
- bitcoinAttestations = attestations.filter((a) => a.kind === "bitcoin").length;
41
- calendarAttestations = attestations.filter((a) => a.kind !== "bitcoin").length;
42
- if (bitcoinAttestations > 0) {
43
- const blocks = attestations.filter((a) => a.kind === "bitcoin").map((a) => a.height);
44
- bitcoinBlock = blocks.length > 0 ? Math.min(...blocks) : null;
45
- }
46
- } catch {
47
- }
48
- return {
49
- id: record.id,
50
- hash: record.hash,
51
- status: record.status,
52
- created_at: record.created_at,
53
- proof_path: record.proof_path,
54
- proof_size_bytes: proofSize,
55
- calendar_attestations: calendarAttestations,
56
- bitcoin_attestations: bitcoinAttestations,
57
- bitcoin_confirmed: bitcoinAttestations > 0,
58
- bitcoin_block: bitcoinBlock
59
- };
60
- }
61
-
62
- // src/tools/watch-window.ts
63
- import { exec } from "child_process";
64
- function openWatchWindow(intervalMinutes = 5) {
65
- const minutes = Math.max(1, Math.floor(intervalMinutes));
66
- const cmd = `start powershell.exe -NoExit -Command "ots-mcp watch ${minutes}"`;
67
- let errorMsg;
68
- exec(cmd, { shell: "cmd" }, (err) => {
69
- if (err) errorMsg = err.message;
70
- });
71
- return { opened: true, interval_minutes: minutes, ...errorMsg ? { error: errorMsg } : {} };
72
- }
73
-
74
- // src/tool-definitions.ts
75
- var TOOL_DEFINITIONS = [
76
- {
77
- name: "create_timestamp",
78
- description: "Stamps a SHA-256 hash against public OpenTimestamps calendars. IMPORTANT: the digest is sent to external calendar servers (alice.btc, bob.btc, finney, catallaxy).",
79
- inputSchema: {
80
- type: "object",
81
- properties: { hash: { type: "string", description: "SHA-256 hex digest (64 chars)" } },
82
- required: ["hash"]
83
- },
84
- annotations: {
85
- readOnlyHint: false,
86
- destructiveHint: false,
87
- idempotentHint: false,
88
- openWorldHint: true
89
- }
90
- },
91
- {
92
- name: "upgrade_timestamp",
93
- description: "Checks if a pending stamp has been confirmed in Bitcoin. Use the id returned by create_timestamp.",
94
- inputSchema: {
95
- type: "object",
96
- properties: { id: { type: "string", description: "UUID from the stamp record" } },
97
- required: ["id"]
98
- },
99
- annotations: {
100
- readOnlyHint: false,
101
- destructiveHint: false,
102
- idempotentHint: true,
103
- openWorldHint: true
104
- }
105
- },
106
- {
107
- name: "verify_timestamp",
108
- description: "Verifies a stamp against Bitcoin. Does NOT affirm document authorship or truth \u2014 only proves the hash existed before a given Bitcoin block.",
109
- inputSchema: {
110
- type: "object",
111
- properties: { id: { type: "string", description: "UUID from the stamp record" } },
112
- required: ["id"]
113
- },
114
- annotations: {
115
- readOnlyHint: true,
116
- destructiveHint: false,
117
- idempotentHint: true,
118
- openWorldHint: true
119
- }
120
- },
121
- {
122
- name: "inspect_timestamp",
123
- description: "Inspects a stored proof file without network calls. Returns calendar_attestations (promises from OTS servers, NOT Bitcoin confirmation) and bitcoin_attestations (actual Bitcoin blocks). A stamp is only truly confirmed when bitcoin_attestations > 0 and bitcoin_confirmed is true.",
124
- inputSchema: {
125
- type: "object",
126
- properties: { id: { type: "string", description: "UUID from the stamp record" } },
127
- required: ["id"]
128
- },
129
- annotations: {
130
- readOnlyHint: true,
131
- destructiveHint: false,
132
- idempotentHint: true,
133
- openWorldHint: false
134
- }
135
- },
136
- {
137
- name: "list_pending",
138
- description: "Lists stamp records with status and retry info.",
139
- inputSchema: {
140
- type: "object",
141
- properties: {
142
- status: { type: "string", enum: ["pending", "confirmed", "failed", "timeout"] },
143
- limit: { type: "number", maximum: 200 },
144
- offset: { type: "number" },
145
- older_than_hours: { type: "number" }
146
- }
147
- },
148
- annotations: {
149
- readOnlyHint: true,
150
- destructiveHint: false,
151
- idempotentHint: true,
152
- openWorldHint: false
153
- }
154
- },
155
- {
156
- name: "watch",
157
- description: "Opens a new terminal window that monitors pending stamps in real-time, polling at the given interval. The window stays open so the user can watch progress.",
158
- inputSchema: {
159
- type: "object",
160
- properties: {
161
- interval_minutes: { type: "number", description: "Polling interval in minutes (default: 5, minimum: 1)" }
162
- }
163
- },
164
- annotations: {
165
- readOnlyHint: true,
166
- destructiveHint: false,
167
- idempotentHint: false,
168
- openWorldHint: false
169
- }
170
- }
171
- ];
172
-
173
- // src/server.ts
174
- async function runServer() {
175
- const config = loadConfig();
176
- const db = getDb();
177
- const server = new Server(
178
- { name: "ots-mcp", version: "0.1.0" },
179
- { capabilities: { tools: {} } }
180
- );
181
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
182
- tools: TOOL_DEFINITIONS
183
- }));
184
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
185
- const { name, arguments: args } = request.params;
186
- try {
187
- let result;
188
- switch (name) {
189
- case "create_timestamp":
190
- result = await createTimestamp(args, db, config);
191
- break;
192
- case "upgrade_timestamp":
193
- result = await upgradeTimestamp(args, db, config);
194
- break;
195
- case "verify_timestamp":
196
- result = await verifyTimestamp(args, db, config);
197
- break;
198
- case "inspect_timestamp":
199
- result = inspectTimestamp(args, db, config);
200
- break;
201
- case "list_pending":
202
- result = listPending(args, db, config);
203
- break;
204
- case "watch":
205
- result = openWatchWindow(args?.interval_minutes);
206
- break;
207
- default:
208
- return { content: [{ type: "text", text: JSON.stringify({ error: "unknown_tool", tool: name }) }], isError: true };
209
- }
210
- const isError = Boolean(result && typeof result === "object" && "error" in result);
211
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], isError };
212
- } catch (e) {
213
- return { content: [{ type: "text", text: JSON.stringify({ error: "internal_error", details: String(e) }) }], isError: true };
214
- }
215
- });
216
- const transport = new StdioServerTransport();
217
- await server.connect(transport);
218
- }
219
- export {
220
- runServer
221
- };
@@ -1,17 +0,0 @@
1
- // src/scheduler/status.ts
2
- import { execFileSync } from "child_process";
3
- async function statusScheduler() {
4
- if (process.platform === "win32") {
5
- try {
6
- const out = execFileSync("schtasks", ["/query", "/tn", "ots-mcp-check-pending", "/fo", "LIST"]).toString();
7
- process.stdout.write(out + "\n");
8
- } catch {
9
- process.stdout.write("Scheduler task not found\n");
10
- }
11
- } else {
12
- process.stdout.write("Check with: crontab -l | grep ots-mcp\n");
13
- }
14
- }
15
- export {
16
- statusScheduler
17
- };
@@ -1,41 +0,0 @@
1
- import {
2
- getDb,
3
- loadConfig
4
- } from "./chunk-4ZDPWS7C.js";
5
-
6
- // src/tools/watch.ts
7
- async function watchPending(intervalMinutes = 5) {
8
- const config = loadConfig();
9
- const db = getDb(config);
10
- process.stdout.write(`Watching pending stamps every ${intervalMinutes} min. Ctrl+C to stop.
11
-
12
- `);
13
- function tick() {
14
- const rows = db.prepare(
15
- `SELECT id, hash, status, attempt_count, bitcoin_block, confirmed_at FROM stamps WHERE status != 'confirmed' ORDER BY created_at DESC`
16
- ).all();
17
- const confirmed = db.prepare(`SELECT COUNT(*) as n FROM stamps WHERE status = 'confirmed'`).get();
18
- process.stdout.write(`${now()} \u2014 ${rows.length} pendientes, ${confirmed.n} confirmados
19
- `);
20
- for (const row of rows) {
21
- process.stdout.write(` ${row.id.slice(0, 8)} ${row.status} (${row.attempt_count} intentos)
22
- `);
23
- }
24
- if (rows.length === 0) {
25
- process.stdout.write(` (ning\xFAn sello pendiente)
26
- `);
27
- }
28
- process.stdout.write("\n");
29
- }
30
- function now() {
31
- return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
32
- }
33
- function loop() {
34
- tick();
35
- setTimeout(loop, Math.max(6e4, intervalMinutes * 60 * 1e3));
36
- }
37
- loop();
38
- }
39
- export {
40
- watchPending
41
- };