moltbook-mcp 0.1.0 → 0.1.2
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/dist/index.js +53 -3
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -420,11 +420,24 @@ async function autoVerify(verification, body) {
|
|
|
420
420
|
verifyBody.verification_code = verification.verification_code;
|
|
421
421
|
}
|
|
422
422
|
const response = await apiRequest("POST", "/verify", { body: verifyBody });
|
|
423
|
-
return { success: response.ok, response };
|
|
423
|
+
return { success: response.ok, response, attemptedAnswer: answer };
|
|
424
424
|
}
|
|
425
|
+
var MAX_VERIFY_ATTEMPTS = 2;
|
|
425
426
|
async function handleVerify(args) {
|
|
426
427
|
const state = loadState();
|
|
427
428
|
clearExpiredState(state);
|
|
429
|
+
const pending = state.pending_verification;
|
|
430
|
+
if (pending && (pending.attempt_count ?? 0) >= MAX_VERIFY_ATTEMPTS) {
|
|
431
|
+
return makeResult({
|
|
432
|
+
ok: false,
|
|
433
|
+
tool: "moltbook_verify",
|
|
434
|
+
error: {
|
|
435
|
+
code: "verify_attempts_exhausted",
|
|
436
|
+
message: "Do NOT retry -- further attempts risk account suspension. Wait for challenge expiry."
|
|
437
|
+
},
|
|
438
|
+
pending_verification: pending
|
|
439
|
+
}, true);
|
|
440
|
+
}
|
|
428
441
|
const rawAnswer = args.answer ?? args.solution;
|
|
429
442
|
const rawChallenge = typeof args.challenge === "string" ? args.challenge : void 0;
|
|
430
443
|
let answer;
|
|
@@ -442,6 +455,17 @@ async function handleVerify(args) {
|
|
|
442
455
|
if (!answer) {
|
|
443
456
|
return makeResult({ ok: false, tool: "moltbook_verify", error: { code: "missing_answer", message: "Provide answer or challenge text to auto-solve." } }, true);
|
|
444
457
|
}
|
|
458
|
+
if (pending?.failed_answers?.includes(answer)) {
|
|
459
|
+
return makeResult({
|
|
460
|
+
ok: false,
|
|
461
|
+
tool: "moltbook_verify",
|
|
462
|
+
error: {
|
|
463
|
+
code: "duplicate_answer_blocked",
|
|
464
|
+
message: "The solver is deterministic -- re-solving produces the same wrong answer. Provide a DIFFERENT answer manually."
|
|
465
|
+
},
|
|
466
|
+
pending_verification: pending
|
|
467
|
+
}, true);
|
|
468
|
+
}
|
|
445
469
|
const verificationCode = args.verification_code ?? state.pending_verification?.verification_code ?? null;
|
|
446
470
|
const body = { answer };
|
|
447
471
|
if (verificationCode) body.verification_code = verificationCode;
|
|
@@ -454,7 +478,15 @@ async function handleVerify(args) {
|
|
|
454
478
|
}
|
|
455
479
|
const verification = extractVerification(response);
|
|
456
480
|
if (verification) {
|
|
457
|
-
|
|
481
|
+
const priorFailed = pending?.failed_answers ?? [];
|
|
482
|
+
state.pending_verification = {
|
|
483
|
+
source_tool: "moltbook_verify",
|
|
484
|
+
detected_at: nowIso(),
|
|
485
|
+
...verification,
|
|
486
|
+
attempt_count: (pending?.attempt_count ?? 0) + 1,
|
|
487
|
+
auto_attempted: pending?.auto_attempted ?? false,
|
|
488
|
+
failed_answers: [...priorFailed, answer]
|
|
489
|
+
};
|
|
458
490
|
state.offense_count += 1;
|
|
459
491
|
} else if (response.ok) {
|
|
460
492
|
state.pending_verification = null;
|
|
@@ -567,7 +599,25 @@ async function runApiTool(toolName, method, path, options = {}) {
|
|
|
567
599
|
http: { status: autoResult.response.status }
|
|
568
600
|
});
|
|
569
601
|
}
|
|
570
|
-
|
|
602
|
+
if (autoResult) {
|
|
603
|
+
state.pending_verification = {
|
|
604
|
+
source_tool: toolName,
|
|
605
|
+
detected_at: nowIso(),
|
|
606
|
+
...verification,
|
|
607
|
+
attempt_count: 1,
|
|
608
|
+
auto_attempted: true,
|
|
609
|
+
failed_answers: [autoResult.attemptedAnswer]
|
|
610
|
+
};
|
|
611
|
+
} else {
|
|
612
|
+
state.pending_verification = {
|
|
613
|
+
source_tool: toolName,
|
|
614
|
+
detected_at: nowIso(),
|
|
615
|
+
...verification,
|
|
616
|
+
attempt_count: 0,
|
|
617
|
+
auto_attempted: false,
|
|
618
|
+
failed_answers: []
|
|
619
|
+
};
|
|
620
|
+
}
|
|
571
621
|
}
|
|
572
622
|
if (response.ok && isWrite && !verification) state.last_write_at = nowIso();
|
|
573
623
|
saveState(state);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moltbook-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Challenge-aware MCP server for Moltbook with write safety guards",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -32,5 +32,9 @@
|
|
|
32
32
|
"typescript": "^5.7.0",
|
|
33
33
|
"vitest": "^4.0.18"
|
|
34
34
|
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/p4stoboy/moltbook-mcp.git"
|
|
38
|
+
},
|
|
35
39
|
"license": "MIT"
|
|
36
40
|
}
|