gogcli-mcp-classroom 4.3.0 → 4.4.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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/dist/index.js +480 -17
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/tools/classroom-extra.ts +25 -3
- package/tests/tools/classroom-extra.test.ts +52 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"metadata": {
|
|
9
9
|
"description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
|
|
10
|
-
"version": "4.
|
|
10
|
+
"version": "4.4.0"
|
|
11
11
|
},
|
|
12
12
|
"plugins": [
|
|
13
13
|
{
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"displayName": "gogcli (Classroom)",
|
|
16
16
|
"source": "./",
|
|
17
17
|
"description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
|
|
18
|
-
"version": "4.
|
|
18
|
+
"version": "4.4.0",
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "Chris Hall"
|
|
21
21
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gogcli-mcp-classroom",
|
|
3
3
|
"displayName": "gogcli (Classroom)",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.4.0",
|
|
5
5
|
"description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Chris Hall",
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,33 @@ var storage2 = new AsyncLocalStorage2();
|
|
|
37
37
|
function withCallerCapabilities(capabilities, fn) {
|
|
38
38
|
return capabilities ? storage2.run(capabilities, fn) : fn();
|
|
39
39
|
}
|
|
40
|
+
function currentCallerCapabilities() {
|
|
41
|
+
return storage2.getStore();
|
|
42
|
+
}
|
|
43
|
+
var ENVELOPE_CAPABILITIES_KEY = "io.modelcontextprotocol/clientCapabilities";
|
|
44
|
+
var ELICITATION_MODES = ["form", "url"];
|
|
45
|
+
function isRecord(value) {
|
|
46
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
47
|
+
}
|
|
48
|
+
function callerCapabilities(ctx) {
|
|
49
|
+
const envelope = isRecord(ctx) && isRecord(ctx.mcpReq) ? ctx.mcpReq.envelope : void 0;
|
|
50
|
+
if (isRecord(envelope)) {
|
|
51
|
+
const declared = envelope[ENVELOPE_CAPABILITIES_KEY];
|
|
52
|
+
if (isRecord(declared))
|
|
53
|
+
return declared;
|
|
54
|
+
}
|
|
55
|
+
return currentCallerCapabilities();
|
|
56
|
+
}
|
|
57
|
+
function callerAcceptsFormElicitation(ctx) {
|
|
58
|
+
const capabilities = callerCapabilities(ctx);
|
|
59
|
+
if (!capabilities)
|
|
60
|
+
return void 0;
|
|
61
|
+
const elicitation = capabilities.elicitation;
|
|
62
|
+
if (!isRecord(elicitation))
|
|
63
|
+
return false;
|
|
64
|
+
const namedModes = ELICITATION_MODES.filter((mode) => mode in elicitation);
|
|
65
|
+
return namedModes.length === 0 || namedModes.includes("form");
|
|
66
|
+
}
|
|
40
67
|
|
|
41
68
|
// ../../node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
|
|
42
69
|
var __create = Object.create;
|
|
@@ -24101,6 +24128,37 @@ var inputRequired = Object.assign(buildInputRequired, {
|
|
|
24101
24128
|
return { method: "roots/list" };
|
|
24102
24129
|
}
|
|
24103
24130
|
});
|
|
24131
|
+
function acceptedContent(responses, key, schema) {
|
|
24132
|
+
const view = inputResponse(responses, key);
|
|
24133
|
+
if (view.kind !== "elicit" || view.action !== "accept" || view.content === void 0) return void 0;
|
|
24134
|
+
if (schema === void 0) return view.content;
|
|
24135
|
+
const outcome = schema["~standard"].validate(view.content);
|
|
24136
|
+
if (outcome instanceof Promise) throw new TypeError("acceptedContent(responses, key, schema) requires a synchronously-validating schema");
|
|
24137
|
+
return outcome.issues === void 0 ? outcome.value : void 0;
|
|
24138
|
+
}
|
|
24139
|
+
function inputResponse(responses, key) {
|
|
24140
|
+
if (responses === void 0 || typeof responses !== "object" || responses === null) return { kind: "missing" };
|
|
24141
|
+
const entry = responses[key];
|
|
24142
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return { kind: "missing" };
|
|
24143
|
+
const candidate = entry;
|
|
24144
|
+
if (candidate["action"] === "accept" || candidate["action"] === "decline" || candidate["action"] === "cancel") {
|
|
24145
|
+
const content = candidate["content"];
|
|
24146
|
+
return {
|
|
24147
|
+
kind: "elicit",
|
|
24148
|
+
action: candidate["action"],
|
|
24149
|
+
...content !== null && typeof content === "object" && !Array.isArray(content) && { content }
|
|
24150
|
+
};
|
|
24151
|
+
}
|
|
24152
|
+
if (Array.isArray(candidate["roots"])) return {
|
|
24153
|
+
kind: "roots",
|
|
24154
|
+
roots: candidate["roots"]
|
|
24155
|
+
};
|
|
24156
|
+
if (typeof candidate["role"] === "string" && candidate["content"] !== void 0) return {
|
|
24157
|
+
kind: "sampling",
|
|
24158
|
+
result: candidate
|
|
24159
|
+
};
|
|
24160
|
+
return { kind: "missing" };
|
|
24161
|
+
}
|
|
24104
24162
|
var REQUEST_STATE_ONLY_LEG_PACING_MS = 250;
|
|
24105
24163
|
function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
24106
24164
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
@@ -34148,14 +34206,14 @@ function serveStdio(factory, options = {}) {
|
|
|
34148
34206
|
return false;
|
|
34149
34207
|
};
|
|
34150
34208
|
const answerLegacyRejection = (request, reason, requestedVersion) => {
|
|
34151
|
-
const
|
|
34209
|
+
const rejection3 = modernOnlyStrictRejection({
|
|
34152
34210
|
kind: "legacy",
|
|
34153
34211
|
reason,
|
|
34154
34212
|
...requestedVersion !== void 0 && { requestedVersion }
|
|
34155
34213
|
}, SUPPORTED_MODERN_PROTOCOL_VERSIONS);
|
|
34156
|
-
if (
|
|
34157
|
-
reportError(/* @__PURE__ */ new Error(`Rejected 2025-era request on a modern-only stdio connection (${
|
|
34158
|
-
return writeErrorResponse(request.id,
|
|
34214
|
+
if (rejection3 === void 0) return Promise.resolve();
|
|
34215
|
+
reportError(/* @__PURE__ */ new Error(`Rejected 2025-era request on a modern-only stdio connection (${rejection3.cell}): ${rejection3.message}`));
|
|
34216
|
+
return writeErrorResponse(request.id, rejection3.code, rejection3.message, rejection3.data);
|
|
34159
34217
|
};
|
|
34160
34218
|
const onInstanceClosed = (channel) => {
|
|
34161
34219
|
if (closing || channel === discarding) return;
|
|
@@ -34458,6 +34516,11 @@ function walk(value, keep, drop) {
|
|
|
34458
34516
|
}
|
|
34459
34517
|
|
|
34460
34518
|
// ../../node_modules/@chrischall/mcp-utils/dist/response/index.js
|
|
34519
|
+
function textResult(data) {
|
|
34520
|
+
return {
|
|
34521
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
34522
|
+
};
|
|
34523
|
+
}
|
|
34461
34524
|
function rawTextResult(text) {
|
|
34462
34525
|
return { content: [{ type: "text", text }] };
|
|
34463
34526
|
}
|
|
@@ -34468,6 +34531,154 @@ function errorResult(message) {
|
|
|
34468
34531
|
};
|
|
34469
34532
|
}
|
|
34470
34533
|
|
|
34534
|
+
// ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
|
|
34535
|
+
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
34536
|
+
var DEFAULT_REQUEST_KEY = "confirmation";
|
|
34537
|
+
var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
|
|
34538
|
+
var UNSUPPORTED_NOTE = "Nothing was done because this client cannot show a confirmation prompt (it declares no MCP elicitation capability), and this action is never taken without one";
|
|
34539
|
+
var STATE_PREFIX = "mcpu.confirm.v1.";
|
|
34540
|
+
function canonicalJson(value) {
|
|
34541
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
34542
|
+
return JSON.stringify(value);
|
|
34543
|
+
if (value === void 0)
|
|
34544
|
+
return "null";
|
|
34545
|
+
if (typeof value === "number")
|
|
34546
|
+
return Number.isFinite(value) ? JSON.stringify(value) : `{"$num":"${String(value)}"}`;
|
|
34547
|
+
if (typeof value === "bigint")
|
|
34548
|
+
return `{"$bigint":"${value.toString()}"}`;
|
|
34549
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
34550
|
+
throw new TypeError(`requireConfirmation: cannot bind a ${typeof value} argument value.`);
|
|
34551
|
+
}
|
|
34552
|
+
if (Array.isArray(value))
|
|
34553
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
34554
|
+
if (value instanceof Date) {
|
|
34555
|
+
return `{"$date":${JSON.stringify(Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString())}}`;
|
|
34556
|
+
}
|
|
34557
|
+
if (ArrayBuffer.isView(value)) {
|
|
34558
|
+
const bytes = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
34559
|
+
return `{"$bytes":${JSON.stringify(bytes.toString("base64"))}}`;
|
|
34560
|
+
}
|
|
34561
|
+
if (value instanceof ArrayBuffer)
|
|
34562
|
+
return `{"$bytes":${JSON.stringify(Buffer.from(value).toString("base64"))}}`;
|
|
34563
|
+
if (value instanceof Map) {
|
|
34564
|
+
const entries2 = [...value.entries()].map(([k, v]) => `[${canonicalJson(k)},${canonicalJson(v)}]`).sort();
|
|
34565
|
+
return `{"$map":[${entries2.join(",")}]}`;
|
|
34566
|
+
}
|
|
34567
|
+
if (value instanceof Set) {
|
|
34568
|
+
return `{"$set":[${[...value].map(canonicalJson).sort().join(",")}]}`;
|
|
34569
|
+
}
|
|
34570
|
+
const proto = Object.getPrototypeOf(value);
|
|
34571
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
34572
|
+
throw new TypeError("requireConfirmation: cannot bind a non-plain object argument value (class instance).");
|
|
34573
|
+
}
|
|
34574
|
+
const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
34575
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
|
|
34576
|
+
}
|
|
34577
|
+
function escapeKey(key) {
|
|
34578
|
+
return key.startsWith("$") ? `$${key}` : key;
|
|
34579
|
+
}
|
|
34580
|
+
function bindingKey(binding) {
|
|
34581
|
+
if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
|
|
34582
|
+
throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
|
|
34583
|
+
}
|
|
34584
|
+
const key = typeof binding.key === "string" ? Buffer.from(binding.key, "utf8") : Buffer.from(binding.key);
|
|
34585
|
+
if (key.length < 32) {
|
|
34586
|
+
throw new RangeError("requireConfirmation: binding.key must be at least 32 bytes.");
|
|
34587
|
+
}
|
|
34588
|
+
return key;
|
|
34589
|
+
}
|
|
34590
|
+
function commitment(action, args) {
|
|
34591
|
+
return createHash("sha256").update(`${action}\0${canonicalJson(args)}`).digest("base64url");
|
|
34592
|
+
}
|
|
34593
|
+
function mintState(key, action, binding) {
|
|
34594
|
+
const exp = Math.floor(Date.now() / 1e3) + (binding.ttlSeconds ?? 600);
|
|
34595
|
+
const body = Buffer.from(JSON.stringify({ c: commitment(action, binding.args), exp })).toString("base64url");
|
|
34596
|
+
const mac3 = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest("base64url");
|
|
34597
|
+
return `${STATE_PREFIX}${body}.${mac3}`;
|
|
34598
|
+
}
|
|
34599
|
+
function verifyState(key, action, binding, state) {
|
|
34600
|
+
if (typeof state !== "string" || !state.startsWith(STATE_PREFIX))
|
|
34601
|
+
return false;
|
|
34602
|
+
const rest = state.slice(STATE_PREFIX.length);
|
|
34603
|
+
const dot = rest.indexOf(".");
|
|
34604
|
+
if (dot < 0)
|
|
34605
|
+
return false;
|
|
34606
|
+
const body = rest.slice(0, dot);
|
|
34607
|
+
const mac3 = Buffer.from(rest.slice(dot + 1), "base64url");
|
|
34608
|
+
const expected = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest();
|
|
34609
|
+
if (mac3.length !== expected.length || !timingSafeEqual(mac3, expected))
|
|
34610
|
+
return false;
|
|
34611
|
+
let payload;
|
|
34612
|
+
try {
|
|
34613
|
+
payload = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
34614
|
+
} catch {
|
|
34615
|
+
return false;
|
|
34616
|
+
}
|
|
34617
|
+
if (typeof payload.exp !== "number" || payload.exp * 1e3 <= Date.now())
|
|
34618
|
+
return false;
|
|
34619
|
+
const want = Buffer.from(commitment(action, binding.args));
|
|
34620
|
+
const got = Buffer.from(typeof payload.c === "string" ? payload.c : "");
|
|
34621
|
+
return got.length === want.length && timingSafeEqual(got, want);
|
|
34622
|
+
}
|
|
34623
|
+
function echoedState(ctx) {
|
|
34624
|
+
const accessor = ctx.mcpReq.requestState;
|
|
34625
|
+
return typeof accessor === "function" ? accessor() : void 0;
|
|
34626
|
+
}
|
|
34627
|
+
function requireConfirmation(ctx, options) {
|
|
34628
|
+
const requestKey = options.requestKey ?? DEFAULT_REQUEST_KEY;
|
|
34629
|
+
const key = options.binding ? bindingKey(options.binding) : void 0;
|
|
34630
|
+
const confirmationSchema = external_exports.object({
|
|
34631
|
+
confirmed: external_exports.boolean().describe(options.confirmationLabel ?? DEFAULT_CONFIRMATION_LABEL)
|
|
34632
|
+
});
|
|
34633
|
+
const ask = () => {
|
|
34634
|
+
const preview = {
|
|
34635
|
+
action: options.action,
|
|
34636
|
+
...options.details === void 0 ? {} : { details: options.details }
|
|
34637
|
+
};
|
|
34638
|
+
return inputRequired({
|
|
34639
|
+
inputRequests: {
|
|
34640
|
+
[requestKey]: inputRequired.elicit({
|
|
34641
|
+
message: `${options.message}
|
|
34642
|
+
${JSON.stringify(preview, null, 2)}`,
|
|
34643
|
+
requestedSchema: confirmationSchema
|
|
34644
|
+
})
|
|
34645
|
+
},
|
|
34646
|
+
...key && options.binding ? { requestState: mintState(key, options.action, options.binding) } : {}
|
|
34647
|
+
});
|
|
34648
|
+
};
|
|
34649
|
+
const response = inputResponse(ctx.mcpReq.inputResponses, requestKey);
|
|
34650
|
+
const accepted = acceptedContent(ctx.mcpReq.inputResponses, requestKey, confirmationSchema);
|
|
34651
|
+
if (response.kind === "missing") {
|
|
34652
|
+
if (callerAcceptsFormElicitation(ctx) === false) {
|
|
34653
|
+
return textResult({
|
|
34654
|
+
confirmed: false,
|
|
34655
|
+
dispatched: false,
|
|
34656
|
+
action: options.action,
|
|
34657
|
+
reason: "confirmation-unsupported",
|
|
34658
|
+
note: options.unsupportedNote ? `${UNSUPPORTED_NOTE}. ${options.unsupportedNote}` : `${UNSUPPORTED_NOTE}.`
|
|
34659
|
+
});
|
|
34660
|
+
}
|
|
34661
|
+
return ask();
|
|
34662
|
+
}
|
|
34663
|
+
if (response.kind === "elicit" && response.action === "accept" && accepted?.confirmed === true) {
|
|
34664
|
+
if (key && options.binding) {
|
|
34665
|
+
const state = echoedState(ctx);
|
|
34666
|
+
if (state === void 0 || state === null) {
|
|
34667
|
+
return errorResult(`Confirmation for ${options.action} was accepted, but the retry carried no requestState, so it cannot be checked against the prompt that was shown. Nothing was done. The likely cause is that the MCP client or host does not round-trip requestState (it must echo the requestState from the input_required result back on the retry); asking again would loop.`);
|
|
34668
|
+
}
|
|
34669
|
+
if (!verifyState(key, options.action, options.binding, state))
|
|
34670
|
+
return ask();
|
|
34671
|
+
}
|
|
34672
|
+
return void 0;
|
|
34673
|
+
}
|
|
34674
|
+
return textResult({
|
|
34675
|
+
confirmed: false,
|
|
34676
|
+
cancelled: true,
|
|
34677
|
+
action: options.action,
|
|
34678
|
+
note: "Nothing was changed because the confirmation was declined, cancelled, or left unchecked."
|
|
34679
|
+
});
|
|
34680
|
+
}
|
|
34681
|
+
|
|
34471
34682
|
// ../../node_modules/@chrischall/mcp-utils/dist/server/index.js
|
|
34472
34683
|
var SERVER_PROTOCOL_VERSIONS = Object.freeze([
|
|
34473
34684
|
"2026-07-28",
|
|
@@ -34763,9 +34974,9 @@ function offsetAt(instant, tz) {
|
|
|
34763
34974
|
const w = wallPartsIn(instant, tz);
|
|
34764
34975
|
const asUTC = Date.UTC(w.year, w.month - 1, w.day, w.hour, w.minute, w.second, instant.getUTCMilliseconds());
|
|
34765
34976
|
const minutes = Math.round((asUTC - instant.getTime()) / 6e4);
|
|
34766
|
-
const
|
|
34977
|
+
const sign2 = minutes < 0 ? "-" : "+";
|
|
34767
34978
|
const abs = Math.abs(minutes);
|
|
34768
|
-
return `${
|
|
34979
|
+
return `${sign2}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
|
|
34769
34980
|
}
|
|
34770
34981
|
function wallPartsIn(instant, tz) {
|
|
34771
34982
|
const parts = new Intl.DateTimeFormat("en-US", {
|
|
@@ -35550,6 +35761,183 @@ function formatAuthHealth(raw, now) {
|
|
|
35550
35761
|
return accounts.map((a) => formatOneAccountHealth(a, now)).join("\n\n");
|
|
35551
35762
|
}
|
|
35552
35763
|
|
|
35764
|
+
// ../gogcli-mcp/src/send-confirm-token.ts
|
|
35765
|
+
import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
35766
|
+
var CONFIRM_TOKEN_TTL_DEFAULT_SECONDS = 600;
|
|
35767
|
+
var PREFIX = "gct1";
|
|
35768
|
+
var secret;
|
|
35769
|
+
var spent = /* @__PURE__ */ new Map();
|
|
35770
|
+
function sendConfirmFallbackEnabled() {
|
|
35771
|
+
return readEnvVar("GOG_SEND_CONFIRM_FALLBACK")?.trim().toLowerCase() === "token";
|
|
35772
|
+
}
|
|
35773
|
+
function confirmTokenTtlSeconds() {
|
|
35774
|
+
const raw = readEnvVar("GOG_CONFIRM_TTL_SECONDS")?.trim();
|
|
35775
|
+
if (raw && /^\d+$/.test(raw)) {
|
|
35776
|
+
const n = Number(raw);
|
|
35777
|
+
if (n > 0) return n;
|
|
35778
|
+
}
|
|
35779
|
+
return CONFIRM_TOKEN_TTL_DEFAULT_SECONDS;
|
|
35780
|
+
}
|
|
35781
|
+
function hmacKey() {
|
|
35782
|
+
if (!secret) {
|
|
35783
|
+
const configured = readEnvVar("GOG_CONFIRM_SECRET");
|
|
35784
|
+
secret = configured ? Buffer.from(configured, "utf8") : randomBytes(32);
|
|
35785
|
+
}
|
|
35786
|
+
return secret;
|
|
35787
|
+
}
|
|
35788
|
+
function canonicalize(value) {
|
|
35789
|
+
if (Array.isArray(value)) return value.map(canonicalize);
|
|
35790
|
+
if (value && typeof value === "object") {
|
|
35791
|
+
const out = {};
|
|
35792
|
+
for (const key of Object.keys(value).sort()) {
|
|
35793
|
+
const v = value[key];
|
|
35794
|
+
if (v !== void 0) out[key] = canonicalize(v);
|
|
35795
|
+
}
|
|
35796
|
+
return out;
|
|
35797
|
+
}
|
|
35798
|
+
return value;
|
|
35799
|
+
}
|
|
35800
|
+
function hashSendPayload(payload) {
|
|
35801
|
+
return createHash2("sha256").update(JSON.stringify(canonicalize(payload))).digest("hex");
|
|
35802
|
+
}
|
|
35803
|
+
function sign(body) {
|
|
35804
|
+
return createHmac2("sha256", hmacKey()).update(`${PREFIX}.${body}`).digest("base64url");
|
|
35805
|
+
}
|
|
35806
|
+
function issueConfirmToken(binding, now = Date.now()) {
|
|
35807
|
+
const exp = now + confirmTokenTtlSeconds() * 1e3;
|
|
35808
|
+
const claims = {
|
|
35809
|
+
t: binding.tool,
|
|
35810
|
+
a: binding.account,
|
|
35811
|
+
g: binding.target,
|
|
35812
|
+
...binding.revision === void 0 ? {} : { r: binding.revision },
|
|
35813
|
+
h: binding.payloadHash,
|
|
35814
|
+
iat: now,
|
|
35815
|
+
exp,
|
|
35816
|
+
n: randomBytes(16).toString("base64url")
|
|
35817
|
+
};
|
|
35818
|
+
const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
|
|
35819
|
+
return { token: `${PREFIX}.${body}.${sign(body)}`, expiresAt: new Date(exp).toISOString() };
|
|
35820
|
+
}
|
|
35821
|
+
function signatureMatches(body, sig) {
|
|
35822
|
+
const expected = Buffer.from(sign(body), "utf8");
|
|
35823
|
+
const actual = Buffer.from(sig, "utf8");
|
|
35824
|
+
return expected.length === actual.length && timingSafeEqual2(expected, actual);
|
|
35825
|
+
}
|
|
35826
|
+
function parseClaims(body) {
|
|
35827
|
+
try {
|
|
35828
|
+
return JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
35829
|
+
} catch {
|
|
35830
|
+
return void 0;
|
|
35831
|
+
}
|
|
35832
|
+
}
|
|
35833
|
+
function verifyConfirmToken(token, binding, now = Date.now()) {
|
|
35834
|
+
for (const [nonce, exp] of spent) if (exp < now) spent.delete(nonce);
|
|
35835
|
+
const parts = token.split(".");
|
|
35836
|
+
if (parts.length !== 3 || parts[0] !== PREFIX || !parts[1] || !parts[2]) return { ok: false, error: "TOKEN_INVALID" };
|
|
35837
|
+
const [, body, sig] = parts;
|
|
35838
|
+
if (!signatureMatches(body, sig)) return { ok: false, error: "TOKEN_INVALID" };
|
|
35839
|
+
const claims = parseClaims(body);
|
|
35840
|
+
if (!claims) return { ok: false, error: "TOKEN_INVALID" };
|
|
35841
|
+
if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
|
|
35842
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
35843
|
+
}
|
|
35844
|
+
if (spent.has(claims.n)) return { ok: false, error: "TOKEN_REUSED" };
|
|
35845
|
+
if (now > claims.exp) return { ok: false, error: "TOKEN_EXPIRED" };
|
|
35846
|
+
if (claims.r !== binding.revision) return { ok: false, error: "DRAFT_CHANGED", reason: "message-id-rotated" };
|
|
35847
|
+
if (claims.h !== binding.payloadHash) return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
|
|
35848
|
+
spent.set(claims.n, claims.exp);
|
|
35849
|
+
return { ok: true };
|
|
35850
|
+
}
|
|
35851
|
+
|
|
35852
|
+
// ../gogcli-mcp/src/dispatch-confirmation.ts
|
|
35853
|
+
var BODY_PREVIEW_MAX = 2048;
|
|
35854
|
+
function bodyPreview(text) {
|
|
35855
|
+
if (!text) return void 0;
|
|
35856
|
+
if (text.length <= BODY_PREVIEW_MAX) return text;
|
|
35857
|
+
return `${text.slice(0, BODY_PREVIEW_MAX)}\u2026 [${text.length - BODY_PREVIEW_MAX} more characters not shown]`;
|
|
35858
|
+
}
|
|
35859
|
+
var CONFIRM_ACTION_INSTRUCTION = "Show this preview to the user verbatim and proceed only after they explicitly approve in chat. Then call again with confirmToken.";
|
|
35860
|
+
var FALLBACK_HINT = "Or set GOG_SEND_CONFIRM_FALLBACK=token to enable two-step confirmation.";
|
|
35861
|
+
var CONFIRM_FALLBACK_DESCRIPTION = ' If the client cannot show that prompt (no MCP elicitation, e.g. claude.ai) and the server sets GOG_SEND_CONFIRM_FALLBACK=token, a two-step flow applies instead: call WITHOUT confirmToken and nothing is sent or changed \u2014 the result has status "confirmation-required", the full preview and a confirmToken. Show that preview to the user verbatim; only after they explicitly approve it in chat, call again with the SAME arguments plus confirmToken. The tool re-reads what it would act on and refuses (DRAFT_CHANGED, with a fresh preview and token) if it changed; TOKEN_EXPIRED / TOKEN_REUSED / TOKEN_INVALID also do nothing.';
|
|
35862
|
+
var confirmTokenParam = external_exports.string().optional().describe(
|
|
35863
|
+
`ONLY for the two-step fallback (client without MCP elicitation, server with GOG_SEND_CONFIRM_FALLBACK=token). The confirmToken from this same tool's phase-1 "confirmation-required" response, passed back ONLY after the user has seen that preview and explicitly approved it in chat \u2014 never on the first call, never invented, never reused. Call again with the same arguments. Ignored when the client supports elicitation.`
|
|
35864
|
+
);
|
|
35865
|
+
var TOKEN_ERROR_NOTE = {
|
|
35866
|
+
TOKEN_EXPIRED: "Nothing was sent or changed: the confirmToken expired. Call again WITHOUT confirmToken for a fresh preview, and ask the user to approve it again.",
|
|
35867
|
+
TOKEN_REUSED: "Nothing was sent or changed by this call: this confirmToken was already used, and one approval acts once. If doing it again is really intended, call again WITHOUT confirmToken and get a new approval.",
|
|
35868
|
+
TOKEN_INVALID: "Nothing was sent or changed: this confirmToken was not issued by this server for this tool, account and target (or the server has restarted since). Call again WITHOUT confirmToken for a fresh preview and approval."
|
|
35869
|
+
};
|
|
35870
|
+
var DRAFT_CHANGED_NOTE = {
|
|
35871
|
+
"message-id-rotated": "Nothing was sent or changed: the target was edited since the user approved it (a draft's messageId or an event's version rotated), so what would happen is not what they saw.",
|
|
35872
|
+
"payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
|
|
35873
|
+
};
|
|
35874
|
+
function isToolResult(value) {
|
|
35875
|
+
return Array.isArray(value.content);
|
|
35876
|
+
}
|
|
35877
|
+
function rejection2(data) {
|
|
35878
|
+
return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
|
|
35879
|
+
}
|
|
35880
|
+
async function tokenConfirmation(op, fallback) {
|
|
35881
|
+
const subject = await fallback.subject();
|
|
35882
|
+
if (isToolResult(subject)) return subject;
|
|
35883
|
+
const binding = {
|
|
35884
|
+
tool: fallback.tool,
|
|
35885
|
+
account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
|
|
35886
|
+
target: subject.target,
|
|
35887
|
+
...subject.revision === void 0 ? {} : { revision: subject.revision },
|
|
35888
|
+
payloadHash: hashSendPayload(subject.payload)
|
|
35889
|
+
};
|
|
35890
|
+
const phaseOne = () => {
|
|
35891
|
+
const { token, expiresAt } = issueConfirmToken(binding);
|
|
35892
|
+
return {
|
|
35893
|
+
action: op,
|
|
35894
|
+
preview: subject.preview,
|
|
35895
|
+
confirmToken: token,
|
|
35896
|
+
expiresAt,
|
|
35897
|
+
ttlSeconds: confirmTokenTtlSeconds(),
|
|
35898
|
+
instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION
|
|
35899
|
+
};
|
|
35900
|
+
};
|
|
35901
|
+
if (!fallback.confirmToken) {
|
|
35902
|
+
return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
|
|
35903
|
+
}
|
|
35904
|
+
const verdict = verifyConfirmToken(fallback.confirmToken, binding);
|
|
35905
|
+
if (verdict.ok) return void 0;
|
|
35906
|
+
if (verdict.error === "DRAFT_CHANGED") {
|
|
35907
|
+
return rejection2({
|
|
35908
|
+
error: "DRAFT_CHANGED",
|
|
35909
|
+
reason: verdict.reason,
|
|
35910
|
+
note: `${DRAFT_CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
|
|
35911
|
+
...phaseOne()
|
|
35912
|
+
});
|
|
35913
|
+
}
|
|
35914
|
+
return rejection2({ error: verdict.error, action: op, note: TOKEN_ERROR_NOTE[verdict.error] });
|
|
35915
|
+
}
|
|
35916
|
+
function gatedElsewhere(what, via, does, tool) {
|
|
35917
|
+
return `${what} ${does} and is not available through ${via}. Use ${tool}, which asks the user to confirm.`;
|
|
35918
|
+
}
|
|
35919
|
+
function hasCommandWord(args, words) {
|
|
35920
|
+
return args.find((a) => words.has(a.toLowerCase()));
|
|
35921
|
+
}
|
|
35922
|
+
async function requireDispatchConfirmation(ctx, options) {
|
|
35923
|
+
const { action, fallback } = options;
|
|
35924
|
+
if (fallback && callerAcceptsFormElicitation(ctx) === false && sendConfirmFallbackEnabled()) {
|
|
35925
|
+
return tokenConfirmation(action, fallback);
|
|
35926
|
+
}
|
|
35927
|
+
const note = fallback ? [options.unsupportedNote, FALLBACK_HINT].filter(Boolean).join(" ") : options.unsupportedNote;
|
|
35928
|
+
return requireConfirmation(ctx, {
|
|
35929
|
+
action,
|
|
35930
|
+
message: options.message,
|
|
35931
|
+
details: options.details,
|
|
35932
|
+
confirmationLabel: options.confirmationLabel,
|
|
35933
|
+
...note ? { unsupportedNote: note } : {}
|
|
35934
|
+
});
|
|
35935
|
+
}
|
|
35936
|
+
function resultText(result) {
|
|
35937
|
+
const first = result.content[0];
|
|
35938
|
+
return first && first.type === "text" && typeof first.text === "string" ? first.text : "{}";
|
|
35939
|
+
}
|
|
35940
|
+
|
|
35553
35941
|
// ../gogcli-mcp/src/tools/auth.ts
|
|
35554
35942
|
var AUTH_RUN_SUBCOMMANDS = ["list", "status", "services", "remove", "alias"];
|
|
35555
35943
|
function registerAuthToolsWith(server, defaultServices) {
|
|
@@ -35715,6 +36103,39 @@ var attachInlineParam = external_exports.array(inlineAttachmentSchema).optional(
|
|
|
35715
36103
|
);
|
|
35716
36104
|
|
|
35717
36105
|
// ../gogcli-mcp/src/tools/classroom.ts
|
|
36106
|
+
var CLASSROOM_CREATE_WORDS = /* @__PURE__ */ new Set(["create", "add", "new"]);
|
|
36107
|
+
var CLASSROOM_GATED = {
|
|
36108
|
+
announcements: { does: "posts to a class", tool: "gog_classroom_announcements_create" },
|
|
36109
|
+
announcement: { does: "posts to a class", tool: "gog_classroom_announcements_create" },
|
|
36110
|
+
ann: { does: "posts to a class", tool: "gog_classroom_announcements_create" },
|
|
36111
|
+
invitations: { does: "invites someone to a class", tool: "gog_classroom_invitations_create" },
|
|
36112
|
+
invitation: { does: "invites someone to a class", tool: "gog_classroom_invitations_create" },
|
|
36113
|
+
invites: { does: "invites someone to a class", tool: "gog_classroom_invitations_create" }
|
|
36114
|
+
};
|
|
36115
|
+
function vetClassroomRun(subcommand, args) {
|
|
36116
|
+
const sub = subcommand.toLowerCase();
|
|
36117
|
+
const gated = Object.hasOwn(CLASSROOM_GATED, sub) ? CLASSROOM_GATED[sub] : void 0;
|
|
36118
|
+
if (!gated) return void 0;
|
|
36119
|
+
const word = hasCommandWord(args, CLASSROOM_CREATE_WORDS);
|
|
36120
|
+
return word ? gatedElsewhere(`gog classroom ${sub} ${word.toLowerCase()}`, "gog_classroom_run", gated.does, gated.tool) : void 0;
|
|
36121
|
+
}
|
|
36122
|
+
async function readCourse(courseId, account, runner = runOrDiagnose) {
|
|
36123
|
+
const got = await runner(["classroom", "courses", "get", pos(courseId)], { account });
|
|
36124
|
+
if (got.isError) return { error: got };
|
|
36125
|
+
let course;
|
|
36126
|
+
try {
|
|
36127
|
+
course = JSON.parse(resultText(got))?.course;
|
|
36128
|
+
} catch {
|
|
36129
|
+
course = void 0;
|
|
36130
|
+
}
|
|
36131
|
+
return {
|
|
36132
|
+
course: {
|
|
36133
|
+
id: courseId,
|
|
36134
|
+
...typeof course?.name === "string" ? { name: course.name } : {},
|
|
36135
|
+
...typeof course?.section === "string" ? { section: course.section } : {}
|
|
36136
|
+
}
|
|
36137
|
+
};
|
|
36138
|
+
}
|
|
35718
36139
|
function registerClassroomTools(server) {
|
|
35719
36140
|
server.registerTool("gog_classroom_courses_list", {
|
|
35720
36141
|
description: "List Google Classroom courses.",
|
|
@@ -35997,19 +36418,42 @@ function registerClassroomTools(server) {
|
|
|
35997
36418
|
return runOrDiagnose(["classroom", "announcements", "get", pos(courseId), pos(announcementId)], { account });
|
|
35998
36419
|
});
|
|
35999
36420
|
server.registerTool("gog_classroom_announcements_create", {
|
|
36000
|
-
description: "Create an announcement in a Google Classroom course.",
|
|
36421
|
+
description: "Create an announcement in a Google Classroom course. Unless state is DRAFT (which students cannot see), this reads the course and asks the MCP host to show the user a confirmation prompt with the class, the full text and when it publishes; nothing is posted unless they accept. To stage one without asking, pass state DRAFT." + CONFIRM_FALLBACK_DESCRIPTION,
|
|
36001
36422
|
annotations: { destructiveHint: true },
|
|
36002
36423
|
inputSchema: external_exports.object({
|
|
36003
36424
|
courseId: external_exports.string().describe("Course ID"),
|
|
36004
36425
|
text: external_exports.string().describe("Announcement text"),
|
|
36005
|
-
state: external_exports.enum(["PUBLISHED", "DRAFT"]).optional().describe("State"),
|
|
36426
|
+
state: external_exports.enum(["PUBLISHED", "DRAFT"]).optional().describe("State (DRAFT is visible only to teachers and needs no confirmation)"),
|
|
36006
36427
|
scheduled: external_exports.string().optional().describe("Scheduled publish time"),
|
|
36007
|
-
account: accountParam
|
|
36428
|
+
account: accountParam,
|
|
36429
|
+
confirmToken: confirmTokenParam
|
|
36008
36430
|
})
|
|
36009
|
-
}, async ({ courseId, text, state, scheduled, account }) => {
|
|
36431
|
+
}, async ({ courseId, text, state, scheduled, account, confirmToken }, ctx) => {
|
|
36010
36432
|
const args = ["classroom", "announcements", "create", pos(courseId), `--text=${text}`];
|
|
36011
36433
|
if (state) args.push(`--state=${state}`);
|
|
36012
36434
|
if (scheduled) args.push(`--scheduled=${scheduled}`);
|
|
36435
|
+
if (state !== "DRAFT") {
|
|
36436
|
+
const read = await readCourse(courseId, account);
|
|
36437
|
+
if (read.error) return read.error;
|
|
36438
|
+
const publishes = scheduled ? `at ${scheduled}` : "immediately";
|
|
36439
|
+
const confirmation = await requireDispatchConfirmation(ctx, {
|
|
36440
|
+
action: "classroom.announcement-create",
|
|
36441
|
+
message: "Review and confirm this Classroom announcement:",
|
|
36442
|
+
confirmationLabel: "Confirm that this announcement should be posted to the class.",
|
|
36443
|
+
details: { course: read.course, publishes, textPreview: bodyPreview(text) },
|
|
36444
|
+
unsupportedNote: "Create it with state DRAFT instead; the user can review and post it from Classroom.",
|
|
36445
|
+
fallback: {
|
|
36446
|
+
tool: "gog_classroom_announcements_create",
|
|
36447
|
+
account,
|
|
36448
|
+
confirmToken,
|
|
36449
|
+
subject: () => {
|
|
36450
|
+
const view = { course: read.course, publishes, text };
|
|
36451
|
+
return { target: courseId, payload: view, preview: view };
|
|
36452
|
+
}
|
|
36453
|
+
}
|
|
36454
|
+
});
|
|
36455
|
+
if (confirmation) return confirmation;
|
|
36456
|
+
}
|
|
36013
36457
|
return runOrDiagnose(args, { account });
|
|
36014
36458
|
});
|
|
36015
36459
|
server.registerTool("gog_classroom_topics_list", {
|
|
@@ -36099,6 +36543,7 @@ function registerClassroomTools(server) {
|
|
|
36099
36543
|
registerRunTool(server, {
|
|
36100
36544
|
service: "classroom",
|
|
36101
36545
|
examples: '"guardians", "materials", "guardian-invitations"',
|
|
36546
|
+
vet: vetClassroomRun,
|
|
36102
36547
|
note: "Covers anything not wrapped by the dedicated tools (guardians, guardian-invitations, materials, coursework assignees, announcement assignees, etc.)."
|
|
36103
36548
|
});
|
|
36104
36549
|
}
|
|
@@ -36124,7 +36569,7 @@ var replySchema = {
|
|
|
36124
36569
|
signatureFile: external_exports.string().optional().describe("Append a local signature file (plain text or HTML), read on the gog server"),
|
|
36125
36570
|
account: accountParam
|
|
36126
36571
|
};
|
|
36127
|
-
var sendReplySchema = external_exports.object(replySchema);
|
|
36572
|
+
var sendReplySchema = external_exports.object({ ...replySchema, confirmToken: confirmTokenParam });
|
|
36128
36573
|
|
|
36129
36574
|
// ../gogcli-mcp/src/tools/sheets.ts
|
|
36130
36575
|
var cellValueParam = external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()]);
|
|
@@ -36136,7 +36581,7 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
|
|
|
36136
36581
|
);
|
|
36137
36582
|
|
|
36138
36583
|
// ../gogcli-mcp/src/server.ts
|
|
36139
|
-
var VERSION = true ? "4.
|
|
36584
|
+
var VERSION = true ? "4.4.0" : "0.0.0";
|
|
36140
36585
|
|
|
36141
36586
|
// ../gogcli-mcp/src/bootstrap-auth.ts
|
|
36142
36587
|
import { join as join5 } from "node:path";
|
|
@@ -36173,12 +36618,12 @@ async function bootstrapGogAuth(env = process.env, options = {}) {
|
|
|
36173
36618
|
const [clientId, clientSecret, refreshToken, account] = values;
|
|
36174
36619
|
const { spawner } = options;
|
|
36175
36620
|
try {
|
|
36176
|
-
const { createHash } = await import("node:crypto");
|
|
36621
|
+
const { createHash: createHash3 } = await import("node:crypto");
|
|
36177
36622
|
const { mkdir, readFile, writeFile, chmod } = await import("node:fs/promises");
|
|
36178
36623
|
const home = options.home ?? (await import("node:os")).homedir();
|
|
36179
36624
|
const dir = join5(home, ".gogcli-mcp");
|
|
36180
36625
|
const marker = join5(dir, AUTH_BOOTSTRAP_MARKER);
|
|
36181
|
-
const fingerprint =
|
|
36626
|
+
const fingerprint = createHash3("sha256").update(values.join("\0")).digest("hex");
|
|
36182
36627
|
const previous = await readFile(marker, "utf8").catch(() => void 0);
|
|
36183
36628
|
if (previous === fingerprint && await accountListed(account, spawner)) return "present";
|
|
36184
36629
|
await run(
|
|
@@ -36470,15 +36915,33 @@ function registerExtraClassroomTools(server) {
|
|
|
36470
36915
|
return runOrDiagnose(["classroom", "topics", "delete", pos(courseId), pos(topicId), "--force"], { account });
|
|
36471
36916
|
});
|
|
36472
36917
|
server.registerTool("gog_classroom_invitations_create", {
|
|
36473
|
-
description: "Create an invitation to a Google Classroom course.",
|
|
36918
|
+
description: "Create an invitation to a Google Classroom course \u2014 Classroom emails the invitee. Reads the course and asks the MCP host to show the user a confirmation prompt with the class, the invitee and the role; nothing is sent unless they accept." + CONFIRM_FALLBACK_DESCRIPTION,
|
|
36474
36919
|
annotations: { destructiveHint: true },
|
|
36475
36920
|
inputSchema: external_exports.object({
|
|
36476
36921
|
courseId: external_exports.string().describe("Course ID"),
|
|
36477
36922
|
userId: external_exports.string().describe("User ID to invite"),
|
|
36478
36923
|
role: external_exports.enum(["STUDENT", "TEACHER", "OWNER"]).describe("Role for the invited user"),
|
|
36479
|
-
account: accountParam
|
|
36924
|
+
account: accountParam,
|
|
36925
|
+
confirmToken: confirmTokenParam
|
|
36480
36926
|
})
|
|
36481
|
-
}, async ({ courseId, userId, role, account }) => {
|
|
36927
|
+
}, async ({ courseId, userId, role, account, confirmToken }, ctx) => {
|
|
36928
|
+
const read = await readCourse(courseId, account, runOrDiagnose);
|
|
36929
|
+
if (read.error) return read.error;
|
|
36930
|
+
const invitation = { course: read.course, invitee: userId, role };
|
|
36931
|
+
const confirmation = await requireDispatchConfirmation(ctx, {
|
|
36932
|
+
action: "classroom.invitation-create",
|
|
36933
|
+
message: role === "OWNER" ? "Review and confirm this Classroom invitation \u2014 it offers OWNERSHIP of the course:" : "Review and confirm this Classroom invitation:",
|
|
36934
|
+
confirmationLabel: "Confirm that this invitation should be sent now.",
|
|
36935
|
+
details: invitation,
|
|
36936
|
+
unsupportedNote: "Ask the user to invite them from Classroom.",
|
|
36937
|
+
fallback: {
|
|
36938
|
+
tool: "gog_classroom_invitations_create",
|
|
36939
|
+
account,
|
|
36940
|
+
confirmToken,
|
|
36941
|
+
subject: () => ({ target: `${courseId}/${userId}`, payload: invitation, preview: invitation })
|
|
36942
|
+
}
|
|
36943
|
+
});
|
|
36944
|
+
if (confirmation) return confirmation;
|
|
36482
36945
|
return runOrDiagnose(["classroom", "invitations", "create", pos(courseId), pos(userId), `--role=${role}`], { account });
|
|
36483
36946
|
});
|
|
36484
36947
|
server.registerTool("gog_classroom_invitations_delete", {
|
package/manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"manifest_version": "0.3",
|
|
4
4
|
"name": "gogcli-mcp-classroom",
|
|
5
5
|
"display_name": "gogcli (Classroom)",
|
|
6
|
-
"version": "4.
|
|
6
|
+
"version": "4.4.0",
|
|
7
7
|
"description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Chris Hall",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gogcli-mcp-classroom",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"mcpName": "io.github.chrischall/gogcli-mcp-classroom",
|
|
5
5
|
"description": "Extended Google Classroom MCP server via gogcli — auth + full Classroom support",
|
|
6
6
|
"author": "Claude Code (AI) <https://www.anthropic.com/claude>",
|
package/server.json
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
"source": "github",
|
|
8
8
|
"subfolder": "packages/gogcli-mcp-classroom"
|
|
9
9
|
},
|
|
10
|
-
"version": "4.
|
|
10
|
+
"version": "4.4.0",
|
|
11
11
|
"packages": [
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "gogcli-mcp-classroom",
|
|
15
|
-
"version": "4.
|
|
15
|
+
"version": "4.4.0",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/server';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { accountParam, runOrDiagnose, pos } from '../../../gogcli-mcp/src/lib.js';
|
|
3
|
+
import { accountParam, runOrDiagnose, pos, readCourse, requireDispatchConfirmation, CONFIRM_FALLBACK_DESCRIPTION, confirmTokenParam } from '../../../gogcli-mcp/src/lib.js';
|
|
4
4
|
import type { GogArg } from '../../../gogcli-mcp/src/lib.js';
|
|
5
5
|
|
|
6
6
|
const courseState = z.enum(['ACTIVE', 'ARCHIVED', 'PROVISIONED', 'DECLINED', 'SUSPENDED']);
|
|
@@ -286,15 +286,37 @@ export function registerExtraClassroomTools(server: McpServer): void {
|
|
|
286
286
|
});
|
|
287
287
|
|
|
288
288
|
server.registerTool('gog_classroom_invitations_create', {
|
|
289
|
-
description: 'Create an invitation to a Google Classroom course.'
|
|
289
|
+
description: 'Create an invitation to a Google Classroom course — Classroom emails the invitee. Reads the course '
|
|
290
|
+
+ 'and asks the MCP host to show the user a confirmation prompt with the class, the invitee and the role; '
|
|
291
|
+
+ 'nothing is sent unless they accept.' + CONFIRM_FALLBACK_DESCRIPTION,
|
|
290
292
|
annotations: { destructiveHint: true },
|
|
291
293
|
inputSchema: z.object({
|
|
292
294
|
courseId: z.string().describe('Course ID'),
|
|
293
295
|
userId: z.string().describe('User ID to invite'),
|
|
294
296
|
role: z.enum(['STUDENT', 'TEACHER', 'OWNER']).describe('Role for the invited user'),
|
|
295
297
|
account: accountParam,
|
|
298
|
+
confirmToken: confirmTokenParam,
|
|
296
299
|
}),
|
|
297
|
-
}, async ({ courseId, userId, role, account }) => {
|
|
300
|
+
}, async ({ courseId, userId, role, account, confirmToken }, ctx) => {
|
|
301
|
+
const read = await readCourse(courseId, account, runOrDiagnose);
|
|
302
|
+
if (read.error) return read.error;
|
|
303
|
+
const invitation = { course: read.course, invitee: userId, role };
|
|
304
|
+
const confirmation = await requireDispatchConfirmation(ctx, {
|
|
305
|
+
action: 'classroom.invitation-create',
|
|
306
|
+
message: role === 'OWNER'
|
|
307
|
+
? 'Review and confirm this Classroom invitation — it offers OWNERSHIP of the course:'
|
|
308
|
+
: 'Review and confirm this Classroom invitation:',
|
|
309
|
+
confirmationLabel: 'Confirm that this invitation should be sent now.',
|
|
310
|
+
details: invitation,
|
|
311
|
+
unsupportedNote: 'Ask the user to invite them from Classroom.',
|
|
312
|
+
fallback: {
|
|
313
|
+
tool: 'gog_classroom_invitations_create',
|
|
314
|
+
account,
|
|
315
|
+
confirmToken,
|
|
316
|
+
subject: () => ({ target: `${courseId}/${userId}`, payload: invitation, preview: invitation }),
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
if (confirmation) return confirmation;
|
|
298
320
|
return runOrDiagnose(['classroom', 'invitations', 'create', pos(courseId), pos(userId), `--role=${role}`], { account });
|
|
299
321
|
});
|
|
300
322
|
|
|
@@ -18,7 +18,9 @@ let harness: TestHarness;
|
|
|
18
18
|
beforeEach(async () => {
|
|
19
19
|
vi.clearAllMocks();
|
|
20
20
|
vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
|
|
21
|
-
harness = await createTestHarness(registerExtraClassroomTools
|
|
21
|
+
harness = await createTestHarness(registerExtraClassroomTools, {
|
|
22
|
+
elicitation: async () => ({ action: 'accept', content: { confirmed: true } }),
|
|
23
|
+
});
|
|
22
24
|
});
|
|
23
25
|
|
|
24
26
|
describe('gog_classroom_courses_create', () => {
|
|
@@ -249,6 +251,55 @@ describe('gog_classroom_topics_delete', () => {
|
|
|
249
251
|
});
|
|
250
252
|
|
|
251
253
|
describe('gog_classroom_invitations_create', () => {
|
|
254
|
+
const COURSE = rawTextResult(JSON.stringify({ course: { id: 'c1', name: 'Algebra II' } }));
|
|
255
|
+
|
|
256
|
+
it('reads the course and prompts with the class, invitee and role', async () => {
|
|
257
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValue(COURSE);
|
|
258
|
+
let message = '';
|
|
259
|
+
const h = await createTestHarness(registerExtraClassroomTools, {
|
|
260
|
+
elicitation: async (r) => { message = r.params.message; return { action: 'decline' }; },
|
|
261
|
+
});
|
|
262
|
+
await h.callTool('gog_classroom_invitations_create', { courseId: 'c1', userId: 'kid@example.com', role: 'OWNER' });
|
|
263
|
+
expect(message).toMatch(/OWNERSHIP/);
|
|
264
|
+
expect(JSON.parse(message.split('\n').slice(1).join('\n')).details)
|
|
265
|
+
.toEqual({ course: { id: 'c1', name: 'Algebra II' }, invitee: 'kid@example.com', role: 'OWNER' });
|
|
266
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(['classroom', 'courses', 'get', pos('c1')], { account: undefined });
|
|
267
|
+
expect(lib.runOrDiagnose).not.toHaveBeenCalledWith(
|
|
268
|
+
['classroom', 'invitations', 'create', pos('c1'), pos('kid@example.com'), '--role=OWNER'], { account: undefined });
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('refuses a client that cannot be prompted', async () => {
|
|
272
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValue(COURSE);
|
|
273
|
+
const h = await createTestHarness(registerExtraClassroomTools);
|
|
274
|
+
const r = JSON.parse((await h.callTool('gog_classroom_invitations_create', { courseId: 'c1', userId: 'u1', role: 'STUDENT' })).content[0]!.text as string);
|
|
275
|
+
expect(r).toMatchObject({ reason: 'confirmation-unsupported', action: 'classroom.invitation-create' });
|
|
276
|
+
expect(r.note).toMatch(/invite them from Classroom/);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('token fallback: phase 1 previews, phase 2 invites', async () => {
|
|
280
|
+
const ORIGINAL = { ...process.env };
|
|
281
|
+
process.env.GOG_SEND_CONFIRM_FALLBACK = 'token';
|
|
282
|
+
try {
|
|
283
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValue(COURSE);
|
|
284
|
+
const h = await createTestHarness(registerExtraClassroomTools);
|
|
285
|
+
const args = { courseId: 'c1', userId: 'u1', role: 'STUDENT' as const };
|
|
286
|
+
const p1 = JSON.parse((await h.callTool('gog_classroom_invitations_create', args)).content[0]!.text as string);
|
|
287
|
+
expect(p1.preview).toEqual({ course: { id: 'c1', name: 'Algebra II' }, invitee: 'u1', role: 'STUDENT' });
|
|
288
|
+
await h.callTool('gog_classroom_invitations_create', { ...args, confirmToken: p1.confirmToken });
|
|
289
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
290
|
+
['classroom', 'invitations', 'create', pos('c1'), pos('u1'), '--role=STUDENT'], { account: undefined });
|
|
291
|
+
} finally {
|
|
292
|
+
process.env = ORIGINAL;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('returns a failed course read without inviting', async () => {
|
|
297
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValue({ content: [{ type: 'text', text: 'Error: not found' }], isError: true });
|
|
298
|
+
const r = await harness.callTool('gog_classroom_invitations_create', { courseId: 'c1', userId: 'u1', role: 'STUDENT' });
|
|
299
|
+
expect(r.isError).toBe(true);
|
|
300
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledTimes(1);
|
|
301
|
+
});
|
|
302
|
+
|
|
252
303
|
it('calls runOrDiagnose with courseId, userId, role', async () => {
|
|
253
304
|
await harness.callTool('gog_classroom_invitations_create', { courseId: 'c1', userId: 'u1', role: 'STUDENT' });
|
|
254
305
|
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|