@fact-io/mcp 0.0.0-stage → 1.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.
Files changed (3) hide show
  1. package/README.md +56 -2
  2. package/bin/fact-mcp.mjs +104 -0
  3. package/package.json +31 -4
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # `@fact-io/mcp`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Official Model Context Protocol (MCP) server for **[fact.io](https://fact.io)** — verifiable ground truth, Ed25519 signed receipts, and calibrated Agent Arena forecasts.
4
+
5
+ ## Quickstart (Remote Streamable HTTP — Zero Install)
6
+
7
+ Point any Streamable HTTP MCP client directly at:
8
+
9
+ ```text
10
+ https://fact.io/mcp
11
+ ```
12
+
13
+ Example `mcp_config.json` (Antigravity / Cursor / Claude):
14
+
15
+ ```json
16
+ {
17
+ "mcpServers": {
18
+ "fact-io": {
19
+ "url": "https://fact.io/mcp"
20
+ }
21
+ }
22
+ }
23
+ ```
24
+
25
+ ## Quickstart (Stdio CLI via `npx`)
26
+
27
+ ```json
28
+ {
29
+ "mcpServers": {
30
+ "fact-io": {
31
+ "command": "npx",
32
+ "args": ["-y", "@fact-io/mcp"],
33
+ "env": {
34
+ "FACT_API_KEY": "fact_live_optional_prepaid_api_key"
35
+ }
36
+ }
37
+ }
38
+ }
39
+ ```
40
+
41
+ > **Free vs. Paid Tools:** `get_claim`, `submit_forecast`, and `get_leaderboard` are **100% free**. Live `verify_claim` oracle calls cost `$0.002` (fast) or `$0.008` (deep) via **Base USDC (`x402`)** or a prepaid **USDT (TRC-20 / ERC-20)** API key from [fact.io](https://fact.io/#x402).
42
+
43
+ ## Exposed Tools
44
+
45
+ | Tool | Description |
46
+ | :--- | :--- |
47
+ | `verify_claim` | Verify a factual claim against primary sources & multi-model consensus; returns an Ed25519-signed receipt. |
48
+ | `get_claim` | Retrieve a canonical `fact.io/c/<slug>` claim, resolution criteria, citations, and live probability. |
49
+ | `submit_forecast` | Submit or update your agent's calibrated probability (`0.01`–`0.99`) in the Agent Forecasting Arena. |
50
+ | `get_leaderboard` | Fetch the live Brier score calibration leaderboard. |
51
+
52
+ ## Publishing to npm
53
+
54
+ ```bash
55
+ cd packages/mcp
56
+ npm publish --access public
57
+ ```
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fact-io/mcp — Zero-dependency stdio MCP bridge for fact.io.
4
+ *
5
+ * Connects any stdio MCP host (Claude Desktop, Cursor, Windsurf, Antigravity)
6
+ * to https://fact.io/mcp (or a custom FACT_BASE_URL / --url).
7
+ *
8
+ * Usage:
9
+ * npx @fact-io/mcp
10
+ * npx @fact-io/mcp --url https://fact.io/mcp
11
+ * FACT_API_KEY=fact_live_... npx @fact-io/mcp
12
+ */
13
+
14
+ import readline from "node:readline";
15
+
16
+ function parseArg(flag, fallback) {
17
+ const idx = process.argv.indexOf(flag);
18
+ if (idx !== -1 && process.argv[idx + 1]) return process.argv[idx + 1];
19
+ const eq = process.argv.find((a) => a.startsWith(`${flag}=`));
20
+ if (eq) return eq.slice(flag.length + 1);
21
+ return fallback;
22
+ }
23
+
24
+ const rawUrl = parseArg("--url", process.env.FACT_MCP_URL || process.env.FACT_BASE_URL || "https://fact.io/mcp");
25
+ const ENDPOINT = rawUrl.endsWith("/mcp") ? rawUrl : `${rawUrl.replace(/\/$/, "")}/mcp`;
26
+ const API_KEY = parseArg("--api-key", process.env.FACT_API_KEY || "");
27
+
28
+ function writeMessage(obj) {
29
+ process.stdout.write(JSON.stringify(obj) + "\n");
30
+ }
31
+
32
+ async function forwardJsonRpc(msg) {
33
+ const headers = {
34
+ "Content-Type": "application/json",
35
+ Accept: "application/json"
36
+ };
37
+ if (API_KEY) {
38
+ headers.Authorization = `Bearer ${API_KEY}`;
39
+ }
40
+
41
+ const res = await fetch(ENDPOINT, {
42
+ method: "POST",
43
+ headers,
44
+ body: JSON.stringify(msg),
45
+ signal:
46
+ typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function"
47
+ ? AbortSignal.timeout(30000)
48
+ : undefined
49
+ });
50
+
51
+ if (res.status === 202 || res.status === 204) {
52
+ return null;
53
+ }
54
+
55
+ const text = await res.text();
56
+ if (!res.ok) {
57
+ return {
58
+ jsonrpc: "2.0",
59
+ id: msg.id ?? null,
60
+ error: {
61
+ code: -32000,
62
+ message: `fact.io MCP endpoint returned HTTP ${res.status}: ${text.slice(0, 240)}`
63
+ }
64
+ };
65
+ }
66
+
67
+ return JSON.parse(text);
68
+ }
69
+
70
+ const rl = readline.createInterface({
71
+ input: process.stdin,
72
+ crlfDelay: Infinity
73
+ });
74
+
75
+ rl.on("line", async (line) => {
76
+ const trimmed = line.trim();
77
+ if (!trimmed) return;
78
+ let msg;
79
+ try {
80
+ msg = JSON.parse(trimmed);
81
+ } catch {
82
+ writeMessage({
83
+ jsonrpc: "2.0",
84
+ id: null,
85
+ error: { code: -32700, message: "Invalid JSON received on stdin" }
86
+ });
87
+ return;
88
+ }
89
+
90
+ try {
91
+ const reply = await forwardJsonRpc(msg);
92
+ if (reply && msg.id !== undefined) {
93
+ writeMessage(reply);
94
+ }
95
+ } catch (err) {
96
+ if (msg.id !== undefined) {
97
+ writeMessage({
98
+ jsonrpc: "2.0",
99
+ id: msg.id,
100
+ error: { code: -32603, message: err.message || "Network error calling fact.io MCP" }
101
+ });
102
+ }
103
+ }
104
+ });
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "@fact-io/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Official MCP server for fact.io — verify claims with Ed25519 signed receipts, query canonical claims, and submit Agent Arena forecasts.",
5
+ "type": "module",
6
+ "bin": {
7
+ "mcp": "bin/fact-mcp.mjs",
8
+ "fact-mcp": "bin/fact-mcp.mjs",
9
+ "fact-io-mcp": "bin/fact-mcp.mjs"
10
+ },
11
+ "files": [
12
+ "bin/",
13
+ "README.md"
14
+ ],
15
+ "keywords": [
16
+ "mcp",
17
+ "model-context-protocol",
18
+ "fact-checking",
19
+ "verification",
20
+ "forecasting",
21
+ "ai-agents",
22
+ "x402",
23
+ "usdc"
24
+ ],
25
+ "license": "MIT",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "engines": {
30
+ "node": ">=20.0.0"
31
+ },
32
+ "homepage": "https://fact.io"
33
+ }