openloops 0.7.0 → 0.7.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/db/indexes/mcp-servers.js +2 -1
  3. package/dist/db/indexes/mcp-servers.mjs +2 -1
  4. package/dist/harness/agent.d.ts +1 -2
  5. package/dist/harness/agent.js +15 -9
  6. package/dist/harness/agent.mjs +15 -9
  7. package/dist/services/automations/runner/automation-runner.js +1 -3
  8. package/dist/services/automations/runner/automation-runner.mjs +1 -3
  9. package/dist/services/mcp-servers/admin/index.d.ts +1 -0
  10. package/dist/services/mcp-servers/admin/index.js +22 -0
  11. package/dist/services/mcp-servers/admin/index.mjs +1 -0
  12. package/dist/services/mcp-servers/admin/module.d.ts +10 -0
  13. package/dist/services/mcp-servers/admin/module.js +55 -0
  14. package/dist/services/mcp-servers/admin/module.mjs +27 -0
  15. package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.d.ts +12 -0
  16. package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.js +50 -0
  17. package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.mjs +26 -0
  18. package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.d.ts +13 -0
  19. package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.js +44 -0
  20. package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.mjs +20 -0
  21. package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.d.ts +12 -0
  22. package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.js +41 -0
  23. package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.mjs +17 -0
  24. package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.d.ts +16 -0
  25. package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.js +42 -0
  26. package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.mjs +18 -0
  27. package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.d.ts +13 -0
  28. package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.js +59 -0
  29. package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.mjs +35 -0
  30. package/dist/services/mcp-servers/entities/mcpserver.entity.d.ts +10 -1
  31. package/dist/services/mcp-servers/entities/mcpserver.entity.js +28 -3
  32. package/dist/services/mcp-servers/entities/mcpserver.entity.mjs +28 -3
  33. package/dist/services/mcp-servers/internal.d.ts +7 -0
  34. package/dist/services/mcp-servers/internal.js +32 -0
  35. package/dist/services/mcp-servers/internal.mjs +8 -0
  36. package/dist/services/mcp-servers/repositories/mcpserver.repository.d.ts +8 -0
  37. package/dist/services/mcp-servers/repositories/mcpserver.repository.js +23 -3
  38. package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +24 -4
  39. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +2 -0
  40. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +2 -0
  41. package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.js +1 -1
  42. package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +1 -1
  43. package/docs/agent.md +1 -1
  44. package/docs/automations.md +23 -6
  45. package/docs/configuration.md +0 -1
  46. package/docs/mcp-servers.md +84 -1
  47. package/examples/automations/run-automation-worker.ts +8 -0
  48. package/examples/mcps/create-mcp.ts +1 -0
  49. package/examples/mcps/internal-mcp-admin.ts +43 -0
  50. package/examples/mcps/internal-mcp.ts +14 -3
  51. package/examples/mcps/update-mcp.ts +1 -1
  52. package/package.json +5 -1
@@ -0,0 +1,17 @@
1
+ import { BaseUseCase } from "../../../../common/base/base.use-case.js";
2
+ import { Scope } from "../../../../common/repositories/index.js";
3
+ import { McpServerRepository } from "../../repositories";
4
+ class GetInternalMcpByIdUseCase extends BaseUseCase {
5
+ constructor(mcpServerRepository = new McpServerRepository()) {
6
+ super();
7
+ this.mcpServerRepository = mcpServerRepository;
8
+ }
9
+ mcpServerRepository;
10
+ async execute(params) {
11
+ const { id, currentUser } = params;
12
+ return await this.mcpServerRepository.findInternalById(id, params.scope ?? Scope.asAdmin(currentUser));
13
+ }
14
+ }
15
+ export {
16
+ GetInternalMcpByIdUseCase
17
+ };
@@ -0,0 +1,16 @@
1
+ import { QueryOptions } from '../../../../common/repositories/index.js';
2
+ import { BaseUseCase, BaseUseCaseParams } from '../../../../common/base/base.use-case.js';
3
+ import { McpServerProps } from '../../entities';
4
+ import { McpServerRepository } from '../../repositories';
5
+ export interface Params extends BaseUseCaseParams {
6
+ options?: QueryOptions;
7
+ }
8
+ export interface Output {
9
+ items: McpServerProps[];
10
+ hasMore: boolean;
11
+ }
12
+ export declare class ListInternalMcpsUseCase extends BaseUseCase<Params, Output> {
13
+ private readonly mcpServerRepository;
14
+ constructor(mcpServerRepository?: McpServerRepository);
15
+ execute(params: Params): Promise<Output>;
16
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var list_internal_mcps_use_case_exports = {};
20
+ __export(list_internal_mcps_use_case_exports, {
21
+ ListInternalMcpsUseCase: () => ListInternalMcpsUseCase
22
+ });
23
+ module.exports = __toCommonJS(list_internal_mcps_use_case_exports);
24
+ var import_base = require("../../../../common/base/base.use-case.js");
25
+ var import_repositories2 = require("../../../../common/repositories/index.js");
26
+ var import_repositories3 = require("../../repositories");
27
+ class ListInternalMcpsUseCase extends import_base.BaseUseCase {
28
+ constructor(mcpServerRepository = new import_repositories3.McpServerRepository()) {
29
+ super();
30
+ this.mcpServerRepository = mcpServerRepository;
31
+ }
32
+ mcpServerRepository;
33
+ async execute(params) {
34
+ const { options, currentUser } = params;
35
+ const { page = 1, limit = 10 } = options || {};
36
+ return await this.mcpServerRepository.findInternalPage(params.scope ?? import_repositories2.Scope.asAdmin(currentUser), { page, limit, sortBy: { updatedAt: -1 } });
37
+ }
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ ListInternalMcpsUseCase
42
+ });
@@ -0,0 +1,18 @@
1
+ import { BaseUseCase } from "../../../../common/base/base.use-case.js";
2
+ import { Scope } from "../../../../common/repositories/index.js";
3
+ import { McpServerRepository } from "../../repositories";
4
+ class ListInternalMcpsUseCase extends BaseUseCase {
5
+ constructor(mcpServerRepository = new McpServerRepository()) {
6
+ super();
7
+ this.mcpServerRepository = mcpServerRepository;
8
+ }
9
+ mcpServerRepository;
10
+ async execute(params) {
11
+ const { options, currentUser } = params;
12
+ const { page = 1, limit = 10 } = options || {};
13
+ return await this.mcpServerRepository.findInternalPage(params.scope ?? Scope.asAdmin(currentUser), { page, limit, sortBy: { updatedAt: -1 } });
14
+ }
15
+ }
16
+ export {
17
+ ListInternalMcpsUseCase
18
+ };
@@ -0,0 +1,13 @@
1
+ import { BaseUseCase, BaseUseCaseParams } from '../../../../common/base/base.use-case.js';
2
+ import { McpServerProps } from '../../entities';
3
+ import { McpServerRepository } from '../../repositories';
4
+ export interface Params extends BaseUseCaseParams {
5
+ id: string;
6
+ payload?: Pick<McpServerProps, 'name' | 'url' | 'headers' | 'enabled' | 'environment' | 'autonomousToken' | '__v'>;
7
+ }
8
+ export type Output = McpServerProps;
9
+ export declare class UpdateInternalMcpUseCase extends BaseUseCase<Params, Output> {
10
+ private readonly mcpServerRepository;
11
+ constructor(mcpServerRepository?: McpServerRepository);
12
+ execute(params: Params): Promise<Output>;
13
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var update_internal_mcp_use_case_exports = {};
20
+ __export(update_internal_mcp_use_case_exports, {
21
+ UpdateInternalMcpUseCase: () => UpdateInternalMcpUseCase
22
+ });
23
+ module.exports = __toCommonJS(update_internal_mcp_use_case_exports);
24
+ var import_base = require("../../../../common/base/base.use-case.js");
25
+ var import_repositories = require("../../../../common/repositories/index.js");
26
+ var import_mongo_db = require("../../../../common/repositories/mongo-db.repository.js");
27
+ var import_entities = require("../../entities");
28
+ var import_repositories2 = require("../../repositories");
29
+ class UpdateInternalMcpUseCase extends import_base.BaseUseCase {
30
+ constructor(mcpServerRepository = new import_repositories2.McpServerRepository()) {
31
+ super();
32
+ this.mcpServerRepository = mcpServerRepository;
33
+ }
34
+ mcpServerRepository;
35
+ async execute(params) {
36
+ const { id, payload, currentUser } = params;
37
+ const scope = params.scope ?? import_repositories.Scope.asAdmin(currentUser);
38
+ if (!payload || Object.keys(payload).length === 0) this.throwHttpError({ statusCode: 400, errorMessage: "Payload is required for updating an internal MCP" });
39
+ const existing = await this.mcpServerRepository.findInternalById(id, scope);
40
+ if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
41
+ if (payload.__v !== void 0 && payload.__v !== existing.__v) throw new import_mongo_db.VersionConflictError();
42
+ if (payload.name !== void 0 && payload.name !== existing.name) {
43
+ if (!payload.name) this.throwHttpError({ statusCode: 400, errorMessage: "An internal MCP needs a name and a url" });
44
+ if (await this.mcpServerRepository.findInternalByName(payload.name, scope)) {
45
+ this.throwHttpError({ statusCode: 409, errorMessage: `There is already an internal MCP named "${payload.name}"` });
46
+ }
47
+ }
48
+ if (payload.url !== void 0 && !payload.url) this.throwHttpError({ statusCode: 400, errorMessage: "An internal MCP needs a name and a url" });
49
+ const { name, url, headers, enabled, environment, autonomousToken } = payload;
50
+ const mcpServer = import_entities.McpServer.fromJSON({ ...existing, ...name !== void 0 && { name }, ...url !== void 0 && { url }, ...headers !== void 0 && { headers }, ...enabled !== void 0 && { enabled }, ...environment !== void 0 && { environment }, ...autonomousToken !== void 0 && { autonomousToken }, _id: id, internal: true });
51
+ const result = await this.mcpServerRepository.update(mcpServer, scope, { expectedVersion: existing.__v });
52
+ if (!result) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
53
+ return result;
54
+ }
55
+ }
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ UpdateInternalMcpUseCase
59
+ });
@@ -0,0 +1,35 @@
1
+ import { BaseUseCase } from "../../../../common/base/base.use-case.js";
2
+ import { Scope } from "../../../../common/repositories/index.js";
3
+ import { VersionConflictError } from "../../../../common/repositories/mongo-db.repository.js";
4
+ import { McpServer } from "../../entities";
5
+ import { McpServerRepository } from "../../repositories";
6
+ class UpdateInternalMcpUseCase extends BaseUseCase {
7
+ constructor(mcpServerRepository = new McpServerRepository()) {
8
+ super();
9
+ this.mcpServerRepository = mcpServerRepository;
10
+ }
11
+ mcpServerRepository;
12
+ async execute(params) {
13
+ const { id, payload, currentUser } = params;
14
+ const scope = params.scope ?? Scope.asAdmin(currentUser);
15
+ if (!payload || Object.keys(payload).length === 0) this.throwHttpError({ statusCode: 400, errorMessage: "Payload is required for updating an internal MCP" });
16
+ const existing = await this.mcpServerRepository.findInternalById(id, scope);
17
+ if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
18
+ if (payload.__v !== void 0 && payload.__v !== existing.__v) throw new VersionConflictError();
19
+ if (payload.name !== void 0 && payload.name !== existing.name) {
20
+ if (!payload.name) this.throwHttpError({ statusCode: 400, errorMessage: "An internal MCP needs a name and a url" });
21
+ if (await this.mcpServerRepository.findInternalByName(payload.name, scope)) {
22
+ this.throwHttpError({ statusCode: 409, errorMessage: `There is already an internal MCP named "${payload.name}"` });
23
+ }
24
+ }
25
+ if (payload.url !== void 0 && !payload.url) this.throwHttpError({ statusCode: 400, errorMessage: "An internal MCP needs a name and a url" });
26
+ const { name, url, headers, enabled, environment, autonomousToken } = payload;
27
+ const mcpServer = McpServer.fromJSON({ ...existing, ...name !== void 0 && { name }, ...url !== void 0 && { url }, ...headers !== void 0 && { headers }, ...enabled !== void 0 && { enabled }, ...environment !== void 0 && { environment }, ...autonomousToken !== void 0 && { autonomousToken }, _id: id, internal: true });
28
+ const result = await this.mcpServerRepository.update(mcpServer, scope, { expectedVersion: existing.__v });
29
+ if (!result) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
30
+ return result;
31
+ }
32
+ }
33
+ export {
34
+ UpdateInternalMcpUseCase
35
+ };
@@ -14,6 +14,10 @@ export interface McpServerProps extends BaseEntityProps {
14
14
  history?: McpManifest[];
15
15
  status?: McpStatus;
16
16
  lastError?: string | null;
17
+ internal?: boolean;
18
+ enabled?: boolean;
19
+ environment?: string;
20
+ autonomousToken?: string;
17
21
  }
18
22
  export declare class McpServer extends BaseEntity {
19
23
  private readonly props;
@@ -26,14 +30,19 @@ export declare class McpServer extends BaseEntity {
26
30
  history?: McpManifest[] | undefined;
27
31
  status?: McpStatus | undefined;
28
32
  lastError?: string | null | undefined;
33
+ internal?: boolean | undefined;
34
+ enabled?: boolean | undefined;
35
+ environment?: string | undefined;
36
+ autonomousToken?: string | undefined;
29
37
  mcpClient?: Client;
30
38
  static fromJSON(props: McpServerProps): McpServer;
31
- constructor(props: McpServerProps, name?: string | undefined, url?: string | undefined, type?: McpType | undefined, headers?: Record<string, string> | undefined, trust?: McpTrust | undefined, approvedHash?: string | null | undefined, history?: McpManifest[] | undefined, status?: McpStatus | undefined, lastError?: string | null | undefined);
39
+ constructor(props: McpServerProps, name?: string | undefined, url?: string | undefined, type?: McpType | undefined, headers?: Record<string, string> | undefined, trust?: McpTrust | undefined, approvedHash?: string | null | undefined, history?: McpManifest[] | undefined, status?: McpStatus | undefined, lastError?: string | null | undefined, internal?: boolean | undefined, enabled?: boolean | undefined, environment?: string | undefined, autonomousToken?: string | undefined);
32
40
  toJSON(): McpServerProps;
33
41
  get latest(): McpManifest | undefined;
34
42
  get approved(): McpManifest | undefined;
35
43
  diffAgainst(manifest: McpManifest): McpManifestDiff;
36
44
  initialize(): this;
45
+ initializeInternal(): this;
37
46
  lockForNewEndpoint(): this;
38
47
  approve(hash: string): this;
39
48
  block(): this;
@@ -30,7 +30,7 @@ __reExport(mcpserver_entity_exports, require("./mcp-manifest"), module.exports);
30
30
  const MAX_HISTORY = 5;
31
31
  const MAX_ERROR_CHARS = 300;
32
32
  class McpServer extends import_base.BaseEntity {
33
- constructor(props, name, url, type, headers, trust, approvedHash, history, status, lastError) {
33
+ constructor(props, name, url, type, headers, trust, approvedHash, history, status, lastError, internal, enabled, environment, autonomousToken) {
34
34
  super(props);
35
35
  this.props = props;
36
36
  this.name = name;
@@ -42,6 +42,10 @@ class McpServer extends import_base.BaseEntity {
42
42
  this.history = history;
43
43
  this.status = status;
44
44
  this.lastError = lastError;
45
+ this.internal = internal;
46
+ this.enabled = enabled;
47
+ this.environment = environment;
48
+ this.autonomousToken = autonomousToken;
45
49
  }
46
50
  props;
47
51
  name;
@@ -53,6 +57,10 @@ class McpServer extends import_base.BaseEntity {
53
57
  history;
54
58
  status;
55
59
  lastError;
60
+ internal;
61
+ enabled;
62
+ environment;
63
+ autonomousToken;
56
64
  mcpClient;
57
65
  static fromJSON(props) {
58
66
  return new McpServer(
@@ -65,7 +73,11 @@ class McpServer extends import_base.BaseEntity {
65
73
  props.approvedHash,
66
74
  props.history,
67
75
  props.status || void 0,
68
- props.lastError
76
+ props.lastError,
77
+ props.internal,
78
+ props.enabled,
79
+ props.environment,
80
+ props.autonomousToken
69
81
  );
70
82
  }
71
83
  toJSON() {
@@ -79,7 +91,11 @@ class McpServer extends import_base.BaseEntity {
79
91
  approvedHash: this.approvedHash,
80
92
  history: this.history,
81
93
  status: this.status,
82
- lastError: this.lastError
94
+ lastError: this.lastError,
95
+ internal: this.internal,
96
+ enabled: this.enabled,
97
+ environment: this.environment,
98
+ autonomousToken: this.autonomousToken
83
99
  };
84
100
  }
85
101
  get latest() {
@@ -97,6 +113,15 @@ class McpServer extends import_base.BaseEntity {
97
113
  this.history = [];
98
114
  this.status = "unknown";
99
115
  this.lastError = null;
116
+ this.internal = void 0;
117
+ this.enabled = void 0;
118
+ this.autonomousToken = void 0;
119
+ return this;
120
+ }
121
+ initializeInternal() {
122
+ this.internal = true;
123
+ this.enabled = this.enabled ?? true;
124
+ this.type = this.type ?? "http";
100
125
  return this;
101
126
  }
102
127
  lockForNewEndpoint() {
@@ -6,7 +6,7 @@ export * from "./mcp-manifest";
6
6
  const MAX_HISTORY = 5;
7
7
  const MAX_ERROR_CHARS = 300;
8
8
  class McpServer extends BaseEntity {
9
- constructor(props, name, url, type, headers, trust, approvedHash, history, status, lastError) {
9
+ constructor(props, name, url, type, headers, trust, approvedHash, history, status, lastError, internal, enabled, environment, autonomousToken) {
10
10
  super(props);
11
11
  this.props = props;
12
12
  this.name = name;
@@ -18,6 +18,10 @@ class McpServer extends BaseEntity {
18
18
  this.history = history;
19
19
  this.status = status;
20
20
  this.lastError = lastError;
21
+ this.internal = internal;
22
+ this.enabled = enabled;
23
+ this.environment = environment;
24
+ this.autonomousToken = autonomousToken;
21
25
  }
22
26
  props;
23
27
  name;
@@ -29,6 +33,10 @@ class McpServer extends BaseEntity {
29
33
  history;
30
34
  status;
31
35
  lastError;
36
+ internal;
37
+ enabled;
38
+ environment;
39
+ autonomousToken;
32
40
  mcpClient;
33
41
  static fromJSON(props) {
34
42
  return new McpServer(
@@ -41,7 +49,11 @@ class McpServer extends BaseEntity {
41
49
  props.approvedHash,
42
50
  props.history,
43
51
  props.status || void 0,
44
- props.lastError
52
+ props.lastError,
53
+ props.internal,
54
+ props.enabled,
55
+ props.environment,
56
+ props.autonomousToken
45
57
  );
46
58
  }
47
59
  toJSON() {
@@ -55,7 +67,11 @@ class McpServer extends BaseEntity {
55
67
  approvedHash: this.approvedHash,
56
68
  history: this.history,
57
69
  status: this.status,
58
- lastError: this.lastError
70
+ lastError: this.lastError,
71
+ internal: this.internal,
72
+ enabled: this.enabled,
73
+ environment: this.environment,
74
+ autonomousToken: this.autonomousToken
59
75
  };
60
76
  }
61
77
  get latest() {
@@ -73,6 +89,15 @@ class McpServer extends BaseEntity {
73
89
  this.history = [];
74
90
  this.status = "unknown";
75
91
  this.lastError = null;
92
+ this.internal = void 0;
93
+ this.enabled = void 0;
94
+ this.autonomousToken = void 0;
95
+ return this;
96
+ }
97
+ initializeInternal() {
98
+ this.internal = true;
99
+ this.enabled = this.enabled ?? true;
100
+ this.type = this.type ?? "http";
76
101
  return this;
77
102
  }
78
103
  lockForNewEndpoint() {
@@ -0,0 +1,7 @@
1
+ export interface StoredInternalMcp {
2
+ name: string;
3
+ url: string;
4
+ headers?: Record<string, string>;
5
+ autonomousToken?: string;
6
+ }
7
+ export declare function listActiveInternalMcps(): Promise<StoredInternalMcp[]>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var internal_exports = {};
20
+ __export(internal_exports, {
21
+ listActiveInternalMcps: () => listActiveInternalMcps
22
+ });
23
+ module.exports = __toCommonJS(internal_exports);
24
+ var import_repositories = require("./repositories");
25
+ async function listActiveInternalMcps() {
26
+ const items = await new import_repositories.McpServerRepository().findActiveInternals();
27
+ return items.flatMap((item) => item.name && item.url ? [{ name: item.name, url: item.url, ...item.headers ? { headers: item.headers } : {}, ...item.autonomousToken ? { autonomousToken: item.autonomousToken } : {} }] : []);
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ listActiveInternalMcps
32
+ });
@@ -0,0 +1,8 @@
1
+ import { McpServerRepository } from "./repositories";
2
+ async function listActiveInternalMcps() {
3
+ const items = await new McpServerRepository().findActiveInternals();
4
+ return items.flatMap((item) => item.name && item.url ? [{ name: item.name, url: item.url, ...item.headers ? { headers: item.headers } : {}, ...item.autonomousToken ? { autonomousToken: item.autonomousToken } : {} }] : []);
5
+ }
6
+ export {
7
+ listActiveInternalMcps
8
+ };
@@ -11,4 +11,12 @@ export declare class McpServerRepository {
11
11
  softDeleteById(id: string, scope: Scope): Promise<McpServerProps | null>;
12
12
  deleteById(id: string, scope: Scope): Promise<number>;
13
13
  findByProps(where: McpServerProps, scope: Scope, options?: QueryOptions): Promise<McpServerProps[]>;
14
+ findInternalById(id: string, scope: Scope): Promise<McpServerProps | null>;
15
+ findInternalByName(name: string, scope: Scope): Promise<McpServerProps | null>;
16
+ findInternalPage(scope: Scope, options: QueryOptions): Promise<{
17
+ items: McpServerProps[];
18
+ hasMore: boolean;
19
+ }>;
20
+ findActiveInternals(): Promise<McpServerProps[]>;
21
+ deleteInternalById(id: string, scope: Scope): Promise<number>;
14
22
  }
@@ -25,6 +25,7 @@ var import_mongodb = require("mongodb");
25
25
  var import_utils = require("../../../common/base/utils/index.js");
26
26
  var import_repositories = require("../../../common/repositories/index.js");
27
27
  var import_database_name = require("../../../common/utils/database-name.js");
28
+ const external = (where) => ({ ...where, internal: { $ne: true } });
28
29
  class McpServerRepository {
29
30
  _ = new import_repositories.MongoRepository({
30
31
  database: (0, import_database_name.getDatabaseName)(),
@@ -41,7 +42,7 @@ class McpServerRepository {
41
42
  return await this._.patchOne({ scope, where: { _id: mcpServer._id }, ...(0, import_utils.entityPatch)(mcpServer), expectedVersion: options?.expectedVersion });
42
43
  }
43
44
  async findById(id, scope) {
44
- return await this._.findOne({ scope, where: { _id: this._.parseId(id) } });
45
+ return await this._.findOne({ scope, where: external({ _id: this._.parseId(id) }) });
45
46
  }
46
47
  async findAllByOwner(ownerId, scope) {
47
48
  return await this._.findAll({
@@ -51,14 +52,33 @@ class McpServerRepository {
51
52
  });
52
53
  }
53
54
  async softDeleteById(id, scope) {
54
- return await this._.softDelete({ scope, where: { _id: this._.parseId(id) } });
55
+ return await this._.softDelete({ scope, where: external({ _id: this._.parseId(id) }) });
55
56
  }
56
57
  async deleteById(id, scope) {
57
- return await this._.deleteOne({ scope, where: { _id: this._.parseId(id) } });
58
+ return await this._.deleteOne({ scope, where: external({ _id: this._.parseId(id) }) });
58
59
  }
59
60
  async findByProps(where, scope, options) {
60
61
  return await this._.findMany({ scope, where, options });
61
62
  }
63
+ async findInternalById(id, scope) {
64
+ return await this._.findOne({ scope, where: { _id: this._.parseId(id), internal: true } });
65
+ }
66
+ async findInternalByName(name, scope) {
67
+ return await this._.findOne({ scope, where: { name, internal: true } });
68
+ }
69
+ async findInternalPage(scope, options) {
70
+ return await this._.findManyPaginated({ scope, where: { internal: true }, options });
71
+ }
72
+ async findActiveInternals() {
73
+ return await this._.findAll({
74
+ scope: import_repositories.Scope.system("Load the internal MCP servers of the solution"),
75
+ where: { internal: true, enabled: true },
76
+ options: { sortBy: { createdAt: 1, _id: 1 } }
77
+ });
78
+ }
79
+ async deleteInternalById(id, scope) {
80
+ return await this._.deleteOne({ scope, where: { _id: this._.parseId(id), internal: true } });
81
+ }
62
82
  }
63
83
  // Annotate the CommonJS export names for ESM import in node:
64
84
  0 && (module.exports = {
@@ -1,7 +1,8 @@
1
1
  import { ObjectId } from "mongodb";
2
2
  import { entityPatch } from "../../../common/base/utils/index.js";
3
- import { MongoRepository } from "../../../common/repositories/index.js";
3
+ import { MongoRepository, Scope } from "../../../common/repositories/index.js";
4
4
  import { getDatabaseName } from "../../../common/utils/database-name.js";
5
+ const external = (where) => ({ ...where, internal: { $ne: true } });
5
6
  class McpServerRepository {
6
7
  _ = new MongoRepository({
7
8
  database: getDatabaseName(),
@@ -18,7 +19,7 @@ class McpServerRepository {
18
19
  return await this._.patchOne({ scope, where: { _id: mcpServer._id }, ...entityPatch(mcpServer), expectedVersion: options?.expectedVersion });
19
20
  }
20
21
  async findById(id, scope) {
21
- return await this._.findOne({ scope, where: { _id: this._.parseId(id) } });
22
+ return await this._.findOne({ scope, where: external({ _id: this._.parseId(id) }) });
22
23
  }
23
24
  async findAllByOwner(ownerId, scope) {
24
25
  return await this._.findAll({
@@ -28,14 +29,33 @@ class McpServerRepository {
28
29
  });
29
30
  }
30
31
  async softDeleteById(id, scope) {
31
- return await this._.softDelete({ scope, where: { _id: this._.parseId(id) } });
32
+ return await this._.softDelete({ scope, where: external({ _id: this._.parseId(id) }) });
32
33
  }
33
34
  async deleteById(id, scope) {
34
- return await this._.deleteOne({ scope, where: { _id: this._.parseId(id) } });
35
+ return await this._.deleteOne({ scope, where: external({ _id: this._.parseId(id) }) });
35
36
  }
36
37
  async findByProps(where, scope, options) {
37
38
  return await this._.findMany({ scope, where, options });
38
39
  }
40
+ async findInternalById(id, scope) {
41
+ return await this._.findOne({ scope, where: { _id: this._.parseId(id), internal: true } });
42
+ }
43
+ async findInternalByName(name, scope) {
44
+ return await this._.findOne({ scope, where: { name, internal: true } });
45
+ }
46
+ async findInternalPage(scope, options) {
47
+ return await this._.findManyPaginated({ scope, where: { internal: true }, options });
48
+ }
49
+ async findActiveInternals() {
50
+ return await this._.findAll({
51
+ scope: Scope.system("Load the internal MCP servers of the solution"),
52
+ where: { internal: true, enabled: true },
53
+ options: { sortBy: { createdAt: 1, _id: 1 } }
54
+ });
55
+ }
56
+ async deleteInternalById(id, scope) {
57
+ return await this._.deleteOne({ scope, where: { _id: this._.parseId(id), internal: true } });
58
+ }
39
59
  }
40
60
  export {
41
61
  McpServerRepository
@@ -22,6 +22,7 @@ __export(list_mcpservers_by_user_use_case_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(list_mcpservers_by_user_use_case_exports);
24
24
  var import_mongodb = require("mongodb");
25
+ var import_repositories = require("../../../common/repositories/index.js");
25
26
  var import_base = require("../../../common/base/base.use-case.js");
26
27
  var import_repositories2 = require("../repositories");
27
28
  class ListMcpServersByUserUseCase extends import_base.BaseUseCase {
@@ -34,6 +35,7 @@ class ListMcpServersByUserUseCase extends import_base.BaseUseCase {
34
35
  const { options, currentUser } = params;
35
36
  const { page = 1, limit: pageSize = 10 } = options || {};
36
37
  const result = await this.mcpServerRepository._.findManyPaginated({
38
+ scope: params.scope ?? import_repositories.Scope.canView(currentUser),
37
39
  where: {
38
40
  ownerId: new import_mongodb.ObjectId(currentUser?.userId)
39
41
  },
@@ -1,4 +1,5 @@
1
1
  import { ObjectId } from "mongodb";
2
+ import { Scope } from "../../../common/repositories/index.js";
2
3
  import { BaseUseCase } from "../../../common/base/base.use-case.js";
3
4
  import { McpServerRepository } from "../repositories";
4
5
  class ListMcpServersByUserUseCase extends BaseUseCase {
@@ -11,6 +12,7 @@ class ListMcpServersByUserUseCase extends BaseUseCase {
11
12
  const { options, currentUser } = params;
12
13
  const { page = 1, limit: pageSize = 10 } = options || {};
13
14
  const result = await this.mcpServerRepository._.findManyPaginated({
15
+ scope: params.scope ?? Scope.canView(currentUser),
14
16
  where: {
15
17
  ownerId: new ObjectId(currentUser?.userId)
16
18
  },
@@ -48,7 +48,7 @@ class UpdateMcpServerUseCase extends import_base.BaseUseCase {
48
48
  }
49
49
  const endpointChanged = payload.url !== void 0 && payload.url !== existing.url || payload.type !== void 0 && payload.type !== existing.type;
50
50
  const headersChanged = payload.headers !== void 0 && JSON.stringify(payload.headers) !== JSON.stringify(existing.headers);
51
- const mcpServer = import_entities.McpServer.fromJSON({ ...existing, ...payload, _id: id, trust: existing.trust, approvedHash: existing.approvedHash, status: existing.status, lastError: existing.lastError, history: existing.history });
51
+ const mcpServer = import_entities.McpServer.fromJSON({ ...existing, ...payload, _id: id, trust: existing.trust, approvedHash: existing.approvedHash, status: existing.status, lastError: existing.lastError, history: existing.history, internal: existing.internal, enabled: existing.enabled, autonomousToken: existing.autonomousToken });
52
52
  if (endpointChanged) {
53
53
  mcpServer.lockForNewEndpoint();
54
54
  }
@@ -25,7 +25,7 @@ class UpdateMcpServerUseCase extends BaseUseCase {
25
25
  }
26
26
  const endpointChanged = payload.url !== void 0 && payload.url !== existing.url || payload.type !== void 0 && payload.type !== existing.type;
27
27
  const headersChanged = payload.headers !== void 0 && JSON.stringify(payload.headers) !== JSON.stringify(existing.headers);
28
- const mcpServer = McpServer.fromJSON({ ...existing, ...payload, _id: id, trust: existing.trust, approvedHash: existing.approvedHash, status: existing.status, lastError: existing.lastError, history: existing.history });
28
+ const mcpServer = McpServer.fromJSON({ ...existing, ...payload, _id: id, trust: existing.trust, approvedHash: existing.approvedHash, status: existing.status, lastError: existing.lastError, history: existing.history, internal: existing.internal, enabled: existing.enabled, autonomousToken: existing.autonomousToken });
29
29
  if (endpointChanged) {
30
30
  mcpServer.lockForNewEndpoint();
31
31
  }
package/docs/agent.md CHANGED
@@ -72,7 +72,7 @@ Omit `chatId` to start a brand-new chat. Pass an existing `chatId` to continue a
72
72
 
73
73
  `currentSession` is optional. It carries device, location and locale, which skills use to answer in the right time zone and language.
74
74
 
75
- `mcpTokens` is optional. It gives the token of the user to each [internal MCP server](mcp-servers.md#internal-mcp-servers), by name. It is never saved. `serviceToken` is the token that the runner of [automations](automations.md#internal-mcp-servers-in-a-automation) passes when there is no session of the user. You do not need it unless you write your own scheduler.
75
+ `mcpTokens` is optional. It gives the token of the user to each [internal MCP server](mcp-servers.md#internal-mcp-servers), by name. It is never saved. In an [autonomous run](#autonomous-mode) with no token for a server, the `autonomousToken` of that server is used, see [automations](automations.md#internal-mcp-servers-in-an-automation).
76
76
 
77
77
  ## Autonomous mode
78
78