grokbot-mcp 0.1.0 → 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -10
- package/dist/index.js.map +1 -1
- package/dist/json-rpc.d.ts +37 -0
- package/dist/json-rpc.d.ts.map +1 -0
- package/dist/json-rpc.js +67 -0
- package/dist/json-rpc.js.map +1 -0
- package/dist/mcp-era-handlers.d.ts +7 -0
- package/dist/mcp-era-handlers.d.ts.map +1 -0
- package/dist/mcp-era-handlers.js +64 -0
- package/dist/mcp-era-handlers.js.map +1 -0
- package/dist/mcp-era-request.d.ts +19 -0
- package/dist/mcp-era-request.d.ts.map +1 -0
- package/dist/mcp-era-request.js +51 -0
- package/dist/mcp-era-request.js.map +1 -0
- package/dist/mcp-tool-parts.d.ts +23 -0
- package/dist/mcp-tool-parts.d.ts.map +1 -0
- package/dist/mcp-tool-parts.js +3 -0
- package/dist/mcp-tool-parts.js.map +1 -0
- package/dist/mcp-tools-dispatch.d.ts +5 -0
- package/dist/mcp-tools-dispatch.d.ts.map +1 -0
- package/dist/mcp-tools-dispatch.js +85 -0
- package/dist/mcp-tools-dispatch.js.map +1 -0
- package/dist/mcp-tools-governance.d.ts +5 -0
- package/dist/mcp-tools-governance.d.ts.map +1 -0
- package/dist/mcp-tools-governance.js +53 -0
- package/dist/mcp-tools-governance.js.map +1 -0
- package/dist/mcp-tools-workforce.d.ts +5 -0
- package/dist/mcp-tools-workforce.d.ts.map +1 -0
- package/dist/mcp-tools-workforce.js +63 -0
- package/dist/mcp-tools-workforce.js.map +1 -0
- package/dist/mcp-tools.d.ts +24 -0
- package/dist/mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools.js +131 -0
- package/dist/mcp-tools.js.map +1 -0
- package/dist/server.d.ts +18 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +78 -0
- package/dist/server.js.map +1 -0
- package/dist/tool-summaries.d.ts +4 -0
- package/dist/tool-summaries.d.ts.map +1 -0
- package/dist/tool-summaries.js +14 -0
- package/dist/tool-summaries.js.map +1 -0
- package/package.json +8 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nuncio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import { createCommandRunner, GROKBOT_VERSION, } from "grokbot-core";
|
|
3
|
+
import { serve } from "./server.js";
|
|
4
|
+
// Built on the first tools/call, so initialize and tools/list never read the Keychain.
|
|
5
|
+
let runner;
|
|
6
|
+
const lazyRunner = {
|
|
7
|
+
run: (name, input, options) => {
|
|
8
|
+
runner ??= createCommandRunner({
|
|
9
|
+
defaultAgent: process.env.GROKBOT_AGENT,
|
|
10
|
+
});
|
|
11
|
+
return runner.run(name, input, options);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
const log = (line) => process.stderr.write(`grokbot-mcp: ${line}\n`);
|
|
15
|
+
log(`v${GROKBOT_VERSION} serving MCP on stdio`);
|
|
16
|
+
await serve({
|
|
17
|
+
input: process.stdin,
|
|
18
|
+
output: process.stdout,
|
|
19
|
+
runner: lazyRunner,
|
|
20
|
+
log,
|
|
21
|
+
});
|
|
12
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAEL,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,uFAAuF;AACvF,IAAI,MAAiC,CAAC;AACtC,MAAM,UAAU,GAAkB;IAChC,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAC5B,MAAM,KAAK,mBAAmB,CAAC;YAC7B,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;SACxC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF,CAAC;AAEF,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC;AAE7E,GAAG,CAAC,IAAI,eAAe,uBAAuB,CAAC,CAAC;AAChD,MAAM,KAAK,CAAC;IACV,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,MAAM,EAAE,UAAU;IAClB,GAAG;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { JsonObject } from "grokbot-core";
|
|
2
|
+
export type RequestId = string | number;
|
|
3
|
+
export interface RpcError {
|
|
4
|
+
readonly code: number;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
readonly data?: object;
|
|
7
|
+
}
|
|
8
|
+
export type Outcome = {
|
|
9
|
+
readonly result: object;
|
|
10
|
+
} | {
|
|
11
|
+
readonly error: RpcError;
|
|
12
|
+
};
|
|
13
|
+
export type Incoming = {
|
|
14
|
+
readonly kind: "request";
|
|
15
|
+
readonly id: RequestId;
|
|
16
|
+
readonly method: string;
|
|
17
|
+
readonly params: JsonObject;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "notification";
|
|
20
|
+
readonly method: string;
|
|
21
|
+
readonly params: JsonObject;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "invalid";
|
|
24
|
+
readonly id: RequestId | null;
|
|
25
|
+
readonly error: RpcError;
|
|
26
|
+
};
|
|
27
|
+
export declare const PARSE_ERROR: RpcError;
|
|
28
|
+
export declare const INVALID_REQUEST: RpcError;
|
|
29
|
+
export declare const INTERNAL_ERROR: RpcError;
|
|
30
|
+
export declare const methodNotFound: (method: string) => RpcError;
|
|
31
|
+
export declare const invalidParams: (detail: string) => RpcError;
|
|
32
|
+
export declare function isJsonObject(value: unknown): value is JsonObject;
|
|
33
|
+
export declare function isRequestId(value: unknown): value is RequestId;
|
|
34
|
+
/** Parses one stdio line. MCP forbids batches and null ids, so both are invalid. */
|
|
35
|
+
export declare function parseIncoming(line: string): Incoming;
|
|
36
|
+
export declare function encodeResponse(id: RequestId | null, outcome: Outcome): string;
|
|
37
|
+
//# sourceMappingURL=json-rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-rpc.d.ts","sourceRoot":"","sources":["../src/json-rpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExC,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,OAAO,GACf;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEjC,MAAM,MAAM,QAAQ,GAChB;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CAC1B,CAAC;AAEN,eAAO,MAAM,WAAW,EAAE,QAAmD,CAAC;AAC9E,eAAO,MAAM,eAAe,EAAE,QAG7B,CAAC;AACF,eAAO,MAAM,cAAc,EAAE,QAG5B,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,QAG9C,CAAC;AAEH,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,KAAG,QAG7C,CAAC;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAqCpD;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAE7E"}
|
package/dist/json-rpc.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const PARSE_ERROR = { code: -32700, message: "Parse error" };
|
|
2
|
+
export const INVALID_REQUEST = {
|
|
3
|
+
code: -32600,
|
|
4
|
+
message: "Invalid Request",
|
|
5
|
+
};
|
|
6
|
+
export const INTERNAL_ERROR = {
|
|
7
|
+
code: -32603,
|
|
8
|
+
message: "Internal error",
|
|
9
|
+
};
|
|
10
|
+
export const methodNotFound = (method) => ({
|
|
11
|
+
code: -32601,
|
|
12
|
+
message: `Method not found: ${method}`,
|
|
13
|
+
});
|
|
14
|
+
export const invalidParams = (detail) => ({
|
|
15
|
+
code: -32602,
|
|
16
|
+
message: `Invalid params: ${detail}`,
|
|
17
|
+
});
|
|
18
|
+
export function isJsonObject(value) {
|
|
19
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
export function isRequestId(value) {
|
|
22
|
+
return typeof value === "string" || Number.isInteger(value);
|
|
23
|
+
}
|
|
24
|
+
/** Parses one stdio line. MCP forbids batches and null ids, so both are invalid. */
|
|
25
|
+
export function parseIncoming(line) {
|
|
26
|
+
let message;
|
|
27
|
+
try {
|
|
28
|
+
message = JSON.parse(line);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return { kind: "invalid", id: null, error: PARSE_ERROR };
|
|
32
|
+
}
|
|
33
|
+
if (!isJsonObject(message)) {
|
|
34
|
+
return { kind: "invalid", id: null, error: INVALID_REQUEST };
|
|
35
|
+
}
|
|
36
|
+
const { id, method, params = {} } = message;
|
|
37
|
+
const hasId = Object.hasOwn(message, "id");
|
|
38
|
+
if (message.jsonrpc !== "2.0" || typeof method !== "string") {
|
|
39
|
+
return {
|
|
40
|
+
kind: "invalid",
|
|
41
|
+
id: isRequestId(id) ? id : null,
|
|
42
|
+
error: INVALID_REQUEST,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (!hasId) {
|
|
46
|
+
return {
|
|
47
|
+
kind: "notification",
|
|
48
|
+
method,
|
|
49
|
+
params: isJsonObject(params) ? params : {},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (!isRequestId(id)) {
|
|
53
|
+
return { kind: "invalid", id: null, error: INVALID_REQUEST };
|
|
54
|
+
}
|
|
55
|
+
if (!isJsonObject(params)) {
|
|
56
|
+
return {
|
|
57
|
+
kind: "invalid",
|
|
58
|
+
id,
|
|
59
|
+
error: invalidParams("params must be an object"),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return { kind: "request", id, method, params };
|
|
63
|
+
}
|
|
64
|
+
export function encodeResponse(id, outcome) {
|
|
65
|
+
return `${JSON.stringify({ jsonrpc: "2.0", id, ...outcome })}\n`;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AC;SACjD,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAoB,EAAE,OAAgB;IACnE,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,IAAI,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type CommandRunner, type JsonObject } from "grokbot-core";
|
|
2
|
+
import type { Outcome } from "./json-rpc.js";
|
|
3
|
+
import { type Era } from "./mcp-era-request.js";
|
|
4
|
+
export type Handler = (params: JsonObject, signal: AbortSignal) => Outcome | Promise<Outcome>;
|
|
5
|
+
/** Each era's methods. Modern drops initialize and ping and adds server/discover. */
|
|
6
|
+
export declare function eraHandlers(runner: CommandRunner): Readonly<Record<Era, ReadonlyMap<string, Handler>>>;
|
|
7
|
+
//# sourceMappingURL=mcp-era-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-era-handlers.d.ts","sourceRoot":"","sources":["../src/mcp-era-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,KAAK,GAAG,EAGT,MAAM,sBAAsB,CAAC;AAG9B,MAAM,MAAM,OAAO,GAAG,CACpB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,WAAW,KAChB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAsChC,qFAAqF;AACrF,wBAAgB,WAAW,CACzB,MAAM,EAAE,aAAa,GACpB,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CA4BrD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { GROKBOT_VERSION, } from "grokbot-core";
|
|
2
|
+
import { LEGACY_VERSIONS, SUPPORTED_VERSIONS, } from "./mcp-era-request.js";
|
|
3
|
+
import { callTool, mcpTools } from "./mcp-tools.js";
|
|
4
|
+
const SERVER_INFO = { name: "grokbot-mcp", version: GROKBOT_VERSION };
|
|
5
|
+
const INSTRUCTIONS = "Drives a GrokBot workforce: the AI agents on the owner's Grok Bot account. Start with grokbot_agents or grokbot_team to see who is available. Never pass yes: true without the owner's explicit approval.";
|
|
6
|
+
/** Both results come from the catalog, so they are identical for every caller until an upgrade. */
|
|
7
|
+
const CACHE_HINTS = { ttlMs: 3_600_000, cacheScope: "public" };
|
|
8
|
+
function initialize(params) {
|
|
9
|
+
const protocolVersion = LEGACY_VERSIONS.find((v) => v === params.protocolVersion) ??
|
|
10
|
+
LEGACY_VERSIONS[0];
|
|
11
|
+
return {
|
|
12
|
+
result: {
|
|
13
|
+
protocolVersion,
|
|
14
|
+
capabilities: { tools: {} },
|
|
15
|
+
serverInfo: SERVER_INFO,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** 2026-07-28 results carry `resultType`, and serverInfo rides in `_meta` because there is no handshake. */
|
|
20
|
+
function complete(handler) {
|
|
21
|
+
return async (params, signal) => {
|
|
22
|
+
const outcome = await handler(params, signal);
|
|
23
|
+
if (!("result" in outcome))
|
|
24
|
+
return outcome;
|
|
25
|
+
return {
|
|
26
|
+
result: {
|
|
27
|
+
resultType: "complete",
|
|
28
|
+
...outcome.result,
|
|
29
|
+
_meta: { "io.modelcontextprotocol/serverInfo": SERVER_INFO },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Each era's methods. Modern drops initialize and ping and adds server/discover. */
|
|
35
|
+
export function eraHandlers(runner) {
|
|
36
|
+
const call = (params, signal) => callTool(params, runner, signal);
|
|
37
|
+
return {
|
|
38
|
+
legacy: new Map([
|
|
39
|
+
["initialize", initialize],
|
|
40
|
+
["ping", () => ({ result: {} })],
|
|
41
|
+
["tools/list", () => ({ result: { tools: mcpTools() } })],
|
|
42
|
+
["tools/call", call],
|
|
43
|
+
]),
|
|
44
|
+
modern: new Map([
|
|
45
|
+
[
|
|
46
|
+
"server/discover",
|
|
47
|
+
complete(() => ({
|
|
48
|
+
result: {
|
|
49
|
+
supportedVersions: SUPPORTED_VERSIONS,
|
|
50
|
+
capabilities: { tools: {} },
|
|
51
|
+
instructions: INSTRUCTIONS,
|
|
52
|
+
...CACHE_HINTS,
|
|
53
|
+
},
|
|
54
|
+
})),
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
"tools/list",
|
|
58
|
+
complete(() => ({ result: { tools: mcpTools(), ...CACHE_HINTS } })),
|
|
59
|
+
],
|
|
60
|
+
["tools/call", complete(call)],
|
|
61
|
+
]),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=mcp-era-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-era-handlers.js","sourceRoot":"","sources":["../src/mcp-era-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,GAEhB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEL,eAAe,EACf,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAOpD,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;AAEtE,MAAM,YAAY,GAChB,2MAA2M,CAAC;AAE9M,mGAAmG;AACnG,MAAM,WAAW,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAW,CAAC;AAExE,SAAS,UAAU,CAAC,MAAkB;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;SACrB,CAAC;QACF,MAAM,EAAE,IAAI,GAAG,CAAkB;YAC/B;gBACE,iBAAiB;gBACjB,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;oBACd,MAAM,EAAE;wBACN,iBAAiB,EAAE,kBAAkB;wBACrC,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;wBAC3B,YAAY,EAAE,YAAY;wBAC1B,GAAG,WAAW;qBACf;iBACF,CAAC,CAAC;aACJ;YACD;gBACE,YAAY;gBACZ,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,GAAG,WAAW,EAAE,EAAE,CAAC,CAAC;aACpE;YACD,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;SAC/B,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { JsonObject } from "grokbot-core";
|
|
2
|
+
import { type RpcError } from "./json-rpc.js";
|
|
3
|
+
/** Revisions that open with the initialize handshake, newest first. */
|
|
4
|
+
export declare const LEGACY_VERSIONS: readonly ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"];
|
|
5
|
+
/** Stateless revisions: every request carries its version and client capabilities in `_meta`. */
|
|
6
|
+
export declare const MODERN_VERSIONS: readonly ["2026-07-28"];
|
|
7
|
+
/** Advertised by server/discover and by -32022: every version this server answers, modern first. */
|
|
8
|
+
export declare const SUPPORTED_VERSIONS: readonly string[];
|
|
9
|
+
export type Era = "legacy" | "modern";
|
|
10
|
+
/**
|
|
11
|
+
* Reads a request's era from its own `_meta`, never from earlier requests.
|
|
12
|
+
* The version is checked before the other fields because a newer revision may define them differently.
|
|
13
|
+
*/
|
|
14
|
+
export declare function requestEra(params: JsonObject): {
|
|
15
|
+
readonly era: Era;
|
|
16
|
+
} | {
|
|
17
|
+
readonly error: RpcError;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=mcp-era-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-era-request.d.ts","sourceRoot":"","sources":["../src/mcp-era-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAA+B,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE3E,uEAAuE;AACvE,eAAO,MAAM,eAAe,mEAKlB,CAAC;AAEX,iGAAiG;AACjG,eAAO,MAAM,eAAe,yBAA0B,CAAC;AAEvD,oGAAoG;AACpG,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAG/C,CAAC;AAEF,MAAM,MAAM,GAAG,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAWtC;;;GAGG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,UAAU,GACjB;IAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,CAuBtD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { invalidParams, isJsonObject } from "./json-rpc.js";
|
|
2
|
+
/** Revisions that open with the initialize handshake, newest first. */
|
|
3
|
+
export const LEGACY_VERSIONS = [
|
|
4
|
+
"2025-11-25",
|
|
5
|
+
"2025-06-18",
|
|
6
|
+
"2025-03-26",
|
|
7
|
+
"2024-11-05",
|
|
8
|
+
];
|
|
9
|
+
/** Stateless revisions: every request carries its version and client capabilities in `_meta`. */
|
|
10
|
+
export const MODERN_VERSIONS = ["2026-07-28"];
|
|
11
|
+
/** Advertised by server/discover and by -32022: every version this server answers, modern first. */
|
|
12
|
+
export const SUPPORTED_VERSIONS = [
|
|
13
|
+
...MODERN_VERSIONS,
|
|
14
|
+
...LEGACY_VERSIONS,
|
|
15
|
+
];
|
|
16
|
+
const PROTOCOL_VERSION = "io.modelcontextprotocol/protocolVersion";
|
|
17
|
+
const CLIENT_CAPABILITIES = "io.modelcontextprotocol/clientCapabilities";
|
|
18
|
+
const unsupportedVersion = (requested) => ({
|
|
19
|
+
code: -32022,
|
|
20
|
+
message: "Unsupported protocol version",
|
|
21
|
+
data: { supported: SUPPORTED_VERSIONS, requested },
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Reads a request's era from its own `_meta`, never from earlier requests.
|
|
25
|
+
* The version is checked before the other fields because a newer revision may define them differently.
|
|
26
|
+
*/
|
|
27
|
+
export function requestEra(params) {
|
|
28
|
+
const meta = params._meta;
|
|
29
|
+
if (!isJsonObject(meta) || !Object.hasOwn(meta, PROTOCOL_VERSION)) {
|
|
30
|
+
return { era: "legacy" };
|
|
31
|
+
}
|
|
32
|
+
const version = meta[PROTOCOL_VERSION];
|
|
33
|
+
if (typeof version !== "string") {
|
|
34
|
+
return {
|
|
35
|
+
error: invalidParams(`_meta ${PROTOCOL_VERSION} must be a string`),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (!MODERN_VERSIONS.some((modern) => modern === version)) {
|
|
39
|
+
return { error: unsupportedVersion(version) };
|
|
40
|
+
}
|
|
41
|
+
if (!Object.hasOwn(meta, CLIENT_CAPABILITIES)) {
|
|
42
|
+
return { error: invalidParams(`_meta ${CLIENT_CAPABILITIES} is required`) };
|
|
43
|
+
}
|
|
44
|
+
if (!isJsonObject(meta[CLIENT_CAPABILITIES])) {
|
|
45
|
+
return {
|
|
46
|
+
error: invalidParams(`_meta ${CLIENT_CAPABILITIES} must be an object`),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return { era: "modern" };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=mcp-era-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-era-request.js","sourceRoot":"","sources":["../src/mcp-era-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,eAAe,CAAC;AAE3E,uEAAuE;A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AAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC,EAAE,CAAC;QAC9C,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,SAAS,mBAAmB,cAAc,CAAC,EAAE,CAAC;IAC9E,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC;QAC7C,OAAO;YACL,KAAK,EAAE,aAAa,CAAC,SAAS,mBAAmB,oBAAoB,CAAC;SACvE,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CommandName, CommandOutputs } from "grokbot-core";
|
|
2
|
+
export type ToolSummary<N extends CommandName> = (output: CommandOutputs[N]) => string;
|
|
3
|
+
/** One command group's tools/call summaries, exhaustive over the group's names. */
|
|
4
|
+
export type ToolSummaries<Names extends CommandName> = {
|
|
5
|
+
readonly [N in Names]: ToolSummary<N>;
|
|
6
|
+
};
|
|
7
|
+
/** How one tool differs from its catalog entry. */
|
|
8
|
+
export interface McpOverride {
|
|
9
|
+
readonly note?: string;
|
|
10
|
+
/** Replaces catalog defaults when the client leaves the param out. */
|
|
11
|
+
readonly defaults?: Readonly<Record<string, number>>;
|
|
12
|
+
readonly destructive?: true;
|
|
13
|
+
/** Params an MCP client may never set (hidden from the schema, refused on call). */
|
|
14
|
+
readonly hiddenParams?: readonly string[];
|
|
15
|
+
/** The command is not offered over MCP at all (CLI only). */
|
|
16
|
+
readonly cliOnly?: true;
|
|
17
|
+
}
|
|
18
|
+
export type McpOverrides<Names extends CommandName> = {
|
|
19
|
+
readonly [N in Names]?: McpOverride;
|
|
20
|
+
};
|
|
21
|
+
export declare const plural: (n: number, one: string, many: string) => string;
|
|
22
|
+
export declare const waitHint: (jobId: string) => string;
|
|
23
|
+
//# sourceMappingURL=mcp-tool-parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool-parts.d.ts","sourceRoot":"","sources":["../src/mcp-tool-parts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEhE,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAC/C,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,KACtB,MAAM,CAAC;AAEZ,mFAAmF;AACnF,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,WAAW,IAAI;IACrD,QAAQ,EAAE,CAAC,IAAI,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC;CACtC,CAAC;AAEF,mDAAmD;AACnD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC;IAC5B,oFAAoF;IACpF,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;CACzB;AAED,MAAM,MAAM,YAAY,CAAC,KAAK,SAAS,WAAW,IAAI;IACpD,QAAQ,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,WAAW;CACpC,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,GAAG,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,WAC3B,CAAC;AAEjC,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,WACsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool-parts.js","sourceRoot":"","sources":["../src/mcp-tool-parts.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,GAAW,EAAE,IAAY,EAAE,EAAE,CAC7D,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAEjC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE,CACxC,0BAA0B,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type DispatchCommandName } from "grokbot-core";
|
|
2
|
+
import { type McpOverrides, type ToolSummaries } from "./mcp-tool-parts.js";
|
|
3
|
+
export declare const DISPATCH_OVERRIDES: McpOverrides<DispatchCommandName>;
|
|
4
|
+
export declare const DISPATCH_SUMMARIES: ToolSummaries<DispatchCommandName>;
|
|
5
|
+
//# sourceMappingURL=mcp-tools-dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools-dispatch.d.ts","sourceRoot":"","sources":["../src/mcp-tools-dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAKzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,aAAa,EAEnB,MAAM,qBAAqB,CAAC;AAY7B,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,mBAAmB,CAUhE,CAAC;AA8CF,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,mBAAmB,CA2BjE,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isActive, } from "grokbot-core";
|
|
2
|
+
import { plural, waitHint, } from "./mcp-tool-parts.js";
|
|
3
|
+
/**
|
|
4
|
+
* Well under the ~300 s at which MCP hosts kill a tool call (Hermes), so ask and wait
|
|
5
|
+
* return a still-running result with the job id first instead of dying mid-wait.
|
|
6
|
+
*/
|
|
7
|
+
const MCP_WAIT_TIMEOUT_SECONDS = 45;
|
|
8
|
+
/** What a finished result means, shared by every tool that waits on a job. */
|
|
9
|
+
const OUTCOMES = '"done" means the bot\'s run for this message ended, not that the task is verified; "ambiguous" means one run answered this message together with another, and the result holds every reply of that run';
|
|
10
|
+
export const DISPATCH_OVERRIDES = {
|
|
11
|
+
ask: {
|
|
12
|
+
note: `Waits ${MCP_WAIT_TIMEOUT_SECONDS} s unless timeout is set; a still-running result carries a job id, and grokbot_wait resumes it. ${OUTCOMES}`,
|
|
13
|
+
defaults: { timeout: MCP_WAIT_TIMEOUT_SECONDS },
|
|
14
|
+
},
|
|
15
|
+
wait: {
|
|
16
|
+
note: `Waits ${MCP_WAIT_TIMEOUT_SECONDS} s unless timeout is set, to stay under MCP host time limits; a still-running result carries the job id, so call grokbot_wait again with it. ${OUTCOMES}`,
|
|
17
|
+
defaults: { timeout: MCP_WAIT_TIMEOUT_SECONDS },
|
|
18
|
+
},
|
|
19
|
+
interrupt: { destructive: true },
|
|
20
|
+
};
|
|
21
|
+
function outcomeText(who, jobId, outcome) {
|
|
22
|
+
switch (outcome.status) {
|
|
23
|
+
case "done":
|
|
24
|
+
return `${who} replied:\n${outcome.finalReply}`;
|
|
25
|
+
case "ambiguous":
|
|
26
|
+
return `${who} finished, but the reply is ambiguous: ${outcome.reason}. Every reply of that run, in order:\n${outcome.replyText}`;
|
|
27
|
+
case "pending":
|
|
28
|
+
return outcome.queued
|
|
29
|
+
? `${outcome.reason}. Job ${jobId} is saved; ${waitHint(jobId)} to send it and keep waiting.`
|
|
30
|
+
: `${who} is still working (${outcome.reason}). Job ${jobId} is saved; ${waitHint(jobId)} to keep waiting.`;
|
|
31
|
+
case "awaiting-approval":
|
|
32
|
+
return `${who} is waiting for owner approval (${outcome.reason}). Approve it in the Grok Bot app, then ${waitHint(jobId)}.`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function memberText({ agent, status }) {
|
|
36
|
+
if (status.awaiting) {
|
|
37
|
+
return `- ${agent.name}: awaiting owner (${status.awaiting.reason})`;
|
|
38
|
+
}
|
|
39
|
+
if (!isActive(status))
|
|
40
|
+
return `- ${agent.name}: idle`;
|
|
41
|
+
const tool = status.activityTool ? ` (${status.activityTool})` : "";
|
|
42
|
+
return `- ${agent.name}: running${tool}`;
|
|
43
|
+
}
|
|
44
|
+
function entryText(entry) {
|
|
45
|
+
switch (entry.kind) {
|
|
46
|
+
case "user-message":
|
|
47
|
+
return `user${entry.fromAgent ? ` (from ${entry.fromAgent.name})` : ""}: ${entry.content}`;
|
|
48
|
+
case "assistant-message":
|
|
49
|
+
return `assistant${entry.toAgent ? ` (to ${entry.toAgent.name})` : ""}: ${entry.content}`;
|
|
50
|
+
// Attachment URLs may be signed links, so only the file name is shown.
|
|
51
|
+
case "reply":
|
|
52
|
+
return entry.reply.type === "text"
|
|
53
|
+
? `reply: ${entry.reply.content}`
|
|
54
|
+
: `reply: ${`${entry.reply.fileName} [attachment]`.trim()}`;
|
|
55
|
+
case "card":
|
|
56
|
+
return `card ${entry.cardType}`;
|
|
57
|
+
case "blob":
|
|
58
|
+
return `blob ${entry.blobHash}`;
|
|
59
|
+
case "unknown":
|
|
60
|
+
return `unknown ${entry.entryKind}`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export const DISPATCH_SUMMARIES = {
|
|
64
|
+
agents: ({ agents }) => [
|
|
65
|
+
`${plural(agents.length, "agent", "agents")}:`,
|
|
66
|
+
...agents.map((a) => `- ${a.name} (${a.kind}, ${a.agentId})`),
|
|
67
|
+
].join("\n"),
|
|
68
|
+
team: ({ members }) => [
|
|
69
|
+
`${plural(members.length, "agent", "agents")}:`,
|
|
70
|
+
...members.map(memberText),
|
|
71
|
+
].join("\n"),
|
|
72
|
+
ask: ({ jobId, agent, outcome }) => outcomeText(agent.name, jobId, outcome),
|
|
73
|
+
send: ({ jobId, agent, queued }) => queued
|
|
74
|
+
? `Queued for ${agent.name}: it is busy, so the message goes out once it is free. Job ${jobId} is saved; ${waitHint(jobId)} to send it and get the reply.`
|
|
75
|
+
: `Sent to ${agent.name}. Job ${jobId} is saved; ${waitHint(jobId)} for the reply.`,
|
|
76
|
+
wait: ({ jobId, agentId, agentName, outcome }) => outcomeText(agentName ?? `Agent ${agentId}`, jobId, outcome),
|
|
77
|
+
tail: ({ agent, entries }) => [
|
|
78
|
+
`${agent.name}, last ${plural(entries.length, "entry", "entries")}:`,
|
|
79
|
+
...entries.map((e) => `#${e.seq} ${entryText(e)}`),
|
|
80
|
+
].join("\n"),
|
|
81
|
+
interrupt: ({ agent, hadActiveRun }) => hadActiveRun
|
|
82
|
+
? `Interrupted the active run on ${agent.name}.`
|
|
83
|
+
: `${agent.name} had no active run.`,
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=mcp-tools-dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools-dispatch.js","sourceRoot":"","sources":["../src/mcp-tools-dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,GAIT,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,MAAM,EAEN,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC,8EAA8E;AAC9E,MAAM,QAAQ,GACZ,wMAAwM,CAAC;AAE3M,MAAM,CAAC,MAAM,kBAAkB,GAAsC;IACnE,GAAG,EAAE;QACH,IAAI,EAAE,SAAS,wBAAwB,mGAAmG,QAAQ,EAAE;QACpJ,QAAQ,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;KAChD;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS,wBAAwB,gJAAgJ,QAAQ,EAAE;QACjM,QAAQ,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;KAChD;IACD,SAAS,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;CACjC,CAAC;AAEF,SAAS,W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,GAAG;QAChD,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,qBAAqB;CACzC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GovernanceCommandName } from "grokbot-core";
|
|
2
|
+
import { type McpOverrides, type ToolSummaries } from "./mcp-tool-parts.js";
|
|
3
|
+
export declare const GOVERNANCE_OVERRIDES: McpOverrides<GovernanceCommandName>;
|
|
4
|
+
export declare const GOVERNANCE_SUMMARIES: ToolSummaries<GovernanceCommandName>;
|
|
5
|
+
//# sourceMappingURL=mcp-tools-governance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools-governance.d.ts","sourceRoot":"","sources":["../src/mcp-tools-governance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,oBAAoB,EAAE,YAAY,CAAC,qBAAqB,CAWpE,CAAC;AAkBF,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,qBAAqB,CAwCrE,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { plural, } from "./mcp-tool-parts.js";
|
|
2
|
+
export const GOVERNANCE_OVERRIDES = {
|
|
3
|
+
answer: {
|
|
4
|
+
note: "Pass value to answer the open widget, or dismiss: true to close it",
|
|
5
|
+
},
|
|
6
|
+
// The viewer URL is a credential, so it never lands in structuredContent.
|
|
7
|
+
vnc: {
|
|
8
|
+
note: "Opens the viewer on the host Mac",
|
|
9
|
+
hiddenParams: ["print-url"],
|
|
10
|
+
},
|
|
11
|
+
// The worker inherits stdio, which is this server's JSON-RPC pipe.
|
|
12
|
+
"worker-start": { cliOnly: true },
|
|
13
|
+
};
|
|
14
|
+
function cardText(card) {
|
|
15
|
+
switch (card.type) {
|
|
16
|
+
case "widget":
|
|
17
|
+
return `widget ${card.entryId}: ${card.prompt}${card.options.length > 0 ? ` [${card.options.join(" | ")}]` : ""}`;
|
|
18
|
+
case "auto-review-approval":
|
|
19
|
+
return `auto-review-approval ${card.entryId}: ${card.summary}${card.command ? ` (${card.command})` : ""}`;
|
|
20
|
+
case "local-tool-permission":
|
|
21
|
+
return `local-tool-permission ${card.entryId}: ${card.action} ${card.target}`;
|
|
22
|
+
default:
|
|
23
|
+
return `${card.type} ${card.entryId}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const resolved = (out) => `${out.resolution}: ${out.card.type} ${out.card.entryId} on ${out.agent.name}.${out.wroteLocalApproval ? " Also recorded in ~/.grokbot/local-tool-approvals.json." : ""}`;
|
|
27
|
+
export const GOVERNANCE_SUMMARIES = {
|
|
28
|
+
approvals: ({ agents }) => agents.length === 0
|
|
29
|
+
? "No open approval cards."
|
|
30
|
+
: agents
|
|
31
|
+
.flatMap(({ agent, awaiting, cards }) => cards.length === 0
|
|
32
|
+
? [`- ${agent.name}: awaiting ${awaiting ?? ""}`.trimEnd()]
|
|
33
|
+
: cards.map((card) => `- ${agent.name}: ${cardText(card)}`))
|
|
34
|
+
.join("\n"),
|
|
35
|
+
answer: ({ agent, card, dismissed, value }) => dismissed
|
|
36
|
+
? `Dismissed widget ${card.entryId} on ${agent.name}.`
|
|
37
|
+
: `Accepted: answered widget ${card.entryId} on ${agent.name} with ${JSON.stringify(value ?? "")}.`,
|
|
38
|
+
approve: resolved,
|
|
39
|
+
deny: resolved,
|
|
40
|
+
computers: ({ computers }) => [
|
|
41
|
+
`${plural(computers.length, "computer", "computers")}:`,
|
|
42
|
+
...computers.map((c) => `- ${c.label || c.machineId} (${c.kind || "unknown"}, ${c.machineId})`),
|
|
43
|
+
].join("\n"),
|
|
44
|
+
"mcp-list": ({ servers }) => [
|
|
45
|
+
`${plural(servers.length, "MCP server", "MCP servers")}:`,
|
|
46
|
+
...servers.map((s) => `- ${s.serverIdentifier} (${s.name}): ${plural(s.toolCount, "tool", "tools")}, ${s.status || "unknown"}`),
|
|
47
|
+
].join("\n"),
|
|
48
|
+
"mcp-call": ({ server, tool, result }) => `${server}/${tool}${result.isError ? " reported an error" : ""}:\n${result.text}`,
|
|
49
|
+
vnc: ({ window }) => `Opened desktop window ${window} on the host.`,
|
|
50
|
+
"worker-plan": ({ plan, registered }) => `Nothing started. Command:\n${plan.command.join(" ")}\nenv: ${plan.envNames.join(" ")}\nRegistered computers now: ${registered.join(", ") || "none"}.`,
|
|
51
|
+
"worker-start": ({ exitCode, tokenServes }) => `Worker exited with code ${exitCode ?? "null (signal)"}. Served the token ${plural(tokenServes, "time", "times")}.`,
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=mcp-tools-governance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools-governance.js","sourceRoot":"","sources":["../src/mcp-tools-governance.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,MAAM,GAEP,MAAM,qBAAqB,CAAC;AAI7B,MAAM,CAAC,MAAM,oBAAoB,GAAwC;IACvE,MAAM,EAAE;QACN,IAAI,EAAE,oEAAoE;KAC3E;IACD,0EAA0E;IAC1E,GAAG,EAAE;QACH,IAAI,EAAE,kCAAkC;QACxC,YAAY,EAAE,CAAC,WAAW,CAAC;KAC5B;IACD,mEAAmE;IACnE,cAAc,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;CAClC,CAAC;AAEF,SAAS,QAAQ,CAAC,IAAU;IAC1B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,UAAU,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACpH,KAAK,sBAAsB;YACz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AAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,MAAM,MAAM,CAAC,IAAI,EAAE;IACnF,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,yBAAyB,MAAM,eAAe;IACnE,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,CACtC,8BAA8B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,+BAA+B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,GAAG;IACxJ,cAAc,EAAE,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,CAC5C,2BAA2B,QAAQ,IAAI,eAAe,sBAAsB,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG;CACtH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WorkforceCommandName } from "grokbot-core";
|
|
2
|
+
import { type McpOverrides, type ToolSummaries } from "./mcp-tool-parts.js";
|
|
3
|
+
export declare const WORKFORCE_OVERRIDES: McpOverrides<WorkforceCommandName>;
|
|
4
|
+
export declare const WORKFORCE_SUMMARIES: ToolSummaries<WorkforceCommandName>;
|
|
5
|
+
//# sourceMappingURL=mcp-tools-workforce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools-workforce.d.ts","sourceRoot":"","sources":["../src/mcp-tools-workforce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAQ7B,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,oBAAoB,CAuBlE,CAAC;AAiBF,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,oBAAoB,CAsCnE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { plural, } from "./mcp-tool-parts.js";
|
|
2
|
+
/** Overrides on protected bots and managed skills, and local file paths, are CLI only. */
|
|
3
|
+
const FORCE = "force-protected";
|
|
4
|
+
const MANAGED = "include-managed";
|
|
5
|
+
export const WORKFORCE_OVERRIDES = {
|
|
6
|
+
hire: {
|
|
7
|
+
note: "Idempotent: calling it again with the same name re-briefs the bot it hired and keeps its instructions unless you pass new ones",
|
|
8
|
+
hiddenParams: ["instructions-file"],
|
|
9
|
+
},
|
|
10
|
+
update: { hiddenParams: ["instructions-file"] },
|
|
11
|
+
fire: { hiddenParams: [FORCE] },
|
|
12
|
+
"skills-list": {
|
|
13
|
+
note: "The skill library is Box-wide: every bot sees the same one",
|
|
14
|
+
},
|
|
15
|
+
"skills-push": {
|
|
16
|
+
note: "Pass the SKILL.md text as markdown. The library is Box-wide (all bots). Same name and content: no-op; different content needs replace and yes, which deletes the old copy for every bot",
|
|
17
|
+
hiddenParams: ["file"],
|
|
18
|
+
destructive: true,
|
|
19
|
+
},
|
|
20
|
+
"skills-remove": {
|
|
21
|
+
note: "Removes an imported skill for every bot (the library is Box-wide)",
|
|
22
|
+
hiddenParams: [MANAGED, FORCE],
|
|
23
|
+
},
|
|
24
|
+
"skills-run": { hiddenParams: [MANAGED] },
|
|
25
|
+
"routines-enable": { hiddenParams: [FORCE] },
|
|
26
|
+
"routines-disable": { hiddenParams: [FORCE] },
|
|
27
|
+
"routines-delete": { hiddenParams: [FORCE] },
|
|
28
|
+
};
|
|
29
|
+
const PUSHED = {
|
|
30
|
+
imported: "Imported skill",
|
|
31
|
+
replaced: "Replaced skill",
|
|
32
|
+
unchanged: "Nothing imported: it already has the same content as skill",
|
|
33
|
+
exists: "Nothing imported: its content could not be compared with the existing skill",
|
|
34
|
+
};
|
|
35
|
+
const names = (agents) => agents.map((a) => a.name).join(", ");
|
|
36
|
+
const routineText = (r) => `${r.name} (${r.automationId}): ${r.enabled ? "on" : "off"}, ${r.schedule || r.trigger || "no trigger"}${r.nextRunAt ? `, next run ${r.nextRunAt}` : ""}`;
|
|
37
|
+
export const WORKFORCE_SUMMARIES = {
|
|
38
|
+
hire: ({ agent, folder, result }) => `${result === "created" ? "Hired" : "Re-briefed the already hired"} ${agent.name} (${agent.agentId}). Folder: ${folder}`,
|
|
39
|
+
update: ({ agent, changed }) => changed.length === 0
|
|
40
|
+
? `${agent.name} already had those values; nothing changed.`
|
|
41
|
+
: `Updated ${agent.name}: ${changed.join(", ")}.`,
|
|
42
|
+
fire: ({ agent }) => `Deleted ${agent.name} (${agent.agentId}).`,
|
|
43
|
+
"room-create": ({ room, members, result }) => `${result === "created" ? "Created" : "Found existing"} room ${room.name} (${room.agentId}) with ${names(members)}. Send it a message with the ask tool.`,
|
|
44
|
+
"room-members": ({ room, members }) => `Room ${room.name} now has ${names(members)}.`,
|
|
45
|
+
"skills-list": ({ agent, skills }) => [
|
|
46
|
+
`The Box-wide (all bots) skill library has ${plural(skills.length, "skill", "skills")} (read through ${agent.name}):`,
|
|
47
|
+
...skills.map((s) => `- ${s.name || s.id} (${s.source}, ${s.id})`),
|
|
48
|
+
].join("\n"),
|
|
49
|
+
"skills-push": ({ agent, skill, result }) => result === "exists"
|
|
50
|
+
? `${PUSHED[result]} ${skill.name} (${skill.id}) in the Box-wide (all bots) skill library. Pass replace and yes to import over it.`
|
|
51
|
+
: `${PUSHED[result]} ${skill.name} (${skill.id}) ${result === "imported" ? "into" : "in"} the Box-wide (all bots) skill library, through ${agent.name}.`,
|
|
52
|
+
"skills-remove": ({ agent, skill, remaining }) => `Removed skill ${skill.name} (${skill.id}) from the Box-wide (all bots) skill library, through ${agent.name}; ${plural(remaining, "skill", "skills")} left.`,
|
|
53
|
+
"skills-run": ({ agent, skill }) => `Started skill ${skill.name} (${skill.id}) from the Box-wide (all bots) skill library on ${agent.name}.`,
|
|
54
|
+
"routines-list": ({ agent, routines }) => [
|
|
55
|
+
`${agent.name} has ${plural(routines.length, "routine", "routines")}:`,
|
|
56
|
+
...routines.map((r) => `- ${routineText(r)}`),
|
|
57
|
+
].join("\n"),
|
|
58
|
+
"routines-enable": ({ agent, routine }) => `Turned on ${agent.name}'s routine ${routineText(routine)}.`,
|
|
59
|
+
"routines-disable": ({ agent, routine }) => `Turned off ${agent.name}'s routine ${routineText(routine)}.`,
|
|
60
|
+
"routines-delete": ({ agent, routine, remaining }) => `Deleted ${agent.name}'s routine ${routine.name} (${routine.automationId}); ${plural(remaining, "routine", "routines")} left.`,
|
|
61
|
+
"routines-create": ({ agent, routine, result }) => `${result === "created" ? "Created" : "Found existing"} routine for ${agent.name}: ${routineText(routine)}.`,
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=mcp-tools-workforce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools-workforce.js","sourceRoot":"","sources":["../src/mcp-tools-workforce.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,MAAM,GAEP,MAAM,qBAAqB,CAAC;AAI7B,0FAA0F;AAC1F,MAAM,KAAK,GAAG,iBAAiB,CAAC;AAChC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAElC,MAAM,CAAC,MAAM,mBAAmB,GAAuC;IACrE,IAAI,EAAE;QACJ,IAAI,EAAE,gIAAgI;QACtI,YAAY,EAAE,CAAC,mBAAmB,CAAC;KACpC;IACD,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC,mBAAmB,CAAC,EAAE;IAC/C,IAAI,EAAE,EAAE,YAAY,EAAE,CAAC,KAAK,CAAC,EAAE;IAC/B,aAAa,EAAE;QACb,IAAI,EAAE,4DAA4D;KACnE;IACD,aAAa,EAAE;QACb,IAAI,EAAE,yLAAyL;QAC/L,YAAY,EAAE,CAAC,MAAM,CAAC;QACtB,WAAW,EAAE,IAAI;KAClB;IACD,eAAe,EAAE;QACf,IAAI,EAAE,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EAAE,CACzC,cAAc,KAAK,CAAC,IAAI,cAAc,WAAW,CAAC,OAAO,CAAC,GAAG;IAC/D,iBAAiB,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CACnD,WAAW,KAAK,CAAC,IAAI,cAAc,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,YAAY,MAAM,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ;IAChI,iBAAiB,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAChD,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,gBAAgB,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,OAAO,CAAC,GAAG;CAC/G,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Command, type CommandJsonSchema, type CommandName, type CommandRunner } from "grokbot-core";
|
|
2
|
+
import { type Outcome } from "./json-rpc.js";
|
|
3
|
+
import type { McpOverride } from "./mcp-tool-parts.js";
|
|
4
|
+
interface ToolAnnotations {
|
|
5
|
+
readonly readOnlyHint: boolean;
|
|
6
|
+
readonly destructiveHint: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface McpTool {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly description: string;
|
|
11
|
+
readonly inputSchema: CommandJsonSchema;
|
|
12
|
+
readonly annotations: ToolAnnotations;
|
|
13
|
+
}
|
|
14
|
+
/** `room-create` -> `grokbot_room_create`: one separator style across every MCP tool name. */
|
|
15
|
+
export declare function toolName(command: CommandName): string;
|
|
16
|
+
/** Inverse of `toolName`; undefined for anything that is not a catalog tool. */
|
|
17
|
+
export declare function commandForTool(tool: string): CommandName | undefined;
|
|
18
|
+
/** The tools/list entry of one catalog command. */
|
|
19
|
+
export declare function mcpTool(command: Command, override?: McpOverride): McpTool;
|
|
20
|
+
export declare function mcpTools(): readonly McpTool[];
|
|
21
|
+
/** `tools/call`: bad tool names are protocol errors; bad arguments and GrokBot failures are tool errors. */
|
|
22
|
+
export declare function callTool(params: Readonly<Record<string, unknown>>, runner: CommandRunner, signal: AbortSignal): Promise<Outcome>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=mcp-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools.d.ts","sourceRoot":"","sources":["../src/mcp-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,aAAa,EAOnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA+B,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,qBAAqB,CAAC;AAQrE,UAAU,eAAe;IACvB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;CACvC;AAgED,8FAA8F;AAC9F,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAErD;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAMpE;AAED,mDAAmD;AACnD,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO,CAezE;AAED,wBAAgB,QAAQ,IAAI,SAAS,OAAO,EAAE,CAI7C;AAiDD,4GAA4G;AAC5G,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAalB"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { GrokBotError, isCommandName, listCommands, paramsJsonSchema, parseCommandInput, } from "grokbot-core";
|
|
2
|
+
import { invalidParams, isJsonObject } from "./json-rpc.js";
|
|
3
|
+
import { DISPATCH_OVERRIDES } from "./mcp-tools-dispatch.js";
|
|
4
|
+
import { GOVERNANCE_OVERRIDES } from "./mcp-tools-governance.js";
|
|
5
|
+
import { WORKFORCE_OVERRIDES } from "./mcp-tools-workforce.js";
|
|
6
|
+
import { summarize } from "./tool-summaries.js";
|
|
7
|
+
const TOOL_PREFIX = "grokbot_";
|
|
8
|
+
const SAFETY = {
|
|
9
|
+
"read-only": {
|
|
10
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
11
|
+
},
|
|
12
|
+
writes: {
|
|
13
|
+
note: "Writes: changes state on a live GrokBot agent",
|
|
14
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
15
|
+
},
|
|
16
|
+
destructive: {
|
|
17
|
+
note: "Destructive: deletes live GrokBot data; pass yes: true only after the owner approves",
|
|
18
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
19
|
+
},
|
|
20
|
+
sensitive: {
|
|
21
|
+
note: "Sensitive: acts with the owner's authority; pass yes: true only after the owner approves",
|
|
22
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const MCP_OVERRIDES = {
|
|
26
|
+
...DISPATCH_OVERRIDES,
|
|
27
|
+
...WORKFORCE_OVERRIDES,
|
|
28
|
+
...GOVERNANCE_OVERRIDES,
|
|
29
|
+
};
|
|
30
|
+
/** Params never offered over MCP: `json` (results are always structured) plus the tool's hidden ones. */
|
|
31
|
+
const hiddenOver = (override) => new Set(["json", ...(override?.hiddenParams ?? [])]);
|
|
32
|
+
/** MCP results are always structured, so the CLI-only `json` flag is dropped. */
|
|
33
|
+
function inputSchema(command, override) {
|
|
34
|
+
const defaults = override?.defaults ?? {};
|
|
35
|
+
const hidden = hiddenOver(override);
|
|
36
|
+
const schema = paramsJsonSchema(command.params);
|
|
37
|
+
const properties = Object.fromEntries(Object.entries(schema.properties)
|
|
38
|
+
.filter(([key]) => !hidden.has(key))
|
|
39
|
+
.map(([key, prop]) => {
|
|
40
|
+
const value = defaults[key];
|
|
41
|
+
return [key, value === undefined ? prop : { ...prop, default: value }];
|
|
42
|
+
}));
|
|
43
|
+
const required = schema.required?.filter((key) => !hidden.has(key));
|
|
44
|
+
const { required: _drop, ...rest } = schema;
|
|
45
|
+
return {
|
|
46
|
+
...rest,
|
|
47
|
+
properties,
|
|
48
|
+
...(required && required.length > 0 ? { required } : {}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** `room-create` -> `grokbot_room_create`: one separator style across every MCP tool name. */
|
|
52
|
+
export function toolName(command) {
|
|
53
|
+
return `${TOOL_PREFIX}${command.replaceAll("-", "_")}`;
|
|
54
|
+
}
|
|
55
|
+
/** Inverse of `toolName`; undefined for anything that is not a catalog tool. */
|
|
56
|
+
export function commandForTool(tool) {
|
|
57
|
+
if (!tool.startsWith(TOOL_PREFIX))
|
|
58
|
+
return undefined;
|
|
59
|
+
const command = tool.slice(TOOL_PREFIX.length).replaceAll("_", "-");
|
|
60
|
+
return isCommandName(command) && toolName(command) === tool
|
|
61
|
+
? command
|
|
62
|
+
: undefined;
|
|
63
|
+
}
|
|
64
|
+
/** The tools/list entry of one catalog command. */
|
|
65
|
+
export function mcpTool(command, override) {
|
|
66
|
+
const { name, summary, safety } = command;
|
|
67
|
+
const notes = [SAFETY[safety].note, override?.note].filter((note) => note !== undefined);
|
|
68
|
+
const { annotations } = SAFETY[safety];
|
|
69
|
+
return {
|
|
70
|
+
name: toolName(name),
|
|
71
|
+
description: notes.length === 0 ? summary : `${[summary, ...notes].join(". ")}.`,
|
|
72
|
+
inputSchema: inputSchema(command, override),
|
|
73
|
+
annotations: override?.destructive
|
|
74
|
+
? { ...annotations, destructiveHint: true }
|
|
75
|
+
: annotations,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function mcpTools() {
|
|
79
|
+
return listCommands()
|
|
80
|
+
.filter((command) => !MCP_OVERRIDES[command.name]?.cliOnly)
|
|
81
|
+
.map((command) => mcpTool(command, MCP_OVERRIDES[command.name]));
|
|
82
|
+
}
|
|
83
|
+
const isBlank = (value) => value === undefined || (typeof value === "string" && !value.trim());
|
|
84
|
+
function withMcpDefaults(name, args) {
|
|
85
|
+
const defaults = Object.entries(MCP_OVERRIDES[name]?.defaults ?? {});
|
|
86
|
+
const missing = defaults.filter(([key]) => isBlank(args[key]));
|
|
87
|
+
return missing.length > 0
|
|
88
|
+
? { ...args, ...Object.fromEntries(missing) }
|
|
89
|
+
: args;
|
|
90
|
+
}
|
|
91
|
+
const errorResult = (text) => ({
|
|
92
|
+
content: [{ type: "text", text }],
|
|
93
|
+
isError: true,
|
|
94
|
+
});
|
|
95
|
+
async function runTool(name, args, runner, signal) {
|
|
96
|
+
const hidden = [...hiddenOver(MCP_OVERRIDES[name])].filter((key) => key !== "json" && args[key] !== undefined);
|
|
97
|
+
if (hidden.length > 0) {
|
|
98
|
+
return errorResult(`${toolName(name)}: ${hidden.join(", ")} cannot be set over MCP; use the grokbot CLI.`);
|
|
99
|
+
}
|
|
100
|
+
const parsed = parseCommandInput(name, withMcpDefaults(name, args));
|
|
101
|
+
if (!parsed.ok)
|
|
102
|
+
return errorResult(parsed.errors.join("\n"));
|
|
103
|
+
try {
|
|
104
|
+
const output = await runner.run(name, parsed.input, { signal });
|
|
105
|
+
return {
|
|
106
|
+
content: [{ type: "text", text: summarize(name, output) }],
|
|
107
|
+
structuredContent: output,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (error instanceof GrokBotError)
|
|
112
|
+
return errorResult(error.message);
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** `tools/call`: bad tool names are protocol errors; bad arguments and GrokBot failures are tool errors. */
|
|
117
|
+
export async function callTool(params, runner, signal) {
|
|
118
|
+
const { name, arguments: args = {} } = params;
|
|
119
|
+
if (typeof name !== "string") {
|
|
120
|
+
return { error: invalidParams("name must be a string") };
|
|
121
|
+
}
|
|
122
|
+
if (!isJsonObject(args)) {
|
|
123
|
+
return { error: invalidParams("arguments must be an object") };
|
|
124
|
+
}
|
|
125
|
+
const command = commandForTool(name);
|
|
126
|
+
if (command === undefined || MCP_OVERRIDES[command]?.cliOnly) {
|
|
127
|
+
return { error: { code: -32602, message: `Unknown tool: ${name}` } };
|
|
128
|
+
}
|
|
129
|
+
return { result: await runTool(command, args, runner, signal) };
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=mcp-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools.js","sourceRoot":"","sources":["../src/mcp-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAgB,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,WAAW,GAAG,UAAU,CAAC;AAoB/B,MAAM,MAAM,GAGR;IACF,WAAW,EAAE;QACX,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,E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,EAAE,EAAE,EAAE,CAAC;IACvE,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;AAClE,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CommandRunner } from "grokbot-core";
|
|
2
|
+
export interface ServeOptions {
|
|
3
|
+
readonly input: NodeJS.ReadableStream;
|
|
4
|
+
/** Receives only newline-terminated JSON-RPC messages. */
|
|
5
|
+
readonly output: {
|
|
6
|
+
readonly write: (chunk: string) => unknown;
|
|
7
|
+
};
|
|
8
|
+
readonly runner: CommandRunner;
|
|
9
|
+
/** Diagnostics; index.ts sends them to stderr. */
|
|
10
|
+
readonly log: (line: string) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Serves MCP over newline-delimited JSON-RPC until `input` ends.
|
|
14
|
+
* Dual-era: a request whose `_meta` names a protocol version is served statelessly
|
|
15
|
+
* by the 2026-07-28 rules; anything else gets today's initialize-era behavior.
|
|
16
|
+
*/
|
|
17
|
+
export declare function serve(options: ServeOptions): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,cAAc,CAAC;AAa9D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IACtC,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;KAAE,CAAC;IAChE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,kDAAkD;IAClD,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED;;;;GAIG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkEhE"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createInterface } from "node:readline";
|
|
2
|
+
import { encodeResponse, INTERNAL_ERROR, isRequestId, methodNotFound, parseIncoming, } from "./json-rpc.js";
|
|
3
|
+
import { eraHandlers } from "./mcp-era-handlers.js";
|
|
4
|
+
import { requestEra } from "./mcp-era-request.js";
|
|
5
|
+
/**
|
|
6
|
+
* Serves MCP over newline-delimited JSON-RPC until `input` ends.
|
|
7
|
+
* Dual-era: a request whose `_meta` names a protocol version is served statelessly
|
|
8
|
+
* by the 2026-07-28 rules; anything else gets today's initialize-era behavior.
|
|
9
|
+
*/
|
|
10
|
+
export async function serve(options) {
|
|
11
|
+
const { input, output, runner, log } = options;
|
|
12
|
+
const handlers = eraHandlers(runner);
|
|
13
|
+
const inFlight = new Map();
|
|
14
|
+
const running = new Set();
|
|
15
|
+
const send = (id, outcome) => {
|
|
16
|
+
output.write(encodeResponse(id, outcome));
|
|
17
|
+
};
|
|
18
|
+
// An aborted request gets no response: the client cancelled it or hung up.
|
|
19
|
+
async function respond(id, method, params) {
|
|
20
|
+
const route = requestEra(params);
|
|
21
|
+
if ("error" in route)
|
|
22
|
+
return send(id, { error: route.error });
|
|
23
|
+
const handler = handlers[route.era].get(method);
|
|
24
|
+
if (!handler)
|
|
25
|
+
return send(id, { error: methodNotFound(method) });
|
|
26
|
+
const controller = new AbortController();
|
|
27
|
+
inFlight.set(id, controller);
|
|
28
|
+
let outcome;
|
|
29
|
+
try {
|
|
30
|
+
outcome = await handler(params, controller.signal);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (!controller.signal.aborted) {
|
|
34
|
+
log(`${method} ${id} failed: ${String(error)}`);
|
|
35
|
+
}
|
|
36
|
+
outcome = { error: INTERNAL_ERROR };
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
inFlight.delete(id);
|
|
40
|
+
}
|
|
41
|
+
if (!controller.signal.aborted)
|
|
42
|
+
send(id, outcome);
|
|
43
|
+
}
|
|
44
|
+
function cancel(params) {
|
|
45
|
+
const { requestId, reason } = params;
|
|
46
|
+
const controller = isRequestId(requestId)
|
|
47
|
+
? inFlight.get(requestId)
|
|
48
|
+
: undefined;
|
|
49
|
+
if (!controller)
|
|
50
|
+
return;
|
|
51
|
+
log(`cancelled request ${requestId}: ${String(reason ?? "no reason")}`);
|
|
52
|
+
controller.abort();
|
|
53
|
+
}
|
|
54
|
+
for await (const line of createInterface({ input, crlfDelay: Infinity })) {
|
|
55
|
+
if (!line.trim())
|
|
56
|
+
continue;
|
|
57
|
+
const message = parseIncoming(line);
|
|
58
|
+
switch (message.kind) {
|
|
59
|
+
case "invalid":
|
|
60
|
+
send(message.id, { error: message.error });
|
|
61
|
+
break;
|
|
62
|
+
case "notification":
|
|
63
|
+
if (message.method === "notifications/cancelled") {
|
|
64
|
+
cancel(message.params);
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
case "request": {
|
|
68
|
+
const task = respond(message.id, message.method, message.params);
|
|
69
|
+
running.add(task);
|
|
70
|
+
task.finally(() => running.delete(task));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (const controller of inFlight.values())
|
|
75
|
+
controller.abort();
|
|
76
|
+
await Promise.all(running);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,cAAc,EAEd,aAAa,GAEd,MAAM,eAAe,CAAC;AAC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OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;gBAC3C,MAAM;YACR,KAAK,cAAc;gBACjB,IAAI,OAAO,CAAC,MAAM,KAAK,yBAAyB,EAAE,CAAC;oBACjD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBACzB,CAAC;gBACD,MAAM;YACR,KAAK,SAAS,CAAC,CAAC,CAAC;gBACf,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;gBACjE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAClB,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;IACD,KAAK,MAAM,UAAU,IAAI,QAAQ,CAAC,MAAM,EAAE;QAAE,UAAU,CAAC,KAAK,EAAE,CAAC;IAC/D,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CommandName, CommandOutput } from "grokbot-core";
|
|
2
|
+
/** The text block of a tools/call result; the typed output rides in structuredContent. */
|
|
3
|
+
export declare function summarize<N extends CommandName>(name: N, output: CommandOutput<N>): string;
|
|
4
|
+
//# sourceMappingURL=tool-summaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-summaries.d.ts","sourceRoot":"","sources":["../src/tool-summaries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAY/D,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,EAC7C,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GACvB,MAAM,CAGR"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DISPATCH_SUMMARIES } from "./mcp-tools-dispatch.js";
|
|
2
|
+
import { GOVERNANCE_SUMMARIES } from "./mcp-tools-governance.js";
|
|
3
|
+
import { WORKFORCE_SUMMARIES } from "./mcp-tools-workforce.js";
|
|
4
|
+
const SUMMARIES = {
|
|
5
|
+
...DISPATCH_SUMMARIES,
|
|
6
|
+
...WORKFORCE_SUMMARIES,
|
|
7
|
+
...GOVERNANCE_SUMMARIES,
|
|
8
|
+
};
|
|
9
|
+
/** The text block of a tools/call result; the typed output rides in structuredContent. */
|
|
10
|
+
export function summarize(name, output) {
|
|
11
|
+
const summary = SUMMARIES[name];
|
|
12
|
+
return summary(output);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=tool-summaries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-summaries.js","sourceRoot":"","sources":["../src/tool-summaries.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,SAAS,GAA+B;IAC5C,GAAG,kBAAkB;IACrB,GAAG,mBAAmB;IACtB,GAAG,oBAAoB;CACxB,CAAC;AAEF,0FAA0F;AAC1F,MAAM,UAAU,SAAS,CACvB,IAAO,EACP,MAAwB;IAExB,MAAM,OAAO,GAAmB,SAAS,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grokbot-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "MCP server over grokbot-core for driving a GrokBot workforce from any MCP-compatible agent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20.3"
|
|
9
|
+
},
|
|
7
10
|
"bin": {
|
|
8
11
|
"grokbot-mcp": "dist/index.js"
|
|
9
12
|
},
|
|
10
13
|
"main": "./dist/index.js",
|
|
11
14
|
"types": "./dist/index.d.ts",
|
|
12
15
|
"files": [
|
|
13
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"!dist/**/*.test.*",
|
|
18
|
+
"!dist/fixtures"
|
|
14
19
|
],
|
|
15
20
|
"dependencies": {
|
|
16
|
-
"grokbot-core": "^0.1.
|
|
21
|
+
"grokbot-core": "^0.1.2"
|
|
17
22
|
},
|
|
18
23
|
"repository": {
|
|
19
24
|
"type": "git",
|