@orkestrel/mcp 0.0.9 → 0.0.11

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.
@@ -1383,7 +1383,7 @@ var MCPServer = class {
1383
1383
  keys: this.#limits.keys,
1384
1384
  depth: this.#limits.depth
1385
1385
  })) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: `_meta` exceeds the configured limit or contains an unsafe value");
1386
- return modern ? this.#modern(request, id, options) : this.#legacy(request, id);
1386
+ return modern ? this.#modern(request, id, options) : this.#legacy(request, id, options);
1387
1387
  }
1388
1388
  async handle(message, options) {
1389
1389
  if (!isBoundedString(message, this.#limits.message)) return JSON.stringify(buildJSONRPCError(null, JSONRPC_PARSE_ERROR, "Parse error"));
@@ -1399,7 +1399,7 @@ var MCPServer = class {
1399
1399
  if (answer === void 0) return void 0;
1400
1400
  return Symbol.asyncIterator in answer ? serializeStream(answer) : JSON.stringify(answer);
1401
1401
  }
1402
- async #legacy(request, id) {
1402
+ async #legacy(request, id, options) {
1403
1403
  switch (request.method) {
1404
1404
  case "initialize": {
1405
1405
  const requested = request.params?.["protocolVersion"];
@@ -1408,7 +1408,7 @@ var MCPServer = class {
1408
1408
  case "ping": return buildJSONRPCResult(id, {});
1409
1409
  case "tools/list": return buildJSONRPCResult(id, { tools: buildToolDescriptors(this.#options.tools) });
1410
1410
  case "tools/call": {
1411
- const result = await this.#runTool(request, id);
1411
+ const result = await this.#runTool(request, id, options);
1412
1412
  return "jsonrpc" in result ? result : buildJSONRPCResult(id, result);
1413
1413
  }
1414
1414
  default: return buildJSONRPCError(id, JSONRPC_METHOD_NOT_FOUND, `Method not found: ${request.method}`);
@@ -1441,7 +1441,7 @@ var MCPServer = class {
1441
1441
  const id = request.id ?? null;
1442
1442
  const input = await this.#input(request, options);
1443
1443
  if (input !== void 0) return input;
1444
- const result = await this.#runTool(request, id);
1444
+ const result = await this.#runTool(request, id, options);
1445
1445
  return "jsonrpc" in result ? result : buildJSONRPCResult(id, buildModernResult(result, this.#options.identity));
1446
1446
  }
1447
1447
  async #input(request, options) {
@@ -1463,12 +1463,12 @@ var MCPServer = class {
1463
1463
  arguments: args
1464
1464
  }, options);
1465
1465
  if (elicitation === void 0) return void 0;
1466
- const principal = await configured.principal(request);
1466
+ const principal = await configured.principal(request, options);
1467
1467
  return this.#required(request, name, elicitation, principal);
1468
1468
  }
1469
1469
  if (!isBoundedString(requestState, this.#limits.state) || !(0, _orkestrel_contract.isRecord)(inputResponses)) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: `inputResponses` and `requestState` are required together");
1470
1470
  const state = parseMCPInputState(await (0, _orkestrel_server.verifyToken)(requestState, configured.secret));
1471
- const principal = await configured.principal(request);
1471
+ const principal = await configured.principal(request, options);
1472
1472
  if (state === void 0 || state.principal !== principal || state.ttl !== configured.ttl || state.origin === id || state.name !== name || !Object.hasOwn(inputResponses, state.key)) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
1473
1473
  const response = inputResponses[state.key];
1474
1474
  if (!isElicitResult(response)) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: the elicitation response is missing or malformed");
@@ -1543,7 +1543,7 @@ var MCPServer = class {
1543
1543
  this.#subscriptions -= 1;
1544
1544
  }
1545
1545
  }
1546
- async #runTool(request, id) {
1546
+ async #runTool(request, id, options) {
1547
1547
  const params = request.params;
1548
1548
  const name = params?.["name"];
1549
1549
  if (!(0, _orkestrel_contract.isString)(name)) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: a string `name` is required");
@@ -1553,7 +1553,8 @@ var MCPServer = class {
1553
1553
  const result = await this.#options.tools.execute({
1554
1554
  id: callId,
1555
1555
  name,
1556
- arguments: args
1556
+ arguments: args,
1557
+ ...options.caller === void 0 ? {} : { caller: options.caller }
1557
1558
  });
1558
1559
  if (!result.success && !isBoundedString(result.error, this.#limits.content)) return buildJSONRPCError(id, JSONRPC_SERVER_ERROR, "Server limit exceeded: tool content is too large");
1559
1560
  if (result.success && result.value !== void 0 && !isBoundedJSON(result.value, {