@agentica/core 0.19.1 → 0.20.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 (43) hide show
  1. package/lib/context/AgenticaOperation.d.ts +3 -4
  2. package/lib/context/internal/AgenticaOperationComposer.js +8 -1
  3. package/lib/context/internal/AgenticaOperationComposer.js.map +1 -1
  4. package/lib/context/internal/AgenticaOperationComposer.spec.js +39 -10
  5. package/lib/context/internal/AgenticaOperationComposer.spec.js.map +1 -1
  6. package/lib/functional/assertHttpLlmApplication.js +168 -168
  7. package/lib/functional/assertMcpController.d.ts +24 -0
  8. package/lib/functional/assertMcpController.js +1701 -0
  9. package/lib/functional/assertMcpController.js.map +1 -0
  10. package/lib/functional/validateHttpLlmApplication.js +148 -148
  11. package/lib/index.d.ts +1 -1
  12. package/lib/index.js +1 -1
  13. package/lib/index.js.map +1 -1
  14. package/lib/index.mjs +1993 -402
  15. package/lib/index.mjs.map +1 -1
  16. package/lib/orchestrate/call.js +11 -1
  17. package/lib/orchestrate/call.js.map +1 -1
  18. package/lib/orchestrate/initialize.js +60 -60
  19. package/lib/structures/IAgenticaController.d.ts +8 -4
  20. package/lib/structures/mcp/index.d.ts +0 -2
  21. package/lib/structures/mcp/index.js +0 -2
  22. package/lib/structures/mcp/index.js.map +1 -1
  23. package/package.json +3 -3
  24. package/src/context/AgenticaOperation.ts +5 -6
  25. package/src/context/internal/AgenticaOperationComposer.spec.ts +45 -14
  26. package/src/context/internal/AgenticaOperationComposer.ts +10 -2
  27. package/src/functional/assertMcpController.ts +49 -0
  28. package/src/index.ts +1 -1
  29. package/src/orchestrate/call.ts +14 -4
  30. package/src/structures/IAgenticaController.ts +9 -4
  31. package/src/structures/mcp/index.ts +0 -2
  32. package/lib/functional/assertMcpLlmApplication.d.ts +0 -18
  33. package/lib/functional/assertMcpLlmApplication.js +0 -74
  34. package/lib/functional/assertMcpLlmApplication.js.map +0 -1
  35. package/lib/structures/mcp/IMcpLlmApplication.d.ts +0 -9
  36. package/lib/structures/mcp/IMcpLlmApplication.js +0 -3
  37. package/lib/structures/mcp/IMcpLlmApplication.js.map +0 -1
  38. package/lib/structures/mcp/IMcpLlmFunction.d.ts +0 -17
  39. package/lib/structures/mcp/IMcpLlmFunction.js +0 -3
  40. package/lib/structures/mcp/IMcpLlmFunction.js.map +0 -1
  41. package/src/functional/assertMcpLlmApplication.ts +0 -32
  42. package/src/structures/mcp/IMcpLlmApplication.ts +0 -10
  43. package/src/structures/mcp/IMcpLlmFunction.ts +0 -19
@@ -85,9 +85,6 @@ const FUNCTION = {
85
85
  title: "Type schema info of the ChatGPT",
86
86
  description: "Type schema info of the ChatGPT.\n\n`IChatGptSchema` is a type schema info of the ChatGPT function calling.\n\n`IChatGptSchema` basically follows the JSON schema definition of the OpenAPI v3.1\nspeciifcation; {@link OpenApiV3_1.IJsonSchema}.\n\nHowever, the `IChatGptSchema` does not follow the entire specification of\nthe OpenAPI v3.1. It has own specific restrictions and definitions. Here is the\nlist of how `IChatGptSchema` is different with the OpenAPI v3.1 JSON schema.\n\n- Decompose mixed type: {@link OpenApiV3_1.IJsonSchema.IMixed}\n- Resolve nullable property: {@link OpenApiV3_1.IJsonSchema.__ISignificant.nullable}\n- Tuple type is banned: {@link OpenApiV3_1.IJsonSchema.ITuple.prefixItems}\n- Constant type is banned: {@link OpenApiV3_1.IJsonSchema.IConstant}\n- Merge {@link OpenApiV3_1.IJsonSchema.IOneOf} to {@link IChatGptSchema.IAnOf}\n- Merge {@link OpenApiV3_1.IJsonSchema.IAllOf} to {@link IChatGptSchema.IObject}\n- Merge {@link OpenApiV3_1.IJsonSchema.IRecursiveReference} to {@link IChatGptSchema.IReference}\n- When {@link IChatGptSchema.IConfig.strict} mode\n - Every object properties must be required\n - Do not allow {@link IChatGptSchema.IObject.additionalProperties}\n\nIf compare with the {@link OpenApi.IJsonSchema}, the emended JSON schema specification,\n\n- {@link IChatGptSchema.IAnyOf} instead of the {@link OpenApi.IJsonSchema.IOneOf}\n- {@link IChatGptSchema.IParameters.$defs} instead of the {@link OpenApi.IJsonSchema.IComponents.schemas}\n- {@link IChatGptSchema.IString.enum} instead of the {@link OpenApi.IJsonSchema.IConstant}\n- {@link IChatGptSchema.additionalProperties} is fixed to `false`\n- No tuple type {@link OpenApi.IJsonSchema.ITuple} support\n- When {@link IChatGptSchema.IConfig.strict} mode\n - Every object properties must be required\n - Do not allow {@link IChatGptSchema.IObject.additionalProperties}\n\nFor reference, if you've composed the `IChatGptSchema` type with the\n{@link IChatGptSchema.IConfig.reference} `false` option (default is `false`),\nonly the recursived named types would be archived into the\n{@link IChatGptSchema.IParameters.$defs}, and the others would be ecaped from the\n{@link IChatGptSchema.IReference} type.\n\nAlso, OpenAI has banned below constraint properties. Instead, `IChatGptSchema`\nfills the {@link IChatGptSchema.__IAttribute.description} property with\nthe comment text like `\"@format uuid\"`.\n\n- {@link OpenApi.IJsonSchema.INumber.minimum}\n- {@link OpenApi.IJsonSchema.INumber.maximum}\n- {@link OpenApi.IJsonSchema.INumber.multipleOf}\n- {@link OpenApi.IJsonSchema.IString.minLength}\n- {@link OpenApi.IJsonSchema.IString.maxLength}\n- {@link OpenApi.IJsonSchema.IString.format}\n- {@link OpenApi.IJsonSchema.IString.pattern}\n- {@link OpenApi.IJsonSchema.IString.contentMediaType}\n- {@link OpenApi.IJsonSchema.IString.default}\n- {@link OpenApi.IJsonSchema.IArray.minItems}\n- {@link OpenApi.IJsonSchema.IArray.maxItems}\n- {@link OpenApi.IJsonSchema.IArray.unique}\n\nAdditionally, OpenAI cannot define the `description` property to the\n{@link IChatGptSchema.IReference} type, and even does not understand\nthe capsulization to the {@link IChatGptSchema.IAnyOf} type.\nTherefore, the `description` is written to the parent object type,\nnot the reference type.\n\n```json\n{\n \"type\": \"object\",\n \"description\": \"### Description of {@link something} property.\\n\\n> Hello?\",\n \"properties\": {\n \"something\": {\n \"$ref\": \"#/$defs/SomeObject\"\n }\n }\n}\n```",
87
87
  anyOf: [
88
- {
89
- $ref: "#/$defs/IChatGptSchema.IObject"
90
- },
91
88
  {
92
89
  type: "object",
93
90
  properties: {
@@ -295,6 +292,9 @@ const FUNCTION = {
295
292
  {
296
293
  $ref: "#/$defs/IChatGptSchema.IArray"
297
294
  },
295
+ {
296
+ $ref: "#/$defs/IChatGptSchema.IObject"
297
+ },
298
298
  {
299
299
  type: "object",
300
300
  properties: {
@@ -416,6 +416,54 @@ const FUNCTION = {
416
416
  }
417
417
  ]
418
418
  },
419
+ "IChatGptSchema.IArray": {
420
+ description: "Array type info.\n\n### Description of {@link items} property:\n\n> Items type info.\n> \n> The `items` means the type of the array elements. In other words, it is\n> the type schema info of the `T` in the TypeScript array type `Array<T>`.",
421
+ type: "object",
422
+ properties: {
423
+ items: {
424
+ title: "Items type info",
425
+ $ref: "#/$defs/IChatGptSchema"
426
+ },
427
+ type: {
428
+ title: "Discriminator value of the type",
429
+ description: "Discriminator value of the type.",
430
+ type: "string",
431
+ "enum": [
432
+ "array"
433
+ ]
434
+ },
435
+ title: {
436
+ title: "Title of the schema",
437
+ description: "Title of the schema.",
438
+ type: "string"
439
+ },
440
+ description: {
441
+ title: "Detailed description of the schema",
442
+ description: "Detailed description of the schema.",
443
+ type: "string"
444
+ },
445
+ deprecated: {
446
+ title: "Whether the type is deprecated or not",
447
+ description: "Whether the type is deprecated or not.",
448
+ type: "boolean"
449
+ },
450
+ example: {
451
+ title: "Example value",
452
+ description: "Example value."
453
+ },
454
+ examples: {
455
+ description: "List of example values as key-value pairs.\n\n------------------------------\n\nDescription of the current {@link Recordstringany} type:\n\n> Construct a type with a set of properties K of type T",
456
+ type: "object",
457
+ properties: {},
458
+ required: [],
459
+ additionalProperties: {}
460
+ }
461
+ },
462
+ required: [
463
+ "items",
464
+ "type"
465
+ ]
466
+ },
419
467
  "IChatGptSchema.IObject": {
420
468
  description: "Object type info.\n\n### Description of {@link properties} property:\n\n> Properties of the object.\n> \n> The `properties` means a list of key-value pairs of the object's\n> regular properties. The key is the name of the regular property,\n> and the value is the type schema info.",
421
469
  type: "object",
@@ -431,9 +479,6 @@ const FUNCTION = {
431
479
  {
432
480
  type: "boolean"
433
481
  },
434
- {
435
- $ref: "#/$defs/IChatGptSchema.IObject"
436
- },
437
482
  {
438
483
  type: "object",
439
484
  properties: {
@@ -641,6 +686,9 @@ const FUNCTION = {
641
686
  {
642
687
  $ref: "#/$defs/IChatGptSchema.IArray"
643
688
  },
689
+ {
690
+ $ref: "#/$defs/IChatGptSchema.IObject"
691
+ },
644
692
  {
645
693
  type: "object",
646
694
  properties: {
@@ -811,54 +859,6 @@ const FUNCTION = {
811
859
  "type"
812
860
  ]
813
861
  },
814
- "IChatGptSchema.IArray": {
815
- description: "Array type info.\n\n### Description of {@link items} property:\n\n> Items type info.\n> \n> The `items` means the type of the array elements. In other words, it is\n> the type schema info of the `T` in the TypeScript array type `Array<T>`.",
816
- type: "object",
817
- properties: {
818
- items: {
819
- title: "Items type info",
820
- $ref: "#/$defs/IChatGptSchema"
821
- },
822
- type: {
823
- title: "Discriminator value of the type",
824
- description: "Discriminator value of the type.",
825
- type: "string",
826
- "enum": [
827
- "array"
828
- ]
829
- },
830
- title: {
831
- title: "Title of the schema",
832
- description: "Title of the schema.",
833
- type: "string"
834
- },
835
- description: {
836
- title: "Detailed description of the schema",
837
- description: "Detailed description of the schema.",
838
- type: "string"
839
- },
840
- deprecated: {
841
- title: "Whether the type is deprecated or not",
842
- description: "Whether the type is deprecated or not.",
843
- type: "boolean"
844
- },
845
- example: {
846
- title: "Example value",
847
- description: "Example value."
848
- },
849
- examples: {
850
- description: "List of example values as key-value pairs.\n\n------------------------------\n\nDescription of the current {@link Recordstringany} type:\n\n> Construct a type with a set of properties K of type T",
851
- type: "object",
852
- properties: {},
853
- required: [],
854
- additionalProperties: {}
855
- }
856
- },
857
- required: [
858
- "items",
859
- "type"
860
- ]
861
- },
862
862
  "IChatGptSchema.IAnyOf": {
863
863
  description: "Union type.\n\nIOneOf` represents an union type of the TypeScript (`A | B | C`).\n\nFor reference, even though your Swagger (or OpenAPI) document has\ndefined `anyOf` instead of the `oneOf`, {@link IChatGptSchema} forcibly\nconverts it to `oneOf` type.",
864
864
  type: "object",
@@ -869,9 +869,6 @@ const FUNCTION = {
869
869
  type: "array",
870
870
  items: {
871
871
  anyOf: [
872
- {
873
- $ref: "#/$defs/IChatGptSchema.IObject"
874
- },
875
872
  {
876
873
  type: "object",
877
874
  properties: {
@@ -1079,6 +1076,9 @@ const FUNCTION = {
1079
1076
  {
1080
1077
  $ref: "#/$defs/IChatGptSchema.IArray"
1081
1078
  },
1079
+ {
1080
+ $ref: "#/$defs/IChatGptSchema.IObject"
1081
+ },
1082
1082
  {
1083
1083
  type: "object",
1084
1084
  properties: {
@@ -1495,9 +1495,6 @@ const FUNCTION = {
1495
1495
  title: "Expected return type",
1496
1496
  description: "Expected return type.\n\nIf the target operation returns nothing (`void`), the `output`\nwould be `undefined`.",
1497
1497
  anyOf: [
1498
- {
1499
- $ref: "#/$defs/IChatGptSchema.IObject"
1500
- },
1501
1498
  {
1502
1499
  type: "object",
1503
1500
  properties: {
@@ -1705,6 +1702,9 @@ const FUNCTION = {
1705
1702
  {
1706
1703
  $ref: "#/$defs/IChatGptSchema.IArray"
1707
1704
  },
1705
+ {
1706
+ $ref: "#/$defs/IChatGptSchema.IObject"
1707
+ },
1708
1708
  {
1709
1709
  type: "object",
1710
1710
  properties: {
@@ -1,5 +1,5 @@
1
- import type { IHttpConnection, IHttpLlmApplication, IHttpLlmFunction, IHttpResponse, ILlmApplication, ILlmFunction, ILlmSchema } from "@samchon/openapi";
2
- import type { IMcpLlmApplication } from "./mcp/IMcpLlmApplication";
1
+ import type { Client } from "@modelcontextprotocol/sdk/client/index.d.ts";
2
+ import type { IHttpConnection, IHttpLlmApplication, IHttpLlmFunction, IHttpResponse, ILlmApplication, ILlmFunction, ILlmSchema, IMcpLlmApplication } from "@samchon/openapi";
3
3
  /**
4
4
  * Controller of the Agentica Agent.
5
5
  *
@@ -16,7 +16,7 @@ import type { IMcpLlmApplication } from "./mcp/IMcpLlmApplication";
16
16
  *
17
17
  * @author Samchon
18
18
  */
19
- export type IAgenticaController<Model extends ILlmSchema.Model> = IAgenticaController.IHttp<Model> | IAgenticaController.IClass<Model> | IAgenticaController.IMcp;
19
+ export type IAgenticaController<Model extends ILlmSchema.Model> = IAgenticaController.IHttp<Model> | IAgenticaController.IClass<Model> | IAgenticaController.IMcp<Model>;
20
20
  export declare namespace IAgenticaController {
21
21
  /**
22
22
  * HTTP controller.
@@ -96,7 +96,11 @@ export declare namespace IAgenticaController {
96
96
  /**
97
97
  * MCP Server controller.
98
98
  */
99
- export interface IMcp extends IBase<"mcp", IMcpLlmApplication> {
99
+ export interface IMcp<Model extends ILlmSchema.Model> extends IBase<"mcp", IMcpLlmApplication<Model>> {
100
+ /**
101
+ * MCP client for connection.
102
+ */
103
+ client: Client;
100
104
  }
101
105
  interface IBase<Protocol, Application> {
102
106
  /**
@@ -1,3 +1 @@
1
- export * from "./IMcpLlmApplication";
2
- export * from "./IMcpLlmFunction";
3
1
  export * from "./IMcpLlmTransportProps";
@@ -14,7 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./IMcpLlmApplication"), exports);
18
- __exportStar(require("./IMcpLlmFunction"), exports);
19
17
  __exportStar(require("./IMcpLlmTransportProps"), exports);
20
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structures/mcp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,oDAAkC;AAClC,0DAAwC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structures/mcp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentica/core",
3
- "version": "0.19.1",
3
+ "version": "0.20.0",
4
4
  "description": "Agentic AI Library specialized in LLM Function Calling",
5
5
  "author": "Wrtn Technologies",
6
6
  "license": "MIT",
@@ -37,12 +37,12 @@
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@modelcontextprotocol/sdk": "^1.9.0",
40
- "@samchon/openapi": "^4.0.0",
40
+ "@samchon/openapi": "^4.2.0",
41
41
  "openai": "^4.80.0",
42
42
  "typia": "^9.0.1"
43
43
  },
44
44
  "dependencies": {
45
- "@samchon/openapi": "^4.0.0",
45
+ "@samchon/openapi": "^4.2.0",
46
46
  "typia": "^9.0.1",
47
47
  "uuid": "^11.0.4"
48
48
  },
@@ -1,8 +1,7 @@
1
- import type { IHttpLlmFunction, ILlmFunction, ILlmSchema } from "@samchon/openapi";
1
+ import type { IHttpLlmFunction, ILlmFunction, ILlmSchema, IMcpLlmFunction } from "@samchon/openapi";
2
2
 
3
3
  import type { IAgenticaOperationJson } from "../json/IAgenticaOperationJson";
4
4
  import type { IAgenticaController } from "../structures/IAgenticaController";
5
- import type { IMcpLlmFunction } from "../structures/mcp/IMcpLlmFunction";
6
5
 
7
6
  /**
8
7
  * Operation information in the Agentica Agent.
@@ -22,7 +21,7 @@ import type { IMcpLlmFunction } from "../structures/mcp/IMcpLlmFunction";
22
21
  export type AgenticaOperation<Model extends ILlmSchema.Model> =
23
22
  | AgenticaOperation.Class<Model>
24
23
  | AgenticaOperation.Http<Model>
25
- | AgenticaOperation.Mcp;
24
+ | AgenticaOperation.Mcp<Model>;
26
25
  export namespace AgenticaOperation {
27
26
  export type Class<Model extends ILlmSchema.Model> = Base<
28
27
  "class",
@@ -34,10 +33,10 @@ export namespace AgenticaOperation {
34
33
  IAgenticaController.IHttp<Model>,
35
34
  IHttpLlmFunction<Model>
36
35
  >;
37
- export type Mcp = Base<
36
+ export type Mcp<Model extends ILlmSchema.Model> = Base<
38
37
  "mcp",
39
- IAgenticaController.IMcp,
40
- IMcpLlmFunction
38
+ IAgenticaController.IMcp<Model>,
39
+ IMcpLlmFunction<Model>
41
40
  >;
42
41
 
43
42
  interface Base<
@@ -1,13 +1,12 @@
1
- import type { IHttpLlmFunction, ILlmFunction, IValidation } from "@samchon/openapi";
1
+ import type { IChatGptSchema, IHttpLlmFunction, ILlmFunction, IMcpLlmFunction, IValidation } from "@samchon/openapi";
2
2
 
3
3
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
4
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
5
5
 
6
6
  import type { IAgenticaConfig } from "../../structures/IAgenticaConfig";
7
7
  import type { IAgenticaController } from "../../structures/IAgenticaController";
8
- import type { IMcpLlmFunction } from "../../structures/mcp/IMcpLlmFunction";
9
8
 
10
- import { assertMcpLlmApplication } from "../../functional/assertMcpLlmApplication";
9
+ import { assertMcpController } from "../../functional/assertMcpController";
11
10
 
12
11
  import { compose, divide, getOperations, toClassOperations, toHttpOperations, toMcpOperations } from "./AgenticaOperationComposer";
13
12
 
@@ -70,16 +69,18 @@ function createMockClassController(name: string, functions: ILlmFunction<any>[])
70
69
  };
71
70
  }
72
71
 
73
- async function createMockMcpController(name: string, functions: IMcpLlmFunction[]): Promise<IAgenticaController.IMcp> {
74
- return {
72
+ async function createMockMcpController(name: string, functions: IMcpLlmFunction<"chatgpt">[]): Promise<IAgenticaController.IMcp<"chatgpt">> {
73
+ const controller = await assertMcpController({
74
+ model: "chatgpt",
75
75
  name,
76
- protocol: "mcp",
77
- application: await assertMcpLlmApplication({
78
- client,
79
- }).then(v => ({
80
- ...v,
76
+ client,
77
+ });
78
+ return {
79
+ ...controller,
80
+ application: {
81
+ ...controller.application,
81
82
  functions,
82
- })),
83
+ },
83
84
  };
84
85
  }
85
86
 
@@ -110,7 +111,17 @@ describe("a AgenticaOperationComposer", () => {
110
111
  const mockMcpController = await createMockMcpController("mcpController", [
111
112
  {
112
113
  name: "function4",
113
- parameters: {},
114
+ parameters: {
115
+ type: "object",
116
+ properties: {},
117
+ additionalProperties: false,
118
+ required: [],
119
+ $defs: {},
120
+ } satisfies IChatGptSchema.IParameters,
121
+ validate: (data: unknown) => ({
122
+ success: true,
123
+ data,
124
+ }),
114
125
  },
115
126
  ]);
116
127
 
@@ -182,7 +193,17 @@ describe("a AgenticaOperationComposer", () => {
182
193
  const mockController = await createMockMcpController("mcpController", [
183
194
  {
184
195
  name: "function1",
185
- parameters: {},
196
+ parameters: {
197
+ type: "object",
198
+ properties: {},
199
+ additionalProperties: false,
200
+ required: [],
201
+ $defs: {},
202
+ },
203
+ validate: (data: unknown) => ({
204
+ success: true,
205
+ data,
206
+ }),
186
207
  },
187
208
  ]);
188
209
 
@@ -245,7 +266,17 @@ describe("a AgenticaOperationComposer", () => {
245
266
  const mockController = await createMockMcpController("mcpController", [
246
267
  {
247
268
  name: "function1",
248
- parameters: {},
269
+ parameters: {
270
+ type: "object",
271
+ properties: {},
272
+ additionalProperties: false,
273
+ required: [],
274
+ $defs: {},
275
+ },
276
+ validate: (data: unknown) => ({
277
+ success: true,
278
+ data,
279
+ }),
249
280
  },
250
281
  ]);
251
282
 
@@ -21,7 +21,10 @@ export function compose<Model extends ILlmSchema.Model>(props: {
21
21
  config?: IAgenticaConfig<Model> | IMicroAgenticaConfig<Model> | undefined;
22
22
  }): AgenticaOperationCollection<Model> {
23
23
  const unique: boolean = (props.controllers.length === 1 || (() => {
24
- const names = props.controllers.map(controllers => controllers.application.functions.map(func => func.name)).flat();
24
+ const names = props.controllers.map(
25
+ // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-call, ts/no-unsafe-member-access
26
+ controllers => controllers.application.functions.map((func: { name: string }) => func.name),
27
+ ).flat();
25
28
  return new Set(names).size === names.length;
26
29
  })());
27
30
 
@@ -126,19 +129,24 @@ export function toClassOperations<Model extends ILlmSchema.Model>(props: {
126
129
  * @internal
127
130
  */
128
131
  export function toMcpOperations<Model extends ILlmSchema.Model>(props: {
129
- controller: IAgenticaController.IMcp;
132
+ controller: IAgenticaController.IMcp<Model>;
130
133
  index: number;
131
134
  naming: (func: string, controllerIndex: number) => string;
132
135
  }): AgenticaOperation<Model>[] {
136
+ // eslint-disable-next-line ts/no-unsafe-call, ts/no-unsafe-member-access, ts/no-unsafe-return
133
137
  return props.controller.application.functions.map(func => ({
134
138
  protocol: "mcp",
135
139
  controller: props.controller,
140
+ // eslint-disable-next-line ts/no-unsafe-assignment
136
141
  function: func,
142
+ // eslint-disable-next-line ts/no-unsafe-argument, ts/no-unsafe-member-access
137
143
  name: props.naming(func.name, props.index),
138
144
  toJSON: () => ({
139
145
  protocol: "mcp",
140
146
  controller: props.controller.name,
147
+ // eslint-disable-next-line ts/no-unsafe-assignment, ts/no-unsafe-member-access
141
148
  function: func.name,
149
+ // eslint-disable-next-line ts/no-unsafe-argument, ts/no-unsafe-member-access
142
150
  name: props.naming(func.name, props.index),
143
151
  }),
144
152
  }));
@@ -0,0 +1,49 @@
1
+ import type { Client } from "@modelcontextprotocol/sdk/client/index.d.ts";
2
+ import type { ILlmSchema, IMcpLlmApplication, IMcpTool } from "@samchon/openapi";
3
+
4
+ import { McpLlm } from "@samchon/openapi";
5
+ import typia from "typia";
6
+
7
+ import type { IAgenticaController } from "../structures/IAgenticaController";
8
+
9
+ /**
10
+ * Create an MCP controller with type assertion.
11
+ *
12
+ * Create an {@link IAgenticaController.IMcp} instance which represents
13
+ * an MCP (Model Context Protocol) controller with LLM function calling
14
+ * schemas and client connection.
15
+ *
16
+ * @param props Properties to create the MCP controller
17
+ * @param props.name Name of the MCP implementation.
18
+ * @param props.client Client connection to the MCP implementation.
19
+ * @param props.model Model schema of the LLM function calling.
20
+ * @param props.options Options to create the MCP controller.
21
+ * @returns MCP LLM application instance
22
+ * @author Samchon
23
+ */
24
+ export async function assertMcpController<Model extends ILlmSchema.Model>(props: {
25
+ name: string;
26
+ client: Client;
27
+ model: Model;
28
+ options?: Partial<IMcpLlmApplication.IOptions<Model>>;
29
+ }): Promise<IAgenticaController.IMcp<Model>> {
30
+ // for peerDependencies
31
+ const { ListToolsResultSchema } = await import("@modelcontextprotocol/sdk/types.js");
32
+
33
+ // get list of tools
34
+ const { tools } = await props.client.request({ method: "tools/list" }, ListToolsResultSchema);
35
+
36
+ // eslint-disable-next-line ts/no-unsafe-assignment, ts/no-unsafe-call, ts/no-unsafe-member-access
37
+ const application: IMcpLlmApplication<Model> = McpLlm.application<Model>({
38
+ model: props.model,
39
+ tools: typia.assert<Array<IMcpTool>>(tools),
40
+ });
41
+
42
+ return {
43
+ protocol: "mcp",
44
+ name: props.name,
45
+ client: props.client,
46
+ // eslint-disable-next-line ts/no-unsafe-assignment
47
+ application,
48
+ };
49
+ }
package/src/index.ts CHANGED
@@ -23,7 +23,7 @@ export * from "./events/MicroAgenticaEvent";
23
23
  export * as factory from "./factory";
24
24
 
25
25
  export * from "./functional/assertHttpLlmApplication";
26
- export * from "./functional/assertMcpLlmApplication";
26
+ export * from "./functional/assertMcpController";
27
27
  export * from "./functional/validateHttpLlmApplication";
28
28
  // @TODO: implement validateMcpLlmApplication
29
29
 
@@ -72,10 +72,13 @@ export async function call<Model extends ILlmSchema.Model>(
72
72
  type: "function",
73
73
  function: {
74
74
  name: s.name,
75
+ // eslint-disable-next-line ts/no-unsafe-assignment, ts/no-unsafe-member-access
75
76
  description: s.function.description,
76
77
  parameters: (
77
78
  "separated" in s.function
79
+ // eslint-disable-next-line ts/no-unsafe-member-access
78
80
  && s.function.separated !== undefined
81
+ // eslint-disable-next-line ts/no-unsafe-member-access
79
82
  ? (s.function.separated.llm
80
83
  ?? ({
81
84
  type: "object",
@@ -84,6 +87,7 @@ export async function call<Model extends ILlmSchema.Model>(
84
87
  additionalProperties: false,
85
88
  $defs: {},
86
89
  } satisfies IChatGptSchema.IParameters))
90
+ // eslint-disable-next-line ts/no-unsafe-member-access
87
91
  : s.function.parameters) as Record<string, any>,
88
92
  },
89
93
  }) as OpenAI.ChatCompletionTool,
@@ -368,7 +372,7 @@ async function propagateClass<Model extends ILlmSchema.Model>(props: {
368
372
 
369
373
  async function propagateMcp<Model extends ILlmSchema.Model>(props: {
370
374
  ctx: AgenticaContext<Model> | MicroAgenticaContext<Model>;
371
- operation: AgenticaOperation.Mcp;
375
+ operation: AgenticaOperation.Mcp<Model>;
372
376
  call: AgenticaCallEvent<Model>;
373
377
  retry: number;
374
378
  }): Promise<AgenticaExecuteHistory<Model>> {
@@ -435,12 +439,14 @@ async function executeClassOperation<Model extends ILlmSchema.Model>(operation:
435
439
  return ((execute as Record<string, unknown>)[operation.function.name] as (...args: unknown[]) => Promise<unknown>)(operationArguments);
436
440
  }
437
441
 
438
- async function executeMcpOperation(
439
- operation: AgenticaOperation.Mcp,
442
+ async function executeMcpOperation<Model extends ILlmSchema.Model>(
443
+ operation: AgenticaOperation.Mcp<Model>,
440
444
  operationArguments: Record<string, unknown>,
441
445
  ): Promise<unknown> {
442
- return operation.controller.application.client.callTool({
446
+ return operation.controller.client.callTool({
447
+ // eslint-disable-next-line ts/no-unsafe-member-access
443
448
  method: operation.function.name,
449
+ // eslint-disable-next-line ts/no-unsafe-assignment, ts/no-unsafe-member-access
444
450
  name: operation.function.name,
445
451
  arguments: operationArguments,
446
452
  }).then(v => v.content);
@@ -512,6 +518,7 @@ async function correct<Model extends ILlmSchema.Model>(
512
518
  type: "function",
513
519
  function: {
514
520
  name: call.operation.name,
521
+ // eslint-disable-next-line ts/no-unsafe-assignment, ts/no-unsafe-member-access
515
522
  description: call.operation.function.description,
516
523
  /**
517
524
  * @TODO fix it
@@ -519,7 +526,9 @@ async function correct<Model extends ILlmSchema.Model>(
519
526
  */
520
527
  parameters: (
521
528
  "separated" in call.operation.function
529
+ // eslint-disable-next-line ts/no-unsafe-member-access
522
530
  && call.operation.function.separated !== undefined
531
+ // eslint-disable-next-line ts/no-unsafe-member-access
523
532
  ? (call.operation.function.separated?.llm
524
533
  ?? ({
525
534
  $defs: {},
@@ -528,6 +537,7 @@ async function correct<Model extends ILlmSchema.Model>(
528
537
  additionalProperties: false,
529
538
  required: [],
530
539
  } satisfies IChatGptSchema.IParameters))
540
+ // eslint-disable-next-line ts/no-unsafe-member-access
531
541
  : call.operation.function.parameters) as unknown as Record<string, unknown>,
532
542
  },
533
543
  },
@@ -1,3 +1,4 @@
1
+ import type { Client } from "@modelcontextprotocol/sdk/client/index.d.ts";
1
2
  import type {
2
3
  IHttpConnection,
3
4
  IHttpLlmApplication,
@@ -6,10 +7,9 @@ import type {
6
7
  ILlmApplication,
7
8
  ILlmFunction,
8
9
  ILlmSchema,
10
+ IMcpLlmApplication,
9
11
  } from "@samchon/openapi";
10
12
 
11
- import type { IMcpLlmApplication } from "./mcp/IMcpLlmApplication";
12
-
13
13
  /**
14
14
  * Controller of the Agentica Agent.
15
15
  *
@@ -29,7 +29,7 @@ import type { IMcpLlmApplication } from "./mcp/IMcpLlmApplication";
29
29
  export type IAgenticaController<Model extends ILlmSchema.Model> =
30
30
  | IAgenticaController.IHttp<Model>
31
31
  | IAgenticaController.IClass<Model>
32
- | IAgenticaController.IMcp;
32
+ | IAgenticaController.IMcp<Model>;
33
33
 
34
34
  export namespace IAgenticaController {
35
35
  /**
@@ -122,7 +122,12 @@ export namespace IAgenticaController {
122
122
  /**
123
123
  * MCP Server controller.
124
124
  */
125
- export interface IMcp extends IBase<"mcp", IMcpLlmApplication> { }
125
+ export interface IMcp<Model extends ILlmSchema.Model> extends IBase<"mcp", IMcpLlmApplication<Model>> {
126
+ /**
127
+ * MCP client for connection.
128
+ */
129
+ client: Client;
130
+ }
126
131
 
127
132
  interface IBase<Protocol, Application> {
128
133
  /**
@@ -1,3 +1 @@
1
- export * from "./IMcpLlmApplication";
2
- export * from "./IMcpLlmFunction";
3
1
  export * from "./IMcpLlmTransportProps";
@@ -1,18 +0,0 @@
1
- import type { Client } from "@modelcontextprotocol/sdk/client/index.d.ts";
2
- import type { IMcpLlmApplication } from "../structures/mcp";
3
- /**
4
- * Create an MCP LLM application instance with type assertion.
5
- *
6
- * Create an {@link IMcpLlmApplication} instance which represents
7
- * an MCP (Model Context Protocol) LLM application.
8
- *
9
- * @param props Properties to create the MCP LLM application instance
10
- * @param props.name Name of the MCP implementation.
11
- * @param props.url URL of the MCP server.
12
- * @param props.version Describes version of an MCP implementation.
13
- * @returns MCP LLM application instance
14
- * @author Samchon
15
- */
16
- export declare function assertMcpLlmApplication(props: {
17
- client: Client;
18
- }): Promise<IMcpLlmApplication>;