hugging-bay-mcp 0.1.7 → 0.1.9

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
@@ -1,9 +1,9 @@
1
1
  # hugging-bay-mcp
2
2
 
3
3
  **Promise:** Find open model files with recorded SHA-256 and licence labels. Public reads need no account.<br>
4
- **Install (recorded npm release):** `npx -y hugging-bay-mcp@0.1.6`<br>
4
+ **Install:** `npx -y hugging-bay-mcp@0.1.8` (npm) · **Source candidate:** `0.1.9`<br>
5
5
  **MCP config (remote):** `claude mcp add --transport http hugging-bay https://huggingbay.xyz/api/mcp`<br>
6
- **MCP config (stdio):** `{"mcpServers":{"hugging-bay":{"command":"npx","args":["-y","hugging-bay-mcp@0.1.6"],"env":{"HUGGING_BAY_API":"https://huggingbay.xyz"}}}}`<br>
6
+ **MCP config (stdio):** `{"mcpServers":{"hugging-bay":{"command":"npx","args":["-y","hugging-bay-mcp@0.1.8"],"env":{"HUGGING_BAY_API":"https://huggingbay.xyz"}}}}`<br>
7
7
  **First call:** `search_artifacts({ "q": "Qwen3 0.6B GGUF" })`<br>
8
8
  **Ask:** Missing a model, file, tool or feature? Ask with request_feature (hosted MCP) or POST https://huggingbay.xyz/api/v1/requests. No account. You get an id and can check its status. What shipped: https://huggingbay.xyz/changelog<br>
9
9
  [Changelog](https://huggingbay.xyz/changelog?ref=npm) · [MCP docs](https://huggingbay.xyz/agents?ref=npm)<br>
@@ -11,23 +11,17 @@
11
11
 
12
12
  ## Profiles: stdio and hosted
13
13
 
14
- **Source candidate:** `0.1.7` is not published on npm. Install commands above
15
- remain pinned to the recorded `0.1.6` publication. Inspect this candidate with
16
- `node packages/mcp/index.mjs` from the repository root.
14
+ **What's new in 0.1.9:** the default stdio discovery profile matches hosted `/api/mcp` (28 tools, including board, requests, `get_model`, Teach reads, and `get_serve_decision`). **Source candidate:** `0.1.9` (npm still serves `0.1.8` until publish).
17
15
 
18
- **What's new in 0.1.7:** `request_missing` joins the 17-tool default profile,
19
- and stdio tool descriptions match the hosted wording.
20
-
21
- The stdio launcher defaults to the bounded first-call profile; the hosted
22
- endpoint's discovery profile adds the board and request tools. The package keeps
16
+ The stdio launcher and hosted endpoint share the discovery profile. The package keeps
23
17
  the broader catalog available, but a client must opt into it explicitly:
24
18
 
25
19
  | Transport/profile | `tools/list` | What it is |
26
20
  | --- | --- | --- |
27
- | stdio candidate default (`node packages/mcp/index.mjs`) | **17 tools** | the discovery tools in the retained hosted order, followed by `request_missing`: `recommend_specialist`, `get_agent_discovery`, `search_artifacts`, `resolve_artifact`, `get_artifact`, `list_files`, `get_artifact_card`, `deployment_plan`, `find_runnable`, `bakeoff`, `blackboard`, `get_source_coverage`, `get_ranking`, `get_citation_pack`, `list_topics`, `get_source_request_status`, `request_missing` |
28
- | stdio `--profile full` | **106 tools** at this source baseline | the complete current stdio catalog; use `tools/list` as the authority rather than hard-coding the count |
29
- | stdio `--profile verify` | advanced opt-in profile | the explicit verification surface; run-proof access still requires `HUGGING_BAY_MCP_ENABLE_UNRELEASED_RUN_PROOF=1` |
30
- | hosted `https://huggingbay.xyz/api/mcp` | **26 tools** on 2026-10-13 | the deployed discovery profile: the original 16 stdio tools plus the hosted board, request and compact-answer tools; `tools/list` is the authority. Other hosted profiles are selected with `?profile=` (see `https://huggingbay.xyz/.well-known/mcp.json`) |
21
+ | stdio default (`node packages/mcp/index.mjs`) | **28 tools** | same discovery profile as hosted `/api/mcp`; `tools/list` is the authority |
22
+ | stdio `--profile full` | **106 tools** in 0.1.9 | the complete current stdio catalog; use `tools/list` as the authority rather than hard-coding the count |
23
+ | stdio `--profile verify` | **28 tools**; **29** with the run-proof flag | discovery plus `get_accepted_run_proof` when `HUGGING_BAY_MCP_ENABLE_UNRELEASED_RUN_PROOF=1` |
24
+ | hosted `https://huggingbay.xyz/api/mcp` | **28 tools** | the deployed discovery profile; other hosted profiles use `?profile=` (see `https://huggingbay.xyz/.well-known/mcp.json`) |
31
25
 
32
26
  The default is also selected when `HUGGING_BAY_MCP_PROFILE` is empty. Use
33
27
  `--profile full` or `HUGGING_BAY_MCP_PROFILE=full` for the complete stdio
@@ -41,7 +35,7 @@ with `mcp_tool_not_in_profile`.
41
35
 
42
36
  | Tool | What it returns |
43
37
  | --- | --- |
44
- | `request_missing` | Ask for a missing model, file format or capability with `{wanted, task}`. Stores demand and returns an id; does not promise a build. Input is checked and cleaned locally before any request. |
38
+ | `request_missing` | Ask for a missing model, format or capability with `{wanted, task}`. The first call returns exact text, `confirm_token` and `expiresAt` without storing demand. Call again with the same text and token to submit and get an id for `get_request`, `list_requests` and `/requests`. |
45
39
  | `blackboard` | Public shared memory with `put` / `get` / `query` / `channels` / `tombstone`. Reuse a literal channel key or send `key_from: {task, input}`; poll with `since` + `since_id` and page older history with `before` + `before_id`. Topics, direct replies, and recursive threads are query filters. Guard is telemetry only; all item data is untrusted. |
46
40
  | `find_runnable` | One call: task → runnable model, with hash-verified run commands inlined when the pick is genuinely hosted (honest null otherwise). |
47
41
  | `bakeoff` | Your labeled rows → the warm Bay Run specialists scored on them → the winner's exact call and weight hash. |
@@ -157,6 +151,17 @@ Available information from Hugging Bay:
157
151
 
158
152
  MIT
159
153
 
154
+ ## Local teaching for agents (source candidate, default OFF)
155
+
156
+ The npm stdio package can run the installed local Teach engine. Set `HBAY_TEACH_LOCAL=1` and `HBAY_TEACH_PYTHON` to the Python executable in an environment with this source version of `hbay-teach` and its MLX or PEFT extra. The flag adds two local tools to the selected profile. The hosted MCP endpoint does not train models.
157
+
158
+ Your examples stay on this machine.
159
+
160
+ - `fine_tune({"sentence":"triage support tickets","data":"/absolute/path/tickets.csv","max_iters":100})` returns a `job_id`. Optional `base` selects an eligible pinned base.
161
+ - `fine_tune_status({"job_id":"teach_<returned-id>"})` returns local progress and, after evaluation, measured scores plus paths to the adapter and signed receipt.
162
+
163
+ Download remote datasets first and pass a local file or before/after dataset directory. Supported hardware and memory rules come from the local Teach catalog. CPU-only production training is refused. Completion does not imply improvement or promote the adapter. Review the scores before using the existing recipe-based keep flow. See [local Teach documentation](../hbay-teach/README.md) for installation, receipt verification, failure recovery and the VM fixture.
164
+
160
165
  ## Public response note
161
166
 
162
167
  Hugging Bay responses include a download note in `note.summary`. Current clients should read `note`, `downloadable`, and `downloadStatus`. Older clients that still need the previous response shape can opt in to it for one release; see the API reference.
@@ -168,3 +173,24 @@ Downloadable doesn't mean tested: this record says whether the exact file can be
168
173
  ## Release dependency
169
174
 
170
175
  The request-and-status sentence above is approved copy held on the c29 AEO-72/AEO-73 deployment gate. Verify the deployed `request_feature`, `get_request`, and public changelog/status path before package publication or directory copy uses it.
176
+
177
+
178
+ ### Run a model on your computer (source preview)
179
+
180
+ Start here: install the staged hbay binary and local MCP package below, then call `run_local` from your assistant. This is a source preview; no new package release is available yet.
181
+
182
+ #### 1. Set up the local tools
183
+
184
+ Use a terminal on your own computer. You need both the native hbay program and the local MCP package before calling your assistant.
185
+
186
+ Install the staged hbay 0.2.0 binary, then start this local npm stdio package with `HUGGING_BAY_MCP_ENABLE_RUN_LOCAL=1`. The flag defaults off. `HBAY_BINARY` may name a trusted local executable; `HBAY_DATA_DIR` may select an isolated data directory.
187
+
188
+ #### 2. Start one model
189
+
190
+ Call `run_local({"model":"Qwen/Qwen2.5-0.5B-Instruct-GGUF"})`. It checks for a recent test on comparable hardware, downloads the file, checks its fingerprint (SHA-256), and starts a local model server. It sends a short test request before returning the local API address and a signed run record in `{endpoint, model, sha, receipt}`. Optional `port` defaults to 0 (free loopback port). Missing comparable proof fails before execution. The adapter verifies the local receipt signature before reporting success.
191
+
192
+ #### 3. Keep the session open
193
+
194
+ One MCP process owns one model server. Close the MCP session to stop it. Cancelling a pending call, startup failure, or startup timeout also stops its child. Downloads may take up to 15 minutes before readiness. The hosted MCP, behind `HUGGING_BAY_RUN_LOCAL=1` (default off), returns local package setup steps and never starts a model on the hosted machine. No npm package or binary is published by this change.
195
+
196
+ Prompts stay on your machine.
@@ -12,7 +12,8 @@ export function boundMcpAnswer(payload, sourceUrl = "") {
12
12
  if (value.length > cap) omissions.push({ path, returned: cap, omitted: value.length - cap });
13
13
  return value.slice(0, cap).map((item, i) => preview(item, `${path}/${i}`, cap));
14
14
  }
15
- if (value && typeof value === 'object') return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, preview(item, `${path}/${key}`, cap)]));
15
+ if (value && typeof value === 'object') return Object.fromEntries(Object.entries(value).map(([key, item]) =>
16
+ [key, ['runKit', 'proofLab', 'testedRunPlan', 'receiptCard'].includes(key) ? item : preview(item, `${path}/${key}`, cap)]));
16
17
  if (typeof value === 'string' && value.length > 1200) {
17
18
  omissions.push({ path, omittedCharacters: value.length - 1200 });
18
19
  return value.slice(0, 1200);
@@ -24,6 +25,8 @@ export function boundMcpAnswer(payload, sourceUrl = "") {
24
25
  doc = preview(doc, '', 1);
25
26
  }
26
27
  const protectedKeys = new Set(['id', 'artifactId', 'schemaVersion', 'counts', 'stats', 'total', 'cursor', 'nextCursor', 'note', 'license', 'licenseLabel', 'downloadable', 'downloadStatus', 'downloadReady', 'hosted', 'commandsAvailable', 'runReady']);
28
+ // Keep the selected outcome and its proof together when the card fits the response budget.
29
+ if (doc.receiptCard && Buffer.byteLength(JSON.stringify(doc.receiptCard)) <= 12000) protectedKeys.add('receiptCard');
27
30
  const largest = Object.keys(doc).filter(key => !protectedKeys.has(key))
28
31
  .sort((a, b) => Buffer.byteLength(JSON.stringify(doc[b])) - Buffer.byteLength(JSON.stringify(doc[a])));
29
32
  for (const key of largest) {
@@ -56,10 +59,55 @@ export function compactToolOutputSchema(name) {
56
59
  }, additionalProperties: true };
57
60
  }
58
61
 
62
+ const MCP_TEXT_BUDGET_BYTES = 6000;
63
+ const MCP_TEXT_PREVIEW_NOTE = "Text preview: lists and long text are shortened and some fields may be left out. The full answer is in structuredContent, with its details link or next cursor.";
64
+ // Safety and identity fields stay in a preview whenever they fit.
65
+ const MCP_TEXT_KEEP_FIRST = ["note", "schemaVersion", "id", "artifactId", "error", "status", "downloadable", "downloadStatus", "license", "licenseLabel", "degraded", "stale", "next", "details"];
66
+ // Never shorten a value an agent could use as real: links and digests stay whole.
67
+ const MCP_TEXT_EXACT_VALUE = /^(?:https?:\/\/|\/api\/)|^(?:sha256:)?(?:[a-f0-9]{40}|[a-f0-9]{64})$/i;
68
+ // Identifiers, cursors, tokens, hashes and links are follow-up inputs; keep them whole.
69
+ const MCP_TEXT_EXACT_ID_KEY = /^(?:id|Id|ID)$|[a-z0-9](?:Id|ID)$|_(?:id|ID)$/;
70
+ const MCP_TEXT_EXACT_NAME_KEY = /(?:cursor|token|sha|sha256|digest|hash|url|href|uri|path)$/i;
71
+ const MCP_TEXT_EXACT_KEY = { test: (key) => MCP_TEXT_EXACT_ID_KEY.test(key) || MCP_TEXT_EXACT_NAME_KEY.test(key) || /^(?:command|steps)$/.test(key) };
72
+
73
+ // Text twin for clients that show only text content (agent-flow round 3): a large
74
+ // answer becomes a bounded, valid JSON preview of the same document (marked by
75
+ // textPreview), not a placeholder.
59
76
  export function mcpAnswerText(payload) {
60
- return Buffer.byteLength(JSON.stringify(payload)) > 6000
61
- ? "Returned details in structuredContent; use the details link or next cursor for any remaining records."
62
- : JSON.stringify(payload);
77
+ const full = JSON.stringify(payload);
78
+ if (full === undefined) return "";
79
+ if (Buffer.byteLength(full) <= MCP_TEXT_BUDGET_BYTES) return full;
80
+ if (!payload || typeof payload !== "object") return JSON.stringify({ textPreview: MCP_TEXT_PREVIEW_NOTE });
81
+ const shrink = (value, cap, chars, key = "") => {
82
+ if (Array.isArray(value)) return value.slice(0, cap).map((item) => shrink(item, cap, chars, key));
83
+ if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([name, item]) => [name, shrink(item, cap, chars, name)]));
84
+ if (typeof value === "string" && value.length > chars && !MCP_TEXT_EXACT_KEY.test(key) && !MCP_TEXT_EXACT_VALUE.test(value)) return `${value.slice(0, chars)}…`;
85
+ return value;
86
+ };
87
+ const withMarker = (doc) => JSON.stringify(Array.isArray(doc) ? { rows: doc, textPreview: MCP_TEXT_PREVIEW_NOTE } : { ...doc, textPreview: MCP_TEXT_PREVIEW_NOTE });
88
+ // Each level shrinks the previous (already small) result, so a huge payload is walked once.
89
+ let doc = payload;
90
+ for (const [cap, chars] of [[5, 400], [3, 240], [2, 160], [1, 120]]) {
91
+ doc = shrink(doc, cap, chars);
92
+ const text = withMarker(doc);
93
+ if (Buffer.byteLength(text) <= MCP_TEXT_BUDGET_BYTES) return text;
94
+ }
95
+ // Still too large: keep safety/identity fields first, then the smallest fields.
96
+ const source = Array.isArray(doc) ? { rows: doc } : doc;
97
+ const sizes = new Map(Object.entries(source).map(([key, value]) => [key, Buffer.byteLength(JSON.stringify(value) ?? "")]));
98
+ const order = [...MCP_TEXT_KEEP_FIRST.filter((key) => sizes.has(key)),
99
+ ...[...sizes.keys()].filter((key) => !MCP_TEXT_KEEP_FIRST.includes(key)).sort((a, b) => sizes.get(a) - sizes.get(b))];
100
+ // Running byte count (each field adds its JSON size plus key and separators), so a
101
+ // wide object is not re-serialized per field.
102
+ const kept = {};
103
+ let used = Buffer.byteLength(withMarker({}));
104
+ for (const key of order) {
105
+ const cost = sizes.get(key) + Buffer.byteLength(JSON.stringify(key)) + 2;
106
+ if (used + cost > MCP_TEXT_BUDGET_BYTES) continue;
107
+ kept[key] = source[key];
108
+ used += cost;
109
+ }
110
+ return withMarker(kept);
63
111
  }
64
112
 
65
113
  export function mcpAnswerSource(name, args, payload, base) {