@calypsohq/elephant-mcp-server 1.3.3 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +16 -0
  2. package/dist/ElephantMcpServer.d.ts +45 -0
  3. package/dist/ElephantMcpServer.js +14 -13
  4. package/dist/auth/ApiKeyStrategy.d.ts +14 -0
  5. package/dist/auth/AuthChallenge.d.ts +27 -0
  6. package/dist/auth/AuthStrategy.d.ts +14 -0
  7. package/dist/auth/BearerAuthenticator.d.ts +17 -0
  8. package/dist/auth/Credential.d.ts +23 -0
  9. package/dist/auth/GrantScopes.d.ts +16 -0
  10. package/dist/auth/JwtGrantStrategy.d.ts +30 -0
  11. package/dist/auth/JwtGrantStrategy.js +11 -1
  12. package/dist/auth/ProtectedResource.d.ts +21 -0
  13. package/dist/auth/ProtectedResource.js +1 -0
  14. package/dist/auth/TokenCipher.d.ts +13 -0
  15. package/dist/calypso/AgentCatalog.d.ts +41 -0
  16. package/dist/calypso/AgentCatalogLoader.d.ts +12 -0
  17. package/dist/calypso/AgentChoice.d.ts +25 -0
  18. package/dist/calypso/AgentResponses.d.ts +47 -0
  19. package/dist/calypso/AnswerDepth.d.ts +30 -0
  20. package/dist/calypso/AnswerDiagnostics.d.ts +23 -0
  21. package/dist/calypso/AnswerSources.d.ts +36 -0
  22. package/dist/calypso/BatchManifest.d.ts +29 -0
  23. package/dist/calypso/BucketDestination.d.ts +17 -0
  24. package/dist/calypso/BucketEdits.d.ts +41 -0
  25. package/dist/calypso/BucketSources.d.ts +28 -0
  26. package/dist/calypso/CalypsoApi.d.ts +28 -0
  27. package/dist/calypso/CalypsoApiClient.d.ts +29 -0
  28. package/dist/calypso/CalypsoApiConfig.d.ts +15 -0
  29. package/dist/calypso/KnowledgeBatches.d.ts +25 -0
  30. package/dist/calypso/KnowledgeBuckets.d.ts +18 -0
  31. package/dist/calypso/KnowledgeFiles.d.ts +45 -0
  32. package/dist/calypso/KnowledgeInventory.d.ts +36 -0
  33. package/dist/calypso/KnowledgeSearch.d.ts +52 -0
  34. package/dist/calypso/KnowledgeWebsites.d.ts +39 -0
  35. package/dist/calypso/UploadContent.d.ts +22 -0
  36. package/dist/calypso/apiErrors.d.ts +14 -0
  37. package/dist/calypso/bucketList.d.ts +48 -0
  38. package/dist/calypso/coerce.d.ts +14 -0
  39. package/dist/calypso/knowledgeTypes.d.ts +64 -0
  40. package/dist/calypso/polling.d.ts +14 -0
  41. package/dist/calypso/uploadBytes.d.ts +8 -0
  42. package/dist/hatching/HatchingCopy.d.ts +11 -0
  43. package/dist/http/HostedServer.d.ts +8 -0
  44. package/dist/http/HostedServer.js +10 -0
  45. package/dist/http/HttpConfig.d.ts +40 -0
  46. package/dist/http/HttpConfig.js +15 -3
  47. package/dist/http/HttpServer.d.ts +36 -0
  48. package/dist/http/KnowledgeInventoryCache.d.ts +21 -0
  49. package/dist/http/McpEndpoint.d.ts +39 -0
  50. package/dist/http/McpEndpoint.js +11 -56
  51. package/dist/http/ModelCatalogCache.d.ts +20 -0
  52. package/dist/http/ProtectedResourceMetadata.d.ts +19 -0
  53. package/dist/http/ProtectedResourceMetadata.js +1 -1
  54. package/dist/http/RateLimiter.d.ts +25 -0
  55. package/dist/http/StatelessMcpEndpoint.d.ts +40 -0
  56. package/dist/http/StatelessMcpEndpoint.js +69 -0
  57. package/dist/index.d.ts +2 -0
  58. package/dist/kit.d.ts +35 -0
  59. package/dist/kit.js +31 -0
  60. package/dist/notices/PostBudget.d.ts +15 -0
  61. package/dist/notices/PostBudget.js +32 -0
  62. package/dist/notices/SlackUsageNotices.d.ts +22 -0
  63. package/dist/notices/SlackUsageNotices.js +57 -0
  64. package/dist/notices/UsageMessage.d.ts +22 -0
  65. package/dist/notices/UsageMessage.js +245 -0
  66. package/dist/notices/UsageNotices.d.ts +25 -0
  67. package/dist/notices/UsageNotices.js +4 -0
  68. package/dist/presets/PresetInstructions.d.ts +20 -0
  69. package/dist/presets/ToolGroup.d.ts +30 -0
  70. package/dist/presets/ToolGroup.js +4 -0
  71. package/dist/presets/ToolPreset.d.ts +80 -0
  72. package/dist/presets/ToolPreset.js +6 -1
  73. package/dist/presets/ToolPresetRegistry.d.ts +18 -0
  74. package/dist/stdio/LocalPresets.d.ts +3 -0
  75. package/dist/stdio/StdioOptions.d.ts +16 -0
  76. package/dist/stdio.d.ts +2 -0
  77. package/dist/tools/AddFileTool.d.ts +91 -0
  78. package/dist/tools/AddFilesTool.d.ts +110 -0
  79. package/dist/tools/AddWebsiteTool.d.ts +42 -0
  80. package/dist/tools/AskTool.d.ts +57 -0
  81. package/dist/tools/CreateBucketTool.d.ts +44 -0
  82. package/dist/tools/ElephantTool.d.ts +12 -0
  83. package/dist/tools/ElephantTool.js +6 -36
  84. package/dist/tools/ListBucketsTool.d.ts +34 -0
  85. package/dist/tools/McpTool.d.ts +56 -0
  86. package/dist/tools/McpTool.js +40 -0
  87. package/dist/tools/MoveSourcesTool.d.ts +30 -0
  88. package/dist/tools/OpenSourceTool.d.ts +28 -0
  89. package/dist/tools/RenameBucketTool.d.ts +30 -0
  90. package/dist/tools/SearchTool.d.ts +36 -0
  91. package/dist/tools/ToolContext.d.ts +20 -0
  92. package/dist/tools/ToolLogger.d.ts +17 -0
  93. package/dist/tools/ToolRegistrar.d.ts +22 -0
  94. package/dist/tools/ToolRegistrar.js +33 -0
  95. package/dist/tools/schemaParts.d.ts +38 -0
  96. package/dist/views/BatchView.d.ts +35 -0
  97. package/dist/views/BucketView.d.ts +34 -0
  98. package/dist/views/ErrorView.d.ts +6 -0
  99. package/dist/views/MoveView.d.ts +20 -0
  100. package/dist/views/SearchView.d.ts +36 -0
  101. package/dist/views/SourceView.d.ts +47 -0
  102. package/dist/views/WebsiteView.d.ts +20 -0
  103. package/dist/views/viewFields.d.ts +11 -0
  104. package/package.json +9 -1
@@ -0,0 +1,245 @@
1
+ /**
2
+ * The tools worth a line in the operator channel: the ones that carry a
3
+ * question or change knowledge. The two inventory tools clients call on
4
+ * their own (`elephant-list-buckets`, `elephant-open-source`) stay quiet.
5
+ */
6
+ export const NOTICED_TOOLS = new Set([
7
+ "elephant-ask",
8
+ "elephant-search",
9
+ "elephant-add-file",
10
+ "elephant-add-files",
11
+ "elephant-add-website",
12
+ "elephant-create-bucket",
13
+ "elephant-rename-bucket",
14
+ "elephant-move-sources",
15
+ ]);
16
+ const TEXT_LIMIT = 500;
17
+ /** Slack's limit for one section field: label, newline and escaped value together. */
18
+ const FIELD_TEXT_LIMIT = 2000;
19
+ /**
20
+ * Builds the Slack post for one call, or null when the tool is not noticed.
21
+ * Only the caller's own input and a status leave the server: nothing from
22
+ * the tool's result or from the Calypso API is included (the same rule the
23
+ * tools' views follow).
24
+ */
25
+ export function buildUsageMessage(call, server, dropped = 0) {
26
+ if (!NOTICED_TOOLS.has(call.tool))
27
+ return null;
28
+ const summary = summarizeArgs(call.tool, call.args);
29
+ const outcome = call.outcome === "ok"
30
+ ? `ok · ${formatDuration(call.durationMs)}`
31
+ : `error · ${formatDuration(call.durationMs)}`;
32
+ const caller = describeCaller(call);
33
+ const headline = summary.headline ? ` · ${summary.headline}` : "";
34
+ const fields = [
35
+ ...summary.fields,
36
+ { label: "Outcome", value: outcome },
37
+ { label: "Caller", value: caller },
38
+ {
39
+ label: "Scopes",
40
+ value: call.scopes.length ? call.scopes.join(" ") : "api key (all)",
41
+ },
42
+ {
43
+ label: "Server",
44
+ value: `${server.version} · ${hostOf(server.publicBaseUrl)}`,
45
+ },
46
+ ];
47
+ if (dropped > 0) {
48
+ fields.push({
49
+ label: "Dropped",
50
+ value: `${dropped} earlier notice${dropped === 1 ? "" : "s"} over the post budget`,
51
+ });
52
+ }
53
+ return {
54
+ // Escaped like the fields: the headline is the caller's own text.
55
+ text: escapeMrkdwn(`Elephant used · ${call.tool}${headline} · ${caller}`),
56
+ blocks: [
57
+ {
58
+ type: "header",
59
+ text: {
60
+ type: "plain_text",
61
+ text: truncate(`🐘 Elephant used · ${call.tool}`, 150),
62
+ emoji: true,
63
+ },
64
+ },
65
+ ...fieldSections(fields),
66
+ ],
67
+ };
68
+ }
69
+ function summarizeArgs(tool, args) {
70
+ const input = isRecord(args) ? args : {};
71
+ const text = (key) => asString(input[key]);
72
+ const list = (key) => asStringList(input[key]);
73
+ const fields = [];
74
+ let headline = "";
75
+ switch (tool) {
76
+ case "elephant-ask": {
77
+ headline = text("prompt");
78
+ fields.push({ label: "Question", value: quote(headline) });
79
+ fields.push({ label: "Agent", value: text("model") });
80
+ fields.push({ label: "Buckets", value: list("buckets").join(", ") });
81
+ fields.push({ label: "Depth", value: text("depth") });
82
+ fields.push({ label: "Pinned sources", value: countOf(list("fileIds")) });
83
+ break;
84
+ }
85
+ case "elephant-search": {
86
+ headline = text("query");
87
+ fields.push({ label: "Query", value: quote(headline) });
88
+ fields.push({ label: "Agent", value: text("agent") });
89
+ fields.push({ label: "Buckets", value: list("buckets").join(", ") });
90
+ fields.push({ label: "Depth", value: text("depth") });
91
+ break;
92
+ }
93
+ case "elephant-add-file": {
94
+ const file = isRecord(input.file) ? asString(input.file.filename) : "";
95
+ headline = text("filename") || file || text("sourceUrl");
96
+ fields.push({ label: "File", value: headline });
97
+ fields.push({ label: "Buckets", value: bucketTargets(input) });
98
+ break;
99
+ }
100
+ case "elephant-add-files": {
101
+ const items = Array.isArray(input.items) ? input.items : [];
102
+ const names = items
103
+ .map((item) => (isRecord(item) ? asString(item.filename) : ""))
104
+ .filter(Boolean);
105
+ headline = `${items.length} file${items.length === 1 ? "" : "s"}`;
106
+ fields.push({
107
+ label: "Files",
108
+ value: `${headline}${names.length ? `: ${names.join(", ")}` : ""}`,
109
+ });
110
+ fields.push({ label: "Buckets", value: bucketTargets(input) });
111
+ break;
112
+ }
113
+ case "elephant-add-website": {
114
+ headline = text("url");
115
+ fields.push({ label: "Website", value: headline });
116
+ fields.push({ label: "Buckets", value: bucketTargets(input) });
117
+ break;
118
+ }
119
+ case "elephant-create-bucket": {
120
+ headline = text("name");
121
+ fields.push({ label: "Bucket", value: headline });
122
+ fields.push({ label: "Slug", value: text("slug") });
123
+ break;
124
+ }
125
+ case "elephant-rename-bucket": {
126
+ headline = text("name");
127
+ fields.push({ label: "Bucket", value: text("bucket") });
128
+ fields.push({ label: "New name", value: headline });
129
+ break;
130
+ }
131
+ case "elephant-move-sources": {
132
+ const sources = list("sourceIds").length;
133
+ headline = `${sources} source${sources === 1 ? "" : "s"}`;
134
+ fields.push({ label: "Sources", value: headline });
135
+ fields.push({ label: "From bucket", value: text("fromBucket") });
136
+ fields.push({ label: "To bucket", value: text("toBucket") });
137
+ break;
138
+ }
139
+ default:
140
+ break;
141
+ }
142
+ return { headline: truncate(headline, 120), fields };
143
+ }
144
+ /** The destination as the caller named it: `bucket`, `bucketSlugs` or `bucketIds` (schemaParts). */
145
+ function bucketTargets(input) {
146
+ return [
147
+ asString(input.bucket),
148
+ ...asStringList(input.bucketSlugs),
149
+ ...asStringList(input.bucketIds),
150
+ ]
151
+ .filter(Boolean)
152
+ .join(", ");
153
+ }
154
+ function describeCaller(call) {
155
+ const parts = [call.principal];
156
+ if (call.grant?.team)
157
+ parts.push(`team ${call.grant.team}`);
158
+ if (call.grant?.cid)
159
+ parts.push(`client ${call.grant.cid}`);
160
+ if (call.grant?.sub)
161
+ parts.push(`person ${call.grant.sub.slice(0, 8)}…`);
162
+ return parts.join(" · ");
163
+ }
164
+ function fieldSections(fields) {
165
+ const present = fields
166
+ .map((field) => ({ label: field.label, value: field.value.trim() }))
167
+ .filter((field) => field.value);
168
+ const blocks = [];
169
+ for (let start = 0; start < present.length; start += 10) {
170
+ blocks.push({
171
+ type: "section",
172
+ fields: present.slice(start, start + 10).map((field) => {
173
+ const label = `*${escapeMrkdwn(field.label)}*\n`;
174
+ return {
175
+ type: "mrkdwn",
176
+ text: label +
177
+ fitEscaped(truncate(field.value, TEXT_LIMIT), FIELD_TEXT_LIMIT - label.length),
178
+ };
179
+ }),
180
+ });
181
+ }
182
+ return blocks;
183
+ }
184
+ function quote(value) {
185
+ return value ? `“${truncate(value, TEXT_LIMIT)}”` : "";
186
+ }
187
+ function countOf(values) {
188
+ return values.length ? String(values.length) : "";
189
+ }
190
+ function formatDuration(ms) {
191
+ if (ms < 1000)
192
+ return `${Math.round(ms)} ms`;
193
+ return `${(ms / 1000).toFixed(1)} s`;
194
+ }
195
+ function hostOf(url) {
196
+ try {
197
+ return new URL(url).host;
198
+ }
199
+ catch {
200
+ return url;
201
+ }
202
+ }
203
+ function truncate(value, max) {
204
+ const normalized = value.trim();
205
+ if (normalized.length <= max)
206
+ return normalized;
207
+ return `${normalized.slice(0, Math.max(0, max - 1))}…`;
208
+ }
209
+ /**
210
+ * `value` escaped and cut so the escaped text fits `budget`: escaping expands
211
+ * (`&` becomes five characters), so a value cut before escaping can still
212
+ * pass a Slack limit. Cuts between characters, never inside an entity.
213
+ */
214
+ function fitEscaped(value, budget) {
215
+ const whole = escapeMrkdwn(value);
216
+ if (whole.length <= budget)
217
+ return whole;
218
+ let used = 0;
219
+ let end = 0;
220
+ for (const char of value) {
221
+ const escaped = escapeMrkdwn(char);
222
+ if (used + escaped.length > budget - 1)
223
+ break;
224
+ used += escaped.length;
225
+ end += char.length;
226
+ }
227
+ return `${escapeMrkdwn(value.slice(0, end).trimEnd())}…`;
228
+ }
229
+ function escapeMrkdwn(value) {
230
+ return value
231
+ .replace(/&/g, "&amp;")
232
+ .replace(/</g, "&lt;")
233
+ .replace(/>/g, "&gt;");
234
+ }
235
+ function isRecord(value) {
236
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
237
+ }
238
+ function asString(value) {
239
+ return typeof value === "string" ? value : "";
240
+ }
241
+ function asStringList(value) {
242
+ return Array.isArray(value)
243
+ ? value.filter((item) => typeof item === "string")
244
+ : [];
245
+ }
@@ -0,0 +1,25 @@
1
+ import type { GrantFacts } from "../auth/Credential.js";
2
+ /** One finished tool call, as the operator channel hears about it. */
3
+ export type ToolCall = {
4
+ readonly tool: string;
5
+ /** The caller's own input, as the tool received it. */
6
+ readonly args: unknown;
7
+ readonly outcome: "ok" | "error";
8
+ readonly durationMs: number;
9
+ /** `grant:<gid>` or `key:sk-…abcd`. */
10
+ readonly principal: string;
11
+ readonly scopes: readonly string[];
12
+ readonly grant?: GrantFacts;
13
+ };
14
+ /**
15
+ * Told after every tool call on the hosted server. Fire-and-forget: a
16
+ * notice runs after the tool has its result and can neither delay nor fail
17
+ * it, so the method returns nothing to wait for.
18
+ */
19
+ export interface UsageNotices {
20
+ toolCalled(call: ToolCall): void;
21
+ }
22
+ /** The local (stdio) server and a hosted server without a webhook. */
23
+ export declare class NoUsageNotices implements UsageNotices {
24
+ toolCalled(): void;
25
+ }
@@ -0,0 +1,4 @@
1
+ /** The local (stdio) server and a hosted server without a webhook. */
2
+ export class NoUsageNotices {
3
+ toolCalled() { }
4
+ }
@@ -0,0 +1,20 @@
1
+ import type { GrantScopes } from "../auth/GrantScopes.js";
2
+ import type { ToolGroup } from "./ToolGroup.js";
3
+ /**
4
+ * The session instructions for one caller: what the server is, then what this
5
+ * connection can do and what it cannot.
6
+ *
7
+ * Composed from the groups the caller holds, so a read-only session is never
8
+ * told it can save a file, and a session that can is told to confirm first.
9
+ * What it cannot do comes with the way to get it, because the model is the
10
+ * only one who can tell the user.
11
+ */
12
+ /**
13
+ * Said to every caller, whatever they allowed. A model asked to delete tends
14
+ * to go looking for the thing first; looking is a tool call, and the honest
15
+ * answer needs none.
16
+ */
17
+ export declare const NEVER_DELETES = "Elephant never deletes. When the user asks to delete, remove, erase or forget a source or a bucket, do not call any tool, not even to look for it: say that Elephant cannot delete and that sources and buckets are removed in the Elephant console at https://elephant.calypso.so.";
18
+ export declare const PresetInstructions: {
19
+ compose(about: string, groups: readonly ToolGroup[], grant: GrantScopes): string;
20
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * What a tool does to the caller's knowledge, and the consent that unlocks it.
3
+ *
4
+ * One endpoint offers every tool; a caller sees the groups they agreed to.
5
+ * A group carries its own words, so the session instructions say exactly what
6
+ * this connection can and cannot do instead of describing the whole product.
7
+ */
8
+ export declare class ToolGroup {
9
+ /** Answering and searching: never changes anything. */
10
+ static readonly read: ToolGroup;
11
+ /** Saving new sources and creating buckets. */
12
+ static readonly add: ToolGroup;
13
+ /** Renaming buckets and moving sources between them. Deletes nothing. */
14
+ static readonly organise: ToolGroup;
15
+ readonly id: string;
16
+ /** OAuth scope a grant must carry for this group's tools. */
17
+ readonly scope: string;
18
+ /** Completes "It can …" for a caller who has the group. */
19
+ readonly can: string;
20
+ /** Completes "It cannot …" for a caller who does not. */
21
+ readonly cannot: string;
22
+ /** A group for another server's tools; Elephant's own are the statics above. */
23
+ static define(options: {
24
+ id: string;
25
+ scope: string;
26
+ can: string;
27
+ cannot: string;
28
+ }): ToolGroup;
29
+ private constructor();
30
+ }
@@ -34,6 +34,10 @@ export class ToolGroup {
34
34
  can;
35
35
  /** Completes "It cannot …" for a caller who does not. */
36
36
  cannot;
37
+ /** A group for another server's tools; Elephant's own are the statics above. */
38
+ static define(options) {
39
+ return new ToolGroup(options);
40
+ }
37
41
  constructor(options) {
38
42
  this.id = options.id;
39
43
  this.scope = options.scope;
@@ -0,0 +1,80 @@
1
+ import type { GrantScopes } from "../auth/GrantScopes.js";
2
+ import type { ProtectedResource } from "../auth/ProtectedResource.js";
3
+ import type { ElephantTool } from "../tools/ElephantTool.js";
4
+ import type { ToolGroup } from "./ToolGroup.js";
5
+ /**
6
+ * Words one caller's session instructions: what the server is, then what the
7
+ * groups they hold let this connection do.
8
+ */
9
+ export type InstructionComposer = (about: string, groups: readonly ToolGroup[], grant: GrantScopes) => string;
10
+ /** The least a preset asks of a tool: a name, and the group that unlocks it. */
11
+ export type PresetTool = {
12
+ readonly name: string;
13
+ readonly group: ToolGroup;
14
+ };
15
+ export type ToolPresetOptions<Tool extends PresetTool = ElephantTool> = {
16
+ /** Stable identifier, e.g. `elephant`. */
17
+ readonly id: string;
18
+ /** HTTP path the preset is served on, e.g. `/elephant/mcp`. */
19
+ readonly path: string;
20
+ /** Name returned in `initialize.serverInfo.name`. */
21
+ readonly serverName: string;
22
+ /** Human name shown on consent and in protected-resource metadata. */
23
+ readonly displayName: string;
24
+ /**
25
+ * What the server is, in a sentence or two. What a caller can and cannot
26
+ * do with it is added per caller; see `instructionsFor`.
27
+ */
28
+ readonly instructions: string;
29
+ /**
30
+ * OAuth scope a bearer token must carry to connect at all. Further tools
31
+ * are unlocked by the scopes of their groups.
32
+ */
33
+ readonly scope: string;
34
+ /** The tools this preset publishes, in `tools/list` order. */
35
+ readonly tools: readonly Tool[];
36
+ /** Where the product is documented; see ProtectedResource. */
37
+ readonly documentationUrl?: string;
38
+ /**
39
+ * How a caller's instructions are worded. Elephant's wording
40
+ * (`PresetInstructions`) unless another product brings its own.
41
+ */
42
+ readonly composeInstructions?: InstructionComposer;
43
+ /**
44
+ * The preset answers questions, so it hatches: empty-team instructions,
45
+ * the `elephant-get-started` prompt, and the hatch card in place of an
46
+ * answer when there is nothing to answer from. Off for Builder.
47
+ */
48
+ readonly hatches?: boolean;
49
+ };
50
+ /**
51
+ * One published plugin surface: its endpoint, its scope, and its tools.
52
+ *
53
+ * The preset is the single answer to "what does this endpoint offer", read by
54
+ * `tools/list`, the protected-resource metadata and the smoke probe alike.
55
+ */
56
+ export declare class ToolPreset<Tool extends PresetTool = ElephantTool> implements ProtectedResource {
57
+ readonly id: string;
58
+ readonly path: string;
59
+ readonly serverName: string;
60
+ readonly displayName: string;
61
+ readonly instructions: string;
62
+ readonly scope: string;
63
+ readonly tools: readonly Tool[];
64
+ readonly hatches: boolean;
65
+ readonly documentationUrl?: string;
66
+ private readonly composeInstructions;
67
+ constructor(options: ToolPresetOptions<Tool>);
68
+ toolNames(): string[];
69
+ /** The groups this preset's tools belong to, in first-seen order. */
70
+ groups(): ToolGroup[];
71
+ /** Every OAuth scope a grant for this preset may carry. */
72
+ scopes(): string[];
73
+ /** The tools one caller is offered: those of the groups they agreed to. */
74
+ toolsFor(grant: GrantScopes): Tool[];
75
+ /** `initialize.instructions` for one caller. */
76
+ instructionsFor(grant: GrantScopes): string;
77
+ /** Absolute resource URL (`aud`) for this preset under a public base URL. */
78
+ resourceUrl(publicBaseUrl: string): string;
79
+ private static assertUniqueNames;
80
+ }
@@ -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 PresetInstructions.compose(this.instructions, this.groups(), grant);
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,3 @@
1
+ import { ToolPreset } from "../presets/ToolPreset.js";
2
+ /** The preset a local server runs, by the id given on the command line. */
3
+ export declare function localPreset(id: string): ToolPreset;
@@ -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;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -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 {};