@hyperodds/mcp 0.2.0 → 0.2.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/README.md CHANGED
@@ -11,6 +11,7 @@
11
11
  <a href="https://github.com/usehyperodds/hyperodds-mcp/blob/main/LICENSE"><img alt="MIT license" src="https://img.shields.io/badge/license-MIT-176646"></a>
12
12
  <a href="https://usehyperodds.com"><img alt="Website" src="https://img.shields.io/badge/web-usehyperodds.com-070b0c"></a>
13
13
  <a href="https://x.com/UseHyperodds"><img alt="X" src="https://img.shields.io/badge/@UseHyperodds-000000?logo=x&logoColor=white"></a>
14
+ <a href="https://heyresearch.xyz/project/hyperodds?utm_source=badge&utm_medium=readme"><img alt="Hyperodds on HEY Research Lab" src="https://heyresearch.xyz/api/badge/hyperodds?style=pill" height="20"></a>
14
15
  </p>
15
16
 
16
17
  Give Claude, Cursor, VS Code or any other MCP client live data on Hyperliquid's HIP-4 outcome
@@ -72,7 +73,7 @@ VS Code (`.vscode/mcp.json`):
72
73
  ```
73
74
 
74
75
  `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.0"]`.
76
+ when you choose, pin it in the entry: `"args": ["-y", "@hyperodds/mcp@0.2.2"]`.
76
77
 
77
78
  The package needs Node.js 22 or later. A client that connects to remote servers can skip it and
78
79
  use `https://api.usehyperodds.com/mcp` directly over Streamable HTTP.
@@ -93,6 +94,8 @@ use `https://api.usehyperodds.com/mcp` directly over Streamable HTTP.
93
94
  | `odds_cluster` | `id`, or the `outcome` of any member | For a question more than one deployer lists: each listing's rule grade (`SAME`, `CLOSE` or `DIFFERENT`), the differences found and the merged book |
94
95
  | `odds_fair` | `outcome` | One market's fair line: probability and band, method, confidence and flags, each source with its weight and age, plus the book and the edge for buying or selling either side |
95
96
  | `odds_new` | `category`, `limit` (up to 100), `offset` | Markets in listing order, newest first, with the same fields as `odds_markets` |
97
+ | `search` | `query` | Up to 20 live markets that match the words of a question, each with an id, a title and its page |
98
+ | `fetch` | `id` (from `search`) | One market as text to quote: the book, volume, fair line and sources, edges, rules and other venues |
96
99
  | `odds_forecast` | `forecasts`: up to 50 of an `outcome` and a `probabilityBps` from 1 to 9999 | With signing on, the forecasts as recorded, signed on your machine; with it off, a sign link |
97
100
  | `odds_forecast_record` | `address` (with signing on, your forecaster if left out), `limit` (up to 100), `offset` | One forecaster's board row, their forecasts past the cutoff with results and scores, and how many are still private |
98
101
  | `odds_leaderboard` | `limit` (up to 100), `offset` | Forecasters ranked by skill over Hyperodds' fair line, with the fair line and the market price scored as baselines |
@@ -206,7 +209,7 @@ error that names it.
206
209
  The bridge forwards each message from your client to `api.usehyperodds.com`. That includes the
207
210
  arguments of every tool call, such as the text of a search, and the name and version your client
208
211
  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.0 node/24.22.0`. Requests pass through Cloudflare on their way
212
+ versions, such as `hyperodds-mcp/0.2.2 node/24.22.0`. Requests pass through Cloudflare on their way
210
213
  to our hosting provider.
211
214
 
212
215
  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
- /** The forecasts asked for, if they can be signed: 1 to 50, each an outcome id and a probabilityBps. */
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.0",
3
+ "version": "0.2.2",
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",