@amoree-code/ocean 1.5.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.
@@ -39,6 +39,41 @@ export class RemoteMcpClient {
39
39
  forwardToolCall(name, args) {
40
40
  return this.#client.callTool({ name, arguments: args });
41
41
  }
42
+ async listResources() {
43
+ if (!this.#client.getServerCapabilities()?.resources)
44
+ return [];
45
+ const resources = [];
46
+ let cursor;
47
+ do {
48
+ const page = await this.#client.listResources(cursor ? { cursor } : undefined);
49
+ resources.push(...page.resources);
50
+ cursor = page.nextCursor;
51
+ } while (cursor);
52
+ return resources;
53
+ }
54
+ readResource(uri) {
55
+ return this.#client.readResource({ uri });
56
+ }
57
+ async listPrompts() {
58
+ if (!this.#client.getServerCapabilities()?.prompts)
59
+ return [];
60
+ const prompts = [];
61
+ let cursor;
62
+ do {
63
+ const page = await this.#client.listPrompts(cursor ? { cursor } : undefined);
64
+ prompts.push(...page.prompts);
65
+ cursor = page.nextCursor;
66
+ } while (cursor);
67
+ return prompts;
68
+ }
69
+ getPrompt(name, args) {
70
+ // MCP prompt arguments are strings; anything else is sent as its JSON text.
71
+ const strings = Object.fromEntries(Object.entries(args).map(([key, value]) => [
72
+ key,
73
+ typeof value === "string" ? value : JSON.stringify(value),
74
+ ]));
75
+ return this.#client.getPrompt({ name, arguments: strings });
76
+ }
42
77
  close() {
43
78
  void this.#client.close().catch(() => { });
44
79
  }
@@ -1,9 +1,11 @@
1
+ import { MEMORY_INSTRUCTIONS } from "@ocean/core/domain/mcp/memory-contract.js";
1
2
  import { marketplacePaths } from "@ocean/market/install/default-marketplace.js";
2
3
  import { gatewayMembers, McpGateway, readGatewayAccess, serveMcpGateway, } from "@ocean/market/mcp/mcp-gateway.js";
3
4
  import { keychainStore } from "@ocean/market/security/secrets.js";
4
5
  import { McpClient } from "@ocean/services/infrastructure/mcp/mcp-client.js";
5
6
  import { RemoteMcpClient } from "../../infrastructure/mcp/remote-mcp-client.js";
6
7
  import { oceanVersion } from "../../version.js";
8
+ const OCEAN_SERVER = "dev.ocean/ocean";
7
9
  // How the gateway (and `ocean mcp status --check`) talks to one member.
8
10
  export function gatewayClientFor(member, version, stderrLabel = `ocean mcp gateway [${member.capability}]`) {
9
11
  return member.transport === "remote"
@@ -24,10 +26,11 @@ export function gatewayClientFor(member, version, stderrLabel = `ocean mcp gatew
24
26
  export async function runMcpGatewayCommand(args = []) {
25
27
  const log = (line) => console.error(`ocean mcp gateway: ${line}`);
26
28
  const paths = marketplacePaths();
29
+ const firstParty = !args.includes("--installed-only");
27
30
  const { members, skipped } = await gatewayMembers({
28
31
  serversRoot: paths.mcpServers,
29
32
  stateRoot: paths.mcpState,
30
- firstParty: !args.includes("--installed-only"),
33
+ firstParty,
31
34
  secrets: keychainStore(),
32
35
  });
33
36
  for (const skip of skipped)
@@ -37,6 +40,11 @@ export async function runMcpGatewayCommand(args = []) {
37
40
  client: (member) => gatewayClientFor(member, version),
38
41
  version,
39
42
  log,
43
+ // When Ocean's own server sits behind the gateway and this client may see it, the client
44
+ // gets Ocean's memory contract in `initialize`, as on a direct connection (T-313).
45
+ ...(firstParty
46
+ ? { instructions: MEMORY_INSTRUCTIONS, instructionsMember: OCEAN_SERVER }
47
+ : {}),
40
48
  access: await readGatewayAccess(paths.gatewayAccess),
41
49
  clientId: args.includes("--client")
42
50
  ? args[args.indexOf("--client") + 1]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/brain",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/context",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/core",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/loop",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -186,9 +186,9 @@ export async function gatewayMembers(options) {
186
186
  });
187
187
  return { members, skipped };
188
188
  }
189
- // Every text a model reads for a tool: its name, its description and each key and string inside
190
- // its input schema (property names, titles, enums and defaults included).
191
- function toolTexts(tool) {
189
+ // Every text a model reads for a tool, resource or prompt: each named field, and each key and
190
+ // string nested inside it (a tool's schema property names, titles, enums and defaults included).
191
+ function modelTexts(fields) {
192
192
  const texts = [];
193
193
  const walk = (value, at) => {
194
194
  if (typeof value === "string")
@@ -203,9 +203,8 @@ function toolTexts(tool) {
203
203
  walk(item, `${at}.${key}`);
204
204
  }
205
205
  };
206
- walk(tool.name, "name");
207
- walk(tool.description, "description");
208
- walk(tool.inputSchema, "inputSchema");
206
+ for (const [at, value] of Object.entries(fields))
207
+ walk(value, at);
209
208
  return texts;
210
209
  }
211
210
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -235,6 +234,12 @@ export class McpGateway {
235
234
  options;
236
235
  #routes = new Map();
237
236
  #tools = [];
237
+ // Resource URIs are exposed unchanged (a server's own texts point at them), so a URI two
238
+ // members both list stays with the first. Prompts are namespaced like tools.
239
+ #resourceRoutes = new Map();
240
+ #resources = [];
241
+ #promptRoutes = new Map();
242
+ #prompts = [];
238
243
  #clients = [];
239
244
  #started;
240
245
  // Who is on the other end, from `initialize`; fixed once members start.
@@ -264,7 +269,26 @@ export class McpGateway {
264
269
  this.#clients.push(...clients);
265
270
  const results = await Promise.allSettled(members.map(async (member, index) => {
266
271
  await withTimeout(clients[index].connect(), timeoutMs, `${member.capability} did not start`);
267
- return withTimeout(clients[index].listTools(), timeoutMs, `${member.capability} did not list its tools`);
272
+ const tools = await withTimeout(clients[index].listTools(), timeoutMs, `${member.capability} did not list its tools`);
273
+ // A member that cannot list resources or prompts keeps its tools.
274
+ const optional = async (what, list) => {
275
+ if (!list)
276
+ return [];
277
+ try {
278
+ return await withTimeout(list(), timeoutMs, `${member.capability} did not list its ${what}`);
279
+ }
280
+ catch (error) {
281
+ this.#log(`${member.capability} ${what} left out: ${errorMessage(error)}`);
282
+ return [];
283
+ }
284
+ };
285
+ const client = clients[index];
286
+ const listing = {
287
+ tools,
288
+ resources: await optional("resources", client.listResources?.bind(client)),
289
+ prompts: await optional("prompts", client.listPrompts?.bind(client)),
290
+ };
291
+ return listing;
268
292
  }));
269
293
  results.forEach((result, index) => {
270
294
  const member = members[index];
@@ -273,16 +297,54 @@ export class McpGateway {
273
297
  clients[index].close();
274
298
  return;
275
299
  }
276
- for (const tool of result.value)
300
+ for (const tool of result.value.tools)
277
301
  this.#expose(member, clients[index], tool);
302
+ for (const resource of result.value.resources)
303
+ this.#exposeResource(member, clients[index], resource);
304
+ for (const prompt of result.value.prompts)
305
+ this.#exposePrompt(member, clients[index], prompt);
278
306
  });
279
307
  }
280
- #expose(member, client, tool) {
281
- const findings = toolTexts(tool).flatMap(({ at, text }) => scanText(at, text));
282
- if (findings.length) {
283
- this.#log(`${member.capability} tool ${tool.name} hidden: ${findings.map((finding) => `${finding.rule} in ${finding.source} ("${finding.excerpt}")`).join("; ")}`);
308
+ // True when a text the model would read carries injected instructions; then it is hidden.
309
+ #injected(member, kind, name, fields) {
310
+ const findings = modelTexts(fields).flatMap(({ at, text }) => scanText(at, text));
311
+ if (!findings.length)
312
+ return false;
313
+ this.#log(`${member.capability} ${kind} ${name} hidden: ${findings.map((finding) => `${finding.rule} in ${finding.source} ("${finding.excerpt}")`).join("; ")}`);
314
+ return true;
315
+ }
316
+ #exposeResource(member, client, resource) {
317
+ if (!isRecord(resource) || typeof resource.uri !== "string")
318
+ return;
319
+ if (this.#injected(member, "resource", resource.uri, resource))
320
+ return;
321
+ if (this.#resourceRoutes.has(resource.uri)) {
322
+ this.#log(`${member.capability} lists resource ${resource.uri} already routed; kept the first`);
284
323
  return;
285
324
  }
325
+ this.#resourceRoutes.set(resource.uri, client);
326
+ this.#resources.push(resource);
327
+ }
328
+ #exposePrompt(member, client, prompt) {
329
+ if (!isRecord(prompt) || typeof prompt.name !== "string")
330
+ return;
331
+ if (this.#injected(member, "prompt", prompt.name, prompt))
332
+ return;
333
+ const name = `${member.prefix}__${prompt.name}`;
334
+ if (this.#promptRoutes.has(name)) {
335
+ this.#log(`${member.capability} lists prompt ${prompt.name} twice; kept the first`);
336
+ return;
337
+ }
338
+ this.#promptRoutes.set(name, { client, prompt: prompt.name });
339
+ this.#prompts.push({ ...prompt, name });
340
+ }
341
+ #expose(member, client, tool) {
342
+ if (this.#injected(member, "tool", tool.name, {
343
+ name: tool.name,
344
+ description: tool.description,
345
+ inputSchema: tool.inputSchema,
346
+ }))
347
+ return;
286
348
  const name = `${member.prefix}__${tool.name}`;
287
349
  if (this.#routes.has(name)) {
288
350
  this.#log(`${member.capability} lists ${tool.name} twice; kept the first`);
@@ -302,6 +364,28 @@ export class McpGateway {
302
364
  throw new GatewayError(-32602, `Unknown MCP tool: ${name}`);
303
365
  return route.client.forwardToolCall(route.tool, args);
304
366
  }
367
+ async resources() {
368
+ await this.start();
369
+ return [...this.#resources];
370
+ }
371
+ async readResource(uri) {
372
+ await this.start();
373
+ const client = this.#resourceRoutes.get(uri);
374
+ if (!client?.readResource)
375
+ throw new GatewayError(-32602, `Unknown MCP resource: ${uri}`);
376
+ return client.readResource(uri);
377
+ }
378
+ async prompts() {
379
+ await this.start();
380
+ return [...this.#prompts];
381
+ }
382
+ async getPrompt(name, args) {
383
+ await this.start();
384
+ const route = this.#promptRoutes.get(name);
385
+ if (!route?.client.getPrompt)
386
+ throw new GatewayError(-32602, `Unknown MCP prompt: ${name}`);
387
+ return route.client.getPrompt(route.prompt, args);
388
+ }
305
389
  async handle(request) {
306
390
  // MCP 2025-06-18 has no batches; anything but one request object is invalid.
307
391
  if (!isRecord(request))
@@ -350,12 +434,14 @@ export class McpGateway {
350
434
  void this.start();
351
435
  return {
352
436
  protocolVersion: "2025-06-18",
353
- capabilities: { tools: {} },
437
+ // Members start after this answer, so resources and prompts are always offered; a
438
+ // gateway whose members have none lists them empty, which MCP allows.
439
+ capabilities: { tools: {}, resources: {}, prompts: {} },
354
440
  serverInfo: {
355
441
  name: this.options.serverName ?? "ocean-gateway",
356
442
  version: this.options.version ?? "0.0.0",
357
443
  },
358
- ...(this.options.instructions
444
+ ...(this.#instructions()
359
445
  ? { instructions: this.options.instructions }
360
446
  : {}),
361
447
  };
@@ -371,10 +457,37 @@ export class McpGateway {
371
457
  throw new GatewayError(-32602, "tools/call needs a tool name and an arguments object");
372
458
  return this.call(params.name, args);
373
459
  }
460
+ case "resources/list":
461
+ return { resources: await this.resources() };
462
+ case "resources/read": {
463
+ const params = isRecord(request.params) ? request.params : {};
464
+ if (typeof params.uri !== "string")
465
+ throw new GatewayError(-32602, "resources/read needs a uri");
466
+ return this.readResource(params.uri);
467
+ }
468
+ case "prompts/list":
469
+ return { prompts: await this.prompts() };
470
+ case "prompts/get": {
471
+ const params = isRecord(request.params) ? request.params : {};
472
+ const args = params.arguments ?? {};
473
+ if (typeof params.name !== "string" || !isRecord(args))
474
+ throw new GatewayError(-32602, "prompts/get needs a prompt name and an arguments object");
475
+ return this.getPrompt(params.name, args);
476
+ }
374
477
  default:
375
478
  throw new GatewayError(-32601, `Unsupported MCP method: ${request.method ?? ""}`);
376
479
  }
377
480
  }
481
+ #instructions() {
482
+ const { instructions, instructionsMember } = this.options;
483
+ if (!instructions)
484
+ return false;
485
+ if (!instructionsMember)
486
+ return true;
487
+ const access = this.options.access ?? { clients: {} };
488
+ return this.members.some((member) => member.capability === instructionsMember &&
489
+ canSee(access, this.#client, member));
490
+ }
378
491
  close() {
379
492
  for (const client of this.#clients)
380
493
  client.close();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/market",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -7,6 +7,8 @@ export class McpClient {
7
7
  pending = new Map();
8
8
  buffer = "";
9
9
  tools = new Map();
10
+ // What the server said it offers in `initialize`; resources and prompts are asked for only then.
11
+ serverCapabilities = {};
10
12
  constructor(options) {
11
13
  this.options = options;
12
14
  }
@@ -40,11 +42,16 @@ export class McpClient {
40
42
  this.child.stdout.on("data", (chunk) => this.consume(chunk));
41
43
  this.child.once("error", (error) => this.failPending(error));
42
44
  this.child.once("close", () => this.failPending(new Error("MCP server stopped")));
43
- await this.request("initialize", {
45
+ const initialized = (await this.request("initialize", {
44
46
  protocolVersion: "2025-06-18",
45
47
  capabilities: {},
46
48
  clientInfo: { name: "ocean", version: "0.3.2" },
47
- });
49
+ }));
50
+ const capabilities = initialized?.capabilities;
51
+ this.serverCapabilities =
52
+ capabilities && typeof capabilities === "object"
53
+ ? capabilities
54
+ : {};
48
55
  this.notify("notifications/initialized", {});
49
56
  }
50
57
  async listTools() {
@@ -80,6 +87,24 @@ export class McpClient {
80
87
  throw new Error(`MCP tool is not allowed: ${name}`);
81
88
  return this.request("tools/call", { name, arguments: arguments_ });
82
89
  }
90
+ async listResources() {
91
+ if (!this.serverCapabilities.resources)
92
+ return [];
93
+ const result = (await this.request("resources/list", {}));
94
+ return result.resources ?? [];
95
+ }
96
+ readResource(uri) {
97
+ return this.request("resources/read", { uri });
98
+ }
99
+ async listPrompts() {
100
+ if (!this.serverCapabilities.prompts)
101
+ return [];
102
+ const result = (await this.request("prompts/list", {}));
103
+ return result.prompts ?? [];
104
+ }
105
+ getPrompt(name, arguments_) {
106
+ return this.request("prompts/get", { name, arguments: arguments_ });
107
+ }
83
108
  close() {
84
109
  if (this.child) {
85
110
  this.child.stdin.destroy();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/services",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -5,9 +5,9 @@
5
5
  {
6
6
  "kind": "skill",
7
7
  "name": "dev.ocean.skills.business-logic",
8
- "version": "1.5.0",
8
+ "version": "1.5.1",
9
9
  "engines": {
10
- "ocean": ">=1.5.0"
10
+ "ocean": ">=1.5.1"
11
11
  },
12
12
  "source": {
13
13
  "type": "path",
@@ -23,9 +23,9 @@
23
23
  {
24
24
  "kind": "skill",
25
25
  "name": "dev.ocean.skills.catch-up",
26
- "version": "1.5.0",
26
+ "version": "1.5.1",
27
27
  "engines": {
28
- "ocean": ">=1.5.0"
28
+ "ocean": ">=1.5.1"
29
29
  },
30
30
  "source": {
31
31
  "type": "path",
@@ -41,9 +41,9 @@
41
41
  {
42
42
  "kind": "skill",
43
43
  "name": "dev.ocean.skills.core-thinking",
44
- "version": "1.5.0",
44
+ "version": "1.5.1",
45
45
  "engines": {
46
- "ocean": ">=1.5.0"
46
+ "ocean": ">=1.5.1"
47
47
  },
48
48
  "source": {
49
49
  "type": "path",
@@ -59,9 +59,9 @@
59
59
  {
60
60
  "kind": "skill",
61
61
  "name": "dev.ocean.skills.design-thinking",
62
- "version": "1.5.0",
62
+ "version": "1.5.1",
63
63
  "engines": {
64
- "ocean": ">=1.5.0"
64
+ "ocean": ">=1.5.1"
65
65
  },
66
66
  "source": {
67
67
  "type": "path",
@@ -77,9 +77,9 @@
77
77
  {
78
78
  "kind": "skill",
79
79
  "name": "dev.ocean.skills.graft",
80
- "version": "1.5.0",
80
+ "version": "1.5.1",
81
81
  "engines": {
82
- "ocean": ">=1.5.0"
82
+ "ocean": ">=1.5.1"
83
83
  },
84
84
  "source": {
85
85
  "type": "path",
@@ -95,9 +95,9 @@
95
95
  {
96
96
  "kind": "skill",
97
97
  "name": "dev.ocean.skills.loop",
98
- "version": "1.5.0",
98
+ "version": "1.5.1",
99
99
  "engines": {
100
- "ocean": ">=1.5.0"
100
+ "ocean": ">=1.5.1"
101
101
  },
102
102
  "source": {
103
103
  "type": "path",
@@ -113,9 +113,9 @@
113
113
  {
114
114
  "kind": "skill",
115
115
  "name": "dev.ocean.skills.session-handoff",
116
- "version": "1.5.0",
116
+ "version": "1.5.1",
117
117
  "engines": {
118
- "ocean": ">=1.5.0"
118
+ "ocean": ">=1.5.1"
119
119
  },
120
120
  "source": {
121
121
  "type": "path",
@@ -131,9 +131,9 @@
131
131
  {
132
132
  "kind": "skill",
133
133
  "name": "dev.ocean.skills.use-browser",
134
- "version": "1.5.0",
134
+ "version": "1.5.1",
135
135
  "engines": {
136
- "ocean": ">=1.5.0"
136
+ "ocean": ">=1.5.1"
137
137
  },
138
138
  "source": {
139
139
  "type": "path",
@@ -149,9 +149,9 @@
149
149
  {
150
150
  "kind": "skill",
151
151
  "name": "dev.ocean.skills.verification",
152
- "version": "1.5.0",
152
+ "version": "1.5.1",
153
153
  "engines": {
154
- "ocean": ">=1.5.0"
154
+ "ocean": ">=1.5.1"
155
155
  },
156
156
  "source": {
157
157
  "type": "path",
@@ -183,9 +183,9 @@
183
183
  "npx"
184
184
  ]
185
185
  },
186
- "version": "1.5.0",
186
+ "version": "1.5.1",
187
187
  "engines": {
188
- "ocean": ">=1.5.0"
188
+ "ocean": ">=1.5.1"
189
189
  },
190
190
  "source": {
191
191
  "type": "path",
@@ -218,9 +218,9 @@
218
218
  "kind": "mcp",
219
219
  "name": "dev.ocean/mcp-gateway",
220
220
  "description": "One MCP endpoint for every registered server: Ocean's own and those installed from the marketplace.",
221
- "version": "1.5.0",
221
+ "version": "1.5.1",
222
222
  "engines": {
223
- "ocean": ">=1.5.0"
223
+ "ocean": ">=1.5.1"
224
224
  },
225
225
  "source": {
226
226
  "type": "path",
@@ -262,9 +262,9 @@
262
262
  "kind": "mcp",
263
263
  "name": "dev.ocean/obsidian",
264
264
  "description": "Ocean's Obsidian vault bridge over MCP.",
265
- "version": "1.5.0",
265
+ "version": "1.5.1",
266
266
  "engines": {
267
- "ocean": ">=1.5.0"
267
+ "ocean": ">=1.5.1"
268
268
  },
269
269
  "source": {
270
270
  "type": "path",
@@ -306,9 +306,9 @@
306
306
  "kind": "mcp",
307
307
  "name": "dev.ocean/ocean",
308
308
  "description": "Ocean's own MCP server: workspace status, tasks, handoffs, sessions and the brain.",
309
- "version": "1.5.0",
309
+ "version": "1.5.1",
310
310
  "engines": {
311
- "ocean": ">=1.5.0"
311
+ "ocean": ">=1.5.1"
312
312
  },
313
313
  "source": {
314
314
  "type": "path",
@@ -360,9 +360,9 @@
360
360
  "npx"
361
361
  ]
362
362
  },
363
- "version": "1.5.0",
363
+ "version": "1.5.1",
364
364
  "engines": {
365
- "ocean": ">=1.5.0"
365
+ "ocean": ">=1.5.1"
366
366
  },
367
367
  "source": {
368
368
  "type": "path",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@amoree-code/ocean",
3
3
  "description": "Local-first memory, tasks and session capture shared by every AI coding client: one private workspace for Claude, Codex, Gemini and more.",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "author": "AMEER ABDULKAREEM JABBAR LAMI",
@@ -45,12 +45,12 @@
45
45
  "@langchain/core": "1.2.14",
46
46
  "@langchain/langgraph": "1.4.19",
47
47
  "@modelcontextprotocol/sdk": "1.32.0",
48
- "@ocean/brain": "1.5.0",
49
- "@ocean/context": "1.5.0",
50
- "@ocean/core": "1.5.0",
51
- "@ocean/loop": "1.5.0",
52
- "@ocean/market": "1.5.0",
53
- "@ocean/services": "1.5.0",
48
+ "@ocean/brain": "1.5.1",
49
+ "@ocean/context": "1.5.1",
50
+ "@ocean/core": "1.5.1",
51
+ "@ocean/loop": "1.5.1",
52
+ "@ocean/market": "1.5.1",
53
+ "@ocean/services": "1.5.1",
54
54
  "playwright-core": "^1.48.0",
55
55
  "sqlite-vec": "0.1.9",
56
56
  "zod": "^4.6.5"