@hyperodds/mcp 0.2.0 → 0.2.1
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/README.md +2 -2
- package/dist/bridge.js +14 -11
- package/dist/forecast.js +20 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ VS Code (`.vscode/mcp.json`):
|
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
`npx -y` runs the newest release each time your client starts. To stay on one version and upgrade
|
|
75
|
-
when you choose, pin it in the entry: `"args": ["-y", "@hyperodds/mcp@0.2.
|
|
75
|
+
when you choose, pin it in the entry: `"args": ["-y", "@hyperodds/mcp@0.2.1"]`.
|
|
76
76
|
|
|
77
77
|
The package needs Node.js 22 or later. A client that connects to remote servers can skip it and
|
|
78
78
|
use `https://api.usehyperodds.com/mcp` directly over Streamable HTTP.
|
|
@@ -206,7 +206,7 @@ error that names it.
|
|
|
206
206
|
The bridge forwards each message from your client to `api.usehyperodds.com`. That includes the
|
|
207
207
|
arguments of every tool call, such as the text of a search, and the name and version your client
|
|
208
208
|
reports when it connects. Each request also carries a user agent with the bridge and Node.js
|
|
209
|
-
versions, such as `hyperodds-mcp/0.2.
|
|
209
|
+
versions, such as `hyperodds-mcp/0.2.1 node/24.22.0`. Requests pass through Cloudflare on their way
|
|
210
210
|
to our hosting provider.
|
|
211
211
|
|
|
212
212
|
Messages go through unchanged, except for the forecast tools while signing is on. The bridge sends
|
package/dist/bridge.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* server as a message the bridge built and signed itself.
|
|
8
8
|
*/
|
|
9
9
|
import { dirname, join } from "node:path";
|
|
10
|
-
import { checkEntries, digest, EntryError, forecastMessage } from "./forecast.js";
|
|
10
|
+
import { checkArguments, checkEntries, digest, EntryError, forecastMessage } from "./forecast.js";
|
|
11
11
|
import { openKey } from "./key.js";
|
|
12
12
|
import { SignedTimes } from "./times.js";
|
|
13
13
|
const PARSE_ERROR = -32700;
|
|
@@ -155,9 +155,21 @@ export class Bridge {
|
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* Signs the forecasts here. A forecaster the client names that isn't this computer's goes to the
|
|
158
|
-
* server as is, for a sign link to that wallet.
|
|
158
|
+
* server as is, for a sign link to that wallet. Arguments and entries the server would refuse are
|
|
159
|
+
* refused here first, in its words and codes.
|
|
159
160
|
*/
|
|
160
161
|
async forecast(msg, id, args, keys, signal) {
|
|
162
|
+
// Checked before any key is read or made, and refused with the server's codes.
|
|
163
|
+
let entries;
|
|
164
|
+
try {
|
|
165
|
+
checkArguments(args);
|
|
166
|
+
entries = checkEntries(args.forecasts);
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
if (!(error instanceof EntryError))
|
|
170
|
+
throw error;
|
|
171
|
+
return toolError(id, error.message, error.code);
|
|
172
|
+
}
|
|
161
173
|
let signer;
|
|
162
174
|
try {
|
|
163
175
|
signer = openKey(keys, args.forecaster === undefined);
|
|
@@ -168,15 +180,6 @@ export class Bridge {
|
|
|
168
180
|
if (!signer ||
|
|
169
181
|
(args.forecaster !== undefined && String(args.forecaster).toLowerCase() !== signer.address))
|
|
170
182
|
return this.send(msg, id, signal);
|
|
171
|
-
let entries;
|
|
172
|
-
try {
|
|
173
|
-
entries = checkEntries(args.forecasts);
|
|
174
|
-
}
|
|
175
|
-
catch (error) {
|
|
176
|
-
if (!(error instanceof EntryError))
|
|
177
|
-
throw error;
|
|
178
|
-
return toolError(id, error.message, error.code);
|
|
179
|
-
}
|
|
180
183
|
const nowMs = (this.opts.now ?? Date.now)();
|
|
181
184
|
const outcomes = entries.map((e) => e.outcome);
|
|
182
185
|
const times = this.times;
|
package/dist/forecast.js
CHANGED
|
@@ -75,14 +75,33 @@ export class EntryError extends Error {
|
|
|
75
75
|
this.code = code;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
const ENTRY_KEYS = new Set(["outcome", "probabilityBps"]);
|
|
79
|
+
/**
|
|
80
|
+
* The forecasts asked for, if they can be signed: 1 to 50, each an outcome id and a probabilityBps
|
|
81
|
+
* and nothing else. A key the message has no place for is refused, as the server refuses it: an
|
|
82
|
+
* agent that sent side: 1 would otherwise sign a probability for the other side than it meant.
|
|
83
|
+
*/
|
|
79
84
|
export function checkEntries(entries) {
|
|
80
85
|
if (!Array.isArray(entries) || !entries.every(isEntry))
|
|
81
86
|
throw new EntryError("invalid_request", "Each forecast takes an outcome id and a probabilityBps, a whole number from 1 to 9999.");
|
|
87
|
+
const extra = [...new Set(entries.flatMap((e) => Object.keys(e).filter((k) => !ENTRY_KEYS.has(k))))];
|
|
88
|
+
if (extra.length > 0)
|
|
89
|
+
throw new EntryError("invalid_request", `Each forecast takes only an outcome id and a probabilityBps, not ${extra.join(", ")}.`);
|
|
82
90
|
if (entries.length < 1 || entries.length > MAX_BATCH)
|
|
83
91
|
throw new EntryError("batch_size", "Send from 1 to 50 forecasts at a time.");
|
|
84
92
|
return entries.map(({ outcome, probabilityBps }) => ({ outcome, probabilityBps }));
|
|
85
93
|
}
|
|
94
|
+
/** What odds_forecast takes. */
|
|
95
|
+
const FORECAST_ARGS = new Set(["signed", "forecasts", "forecaster"]);
|
|
96
|
+
/**
|
|
97
|
+
* Arguments odds_forecast doesn't take, refused as the server refuses them, before any key is read
|
|
98
|
+
* or made: a misspelt forecaster would otherwise sign here what was meant for another wallet.
|
|
99
|
+
*/
|
|
100
|
+
export function checkArguments(args) {
|
|
101
|
+
const unknown = Object.keys(args).filter((k) => !FORECAST_ARGS.has(k));
|
|
102
|
+
if (unknown.length > 0)
|
|
103
|
+
throw new EntryError("invalid_request", `odds_forecast takes signed, or forecasts with an optional forecaster, not ${unknown.join(", ")}.`);
|
|
104
|
+
}
|
|
86
105
|
/**
|
|
87
106
|
* The message for these forecasts: one as a Forecast, more as a ForecastBatch, signed at `time`
|
|
88
107
|
* (Unix seconds). The nonce is 63 random bits, too many to repeat in practice, and goes as a string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperodds/mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Stdio bridge to the hosted Hyperodds MCP server: Hyperliquid HIP-4 outcome market data for local MCP clients, and forecasts signed on your machine for Hyperodds' public record.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|