@onedollarcomputer/odc-mcp 0.3.1 → 0.5.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 (2) hide show
  1. package/bin.js +97 -28
  2. package/package.json +1 -1
package/bin.js CHANGED
@@ -35,7 +35,7 @@ const API_ORIGIN = readApiOrigin();
35
35
  // Function below died with the Oct 2026 billing closure (500/503). NOTE: this
36
36
  // is a cloudflared quick-tunnel URL and CHANGES when that tunnel restarts;
37
37
  // read the current one from /data/odc-api/tunnel-api.log on the box.
38
- const MARITIME_API = "https://executives-loop-seattle-aware.trycloudflare.com";
38
+ const MARITIME_API = "https://wait-successfully-vincent-operational.trycloudflare.com";
39
39
 
40
40
  const DEFAULT_API =
41
41
  process.env.ODC_CURRICULUM_API ||
@@ -121,7 +121,13 @@ async function api(method, apiPath, { token, body, firebaseIdToken } = {}) {
121
121
  data = { raw: text };
122
122
  }
123
123
  if (!res.ok) {
124
- const err = new Error(data.error || res.statusText || `HTTP ${res.status}`);
124
+ let message = data.error || res.statusText || `HTTP ${res.status}`;
125
+ // Speak agent: a rejected token is a reconnect, not a mystery.
126
+ if (res.status === 401 && token) {
127
+ message =
128
+ "That connection is no longer valid (expired or revoked by the user). Call odc_connect to reconnect — the user approves again with Google.";
129
+ }
130
+ const err = new Error(message);
125
131
  err.status = res.status;
126
132
  err.data = data;
127
133
  // Try next host on network-ish failures only; 4xx from API is final
@@ -138,7 +144,7 @@ async function api(method, apiPath, { token, body, firebaseIdToken } = {}) {
138
144
  if (err && err.status && err.status < 500 && err.status !== 404) throw err;
139
145
  }
140
146
  }
141
- throw lastErr || new Error("All curriculum API hosts failed");
147
+ throw lastErr || new Error("Could not reach the One Dollar Computer service — check the connection and try again in a moment.");
142
148
  }
143
149
 
144
150
  function textResult(obj) {
@@ -165,20 +171,41 @@ function loadProjectBrief() {
165
171
  "Firmware must be complete Simple Rust: use odc::*; fn main() { … }",
166
172
  "Never read_button() / pin 13 / BUTTON — bootloader only",
167
173
  "New projects are private; project_publish is irreversible",
168
- "Pair once with curriculum_pair (Agent → Copy on /project/ or /c/)"
174
+ "Connect once with odc_connect (the user approves with Google); an Agent link from the site with curriculum_pair also works"
169
175
  ],
170
176
  aiDocs
171
177
  };
172
178
  }
173
179
 
174
- const server = new McpServer({
175
- name: "odc-curriculum",
176
- version: "0.3.1"
177
- });
180
+ const server = new McpServer(
181
+ {
182
+ name: "odc-curriculum",
183
+ version: "0.5.0"
184
+ },
185
+ {
186
+ instructions:
187
+ "One Dollar Computer MCP: work with the user's firmware projects (Simple Rust) and curriculum lessons on their One Dollar Computer account. " +
188
+ "Start by checking curriculum_status. If it says paired: false, call odc_connect and show the user the approveUrl — they open it in their own browser, sign in with Google, and approve. Never ask the user for a password, and never fetch the approveUrl yourself. " +
189
+ "Firmware rules: complete Simple Rust programs (use odc::*; fn main), pins by their printed numbers 0–19, LED is pin 19, never pin 13 or read_button() (bootloader only). " +
190
+ "project_publish is irreversible — confirm with the user before calling it. odc_compile needs no pairing. " +
191
+ "If a call answers that the connection is no longer valid, reconnect with odc_connect. " +
192
+ "When you finish a task, odc_feedback lets you tell the team how it went — optional, once per session is plenty."
193
+ }
194
+ );
195
+
196
+ // One friendly, consistent answer for every not-connected call: agents
197
+ // should always know the exact next step instead of guessing.
198
+ function notPaired() {
199
+ return textResult({
200
+ ok: false,
201
+ error: "Not connected yet.",
202
+ next: "Call odc_connect — it returns an approval link to show the user (they sign in with Google and approve; a first sign-in creates their account). If the user already gave you an Agent link from the website, call curriculum_pair with it instead."
203
+ });
204
+ }
178
205
 
179
206
  server.tool(
180
207
  "curriculum_pair",
181
- "Connect to ODC (curriculum lessons AND firmware projects). Pass the Agent link from /c/ or /project/ (while signed in). REQUIRED: call this tool — do NOT fetch the URL as a webpage, do NOT scrape onedollarcomputer.com, do NOT create local files. After pairing: for lessons use curriculum_agent_brief; for firmware projects use project_brief then project_get / project_update. Board firmware must be Simple Rust (use odc::*;).",
208
+ "Connect with an Agent link the user copied from the website (the manual alternative — most users should just use odc_connect, which needs no link). Pass the full link or its code. Do NOT fetch the link as a webpage and do NOT scrape the site. After pairing: curriculum_agent_brief for lessons, project_brief for firmware projects.",
182
209
  {
183
210
  connect_url_or_code: z.string().describe("Full Agent link or the connect code")
184
211
  },
@@ -253,7 +280,7 @@ server.tool(
253
280
  "odc_connect",
254
281
  "Connect this agent to the user's One Dollar Computer account — the EASY first-time flow (no link to copy from the site). Call this tool, then show the user the approveUrl from the result: they open it in any browser, sign in with Google (a first sign-in creates their account), and approve. This tool waits for the approval and stores the pairing token itself. Do NOT fetch the approveUrl as a webpage. After connecting: for lessons use curriculum_agent_brief; for firmware projects use project_brief then project_get / project_update. Board firmware must be Simple Rust (use odc::*;).",
255
282
  {
256
- wait_seconds: z.number().optional().describe("How long to wait for the user to approve (default 300, max 600). If the wait ends first, the result is status pending with the approveUrl — show it to the user and call odc_connect again later is NOT needed; the same tool can be called again to keep waiting only while the link is fresh (10 minutes).")
283
+ wait_seconds: z.number().optional().describe("How long to wait for the user to approve (default 300, max 600). If the wait ends first, the result is status pending with the approveUrl — show it to the user and call odc_connect again later is NOT needed; the same tool can be called again to keep waiting only while the link is fresh (30 minutes).")
257
284
  },
258
285
  async ({ wait_seconds }) => {
259
286
  const waitMs = Math.min(Math.max(Number(wait_seconds ?? 300) || 0, 0), 600) * 1000;
@@ -314,11 +341,51 @@ server.tool(
314
341
  status: "pending",
315
342
  approveUrl,
316
343
  message:
317
- "Not approved yet. Show the user this approveUrl: they open it in any browser, sign in with Google, and approve. The link stays fresh for 10 minutes from the start of this call."
344
+ "Not approved yet. Show the user this approveUrl: they open it in any browser, sign in with Google, and approve. The link stays fresh for 30 minutes from the start of this call."
318
345
  });
319
346
  }
320
347
  );
321
348
 
349
+ server.tool(
350
+ "odc_feedback",
351
+ "Tell the One Dollar Computer team how working with this MCP went — what worked, what failed, what confused you. Honest, specific reports are read by the team and shape the next version. This report is one-way: it changes nothing, grants nothing, and no other agent will ever see it. Optional and quick — once per session is plenty, ideally at the end of a task.",
352
+ {
353
+ rating: z.number().describe("Overall experience: integer 1 (bad) to 5 (great)"),
354
+ category: z.enum(["connect", "compile", "projects", "lessons", "docs", "other"]).optional().describe("What the report is mostly about"),
355
+ worked: z.string().optional().describe("What worked well (short, max ~600 characters)"),
356
+ failed: z.string().optional().describe("What failed, confused you, or was missing (short, max ~600 characters)"),
357
+ agent: z.string().optional().describe("Your agent name and version, e.g. 'Claude Code 2.x', 'Cursor 1.x'")
358
+ },
359
+ async (args) => {
360
+ const rating = Math.round(Number(args.rating));
361
+ if (!Number.isInteger(rating) || rating < 1 || rating > 5) {
362
+ return textResult({ ok: false, error: "rating must be an integer from 1 to 5." });
363
+ }
364
+ if (!args.worked && !args.failed) {
365
+ return textResult({ ok: false, error: "Add a short worked or failed note — an empty report helps nobody." });
366
+ }
367
+ try {
368
+ const data = await api("POST", "/feedback", {
369
+ token: getToken() || undefined,
370
+ body: {
371
+ rating,
372
+ category: args.category || "other",
373
+ worked: args.worked || "",
374
+ failed: args.failed || "",
375
+ agent: args.agent || ""
376
+ }
377
+ });
378
+ return textResult({
379
+ ok: true,
380
+ message: "Thanks — your report went to the One Dollar Computer team. It is read by people, never fed to other agents.",
381
+ raw: data
382
+ });
383
+ } catch (err) {
384
+ return textResult({ ok: false, error: `Could not send the report: ${err.message}` });
385
+ }
386
+ }
387
+ );
388
+
322
389
  const BUILDS_DIR = path.join(os.homedir(), ".config", "odc", "builds");
323
390
 
324
391
  async function rtdb(method, rtdbPath, body) {
@@ -490,16 +557,20 @@ server.tool(
490
557
  server.registerTool(
491
558
  "curriculum_status",
492
559
  {
493
- description: "Show whether an agent token is stored and the API base URL."
560
+ description: "Check the connection state: whether this agent is connected to a One Dollar Computer account, and which API it talks to. Call this first when unsure — it never changes anything."
494
561
  },
495
562
  async () => {
496
563
  const token = getToken();
497
- return textResult({
564
+ const out = {
498
565
  paired: !!token,
499
566
  api: DEFAULT_API,
500
567
  tokenPath: TOKEN_PATH,
501
568
  tokenPreview: token ? `${token.slice(0, 16)}…` : null
502
- });
569
+ };
570
+ if (!token) {
571
+ out.next = "Call odc_connect — it returns an approval link to show the user (they sign in with Google and approve).";
572
+ }
573
+ return textResult(out);
503
574
  }
504
575
  );
505
576
 
@@ -507,7 +578,7 @@ server.registerTool(
507
578
  "curriculum_agent_brief",
508
579
  {
509
580
  description:
510
- "Return the curriculum authoring contract: HTML5 teaching UI is free; board firmware must be Simple Rust (use odc::*;). Call after curriculum_pair before writing lessons."
581
+ "Return the curriculum authoring contract: HTML5 teaching UI is free; board firmware must be Simple Rust (use odc::*;). Call after connecting (odc_connect or curriculum_pair) before writing lessons."
511
582
  },
512
583
  async () => textResult({
513
584
  docsUrl: "https://onedollarcomputer.com/c/AGENT_LESSONS.md",
@@ -526,9 +597,7 @@ server.registerTool(
526
597
  async () => {
527
598
  const token = getToken();
528
599
  if (!token) {
529
- return textResult({
530
- error: "Not paired. Ask the user for a Connect agent link, then call curriculum_pair."
531
- });
600
+ return notPaired();
532
601
  }
533
602
  const data = await api("GET", "/lessons", { token });
534
603
  return textResult(data);
@@ -554,7 +623,7 @@ server.tool(
554
623
  async (args) => {
555
624
  const token = getToken();
556
625
  if (!token) {
557
- return textResult({ error: "Not paired. Use curriculum_pair first." });
626
+ return notPaired();
558
627
  }
559
628
  const body = { title: args.title };
560
629
  if (args.overview !== undefined) body.overview = args.overview;
@@ -578,7 +647,7 @@ server.tool(
578
647
  async ({ lesson_id }) => {
579
648
  const token = getToken();
580
649
  if (!token) {
581
- return textResult({ error: "Not paired. Use curriculum_pair first." });
650
+ return notPaired();
582
651
  }
583
652
  const data = await api("GET", `/lessons/${encodeURIComponent(lesson_id)}`, { token });
584
653
  return textResult(data);
@@ -616,7 +685,7 @@ server.tool(
616
685
  async (args) => {
617
686
  const token = getToken();
618
687
  if (!token) {
619
- return textResult({ error: "Not paired. Use curriculum_pair first." });
688
+ return notPaired();
620
689
  }
621
690
  const body = {};
622
691
  if (args.title !== undefined) body.title = args.title;
@@ -645,7 +714,7 @@ server.registerTool(
645
714
  "project_brief",
646
715
  {
647
716
  description:
648
- "Firmware project authoring contract (Simple Rust, pin 13 warning, publish rules). Call after curriculum_pair before project_create / project_update."
717
+ "Firmware project authoring contract (Simple Rust, pin 13 warning, publish rules). Call after connecting (odc_connect or curriculum_pair) before project_create / project_update."
649
718
  },
650
719
  async () => textResult(loadProjectBrief())
651
720
  );
@@ -658,7 +727,7 @@ server.registerTool(
658
727
  async () => {
659
728
  const token = getToken();
660
729
  if (!token) {
661
- return textResult({ error: "Not paired. Use curriculum_pair first (Agent → Copy on /project/)." });
730
+ return notPaired();
662
731
  }
663
732
  const data = await api("GET", "/projects", { token });
664
733
  return textResult(data);
@@ -678,7 +747,7 @@ server.registerTool(
678
747
  async (args) => {
679
748
  const token = getToken();
680
749
  if (!token) {
681
- return textResult({ error: "Not paired. Use curriculum_pair first." });
750
+ return notPaired();
682
751
  }
683
752
  const body = { name: args.name };
684
753
  if (args.code !== undefined) body.code = args.code;
@@ -698,7 +767,7 @@ server.registerTool(
698
767
  async ({ project_id }) => {
699
768
  const token = getToken();
700
769
  if (!token) {
701
- return textResult({ error: "Not paired. Use curriculum_pair first." });
770
+ return notPaired();
702
771
  }
703
772
  const data = await api("GET", `/projects/${encodeURIComponent(project_id)}`, { token });
704
773
  return textResult(data);
@@ -721,7 +790,7 @@ server.registerTool(
721
790
  async (args) => {
722
791
  const token = getToken();
723
792
  if (!token) {
724
- return textResult({ error: "Not paired. Use curriculum_pair first." });
793
+ return notPaired();
725
794
  }
726
795
  const body = {};
727
796
  if (args.name !== undefined) body.name = args.name;
@@ -748,7 +817,7 @@ server.registerTool(
748
817
  async ({ project_id }) => {
749
818
  const token = getToken();
750
819
  if (!token) {
751
- return textResult({ error: "Not paired. Use curriculum_pair first." });
820
+ return notPaired();
752
821
  }
753
822
  const data = await api("POST", `/projects/${encodeURIComponent(project_id)}/publish`, {
754
823
  token,
@@ -770,7 +839,7 @@ server.registerTool(
770
839
  async ({ project_id }) => {
771
840
  const token = getToken();
772
841
  if (!token) {
773
- return textResult({ error: "Not paired. Use curriculum_pair first." });
842
+ return notPaired();
774
843
  }
775
844
  const data = await api("POST", `/projects/${encodeURIComponent(project_id)}/fork`, {
776
845
  token,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onedollarcomputer/odc-mcp",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "MCP server for One Dollar Computer \u2014 curriculum lessons and firmware projects",
5
5
  "type": "module",
6
6
  "bin": {