@calypsohq/elephant-mcp-server 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -12
- package/dist/ElephantMcpServer.d.ts +45 -0
- package/dist/ElephantMcpServer.js +3 -26
- package/dist/auth/ApiKeyStrategy.d.ts +14 -0
- package/dist/auth/AuthChallenge.d.ts +27 -0
- package/dist/auth/AuthStrategy.d.ts +14 -0
- package/dist/auth/BearerAuthenticator.d.ts +17 -0
- package/dist/auth/Credential.d.ts +23 -0
- package/dist/auth/GrantScopes.d.ts +16 -0
- package/dist/auth/JwtGrantStrategy.d.ts +30 -0
- package/dist/auth/ProtectedResource.d.ts +21 -0
- package/dist/auth/ProtectedResource.js +1 -0
- package/dist/auth/TokenCipher.d.ts +13 -0
- package/dist/calypso/AgentCatalog.d.ts +41 -0
- package/dist/calypso/AgentCatalogLoader.d.ts +12 -0
- package/dist/calypso/AgentChoice.d.ts +25 -0
- package/dist/calypso/AgentResponses.d.ts +47 -0
- package/dist/calypso/AnswerDepth.d.ts +30 -0
- package/dist/calypso/AnswerDiagnostics.d.ts +23 -0
- package/dist/calypso/AnswerSources.d.ts +36 -0
- package/dist/calypso/BatchManifest.d.ts +29 -0
- package/dist/calypso/BucketDestination.d.ts +17 -0
- package/dist/calypso/BucketEdits.d.ts +41 -0
- package/dist/calypso/BucketSources.d.ts +28 -0
- package/dist/calypso/CalypsoApi.d.ts +28 -0
- package/dist/calypso/CalypsoApiClient.d.ts +29 -0
- package/dist/calypso/CalypsoApiConfig.d.ts +15 -0
- package/dist/calypso/KnowledgeBatches.d.ts +25 -0
- package/dist/calypso/KnowledgeBuckets.d.ts +18 -0
- package/dist/calypso/KnowledgeFiles.d.ts +45 -0
- package/dist/calypso/KnowledgeInventory.d.ts +36 -0
- package/dist/calypso/KnowledgeSearch.d.ts +52 -0
- package/dist/calypso/KnowledgeWebsites.d.ts +39 -0
- package/dist/calypso/UploadContent.d.ts +22 -0
- package/dist/calypso/apiErrors.d.ts +14 -0
- package/dist/calypso/bucketList.d.ts +48 -0
- package/dist/calypso/coerce.d.ts +14 -0
- package/dist/calypso/knowledgeTypes.d.ts +64 -0
- package/dist/calypso/polling.d.ts +14 -0
- package/dist/calypso/uploadBytes.d.ts +8 -0
- package/dist/hatching/HatchingCopy.d.ts +11 -0
- package/dist/http/HostedServer.d.ts +8 -0
- package/dist/http/HttpConfig.d.ts +40 -0
- package/dist/http/HttpConfig.js +11 -2
- package/dist/http/HttpServer.d.ts +36 -0
- package/dist/http/KnowledgeInventoryCache.d.ts +21 -0
- package/dist/http/McpEndpoint.d.ts +39 -0
- package/dist/http/McpEndpoint.js +9 -56
- package/dist/http/ModelCatalogCache.d.ts +20 -0
- package/dist/http/ProtectedResourceMetadata.d.ts +19 -0
- package/dist/http/ProtectedResourceMetadata.js +1 -1
- package/dist/http/RateLimiter.d.ts +25 -0
- package/dist/http/StatelessMcpEndpoint.d.ts +40 -0
- package/dist/http/StatelessMcpEndpoint.js +69 -0
- package/dist/index.d.ts +2 -0
- package/dist/kit.d.ts +35 -0
- package/dist/kit.js +31 -0
- package/dist/notices/PostBudget.d.ts +15 -0
- package/dist/notices/SlackUsageNotices.d.ts +22 -0
- package/dist/notices/UsageMessage.d.ts +22 -0
- package/dist/notices/UsageNotices.d.ts +25 -0
- package/dist/presets/PresetInstructions.d.ts +20 -0
- package/dist/presets/ToolGroup.d.ts +30 -0
- package/dist/presets/ToolGroup.js +4 -0
- package/dist/presets/ToolPreset.d.ts +80 -0
- package/dist/presets/ToolPreset.js +6 -1
- package/dist/presets/ToolPresetRegistry.d.ts +18 -0
- package/dist/stdio/LocalPresets.d.ts +3 -0
- package/dist/stdio/StdioOptions.d.ts +16 -0
- package/dist/stdio.d.ts +2 -0
- package/dist/tools/AddFileTool.d.ts +91 -0
- package/dist/tools/AddFilesTool.d.ts +110 -0
- package/dist/tools/AddWebsiteTool.d.ts +42 -0
- package/dist/tools/AskTool.d.ts +57 -0
- package/dist/tools/CreateBucketTool.d.ts +44 -0
- package/dist/tools/ElephantTool.d.ts +12 -0
- package/dist/tools/ElephantTool.js +6 -36
- package/dist/tools/ListBucketsTool.d.ts +34 -0
- package/dist/tools/McpTool.d.ts +56 -0
- package/dist/tools/McpTool.js +40 -0
- package/dist/tools/MoveSourcesTool.d.ts +30 -0
- package/dist/tools/OpenSourceTool.d.ts +28 -0
- package/dist/tools/RenameBucketTool.d.ts +30 -0
- package/dist/tools/SearchTool.d.ts +36 -0
- package/dist/tools/ToolContext.d.ts +20 -0
- package/dist/tools/ToolLogger.d.ts +17 -0
- package/dist/tools/ToolRegistrar.d.ts +22 -0
- package/dist/tools/ToolRegistrar.js +33 -0
- package/dist/tools/schemaParts.d.ts +38 -0
- package/dist/views/BatchView.d.ts +35 -0
- package/dist/views/BucketView.d.ts +34 -0
- package/dist/views/ErrorView.d.ts +6 -0
- package/dist/views/MoveView.d.ts +20 -0
- package/dist/views/SearchView.d.ts +36 -0
- package/dist/views/SourceView.d.ts +47 -0
- package/dist/views/WebsiteView.d.ts +20 -0
- package/dist/views/viewFields.d.ts +11 -0
- package/package.json +9 -1
|
@@ -14,6 +14,8 @@ export class ToolPreset {
|
|
|
14
14
|
scope;
|
|
15
15
|
tools;
|
|
16
16
|
hatches;
|
|
17
|
+
documentationUrl;
|
|
18
|
+
composeInstructions;
|
|
17
19
|
constructor(options) {
|
|
18
20
|
this.id = options.id;
|
|
19
21
|
this.path = options.path;
|
|
@@ -23,6 +25,9 @@ export class ToolPreset {
|
|
|
23
25
|
this.scope = options.scope;
|
|
24
26
|
this.tools = options.tools;
|
|
25
27
|
this.hatches = options.hatches ?? false;
|
|
28
|
+
this.documentationUrl = options.documentationUrl;
|
|
29
|
+
this.composeInstructions =
|
|
30
|
+
options.composeInstructions ?? PresetInstructions.compose;
|
|
26
31
|
ToolPreset.assertUniqueNames(this.id, this.toolNames());
|
|
27
32
|
}
|
|
28
33
|
toolNames() {
|
|
@@ -44,7 +49,7 @@ export class ToolPreset {
|
|
|
44
49
|
}
|
|
45
50
|
/** `initialize.instructions` for one caller. */
|
|
46
51
|
instructionsFor(grant) {
|
|
47
|
-
return
|
|
52
|
+
return this.composeInstructions(this.instructions, this.groups(), grant);
|
|
48
53
|
}
|
|
49
54
|
/** Absolute resource URL (`aud`) for this preset under a public base URL. */
|
|
50
55
|
resourceUrl(publicBaseUrl) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AddFilesTool } from "../tools/AddFilesTool.js";
|
|
2
|
+
import { AddFileTool } from "../tools/AddFileTool.js";
|
|
3
|
+
import { AddWebsiteTool } from "../tools/AddWebsiteTool.js";
|
|
4
|
+
import { AskTool } from "../tools/AskTool.js";
|
|
5
|
+
import { CreateBucketTool } from "../tools/CreateBucketTool.js";
|
|
6
|
+
import { ListBucketsTool } from "../tools/ListBucketsTool.js";
|
|
7
|
+
import { MoveSourcesTool } from "../tools/MoveSourcesTool.js";
|
|
8
|
+
import { OpenSourceTool } from "../tools/OpenSourceTool.js";
|
|
9
|
+
import { RenameBucketTool } from "../tools/RenameBucketTool.js";
|
|
10
|
+
import { SearchTool } from "../tools/SearchTool.js";
|
|
11
|
+
import { ToolPreset } from "./ToolPreset.js";
|
|
12
|
+
/** Every published surface, declared explicitly. */
|
|
13
|
+
export declare const ToolPresetRegistry: Readonly<{
|
|
14
|
+
elephant: ToolPreset<AddFilesTool | AddFileTool | AddWebsiteTool | AskTool | CreateBucketTool | ListBucketsTool | MoveSourcesTool | OpenSourceTool | RenameBucketTool | SearchTool>;
|
|
15
|
+
elephantBuilder: ToolPreset<AddFilesTool | AddFileTool | AddWebsiteTool | CreateBucketTool>;
|
|
16
|
+
all: () => ToolPreset[];
|
|
17
|
+
byId: (id: string) => ToolPreset | undefined;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type StdioOptions = {
|
|
2
|
+
/** Preset id: `elephant`, `elephant-builder`, or `all` (both tool sets). */
|
|
3
|
+
readonly preset: string;
|
|
4
|
+
readonly apiKey: string | undefined;
|
|
5
|
+
readonly apiBaseUrl: string;
|
|
6
|
+
readonly help: boolean;
|
|
7
|
+
readonly version: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const USAGE = "Usage: elephant-mcp [--preset elephant|elephant-builder|all]\n\nRuns Elephant by Calypso as a local MCP server over stdio.\n\nEnvironment:\n CALYPSO_API_KEY your Calypso API key (required)\n CALYPSO_API_BASE_URL Calypso API base URL, ending in /v1\n (default https://api.calypso.so/v1)\n ELEPHANT_PRESET default for --preset (default all)\n\nOptions:\n --preset <id> which tools to publish: elephant (read only),\n elephant-builder (add only) or all (read, add and\n organise; the default)\n --version print the version and exit\n --help print this help and exit\n";
|
|
10
|
+
/**
|
|
11
|
+
* Settings for the local stdio server: flags first, then env, then defaults.
|
|
12
|
+
*
|
|
13
|
+
* The key is read from the environment only, never from a flag, so it does
|
|
14
|
+
* not show up in a process list or a shell history.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseStdioOptions(argv: readonly string[], env: NodeJS.ProcessEnv): StdioOptions;
|
package/dist/stdio.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolGroup } from "../presets/ToolGroup.js";
|
|
3
|
+
import { ElephantTool, type ToolArgs, type ToolOutput } from "./ElephantTool.js";
|
|
4
|
+
import type { ToolContext } from "./ToolContext.js";
|
|
5
|
+
declare const inputSchema: {
|
|
6
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
7
|
+
waitForIndexing: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
bucketIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
bucketSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
bucket: z.ZodOptional<z.ZodString>;
|
|
11
|
+
createMissingBuckets: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
file: z.ZodOptional<z.ZodObject<{
|
|
13
|
+
download_url: z.ZodString;
|
|
14
|
+
file_id: z.ZodString;
|
|
15
|
+
mime_type: z.ZodOptional<z.ZodString>;
|
|
16
|
+
file_name: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
file_id: string;
|
|
19
|
+
download_url: string;
|
|
20
|
+
mime_type?: string | undefined;
|
|
21
|
+
file_name?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
file_id: string;
|
|
24
|
+
download_url: string;
|
|
25
|
+
mime_type?: string | undefined;
|
|
26
|
+
file_name?: string | undefined;
|
|
27
|
+
}>>;
|
|
28
|
+
sourceUrl: z.ZodOptional<z.ZodString>;
|
|
29
|
+
contentBase64: z.ZodOptional<z.ZodString>;
|
|
30
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
31
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
32
|
+
title: z.ZodOptional<z.ZodString>;
|
|
33
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
34
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
35
|
+
};
|
|
36
|
+
type Args = ToolArgs<typeof inputSchema>;
|
|
37
|
+
/** `elephant-add-file`: one file into a bucket, from ChatGPT or a link. */
|
|
38
|
+
export declare class AddFileTool extends ElephantTool<typeof inputSchema> {
|
|
39
|
+
readonly name = "elephant-add-file";
|
|
40
|
+
readonly title = "Add a file";
|
|
41
|
+
readonly description: string;
|
|
42
|
+
readonly inputSchema: {
|
|
43
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
44
|
+
waitForIndexing: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
bucketIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
46
|
+
bucketSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
47
|
+
bucket: z.ZodOptional<z.ZodString>;
|
|
48
|
+
createMissingBuckets: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
file: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
download_url: z.ZodString;
|
|
51
|
+
file_id: z.ZodString;
|
|
52
|
+
mime_type: z.ZodOptional<z.ZodString>;
|
|
53
|
+
file_name: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
file_id: string;
|
|
56
|
+
download_url: string;
|
|
57
|
+
mime_type?: string | undefined;
|
|
58
|
+
file_name?: string | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
file_id: string;
|
|
61
|
+
download_url: string;
|
|
62
|
+
mime_type?: string | undefined;
|
|
63
|
+
file_name?: string | undefined;
|
|
64
|
+
}>>;
|
|
65
|
+
sourceUrl: z.ZodOptional<z.ZodString>;
|
|
66
|
+
contentBase64: z.ZodOptional<z.ZodString>;
|
|
67
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
68
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
69
|
+
title: z.ZodOptional<z.ZodString>;
|
|
70
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
71
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
72
|
+
};
|
|
73
|
+
readonly group: ToolGroup;
|
|
74
|
+
readonly fileParams: readonly ["file"];
|
|
75
|
+
readonly annotations: {
|
|
76
|
+
readOnlyHint: boolean;
|
|
77
|
+
destructiveHint: boolean;
|
|
78
|
+
idempotentHint: boolean;
|
|
79
|
+
openWorldHint: boolean;
|
|
80
|
+
};
|
|
81
|
+
protected readonly failure = "Adding the file failed.";
|
|
82
|
+
protected run(args: Args, { api, log }: ToolContext): Promise<ToolOutput>;
|
|
83
|
+
/**
|
|
84
|
+
* A ChatGPT attachment arrives as a temporary download link. It is handed
|
|
85
|
+
* to Calypso as a link to import, so the bytes go from OpenAI to Calypso
|
|
86
|
+
* under Calypso's own fetch policy and never through this server.
|
|
87
|
+
*/
|
|
88
|
+
private static uploadParams;
|
|
89
|
+
private static downloadUrl;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolGroup } from "../presets/ToolGroup.js";
|
|
3
|
+
import { ElephantTool, type ToolArgs, type ToolOutput } from "./ElephantTool.js";
|
|
4
|
+
import type { ToolContext } from "./ToolContext.js";
|
|
5
|
+
declare const inputSchema: {
|
|
6
|
+
waitForBatchReady: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
bucketIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
8
|
+
bucketSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
bucket: z.ZodOptional<z.ZodString>;
|
|
10
|
+
createMissingBuckets: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
items: z.ZodArray<z.ZodObject<{
|
|
12
|
+
bucketIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
13
|
+
bucketSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
|
+
bucket: z.ZodOptional<z.ZodString>;
|
|
15
|
+
createMissingBuckets: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
filename: z.ZodString;
|
|
17
|
+
mimeType: z.ZodString;
|
|
18
|
+
contentBase64: z.ZodString;
|
|
19
|
+
clientFileId: z.ZodOptional<z.ZodString>;
|
|
20
|
+
title: z.ZodOptional<z.ZodString>;
|
|
21
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
22
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
filename: string;
|
|
25
|
+
mimeType: string;
|
|
26
|
+
contentBase64: string;
|
|
27
|
+
metadata?: Record<string, unknown> | undefined;
|
|
28
|
+
title?: string | undefined;
|
|
29
|
+
bucket?: string | undefined;
|
|
30
|
+
tags?: string[] | undefined;
|
|
31
|
+
clientFileId?: string | undefined;
|
|
32
|
+
bucketIds?: string[] | undefined;
|
|
33
|
+
bucketSlugs?: string[] | undefined;
|
|
34
|
+
createMissingBuckets?: boolean | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
filename: string;
|
|
37
|
+
mimeType: string;
|
|
38
|
+
contentBase64: string;
|
|
39
|
+
metadata?: Record<string, unknown> | undefined;
|
|
40
|
+
title?: string | undefined;
|
|
41
|
+
bucket?: string | undefined;
|
|
42
|
+
tags?: string[] | undefined;
|
|
43
|
+
clientFileId?: string | undefined;
|
|
44
|
+
bucketIds?: string[] | undefined;
|
|
45
|
+
bucketSlugs?: string[] | undefined;
|
|
46
|
+
createMissingBuckets?: boolean | undefined;
|
|
47
|
+
}>, "many">;
|
|
48
|
+
batchIdempotencyKey: z.ZodOptional<z.ZodString>;
|
|
49
|
+
};
|
|
50
|
+
/** `elephant-add-files`: up to a hundred files in one request. */
|
|
51
|
+
export declare class AddFilesTool extends ElephantTool<typeof inputSchema> {
|
|
52
|
+
readonly name = "elephant-add-files";
|
|
53
|
+
readonly title = "Add files";
|
|
54
|
+
readonly description: string;
|
|
55
|
+
readonly inputSchema: {
|
|
56
|
+
waitForBatchReady: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
bucketIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
58
|
+
bucketSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
59
|
+
bucket: z.ZodOptional<z.ZodString>;
|
|
60
|
+
createMissingBuckets: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
items: z.ZodArray<z.ZodObject<{
|
|
62
|
+
bucketIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
63
|
+
bucketSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
64
|
+
bucket: z.ZodOptional<z.ZodString>;
|
|
65
|
+
createMissingBuckets: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
filename: z.ZodString;
|
|
67
|
+
mimeType: z.ZodString;
|
|
68
|
+
contentBase64: z.ZodString;
|
|
69
|
+
clientFileId: z.ZodOptional<z.ZodString>;
|
|
70
|
+
title: z.ZodOptional<z.ZodString>;
|
|
71
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
72
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
filename: string;
|
|
75
|
+
mimeType: string;
|
|
76
|
+
contentBase64: string;
|
|
77
|
+
metadata?: Record<string, unknown> | undefined;
|
|
78
|
+
title?: string | undefined;
|
|
79
|
+
bucket?: string | undefined;
|
|
80
|
+
tags?: string[] | undefined;
|
|
81
|
+
clientFileId?: string | undefined;
|
|
82
|
+
bucketIds?: string[] | undefined;
|
|
83
|
+
bucketSlugs?: string[] | undefined;
|
|
84
|
+
createMissingBuckets?: boolean | undefined;
|
|
85
|
+
}, {
|
|
86
|
+
filename: string;
|
|
87
|
+
mimeType: string;
|
|
88
|
+
contentBase64: string;
|
|
89
|
+
metadata?: Record<string, unknown> | undefined;
|
|
90
|
+
title?: string | undefined;
|
|
91
|
+
bucket?: string | undefined;
|
|
92
|
+
tags?: string[] | undefined;
|
|
93
|
+
clientFileId?: string | undefined;
|
|
94
|
+
bucketIds?: string[] | undefined;
|
|
95
|
+
bucketSlugs?: string[] | undefined;
|
|
96
|
+
createMissingBuckets?: boolean | undefined;
|
|
97
|
+
}>, "many">;
|
|
98
|
+
batchIdempotencyKey: z.ZodOptional<z.ZodString>;
|
|
99
|
+
};
|
|
100
|
+
readonly group: ToolGroup;
|
|
101
|
+
readonly annotations: {
|
|
102
|
+
readOnlyHint: boolean;
|
|
103
|
+
destructiveHint: boolean;
|
|
104
|
+
idempotentHint: boolean;
|
|
105
|
+
openWorldHint: boolean;
|
|
106
|
+
};
|
|
107
|
+
protected readonly failure = "Adding the files failed.";
|
|
108
|
+
protected run(args: ToolArgs<typeof inputSchema>, { api, log }: ToolContext): Promise<ToolOutput>;
|
|
109
|
+
}
|
|
110
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolGroup } from "../presets/ToolGroup.js";
|
|
3
|
+
import { ElephantTool, type ToolArgs, type ToolOutput } from "./ElephantTool.js";
|
|
4
|
+
import type { ToolContext } from "./ToolContext.js";
|
|
5
|
+
declare const inputSchema: {
|
|
6
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
7
|
+
bucketIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
8
|
+
bucketSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
bucket: z.ZodOptional<z.ZodString>;
|
|
10
|
+
createMissingBuckets: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
url: z.ZodString;
|
|
12
|
+
title: z.ZodOptional<z.ZodString>;
|
|
13
|
+
tagsHint: z.ZodOptional<z.ZodString>;
|
|
14
|
+
preferredLanguage: z.ZodOptional<z.ZodString>;
|
|
15
|
+
};
|
|
16
|
+
/** `elephant-add-website`: a web page into a bucket. */
|
|
17
|
+
export declare class AddWebsiteTool extends ElephantTool<typeof inputSchema> {
|
|
18
|
+
readonly name = "elephant-add-website";
|
|
19
|
+
readonly title = "Add a website";
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly inputSchema: {
|
|
22
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
23
|
+
bucketIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
24
|
+
bucketSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
25
|
+
bucket: z.ZodOptional<z.ZodString>;
|
|
26
|
+
createMissingBuckets: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
url: z.ZodString;
|
|
28
|
+
title: z.ZodOptional<z.ZodString>;
|
|
29
|
+
tagsHint: z.ZodOptional<z.ZodString>;
|
|
30
|
+
preferredLanguage: z.ZodOptional<z.ZodString>;
|
|
31
|
+
};
|
|
32
|
+
readonly group: ToolGroup;
|
|
33
|
+
readonly annotations: {
|
|
34
|
+
readOnlyHint: boolean;
|
|
35
|
+
destructiveHint: boolean;
|
|
36
|
+
idempotentHint: boolean;
|
|
37
|
+
openWorldHint: boolean;
|
|
38
|
+
};
|
|
39
|
+
protected readonly failure = "Adding the website failed.";
|
|
40
|
+
protected run(args: ToolArgs<typeof inputSchema>, { api, log }: ToolContext): Promise<ToolOutput>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolGroup } from "../presets/ToolGroup.js";
|
|
3
|
+
import { ElephantTool, type ToolArgs, type ToolOutput } from "./ElephantTool.js";
|
|
4
|
+
import type { ToolContext } from "./ToolContext.js";
|
|
5
|
+
declare const inputSchema: {
|
|
6
|
+
prompt: z.ZodString;
|
|
7
|
+
fileIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
8
|
+
model: z.ZodOptional<z.ZodString>;
|
|
9
|
+
buckets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
depth: z.ZodOptional<z.ZodEnum<["fast", "balanced", "deep"]>>;
|
|
11
|
+
};
|
|
12
|
+
/** `elephant-ask`: a cited answer written from the team's knowledge. */
|
|
13
|
+
export declare class AskTool extends ElephantTool<typeof inputSchema> {
|
|
14
|
+
readonly name = "elephant-ask";
|
|
15
|
+
readonly title = "Ask Elephant";
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly inputSchema: {
|
|
18
|
+
prompt: z.ZodString;
|
|
19
|
+
fileIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
+
model: z.ZodOptional<z.ZodString>;
|
|
21
|
+
buckets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
22
|
+
depth: z.ZodOptional<z.ZodEnum<["fast", "balanced", "deep"]>>;
|
|
23
|
+
};
|
|
24
|
+
readonly group: ToolGroup;
|
|
25
|
+
readonly annotations: {
|
|
26
|
+
readOnlyHint: boolean;
|
|
27
|
+
destructiveHint: boolean;
|
|
28
|
+
openWorldHint: boolean;
|
|
29
|
+
};
|
|
30
|
+
protected readonly failure = "Elephant could not answer.";
|
|
31
|
+
protected run(args: ToolArgs<typeof inputSchema>, { api, agents, inventory, log }: ToolContext): Promise<ToolOutput>;
|
|
32
|
+
/**
|
|
33
|
+
* The connector agent first; the catalog's default when this API does not
|
|
34
|
+
* know it yet. Only an "unknown agent" answer falls back: anything else is
|
|
35
|
+
* the real outcome of the question.
|
|
36
|
+
*/
|
|
37
|
+
private static askWithFallback;
|
|
38
|
+
/**
|
|
39
|
+
* One line naming the buckets the answer did not read, when there were
|
|
40
|
+
* more than one answer reads. Names come from the bucket list; an id is
|
|
41
|
+
* shown when a name cannot be read.
|
|
42
|
+
*/
|
|
43
|
+
private static coverageNote;
|
|
44
|
+
/**
|
|
45
|
+
* One closing line saying the depth the answer got, so the caller knows
|
|
46
|
+
* what a retry one step higher would buy, and when a plan capped the ask.
|
|
47
|
+
*/
|
|
48
|
+
private static depthNote;
|
|
49
|
+
/**
|
|
50
|
+
* A file id the API does not know arrives as a bare 404. Say what it means
|
|
51
|
+
* and what to do, since "404 status code (no body)" tells the caller nothing.
|
|
52
|
+
*/
|
|
53
|
+
private static readable;
|
|
54
|
+
/** Whether the answer text already ends in its own list of sources. */
|
|
55
|
+
private static namesItsSources;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolGroup } from "../presets/ToolGroup.js";
|
|
3
|
+
import { ElephantTool, type ToolArgs, type ToolOutput } from "./ElephantTool.js";
|
|
4
|
+
import type { ToolContext } from "./ToolContext.js";
|
|
5
|
+
declare const inputSchema: {
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
8
|
+
description: z.ZodOptional<z.ZodString>;
|
|
9
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
10
|
+
};
|
|
11
|
+
/** `elephant-create-bucket`: a new, empty folder of sources. */
|
|
12
|
+
export declare class CreateBucketTool extends ElephantTool<typeof inputSchema> {
|
|
13
|
+
readonly name = "elephant-create-bucket";
|
|
14
|
+
readonly title = "Create a bucket";
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly inputSchema: {
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
19
|
+
description: z.ZodOptional<z.ZodString>;
|
|
20
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
21
|
+
};
|
|
22
|
+
readonly group: ToolGroup;
|
|
23
|
+
readonly outputSchema: {
|
|
24
|
+
id: z.ZodOptional<z.ZodString>;
|
|
25
|
+
name: z.ZodOptional<z.ZodString>;
|
|
26
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
27
|
+
status: z.ZodOptional<z.ZodString>;
|
|
28
|
+
};
|
|
29
|
+
readonly annotations: {
|
|
30
|
+
readOnlyHint: boolean;
|
|
31
|
+
destructiveHint: boolean;
|
|
32
|
+
idempotentHint: boolean;
|
|
33
|
+
openWorldHint: boolean;
|
|
34
|
+
};
|
|
35
|
+
protected readonly failure = "Creating the bucket failed.";
|
|
36
|
+
protected run(args: ToolArgs<typeof inputSchema>, { api, log }: ToolContext): Promise<ToolOutput>;
|
|
37
|
+
/**
|
|
38
|
+
* Structured output is checked strictly against `outputSchema`: only the
|
|
39
|
+
* declared fields go in the structured part. The text carries the bucket's
|
|
40
|
+
* view, which also has its description.
|
|
41
|
+
*/
|
|
42
|
+
private static declaredFields;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type InputShape, McpTool } from "./McpTool.js";
|
|
2
|
+
import type { ToolContext } from "./ToolContext.js";
|
|
3
|
+
export type { InputShape, ToolArgs, ToolOutput } from "./McpTool.js";
|
|
4
|
+
/**
|
|
5
|
+
* One Elephant tool: a tool handed Elephant's context (the Calypso API as the
|
|
6
|
+
* caller, their agents, their knowledge inventory).
|
|
7
|
+
*
|
|
8
|
+
* Each subclass owns everything a client sees about it, in Elephant's words.
|
|
9
|
+
* Everything a tool of any Calypso server shares lives in `McpTool`.
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class ElephantTool<Shape extends InputShape = InputShape> extends McpTool<ToolContext, Shape> {
|
|
12
|
+
}
|
|
@@ -1,40 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { McpTool } from "./McpTool.js";
|
|
2
2
|
/**
|
|
3
|
-
* One Elephant tool:
|
|
3
|
+
* One Elephant tool: a tool handed Elephant's context (the Calypso API as the
|
|
4
|
+
* caller, their agents, their knowledge inventory).
|
|
4
5
|
*
|
|
5
|
-
* Each subclass owns everything a client sees about it, in Elephant's words
|
|
6
|
-
*
|
|
7
|
-
* `call` turns failures into tool errors the model can read and act on,
|
|
8
|
-
* instead of protocol errors it cannot.
|
|
6
|
+
* Each subclass owns everything a client sees about it, in Elephant's words.
|
|
7
|
+
* Everything a tool of any Calypso server shares lives in `McpTool`.
|
|
9
8
|
*/
|
|
10
|
-
export class ElephantTool {
|
|
11
|
-
outputSchema;
|
|
12
|
-
/**
|
|
13
|
-
* Top-level inputs that take a file the user attached in ChatGPT, declared
|
|
14
|
-
* in `_meta["openai/fileParams"]`.
|
|
15
|
-
*/
|
|
16
|
-
fileParams;
|
|
17
|
-
async call(args, context) {
|
|
18
|
-
try {
|
|
19
|
-
return ElephantTool.result(await this.run(args, context));
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
23
|
-
const message = ErrorView.of(detail);
|
|
24
|
-
await context.log.event("error", `${this.name} failed.`, { tool: this.name, error: message }, { detail });
|
|
25
|
-
return {
|
|
26
|
-
isError: true,
|
|
27
|
-
content: [{ type: "text", text: `Error: ${this.failure} ${message}` }],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
static result(output) {
|
|
32
|
-
if ("text" in output) {
|
|
33
|
-
return { content: [{ type: "text", text: output.text }] };
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
content: [{ type: "text", text: JSON.stringify(output.json, null, 2) }],
|
|
37
|
-
...(output.structured ? { structuredContent: output.structured } : {}),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
9
|
+
export class ElephantTool extends McpTool {
|
|
40
10
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolGroup } from "../presets/ToolGroup.js";
|
|
3
|
+
import { ElephantTool, type ToolArgs, type ToolOutput } from "./ElephantTool.js";
|
|
4
|
+
import type { ToolContext } from "./ToolContext.js";
|
|
5
|
+
declare const inputSchema: {
|
|
6
|
+
includeArchived: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
includeSources: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
};
|
|
9
|
+
/** `elephant-list-buckets`: what Elephant knows about, folder by folder. */
|
|
10
|
+
export declare class ListBucketsTool extends ElephantTool<typeof inputSchema> {
|
|
11
|
+
readonly name = "elephant-list-buckets";
|
|
12
|
+
readonly title = "List buckets";
|
|
13
|
+
readonly description: string;
|
|
14
|
+
readonly inputSchema: {
|
|
15
|
+
includeArchived: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
includeSources: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
};
|
|
18
|
+
readonly group: ToolGroup;
|
|
19
|
+
readonly annotations: {
|
|
20
|
+
readOnlyHint: boolean;
|
|
21
|
+
destructiveHint: boolean;
|
|
22
|
+
idempotentHint: boolean;
|
|
23
|
+
openWorldHint: boolean;
|
|
24
|
+
};
|
|
25
|
+
protected readonly failure = "Listing the team's buckets failed.";
|
|
26
|
+
protected run(args: ToolArgs<typeof inputSchema>, { api, log }: ToolContext): Promise<ToolOutput>;
|
|
27
|
+
/**
|
|
28
|
+
* The bucket with its sources named. A bucket whose sources cannot be read
|
|
29
|
+
* is returned as it was: the names are a help, and a listing that fails
|
|
30
|
+
* because one bucket's names did not load would be worse than ids alone.
|
|
31
|
+
*/
|
|
32
|
+
private static named;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CallToolResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { ToolGroup } from "../presets/ToolGroup.js";
|
|
4
|
+
import type { ToolLogger } from "./ToolLogger.js";
|
|
5
|
+
export type InputShape = Record<string, z.ZodTypeAny>;
|
|
6
|
+
export type ToolArgs<Shape extends InputShape> = z.objectOutputType<Shape, z.ZodTypeAny>;
|
|
7
|
+
/** What a tool produced: a JSON payload, or text, plus optional structure. */
|
|
8
|
+
export type ToolOutput = {
|
|
9
|
+
readonly json: unknown;
|
|
10
|
+
readonly structured?: Record<string, unknown>;
|
|
11
|
+
} | {
|
|
12
|
+
readonly text: string;
|
|
13
|
+
};
|
|
14
|
+
/** What every tool is handed, whatever else its product adds: a logger. */
|
|
15
|
+
export type ToolRuntime = {
|
|
16
|
+
readonly log: ToolLogger;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* One MCP tool: its public name, wording and inputs, and what it does.
|
|
20
|
+
*
|
|
21
|
+
* Each subclass owns everything a client sees about it, so there is no second
|
|
22
|
+
* layer that renames or rewrites tools on the way out. `call` turns failures
|
|
23
|
+
* into tool errors the model can read and act on, instead of protocol errors
|
|
24
|
+
* it cannot. `Context` is what the product hands its tools per request.
|
|
25
|
+
*/
|
|
26
|
+
export declare abstract class McpTool<Context extends ToolRuntime, Shape extends InputShape = InputShape> {
|
|
27
|
+
abstract readonly name: string;
|
|
28
|
+
abstract readonly title: string;
|
|
29
|
+
abstract readonly description: string;
|
|
30
|
+
abstract readonly inputSchema: Shape;
|
|
31
|
+
/** What the tool does, which decides who is offered it. */
|
|
32
|
+
abstract readonly group: ToolGroup;
|
|
33
|
+
/**
|
|
34
|
+
* The three hints a directory review reads are stated outright on every
|
|
35
|
+
* tool, never left to a default: whether it only reads, whether it can
|
|
36
|
+
* destroy anything, and whether it reaches beyond the caller's own
|
|
37
|
+
* knowledge (a public URL, say). The reading tools answer true, false,
|
|
38
|
+
* false.
|
|
39
|
+
*/
|
|
40
|
+
abstract readonly annotations: ToolAnnotations & {
|
|
41
|
+
readOnlyHint: boolean;
|
|
42
|
+
destructiveHint: boolean;
|
|
43
|
+
openWorldHint: boolean;
|
|
44
|
+
};
|
|
45
|
+
readonly outputSchema?: InputShape;
|
|
46
|
+
/**
|
|
47
|
+
* Top-level inputs that take a file the user attached in ChatGPT, declared
|
|
48
|
+
* in `_meta["openai/fileParams"]`.
|
|
49
|
+
*/
|
|
50
|
+
readonly fileParams?: readonly string[];
|
|
51
|
+
/** First words of the error a failed call returns. */
|
|
52
|
+
protected abstract readonly failure: string;
|
|
53
|
+
protected abstract run(args: ToolArgs<Shape>, context: Context): Promise<ToolOutput>;
|
|
54
|
+
call(args: ToolArgs<Shape>, context: Context): Promise<CallToolResult>;
|
|
55
|
+
private static result;
|
|
56
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ErrorView } from "../views/ErrorView.js";
|
|
2
|
+
/**
|
|
3
|
+
* One MCP tool: its public name, wording and inputs, and what it does.
|
|
4
|
+
*
|
|
5
|
+
* Each subclass owns everything a client sees about it, so there is no second
|
|
6
|
+
* layer that renames or rewrites tools on the way out. `call` turns failures
|
|
7
|
+
* into tool errors the model can read and act on, instead of protocol errors
|
|
8
|
+
* it cannot. `Context` is what the product hands its tools per request.
|
|
9
|
+
*/
|
|
10
|
+
export class McpTool {
|
|
11
|
+
outputSchema;
|
|
12
|
+
/**
|
|
13
|
+
* Top-level inputs that take a file the user attached in ChatGPT, declared
|
|
14
|
+
* in `_meta["openai/fileParams"]`.
|
|
15
|
+
*/
|
|
16
|
+
fileParams;
|
|
17
|
+
async call(args, context) {
|
|
18
|
+
try {
|
|
19
|
+
return McpTool.result(await this.run(args, context));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
23
|
+
const message = ErrorView.of(detail);
|
|
24
|
+
await context.log.event("error", `${this.name} failed.`, { tool: this.name, error: message }, { detail });
|
|
25
|
+
return {
|
|
26
|
+
isError: true,
|
|
27
|
+
content: [{ type: "text", text: `Error: ${this.failure} ${message}` }],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
static result(output) {
|
|
32
|
+
if ("text" in output) {
|
|
33
|
+
return { content: [{ type: "text", text: output.text }] };
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: "text", text: JSON.stringify(output.json, null, 2) }],
|
|
37
|
+
...(output.structured ? { structuredContent: output.structured } : {}),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolGroup } from "../presets/ToolGroup.js";
|
|
3
|
+
import { ElephantTool, type ToolArgs, type ToolOutput } from "./ElephantTool.js";
|
|
4
|
+
import type { ToolContext } from "./ToolContext.js";
|
|
5
|
+
declare const inputSchema: {
|
|
6
|
+
sourceIds: z.ZodArray<z.ZodString, "many">;
|
|
7
|
+
fromBucket: z.ZodString;
|
|
8
|
+
toBucket: z.ZodString;
|
|
9
|
+
};
|
|
10
|
+
/** `elephant-move-sources`: the same sources, filed in another bucket. */
|
|
11
|
+
export declare class MoveSourcesTool extends ElephantTool<typeof inputSchema> {
|
|
12
|
+
readonly name = "elephant-move-sources";
|
|
13
|
+
readonly title = "Move sources";
|
|
14
|
+
readonly description: string;
|
|
15
|
+
readonly inputSchema: {
|
|
16
|
+
sourceIds: z.ZodArray<z.ZodString, "many">;
|
|
17
|
+
fromBucket: z.ZodString;
|
|
18
|
+
toBucket: z.ZodString;
|
|
19
|
+
};
|
|
20
|
+
readonly group: ToolGroup;
|
|
21
|
+
readonly annotations: {
|
|
22
|
+
readOnlyHint: boolean;
|
|
23
|
+
destructiveHint: boolean;
|
|
24
|
+
idempotentHint: boolean;
|
|
25
|
+
openWorldHint: boolean;
|
|
26
|
+
};
|
|
27
|
+
protected readonly failure = "Moving the sources failed.";
|
|
28
|
+
protected run(args: ToolArgs<typeof inputSchema>, { api, log }: ToolContext): Promise<ToolOutput>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|