apcore-mcp 0.1.0 → 0.2.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.
- package/dist/adapters/annotations.d.ts +4 -4
- package/dist/adapters/annotations.js +15 -15
- package/dist/adapters/annotations.js.map +1 -1
- package/dist/adapters/errors.d.ts.map +1 -1
- package/dist/adapters/errors.js +16 -15
- package/dist/adapters/errors.js.map +1 -1
- package/dist/adapters/idNormalizer.d.ts +1 -0
- package/dist/adapters/idNormalizer.d.ts.map +1 -1
- package/dist/adapters/idNormalizer.js +5 -0
- package/dist/adapters/idNormalizer.js.map +1 -1
- package/dist/adapters/schema.d.ts +3 -3
- package/dist/adapters/schema.d.ts.map +1 -1
- package/dist/adapters/schema.js +20 -12
- package/dist/adapters/schema.js.map +1 -1
- package/dist/converters/openai.d.ts +6 -6
- package/dist/converters/openai.js +8 -8
- package/dist/converters/openai.js.map +1 -1
- package/dist/index.d.ts +19 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/server/factory.d.ts +1 -1
- package/dist/server/factory.d.ts.map +1 -1
- package/dist/server/factory.js +20 -8
- package/dist/server/factory.js.map +1 -1
- package/dist/server/listener.d.ts.map +1 -1
- package/dist/server/listener.js +4 -3
- package/dist/server/listener.js.map +1 -1
- package/dist/server/router.d.ts +5 -3
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/router.js +12 -4
- package/dist/server/router.js.map +1 -1
- package/dist/server/transport.d.ts.map +1 -1
- package/dist/server/transport.js +60 -6
- package/dist/server/transport.js.map +1 -1
- package/dist/types.d.ts +40 -32
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +25 -5
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,10 +11,10 @@ export declare class AnnotationMapper {
|
|
|
11
11
|
* Convert apcore module annotations to MCP annotations dict.
|
|
12
12
|
*
|
|
13
13
|
* Returns default values when annotations are null:
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
16
|
-
* -
|
|
17
|
-
* -
|
|
14
|
+
* - readOnlyHint: false
|
|
15
|
+
* - destructiveHint: false
|
|
16
|
+
* - idempotentHint: false
|
|
17
|
+
* - openWorldHint: true
|
|
18
18
|
* - title: null
|
|
19
19
|
*/
|
|
20
20
|
toMcpAnnotations(annotations: ModuleAnnotations | null): McpAnnotationsDict;
|
|
@@ -10,27 +10,27 @@ export class AnnotationMapper {
|
|
|
10
10
|
* Convert apcore module annotations to MCP annotations dict.
|
|
11
11
|
*
|
|
12
12
|
* Returns default values when annotations are null:
|
|
13
|
-
* -
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
16
|
-
* -
|
|
13
|
+
* - readOnlyHint: false
|
|
14
|
+
* - destructiveHint: false
|
|
15
|
+
* - idempotentHint: false
|
|
16
|
+
* - openWorldHint: true
|
|
17
17
|
* - title: null
|
|
18
18
|
*/
|
|
19
19
|
toMcpAnnotations(annotations) {
|
|
20
20
|
if (annotations === null) {
|
|
21
21
|
return {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
readOnlyHint: false,
|
|
23
|
+
destructiveHint: false,
|
|
24
|
+
idempotentHint: false,
|
|
25
|
+
openWorldHint: true,
|
|
26
26
|
title: null,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
readOnlyHint: annotations.readonly,
|
|
31
|
+
destructiveHint: annotations.destructive,
|
|
32
|
+
idempotentHint: annotations.idempotent,
|
|
33
|
+
openWorldHint: annotations.openWorld,
|
|
34
34
|
title: null,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
@@ -50,8 +50,8 @@ export class AnnotationMapper {
|
|
|
50
50
|
`readonly=${annotations.readonly}`,
|
|
51
51
|
`destructive=${annotations.destructive}`,
|
|
52
52
|
`idempotent=${annotations.idempotent}`,
|
|
53
|
-
`requires_approval=${annotations.
|
|
54
|
-
`open_world=${annotations.
|
|
53
|
+
`requires_approval=${annotations.requiresApproval}`,
|
|
54
|
+
`open_world=${annotations.openWorld}`,
|
|
55
55
|
];
|
|
56
56
|
return `\n\n[Annotations: ${parts.join(", ")}]`;
|
|
57
57
|
}
|
|
@@ -64,7 +64,7 @@ export class AnnotationMapper {
|
|
|
64
64
|
if (annotations === null) {
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
67
|
-
return annotations.
|
|
67
|
+
return annotations.requiresApproval;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
//# sourceMappingURL=annotations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../src/adapters/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,gBAAgB;IAC3B;;;;;;;;;OASG;IACH,gBAAgB,CAAC,WAAqC;QACpD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO;gBACL,
|
|
1
|
+
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../src/adapters/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,gBAAgB;IAC3B;;;;;;;;;OASG;IACH,gBAAgB,CAAC,WAAqC;QACpD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO;gBACL,YAAY,EAAE,KAAK;gBACnB,eAAe,EAAE,KAAK;gBACtB,cAAc,EAAE,KAAK;gBACrB,aAAa,EAAE,IAAI;gBACnB,KAAK,EAAE,IAAI;aACZ,CAAC;QACJ,CAAC;QAED,OAAO;YACL,YAAY,EAAE,WAAW,CAAC,QAAQ;YAClC,eAAe,EAAE,WAAW,CAAC,WAAW;YACxC,cAAc,EAAE,WAAW,CAAC,UAAU;YACtC,aAAa,EAAE,WAAW,CAAC,SAAS;YACpC,KAAK,EAAE,IAAI;SACZ,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,mBAAmB,CAAC,WAAqC;QACvD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,KAAK,GAAa;YACtB,YAAY,WAAW,CAAC,QAAQ,EAAE;YAClC,eAAe,WAAW,CAAC,WAAW,EAAE;YACxC,cAAc,WAAW,CAAC,UAAU,EAAE;YACtC,qBAAqB,WAAW,CAAC,gBAAgB,EAAE;YACnD,cAAc,WAAW,CAAC,SAAS,EAAE;SACtC,CAAC;QAEF,OAAO,qBAAqB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,WAAqC;QACvD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,WAAW,CAAC,gBAAgB,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/adapters/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/adapters/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD,qBAAa,WAAW;IACtB;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB;IAuD5C;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAetB;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;CA4B/B"}
|
package/dist/adapters/errors.js
CHANGED
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* internal error details, and formats schema validation errors with
|
|
6
6
|
* field-level detail.
|
|
7
7
|
*/
|
|
8
|
+
import { ErrorCodes } from "../types.js";
|
|
8
9
|
/** Internal error codes that should be sanitized to a generic message. */
|
|
9
10
|
const INTERNAL_ERROR_CODES = new Set([
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
ErrorCodes.CALL_DEPTH_EXCEEDED,
|
|
12
|
+
ErrorCodes.CIRCULAR_CALL,
|
|
13
|
+
ErrorCodes.CALL_FREQUENCY_EXCEEDED,
|
|
13
14
|
]);
|
|
14
15
|
export class ErrorMapper {
|
|
15
16
|
/**
|
|
@@ -26,43 +27,43 @@ export class ErrorMapper {
|
|
|
26
27
|
// Internal error codes -> generic message
|
|
27
28
|
if (INTERNAL_ERROR_CODES.has(code)) {
|
|
28
29
|
return {
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
isError: true,
|
|
31
|
+
errorType: code,
|
|
31
32
|
message: "Internal error occurred",
|
|
32
33
|
details: null,
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
// ACL denied -> sanitized access denied
|
|
36
|
-
if (code ===
|
|
37
|
+
if (code === ErrorCodes.ACL_DENIED) {
|
|
37
38
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
isError: true,
|
|
40
|
+
errorType: ErrorCodes.ACL_DENIED,
|
|
40
41
|
message: "Access denied",
|
|
41
42
|
details: null,
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
// Schema validation error -> formatted with field-level details
|
|
45
|
-
if (code ===
|
|
46
|
+
if (code === ErrorCodes.SCHEMA_VALIDATION_ERROR) {
|
|
46
47
|
const message = this._formatValidationError(details);
|
|
47
48
|
return {
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
isError: true,
|
|
50
|
+
errorType: ErrorCodes.SCHEMA_VALIDATION_ERROR,
|
|
50
51
|
message,
|
|
51
52
|
details,
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
// Other known ModuleError codes -> pass through
|
|
55
56
|
return {
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
isError: true,
|
|
58
|
+
errorType: code,
|
|
58
59
|
message: error.message,
|
|
59
60
|
details,
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
// Unknown/unexpected exceptions -> generic error
|
|
63
64
|
return {
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
isError: true,
|
|
66
|
+
errorType: ErrorCodes.INTERNAL_ERROR,
|
|
66
67
|
message: "Internal error occurred",
|
|
67
68
|
details: null,
|
|
68
69
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/adapters/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/adapters/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,0EAA0E;AAC1E,MAAM,oBAAoB,GAAgB,IAAI,GAAG,CAAC;IAChD,UAAU,CAAC,mBAAmB;IAC9B,UAAU,CAAC,aAAa;IACxB,UAAU,CAAC,uBAAuB;CACnC,CAAC,CAAC;AAEH,MAAM,OAAO,WAAW;IACtB;;;;;OAKG;IACH,UAAU,CAAC,KAAc;QACvB,+CAA+C;QAC/C,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;YACxB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;YAE9B,0CAA0C;YAC1C,IAAI,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnC,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,SAAS,EAAE,IAAI;oBACf,OAAO,EAAE,yBAAyB;oBAClC,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;YAED,wCAAwC;YACxC,IAAI,IAAI,KAAK,UAAU,CAAC,UAAU,EAAE,CAAC;gBACnC,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,SAAS,EAAE,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AAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClD,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,MAAM,WAAW,GAAG,MAAM;aACvB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACX,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC5C,MAAM,KAAK,GAAG,GAA8B,CAAC;gBAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;gBAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC;gBACvD,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAClD,CAAC;YACD,OAAO,KAAK,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,OAAO,GAAG,WAAW,MAAM,WAAW,EAAE,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -8,6 +8,7 @@ export declare class ModuleIDNormalizer {
|
|
|
8
8
|
/**
|
|
9
9
|
* Normalize an apcore module ID to an MCP-compatible tool name.
|
|
10
10
|
*
|
|
11
|
+
* Validates the module ID against MODULE_ID_PATTERN before converting.
|
|
11
12
|
* Replaces dots (`.`) with hyphens (`-`).
|
|
12
13
|
*/
|
|
13
14
|
normalize(moduleId: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idNormalizer.d.ts","sourceRoot":"","sources":["../../src/adapters/idNormalizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"idNormalizer.d.ts","sourceRoot":"","sources":["../../src/adapters/idNormalizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,qBAAa,kBAAkB;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IASnC;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAGtC"}
|
|
@@ -4,13 +4,18 @@
|
|
|
4
4
|
* apcore uses dot-separated module IDs (e.g. "myorg.tools.search")
|
|
5
5
|
* while MCP tool names use hyphens (e.g. "myorg-tools-search").
|
|
6
6
|
*/
|
|
7
|
+
import { MODULE_ID_PATTERN } from "../types.js";
|
|
7
8
|
export class ModuleIDNormalizer {
|
|
8
9
|
/**
|
|
9
10
|
* Normalize an apcore module ID to an MCP-compatible tool name.
|
|
10
11
|
*
|
|
12
|
+
* Validates the module ID against MODULE_ID_PATTERN before converting.
|
|
11
13
|
* Replaces dots (`.`) with hyphens (`-`).
|
|
12
14
|
*/
|
|
13
15
|
normalize(moduleId) {
|
|
16
|
+
if (!MODULE_ID_PATTERN.test(moduleId)) {
|
|
17
|
+
throw new Error(`Invalid module ID "${moduleId}": must match pattern ${MODULE_ID_PATTERN}`);
|
|
18
|
+
}
|
|
14
19
|
return moduleId.replaceAll(".", "-");
|
|
15
20
|
}
|
|
16
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idNormalizer.js","sourceRoot":"","sources":["../../src/adapters/idNormalizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,OAAO,kBAAkB;IAC7B
|
|
1
|
+
{"version":3,"file":"idNormalizer.js","sourceRoot":"","sources":["../../src/adapters/idNormalizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,OAAO,kBAAkB;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,QAAgB;QACxB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,sBAAsB,QAAQ,yBAAyB,iBAAiB,EAAE,CAC3E,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,QAAgB;QAC1B,OAAO,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
import type { JsonSchema, ModuleDescriptor } from "../types.js";
|
|
8
8
|
export declare class SchemaConverter {
|
|
9
9
|
/**
|
|
10
|
-
* Convert a module descriptor's
|
|
10
|
+
* Convert a module descriptor's inputSchema to an MCP-compatible schema.
|
|
11
11
|
*/
|
|
12
12
|
convertInputSchema(descriptor: ModuleDescriptor): JsonSchema;
|
|
13
13
|
/**
|
|
14
|
-
* Convert a module descriptor's
|
|
14
|
+
* Convert a module descriptor's outputSchema to an MCP-compatible schema.
|
|
15
15
|
*/
|
|
16
16
|
convertOutputSchema(descriptor: ModuleDescriptor): JsonSchema;
|
|
17
17
|
/**
|
|
@@ -24,7 +24,7 @@ export declare class SchemaConverter {
|
|
|
24
24
|
* Handles dicts (objects), arrays, and primitive values.
|
|
25
25
|
* Skips the `$defs` key itself during traversal.
|
|
26
26
|
*/
|
|
27
|
-
_inlineRefs(node: unknown, defs: Record<string, JsonSchema>): unknown;
|
|
27
|
+
_inlineRefs(node: unknown, defs: Record<string, JsonSchema>, activeRefs: Set<string>): unknown;
|
|
28
28
|
/**
|
|
29
29
|
* Resolve a `$ref` path (e.g. `#/$defs/MyType`) against the $defs map.
|
|
30
30
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/adapters/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhE,qBAAa,eAAe;IAC1B;;OAEG;IACH,kBAAkB,CAAC,UAAU,EAAE,gBAAgB,GAAG,UAAU;IAI5D;;OAEG;IACH,mBAAmB,CAAC,UAAU,EAAE,gBAAgB,GAAG,UAAU;IAI7D;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU;IAe9C;;;;;OAKG;IACH,WAAW,CACT,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/adapters/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhE,qBAAa,eAAe;IAC1B;;OAEG;IACH,kBAAkB,CAAC,UAAU,EAAE,gBAAgB,GAAG,UAAU;IAI5D;;OAEG;IACH,mBAAmB,CAAC,UAAU,EAAE,gBAAgB,GAAG,UAAU;IAI7D;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU;IAe9C;;;;;OAKG;IACH,WAAW,CACT,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAChC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GACtB,OAAO;IA0CV;;;;;OAKG;IACH,WAAW,CACT,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAC/B,UAAU;IAoBb;;;;;OAKG;IACH,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU;CAclD"}
|
package/dist/adapters/schema.js
CHANGED
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export class SchemaConverter {
|
|
8
8
|
/**
|
|
9
|
-
* Convert a module descriptor's
|
|
9
|
+
* Convert a module descriptor's inputSchema to an MCP-compatible schema.
|
|
10
10
|
*/
|
|
11
11
|
convertInputSchema(descriptor) {
|
|
12
|
-
return this._convertSchema(descriptor.
|
|
12
|
+
return this._convertSchema(descriptor.inputSchema);
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Convert a module descriptor's
|
|
15
|
+
* Convert a module descriptor's outputSchema to an MCP-compatible schema.
|
|
16
16
|
*/
|
|
17
17
|
convertOutputSchema(descriptor) {
|
|
18
|
-
return this._convertSchema(descriptor.
|
|
18
|
+
return this._convertSchema(descriptor.outputSchema);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Apply all schema transformations: deep copy, inline $ref, ensure object type.
|
|
@@ -26,8 +26,8 @@ export class SchemaConverter {
|
|
|
26
26
|
// Extract and remove $defs before inlining
|
|
27
27
|
const defs = copied["$defs"] ?? {};
|
|
28
28
|
delete copied["$defs"];
|
|
29
|
-
// Inline all $ref references
|
|
30
|
-
const inlined = this._inlineRefs(copied, defs);
|
|
29
|
+
// Inline all $ref references (with circular ref detection)
|
|
30
|
+
const inlined = this._inlineRefs(copied, defs, new Set());
|
|
31
31
|
// Ensure the top-level schema has type: "object"
|
|
32
32
|
return this._ensureObjectType(inlined);
|
|
33
33
|
}
|
|
@@ -37,17 +37,25 @@ export class SchemaConverter {
|
|
|
37
37
|
* Handles dicts (objects), arrays, and primitive values.
|
|
38
38
|
* Skips the `$defs` key itself during traversal.
|
|
39
39
|
*/
|
|
40
|
-
_inlineRefs(node, defs) {
|
|
40
|
+
_inlineRefs(node, defs, activeRefs) {
|
|
41
41
|
if (Array.isArray(node)) {
|
|
42
|
-
return node.map((item) => this._inlineRefs(item, defs));
|
|
42
|
+
return node.map((item) => this._inlineRefs(item, defs, activeRefs));
|
|
43
43
|
}
|
|
44
44
|
if (node !== null && typeof node === "object") {
|
|
45
45
|
const obj = node;
|
|
46
46
|
// If this object is a $ref, resolve it
|
|
47
47
|
if (typeof obj["$ref"] === "string") {
|
|
48
|
-
const
|
|
49
|
-
//
|
|
50
|
-
|
|
48
|
+
const refPath = obj["$ref"];
|
|
49
|
+
// Detect circular references
|
|
50
|
+
if (activeRefs.has(refPath)) {
|
|
51
|
+
throw new Error(`Circular $ref detected: ${refPath}`);
|
|
52
|
+
}
|
|
53
|
+
const resolved = this._resolveRef(refPath, defs);
|
|
54
|
+
// Track this ref as active during recursion
|
|
55
|
+
activeRefs.add(refPath);
|
|
56
|
+
const result = this._inlineRefs(resolved, defs, activeRefs);
|
|
57
|
+
activeRefs.delete(refPath);
|
|
58
|
+
return result;
|
|
51
59
|
}
|
|
52
60
|
// Otherwise, recurse into each key (skip $defs)
|
|
53
61
|
const result = {};
|
|
@@ -55,7 +63,7 @@ export class SchemaConverter {
|
|
|
55
63
|
if (key === "$defs") {
|
|
56
64
|
continue;
|
|
57
65
|
}
|
|
58
|
-
result[key] = this._inlineRefs(value, defs);
|
|
66
|
+
result[key] = this._inlineRefs(value, defs, activeRefs);
|
|
59
67
|
}
|
|
60
68
|
return result;
|
|
61
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/adapters/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,OAAO,eAAe;IAC1B;;OAEG;IACH,kBAAkB,CAAC,UAA4B;QAC7C,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/adapters/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,OAAO,eAAe;IAC1B;;OAEG;IACH,kBAAkB,CAAC,UAA4B;QAC7C,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,UAA4B;QAC9C,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,MAAkB;QAC/B,2CAA2C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ACrC,CAAC;IAED;;;;;OAKG;IACH,iBAAiB,CAAC,MAAkB;QAClC,yBAAyB;QACzB,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QAC5C,CAAC;QAED,uCAAuC;QACvC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE,CAAC;YACjC,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,gCAAgC;QAChC,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -45,10 +45,10 @@ export declare class OpenAIConverter {
|
|
|
45
45
|
* Convert all modules in a Registry to OpenAI tool definitions.
|
|
46
46
|
*
|
|
47
47
|
* Iterates registry.list() with optional tag/prefix filtering,
|
|
48
|
-
* calls registry.
|
|
48
|
+
* calls registry.getDefinition() for each module ID, skips null
|
|
49
49
|
* definitions (race-condition guard), and converts each descriptor.
|
|
50
50
|
*
|
|
51
|
-
* @param registry - apcore Registry with list() and
|
|
51
|
+
* @param registry - apcore Registry with list() and getDefinition() methods.
|
|
52
52
|
* @param options - Optional filtering and conversion options.
|
|
53
53
|
* @returns Array of OpenAI-compatible tool definition objects.
|
|
54
54
|
*/
|
|
@@ -56,13 +56,13 @@ export declare class OpenAIConverter {
|
|
|
56
56
|
/**
|
|
57
57
|
* Convert a single ModuleDescriptor to an OpenAI tool definition.
|
|
58
58
|
*
|
|
59
|
-
* - Normalizes the
|
|
60
|
-
* - Converts the
|
|
59
|
+
* - Normalizes the moduleId via ModuleIDNormalizer (dots -> dashes).
|
|
60
|
+
* - Converts the inputSchema via SchemaConverter.
|
|
61
61
|
* - Optionally appends an annotation suffix to the description.
|
|
62
62
|
* - Optionally applies strict-mode transformations to the schema.
|
|
63
63
|
*
|
|
64
|
-
* @param descriptor - Module descriptor with
|
|
65
|
-
*
|
|
64
|
+
* @param descriptor - Module descriptor with moduleId, description,
|
|
65
|
+
* inputSchema, and optional annotations.
|
|
66
66
|
* @param options - Optional conversion flags.
|
|
67
67
|
* @returns OpenAI-compatible tool definition object.
|
|
68
68
|
*/
|
|
@@ -37,10 +37,10 @@ export class OpenAIConverter {
|
|
|
37
37
|
* Convert all modules in a Registry to OpenAI tool definitions.
|
|
38
38
|
*
|
|
39
39
|
* Iterates registry.list() with optional tag/prefix filtering,
|
|
40
|
-
* calls registry.
|
|
40
|
+
* calls registry.getDefinition() for each module ID, skips null
|
|
41
41
|
* definitions (race-condition guard), and converts each descriptor.
|
|
42
42
|
*
|
|
43
|
-
* @param registry - apcore Registry with list() and
|
|
43
|
+
* @param registry - apcore Registry with list() and getDefinition() methods.
|
|
44
44
|
* @param options - Optional filtering and conversion options.
|
|
45
45
|
* @returns Array of OpenAI-compatible tool definition objects.
|
|
46
46
|
*/
|
|
@@ -55,7 +55,7 @@ export class OpenAIConverter {
|
|
|
55
55
|
});
|
|
56
56
|
const tools = [];
|
|
57
57
|
for (const moduleId of moduleIds) {
|
|
58
|
-
const descriptor = registry.
|
|
58
|
+
const descriptor = registry.getDefinition(moduleId);
|
|
59
59
|
if (descriptor === null) {
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
@@ -66,20 +66,20 @@ export class OpenAIConverter {
|
|
|
66
66
|
/**
|
|
67
67
|
* Convert a single ModuleDescriptor to an OpenAI tool definition.
|
|
68
68
|
*
|
|
69
|
-
* - Normalizes the
|
|
70
|
-
* - Converts the
|
|
69
|
+
* - Normalizes the moduleId via ModuleIDNormalizer (dots -> dashes).
|
|
70
|
+
* - Converts the inputSchema via SchemaConverter.
|
|
71
71
|
* - Optionally appends an annotation suffix to the description.
|
|
72
72
|
* - Optionally applies strict-mode transformations to the schema.
|
|
73
73
|
*
|
|
74
|
-
* @param descriptor - Module descriptor with
|
|
75
|
-
*
|
|
74
|
+
* @param descriptor - Module descriptor with moduleId, description,
|
|
75
|
+
* inputSchema, and optional annotations.
|
|
76
76
|
* @param options - Optional conversion flags.
|
|
77
77
|
* @returns OpenAI-compatible tool definition object.
|
|
78
78
|
*/
|
|
79
79
|
convertDescriptor(descriptor, options) {
|
|
80
80
|
const embedAnnotations = options?.embedAnnotations ?? false;
|
|
81
81
|
const strict = options?.strict ?? false;
|
|
82
|
-
const name = this._idNormalizer.normalize(descriptor.
|
|
82
|
+
const name = this._idNormalizer.normalize(descriptor.moduleId);
|
|
83
83
|
let parameters = this._schemaConverter.convertInputSchema(descriptor);
|
|
84
84
|
// Build description with optional annotation suffix
|
|
85
85
|
let description = descriptor.description;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/converters/openai.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAmBjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,eAAe;IACT,gBAAgB,CAAkB;IAClC,iBAAiB,CAAmB;IACpC,aAAa,CAAqB;IAEnD;QACE,IAAI,CAAC,gBAAgB,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,IAAI,CAAC,iBAAiB,GAAG,IAAI,gBAAgB,EAAE,CAAC;QAChD,IAAI,CAAC,aAAa,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAChD,CAAC;IAED;;;;;;;;;;OAUG;IACH,eAAe,CACb,QAAkB,EAClB,OAAgC;QAEhC,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;QAC3B,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;QAC/B,MAAM,gBAAgB,GAAG,OAAO,EAAE,gBAAgB,CAAC;QACnD,MAAM,MAAM,GAAG,OAAO,EAAE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C;wBACxD,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;4BAC/B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gCAClC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,EAAE,MAAM,CAAC,CAAC;4BAChD,CAAC;wBACH,CAAC;6BAAM,CAAC;4BACN,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;wBAC7C,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,iCAAiC;gBACjC,UAAU,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;YAChE,CAAC;YAED,iCAAiC;YACjC,MAAM,CAAC,UAAU,CAAC,GAAG,gBAAgB,CAAC;QACxC,CAAC;QAED,2BAA2B;QAC3B,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE,CAAC;YAChE,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAC1C,MAAM,CAAC,OAAO,CAAe,CAC9B,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,22 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { ConvertRegistryOptions } from "./converters/openai.js";
|
|
9
9
|
import type { RegistryOrExecutor, OpenAIToolDef } from "./types.js";
|
|
10
|
-
export declare const VERSION
|
|
10
|
+
export declare const VERSION: string;
|
|
11
11
|
export type { Registry, Executor, RegistryOrExecutor, OpenAIToolDef } from "./types.js";
|
|
12
|
-
export type { ModuleDescriptor, ModuleAnnotations, JsonSchema } from "./types.js";
|
|
12
|
+
export type { ModuleDescriptor, ModuleAnnotations, JsonSchema, ModuleError, McpAnnotationsDict, McpErrorResponse, TextContentDict, } from "./types.js";
|
|
13
|
+
export { REGISTRY_EVENTS, ErrorCodes, MODULE_ID_PATTERN } from "./types.js";
|
|
14
|
+
export { MCPServerFactory } from "./server/factory.js";
|
|
15
|
+
export { ExecutionRouter } from "./server/router.js";
|
|
16
|
+
export type { CallResult } from "./server/router.js";
|
|
17
|
+
export { RegistryListener } from "./server/listener.js";
|
|
18
|
+
export { TransportManager } from "./server/transport.js";
|
|
19
|
+
export { AnnotationMapper } from "./adapters/annotations.js";
|
|
20
|
+
export { SchemaConverter } from "./adapters/schema.js";
|
|
21
|
+
export { ErrorMapper } from "./adapters/errors.js";
|
|
22
|
+
export { ModuleIDNormalizer } from "./adapters/idNormalizer.js";
|
|
23
|
+
export { OpenAIConverter } from "./converters/openai.js";
|
|
24
|
+
export type { ConvertOptions, ConvertRegistryOptions } from "./converters/openai.js";
|
|
25
|
+
export type { BuildToolsOptions } from "./server/factory.js";
|
|
13
26
|
/** Options for serve() */
|
|
14
27
|
export interface ServeOptions {
|
|
15
28
|
/** Transport type. Default: "stdio" */
|
|
@@ -22,6 +35,10 @@ export interface ServeOptions {
|
|
|
22
35
|
name?: string;
|
|
23
36
|
/** MCP server version. Default: package version */
|
|
24
37
|
version?: string;
|
|
38
|
+
/** Enable dynamic tool registration/unregistration. Default: false */
|
|
39
|
+
dynamic?: boolean;
|
|
40
|
+
/** Enable input validation against schemas. Default: false */
|
|
41
|
+
validateInputs?: boolean;
|
|
25
42
|
}
|
|
26
43
|
/**
|
|
27
44
|
* Launch an MCP Server that exposes all apcore modules as tools.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAA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2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAsB,KAAK,CACzB,kBAAkB,EAAE,kBAAkB,EACtC,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED,kCAAkC;AAClC,MAAM,WAAW,oBAAqB,SAAQ,sBAAsB;CAAG;AAEvE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,kBAAkB,EAAE,kBAAkB,EACtC,OAAO,GAAE,oBAAyB,GACjC,aAAa,EAAE,CAKjB"}
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,25 @@
|
|
|
5
5
|
* - serve(registryOrExecutor, options?) - Launch an MCP Server
|
|
6
6
|
* - toOpenaiTools(registryOrExecutor, options?) - Export OpenAI tool definitions
|
|
7
7
|
*/
|
|
8
|
+
import { createRequire } from "node:module";
|
|
8
9
|
import { OpenAIConverter } from "./converters/openai.js";
|
|
9
10
|
import { MCPServerFactory } from "./server/factory.js";
|
|
10
11
|
import { ExecutionRouter } from "./server/router.js";
|
|
11
12
|
import { TransportManager } from "./server/transport.js";
|
|
12
|
-
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
const pkg = require("../package.json");
|
|
15
|
+
export const VERSION = pkg.version;
|
|
16
|
+
export { REGISTRY_EVENTS, ErrorCodes, MODULE_ID_PATTERN } from "./types.js";
|
|
17
|
+
// ─── Building Block Exports ──────────────────────────────────────────────────
|
|
18
|
+
export { MCPServerFactory } from "./server/factory.js";
|
|
19
|
+
export { ExecutionRouter } from "./server/router.js";
|
|
20
|
+
export { RegistryListener } from "./server/listener.js";
|
|
21
|
+
export { TransportManager } from "./server/transport.js";
|
|
22
|
+
export { AnnotationMapper } from "./adapters/annotations.js";
|
|
23
|
+
export { SchemaConverter } from "./adapters/schema.js";
|
|
24
|
+
export { ErrorMapper } from "./adapters/errors.js";
|
|
25
|
+
export { ModuleIDNormalizer } from "./adapters/idNormalizer.js";
|
|
26
|
+
export { OpenAIConverter } from "./converters/openai.js";
|
|
13
27
|
/**
|
|
14
28
|
* Extract Registry from either a Registry or Executor instance.
|
|
15
29
|
*/
|
|
@@ -25,7 +39,7 @@ function resolveRegistry(registryOrExecutor) {
|
|
|
25
39
|
* Get or create an Executor from either a Registry or Executor instance.
|
|
26
40
|
*/
|
|
27
41
|
function resolveExecutor(registryOrExecutor) {
|
|
28
|
-
if ("
|
|
42
|
+
if ("call" in registryOrExecutor || "callAsync" in registryOrExecutor) {
|
|
29
43
|
// Already an Executor
|
|
30
44
|
return registryOrExecutor;
|
|
31
45
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQzD,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EA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;IACnE,CAAC;SAAM,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;QAC/B,MAAM,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,uBAAuB,SAAmB,mDAAmD,CAC9F,CAAC;IACJ,CAAC;AACH,CAAC;AAKD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,kBAAsC,EACtC,UAAgC,EAAE;IAElC,MAAM,QAAQ,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,IAAI,eAAe,EAAE,CAAC;IACxC,MAAM,KAAK,GAAG,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3D,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/server/factory.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare class MCPServerFactory {
|
|
|
31
31
|
* Build an MCP Tool object from an apcore module descriptor.
|
|
32
32
|
*
|
|
33
33
|
* Maps descriptor fields to MCP Tool format:
|
|
34
|
-
* - name = descriptor.
|
|
34
|
+
* - name = descriptor.moduleId
|
|
35
35
|
* - description = descriptor.description
|
|
36
36
|
* - inputSchema = converted via SchemaConverter
|
|
37
37
|
* - annotations = mapped from AnnotationMapper with camelCase keys
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/server/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKnE,OAAO,KAAK,EACV,IAAI,EAGL,MAAM,oCAAoC,CAAC;AAI5C,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE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AAE,QAAQ,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,EAAE;IA2BnE;;;;;;OAMG;IACH,gBAAgB,CACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,IAAI,EAAE,EACb,MAAM,EAAE,eAAe,GACtB,IAAI;CAyBR"}
|
package/dist/server/factory.js
CHANGED
|
@@ -31,25 +31,37 @@ export class MCPServerFactory {
|
|
|
31
31
|
* Build an MCP Tool object from an apcore module descriptor.
|
|
32
32
|
*
|
|
33
33
|
* Maps descriptor fields to MCP Tool format:
|
|
34
|
-
* - name = descriptor.
|
|
34
|
+
* - name = descriptor.moduleId
|
|
35
35
|
* - description = descriptor.description
|
|
36
36
|
* - inputSchema = converted via SchemaConverter
|
|
37
37
|
* - annotations = mapped from AnnotationMapper with camelCase keys
|
|
38
38
|
*/
|
|
39
39
|
buildTool(descriptor) {
|
|
40
|
+
if (!descriptor.moduleId || typeof descriptor.moduleId !== "string") {
|
|
41
|
+
throw new Error("ModuleDescriptor.moduleId is required and must be a string");
|
|
42
|
+
}
|
|
43
|
+
if (!descriptor.description || typeof descriptor.description !== "string") {
|
|
44
|
+
throw new Error("ModuleDescriptor.description is required and must be a string");
|
|
45
|
+
}
|
|
40
46
|
const mcpAnnotations = this._annotationMapper.toMcpAnnotations(descriptor.annotations);
|
|
41
47
|
const convertedSchema = this._schemaConverter.convertInputSchema(descriptor);
|
|
48
|
+
const hasApproval = this._annotationMapper.hasRequiresApproval(descriptor.annotations);
|
|
42
49
|
const tool = {
|
|
43
|
-
name: descriptor.
|
|
50
|
+
name: descriptor.moduleId,
|
|
44
51
|
description: descriptor.description,
|
|
45
52
|
inputSchema: convertedSchema,
|
|
46
53
|
annotations: {
|
|
47
|
-
readOnlyHint: mcpAnnotations.
|
|
48
|
-
destructiveHint: mcpAnnotations.
|
|
49
|
-
idempotentHint: mcpAnnotations.
|
|
50
|
-
openWorldHint: mcpAnnotations.
|
|
54
|
+
readOnlyHint: mcpAnnotations.readOnlyHint,
|
|
55
|
+
destructiveHint: mcpAnnotations.destructiveHint,
|
|
56
|
+
idempotentHint: mcpAnnotations.idempotentHint,
|
|
57
|
+
openWorldHint: mcpAnnotations.openWorldHint,
|
|
51
58
|
},
|
|
52
59
|
};
|
|
60
|
+
if (hasApproval) {
|
|
61
|
+
tool._meta = {
|
|
62
|
+
requiresApproval: true,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
53
65
|
return tool;
|
|
54
66
|
}
|
|
55
67
|
/**
|
|
@@ -66,9 +78,9 @@ export class MCPServerFactory {
|
|
|
66
78
|
});
|
|
67
79
|
for (const moduleId of moduleIds) {
|
|
68
80
|
try {
|
|
69
|
-
const descriptor = registry.
|
|
81
|
+
const descriptor = registry.getDefinition(moduleId);
|
|
70
82
|
if (descriptor === null) {
|
|
71
|
-
console.warn(`Skipping module "${moduleId}":
|
|
83
|
+
console.warn(`Skipping module "${moduleId}": getDefinition returned null`);
|
|
72
84
|
continue;
|
|
73
85
|
}
|
|
74
86
|
tools.push(this.buildTool(descriptor));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/server/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAO5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAU9D,MAAM,OAAO,gBAAgB;IACV,gBAAgB,CAAkB;IAClC,iBAAiB,CAAmB;IAErD;QACE,IAAI,CAAC,gBAAgB,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,IAAI,CAAC,iBAAiB,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAClD,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CACV,OAAe,YAAY,EAC3B,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AAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;YAED,MAAM,MAAM,GAAmB;gBAC7B,OAAO,EAAE,OAAwB;gBACjC,OAAO,EAAE,KAAK;aACf,CAAC;YAEF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../src/server/listener.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../src/server/listener.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,OAAO,CAAU;IAEzB;;;;;OAKG;gBACS,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB;IAOzD;;;;OAIG;IACH,IAAI,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAE7B;IAED;;;;;OAKG;IACH,KAAK,IAAI,IAAI;IAoBb;;;;OAIG;IACH,IAAI,IAAI,IAAI;IAIZ;;;;;;;OAOG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAsBnC;;;;;;OAMG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAItC"}
|
package/dist/server/listener.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Subscribes to a Registry's "register" and "unregister" events to
|
|
5
5
|
* dynamically maintain a map of MCP Tool objects as modules come and go.
|
|
6
6
|
*/
|
|
7
|
+
import { REGISTRY_EVENTS } from "../types.js";
|
|
7
8
|
export class RegistryListener {
|
|
8
9
|
_registry;
|
|
9
10
|
_factory;
|
|
@@ -40,13 +41,13 @@ export class RegistryListener {
|
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
43
|
this._active = true;
|
|
43
|
-
this._registry.on(
|
|
44
|
+
this._registry.on(REGISTRY_EVENTS.REGISTER, (...args) => {
|
|
44
45
|
if (!this._active)
|
|
45
46
|
return;
|
|
46
47
|
const moduleId = args[0];
|
|
47
48
|
this._onRegister(moduleId);
|
|
48
49
|
});
|
|
49
|
-
this._registry.on(
|
|
50
|
+
this._registry.on(REGISTRY_EVENTS.UNREGISTER, (...args) => {
|
|
50
51
|
if (!this._active)
|
|
51
52
|
return;
|
|
52
53
|
const moduleId = args[0];
|
|
@@ -71,7 +72,7 @@ export class RegistryListener {
|
|
|
71
72
|
*/
|
|
72
73
|
_onRegister(moduleId) {
|
|
73
74
|
try {
|
|
74
|
-
const descriptor = this._registry.
|
|
75
|
+
const descriptor = this._registry.getDefinition(moduleId);
|
|
75
76
|
if (descriptor === null) {
|
|
76
77
|
console.warn(`RegistryListener: cannot build tool for "${moduleId}": definition is null`);
|
|
77
78
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listener.js","sourceRoot":"","sources":["../../src/server/listener.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"listener.js","sourceRoot":"","sources":["../../src/server/listener.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C,MAAM,OAAO,gBAAgB;IACV,SAAS,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QAC1B,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAC1D,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;gBACxB,OAAO,CAAC,IAAI,CACV,4CAA4C,QAAQ,uBAAuB,CAC5E,CAAC;gBACF,OAAO;YACT,CAAC;YAED,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YACjD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,sCAAsC,QAAQ,GAAG,CAAC,CAAC;QACjE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CACV,8CAA8C,QAAQ,MACpD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,QAAgB;QAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,wCAAwC,QAAQ,GAAG,CAAC,CAAC;IACnE,CAAC;CACF"}
|
package/dist/server/router.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ExecutionRouter - Routes MCP tool calls to apcore module execution.
|
|
3
3
|
*
|
|
4
|
-
* Bridges the MCP tools/call protocol with apcore's Executor.
|
|
4
|
+
* Bridges the MCP tools/call protocol with apcore's Executor.call() or callAsync(),
|
|
5
5
|
* handling success/error formatting for MCP text content responses.
|
|
6
6
|
*/
|
|
7
7
|
import type { Executor, TextContentDict } from "../types.js";
|
|
@@ -13,13 +13,15 @@ export declare class ExecutionRouter {
|
|
|
13
13
|
/**
|
|
14
14
|
* Create an ExecutionRouter.
|
|
15
15
|
*
|
|
16
|
-
* @param executor - Duck-typed executor with
|
|
16
|
+
* @param executor - Duck-typed executor with call(moduleId, inputs) or callAsync(moduleId, inputs)
|
|
17
17
|
*/
|
|
18
18
|
constructor(executor: Executor);
|
|
19
19
|
/**
|
|
20
20
|
* Handle an MCP tools/call request by routing to the executor.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* Tries executor.call() first, then falls back to executor.callAsync().
|
|
23
|
+
*
|
|
24
|
+
* @param toolName - The MCP tool name (maps to apcore moduleId)
|
|
23
25
|
* @param args - The tool call arguments
|
|
24
26
|
* @returns Tuple of [content, isError] where content is an array of text content dicts
|
|
25
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/server/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;AAEtD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAE3C;;;;OAIG;gBACS,QAAQ,EAAE,QAAQ;IAK9B
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/server/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;AAEtD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAE3C;;;;OAIG;gBACS,QAAQ,EAAE,QAAQ;IAK9B;;;;;;;;OAQG;IACG,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,UAAU,CAAC;CA+BvB"}
|
package/dist/server/router.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ExecutionRouter - Routes MCP tool calls to apcore module execution.
|
|
3
3
|
*
|
|
4
|
-
* Bridges the MCP tools/call protocol with apcore's Executor.
|
|
4
|
+
* Bridges the MCP tools/call protocol with apcore's Executor.call() or callAsync(),
|
|
5
5
|
* handling success/error formatting for MCP text content responses.
|
|
6
6
|
*/
|
|
7
7
|
import { ErrorMapper } from "../adapters/errors.js";
|
|
@@ -11,7 +11,7 @@ export class ExecutionRouter {
|
|
|
11
11
|
/**
|
|
12
12
|
* Create an ExecutionRouter.
|
|
13
13
|
*
|
|
14
|
-
* @param executor - Duck-typed executor with
|
|
14
|
+
* @param executor - Duck-typed executor with call(moduleId, inputs) or callAsync(moduleId, inputs)
|
|
15
15
|
*/
|
|
16
16
|
constructor(executor) {
|
|
17
17
|
this._executor = executor;
|
|
@@ -20,13 +20,21 @@ export class ExecutionRouter {
|
|
|
20
20
|
/**
|
|
21
21
|
* Handle an MCP tools/call request by routing to the executor.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* Tries executor.call() first, then falls back to executor.callAsync().
|
|
24
|
+
*
|
|
25
|
+
* @param toolName - The MCP tool name (maps to apcore moduleId)
|
|
24
26
|
* @param args - The tool call arguments
|
|
25
27
|
* @returns Tuple of [content, isError] where content is an array of text content dicts
|
|
26
28
|
*/
|
|
27
29
|
async handleCall(toolName, args) {
|
|
28
30
|
try {
|
|
29
|
-
const
|
|
31
|
+
const callFn = this._executor.call
|
|
32
|
+
? this._executor.call.bind(this._executor)
|
|
33
|
+
: this._executor.callAsync?.bind(this._executor);
|
|
34
|
+
if (!callFn) {
|
|
35
|
+
throw new Error("Executor must implement call() or callAsync()");
|
|
36
|
+
}
|
|
37
|
+
const result = await callFn(toolName, args);
|
|
30
38
|
const content = [
|
|
31
39
|
{
|
|
32
40
|
type: "text",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/server/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMpD,MAAM,OAAO,eAAe;IACT,SAAS,CAAW;IACpB,YAAY,CAAc;IAE3C;;;;OAIG;IACH,YAAY,QAAkB;QAC5B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,YAAY,GAAG,IAAI,WAAW,EAAE,CAAC;IACxC,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/server/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMpD,MAAM,OAAO,eAAe;IACT,SAAS,CAAW;IACpB,YAAY,CAAc;IAE3C;;;;OAIG;IACH,YAAY,QAAkB;QAC5B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,YAAY,GAAG,IAAI,WAAW,EAAE,CAAC;IACxC,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,UAAU,CACd,QAAgB,EAChB,IAA6B;QAE7B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI;gBAChC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;gBAC1C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACnD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;YACnE,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAE5C,MAAM,OAAO,GAAsB;gBACjC;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;iBAC7B;aACF,CAAC;YAEF,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAEtD,MAAM,OAAO,GAAsB;gBACjC;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,SAAS,CAAC,OAAO;iBACxB;aACF,CAAC;YAEF,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/server/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAsC,KAAK,MAAM,IAAI,UAAU,EAAuB,MAAM,WAAW,CAAC;AAC/G,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKxE,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/server/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAsC,KAAK,MAAM,IAAI,UAAU,EAAuB,MAAM,WAAW,CAAC;AAC/G,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKxE,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA+CD,qBAAa,gBAAgB;IAC3B,wEAAwE;IACxE,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;;;;;;OAOG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7C;;;;;;;;OAQG;IACG,iBAAiB,CACrB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;IAuDhB;;;;;;;;;OASG;IACG,MAAM,CACV,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;IAuEhB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B;;;;;;OAMG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAcpD"}
|
package/dist/server/transport.js
CHANGED
|
@@ -10,15 +10,51 @@ import { createServer } from "node:http";
|
|
|
10
10
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
11
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
12
12
|
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
13
|
+
/** Default maximum request body size in bytes (4MB). */
|
|
14
|
+
const DEFAULT_MAX_BODY_BYTES = 4 * 1024 * 1024;
|
|
15
|
+
/** Maximum request body size in bytes. Configurable via APCORE_MAX_BODY_BYTES env var. */
|
|
16
|
+
const MAX_BODY_BYTES = (() => {
|
|
17
|
+
const env = process.env.APCORE_MAX_BODY_BYTES;
|
|
18
|
+
if (env === undefined)
|
|
19
|
+
return DEFAULT_MAX_BODY_BYTES;
|
|
20
|
+
const parsed = Number.parseInt(env, 10);
|
|
21
|
+
if (!Number.isFinite(parsed) || parsed <= 0)
|
|
22
|
+
return DEFAULT_MAX_BODY_BYTES;
|
|
23
|
+
return parsed;
|
|
24
|
+
})();
|
|
13
25
|
/**
|
|
14
26
|
* Read the full request body as a string.
|
|
27
|
+
*
|
|
28
|
+
* Enforces a maximum byte size to prevent memory exhaustion.
|
|
29
|
+
* @param req - The incoming HTTP request
|
|
30
|
+
* @param maxBytes - Maximum allowed body size in bytes (default: MAX_BODY_BYTES)
|
|
15
31
|
*/
|
|
16
|
-
function readBody(req) {
|
|
32
|
+
function readBody(req, maxBytes = MAX_BODY_BYTES) {
|
|
17
33
|
return new Promise((resolve, reject) => {
|
|
18
34
|
let data = "";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
req.on("
|
|
35
|
+
let bytes = 0;
|
|
36
|
+
let rejected = false;
|
|
37
|
+
req.on("data", (chunk) => {
|
|
38
|
+
if (rejected)
|
|
39
|
+
return;
|
|
40
|
+
bytes += chunk.length;
|
|
41
|
+
if (bytes > maxBytes) {
|
|
42
|
+
rejected = true;
|
|
43
|
+
// Resume to drain remaining data, allowing the response to be sent
|
|
44
|
+
req.resume();
|
|
45
|
+
reject(new Error("Request body too large"));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
data += chunk.toString();
|
|
49
|
+
});
|
|
50
|
+
req.on("end", () => {
|
|
51
|
+
if (!rejected)
|
|
52
|
+
resolve(data);
|
|
53
|
+
});
|
|
54
|
+
req.on("error", (err) => {
|
|
55
|
+
if (!rejected)
|
|
56
|
+
reject(err);
|
|
57
|
+
});
|
|
22
58
|
});
|
|
23
59
|
}
|
|
24
60
|
export class TransportManager {
|
|
@@ -70,7 +106,16 @@ export class TransportManager {
|
|
|
70
106
|
}
|
|
71
107
|
catch (err) {
|
|
72
108
|
if (!res.headersSent) {
|
|
73
|
-
|
|
109
|
+
const message = err instanceof Error ? err.message : "";
|
|
110
|
+
if (message === "Request body too large") {
|
|
111
|
+
res.writeHead(413).end("Request Entity Too Large");
|
|
112
|
+
}
|
|
113
|
+
else if (err instanceof SyntaxError) {
|
|
114
|
+
res.writeHead(400).end("Bad Request");
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
res.writeHead(500).end("Internal Server Error");
|
|
118
|
+
}
|
|
74
119
|
}
|
|
75
120
|
}
|
|
76
121
|
});
|
|
@@ -131,7 +176,16 @@ export class TransportManager {
|
|
|
131
176
|
}
|
|
132
177
|
catch (err) {
|
|
133
178
|
if (!res.headersSent) {
|
|
134
|
-
|
|
179
|
+
const message = err instanceof Error ? err.message : "";
|
|
180
|
+
if (message === "Request body too large") {
|
|
181
|
+
res.writeHead(413).end("Request Entity Too Large");
|
|
182
|
+
}
|
|
183
|
+
else if (err instanceof SyntaxError) {
|
|
184
|
+
res.writeHead(400).end("Bad Request");
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
res.writeHead(500).end("Internal Server Error");
|
|
188
|
+
}
|
|
135
189
|
}
|
|
136
190
|
}
|
|
137
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/server/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAwE,MAAM,WAAW,CAAC;AAE/G,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAS7E
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/server/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAwE,MAAM,WAAW,CAAC;AAE/G,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,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CAAC;gBACF,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;QAE7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,CAAC,UAAW,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,iBAAiB,CAAC,IAAY,EAAE,IAAY;QAC1C,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,IACE,OAAO,IAAI,KAAK,QAAQ;YACxB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;YACvB,IAAI,GAAG,CAAC;YACR,IAAI,GAAG,KAAK,EACZ,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,73 +1,82 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* APCore MCP Bridge — Type Definitions
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* concrete classes, we decouple from the apcore package at compile time.
|
|
4
|
+
* All interfaces use camelCase to match apcore-typescript conventions.
|
|
5
|
+
* The protocol spec uses snake_case as canonical; this file maps to TypeScript idioms.
|
|
7
6
|
*/
|
|
8
|
-
/** JSON Schema type alias */
|
|
9
7
|
export type JsonSchema = Record<string, unknown>;
|
|
10
|
-
|
|
8
|
+
export type RegistryOrExecutor = Registry | Executor;
|
|
9
|
+
/** Standard registry event names. */
|
|
10
|
+
export declare const REGISTRY_EVENTS: Readonly<{
|
|
11
|
+
readonly REGISTER: "register";
|
|
12
|
+
readonly UNREGISTER: "unregister";
|
|
13
|
+
}>;
|
|
14
|
+
/** Framework error codes used by ErrorMapper. */
|
|
15
|
+
export declare const ErrorCodes: Readonly<{
|
|
16
|
+
readonly MODULE_NOT_FOUND: "MODULE_NOT_FOUND";
|
|
17
|
+
readonly SCHEMA_VALIDATION_ERROR: "SCHEMA_VALIDATION_ERROR";
|
|
18
|
+
readonly ACL_DENIED: "ACL_DENIED";
|
|
19
|
+
readonly CALL_DEPTH_EXCEEDED: "CALL_DEPTH_EXCEEDED";
|
|
20
|
+
readonly CIRCULAR_CALL: "CIRCULAR_CALL";
|
|
21
|
+
readonly CALL_FREQUENCY_EXCEEDED: "CALL_FREQUENCY_EXCEEDED";
|
|
22
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
23
|
+
readonly MODULE_TIMEOUT: "MODULE_TIMEOUT";
|
|
24
|
+
readonly MODULE_LOAD_ERROR: "MODULE_LOAD_ERROR";
|
|
25
|
+
readonly MODULE_EXECUTE_ERROR: "MODULE_EXECUTE_ERROR";
|
|
26
|
+
readonly GENERAL_INVALID_INPUT: "GENERAL_INVALID_INPUT";
|
|
27
|
+
}>;
|
|
28
|
+
/** Valid module ID pattern. No hyphens allowed. */
|
|
29
|
+
export declare const MODULE_ID_PATTERN: RegExp;
|
|
11
30
|
export interface ModuleAnnotations {
|
|
12
31
|
readonly: boolean;
|
|
13
32
|
destructive: boolean;
|
|
14
33
|
idempotent: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
34
|
+
requiresApproval: boolean;
|
|
35
|
+
openWorld: boolean;
|
|
17
36
|
}
|
|
18
|
-
/** Module descriptor from apcore */
|
|
19
37
|
export interface ModuleDescriptor {
|
|
20
|
-
|
|
38
|
+
moduleId: string;
|
|
21
39
|
description: string;
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
inputSchema: JsonSchema;
|
|
41
|
+
outputSchema: JsonSchema;
|
|
24
42
|
annotations: ModuleAnnotations | null;
|
|
25
|
-
name?: string | null;
|
|
26
43
|
documentation?: string | null;
|
|
27
44
|
tags?: string[];
|
|
28
45
|
version?: string;
|
|
29
46
|
examples?: unknown[];
|
|
30
47
|
}
|
|
31
|
-
/** apcore Registry interface (duck-typed) */
|
|
32
48
|
export interface Registry {
|
|
33
49
|
list(options?: {
|
|
34
50
|
tags?: string[] | null;
|
|
35
51
|
prefix?: string | null;
|
|
36
52
|
}): string[];
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
getDefinition(moduleId: string): ModuleDescriptor | null;
|
|
54
|
+
has?(moduleId: string): boolean;
|
|
39
55
|
on(event: string, callback: (...args: unknown[]) => void): void;
|
|
40
56
|
discover?(): number;
|
|
41
57
|
}
|
|
42
|
-
/** apcore Executor interface (duck-typed) */
|
|
43
58
|
export interface Executor {
|
|
44
59
|
registry: Registry;
|
|
45
|
-
call(
|
|
46
|
-
|
|
60
|
+
call(moduleId: string, inputs: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
61
|
+
callAsync?(moduleId: string, inputs: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
47
62
|
}
|
|
48
|
-
/** Accept either Registry or Executor */
|
|
49
|
-
export type RegistryOrExecutor = Registry | Executor;
|
|
50
|
-
/** apcore ModuleError interface (duck-typed) */
|
|
51
63
|
export interface ModuleError extends Error {
|
|
52
64
|
code: string;
|
|
53
65
|
details: Record<string, unknown> | null;
|
|
54
66
|
}
|
|
55
|
-
/** MCP annotations dict returned by AnnotationMapper */
|
|
56
67
|
export interface McpAnnotationsDict {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
readOnlyHint: boolean;
|
|
69
|
+
destructiveHint: boolean;
|
|
70
|
+
idempotentHint: boolean;
|
|
71
|
+
openWorldHint: boolean;
|
|
61
72
|
title: string | null;
|
|
62
73
|
}
|
|
63
|
-
/** MCP error response from ErrorMapper */
|
|
64
74
|
export interface McpErrorResponse {
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
isError: true;
|
|
76
|
+
errorType: string;
|
|
67
77
|
message: string;
|
|
68
78
|
details: Record<string, unknown> | null;
|
|
69
79
|
}
|
|
70
|
-
/** OpenAI tool definition */
|
|
71
80
|
export interface OpenAIToolDef {
|
|
72
81
|
type: "function";
|
|
73
82
|
function: {
|
|
@@ -77,7 +86,6 @@ export interface OpenAIToolDef {
|
|
|
77
86
|
strict?: boolean;
|
|
78
87
|
};
|
|
79
88
|
}
|
|
80
|
-
/** Text content for MCP responses */
|
|
81
89
|
export interface TextContentDict {
|
|
82
90
|
type: "text";
|
|
83
91
|
text: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjD,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAIrD,qCAAqC;AACrC,eAAO,MAAM,eAAe;;;EAGjB,CAAC;AAEZ,iDAAiD;AACjD,eAAO,MAAM,UAAU;;;;;;;;;;;;EAYZ,CAAC;AAEZ,mDAAmD;AACnD,eAAO,MAAM,iBAAiB,QAA0C,CAAC;AAIzE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IAC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EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACzC;AAID,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACzC;AAID,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,UAAU,CAAC;QACvB,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;CACH;AAID,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/dist/types.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* APCore MCP Bridge — Type Definitions
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* concrete classes, we decouple from the apcore package at compile time.
|
|
4
|
+
* All interfaces use camelCase to match apcore-typescript conventions.
|
|
5
|
+
* The protocol spec uses snake_case as canonical; this file maps to TypeScript idioms.
|
|
7
6
|
*/
|
|
8
|
-
|
|
7
|
+
// ─── Constants ───────────────────────────────────────────────────────────────
|
|
8
|
+
/** Standard registry event names. */
|
|
9
|
+
export const REGISTRY_EVENTS = Object.freeze({
|
|
10
|
+
REGISTER: "register",
|
|
11
|
+
UNREGISTER: "unregister",
|
|
12
|
+
});
|
|
13
|
+
/** Framework error codes used by ErrorMapper. */
|
|
14
|
+
export const ErrorCodes = Object.freeze({
|
|
15
|
+
MODULE_NOT_FOUND: "MODULE_NOT_FOUND",
|
|
16
|
+
SCHEMA_VALIDATION_ERROR: "SCHEMA_VALIDATION_ERROR",
|
|
17
|
+
ACL_DENIED: "ACL_DENIED",
|
|
18
|
+
CALL_DEPTH_EXCEEDED: "CALL_DEPTH_EXCEEDED",
|
|
19
|
+
CIRCULAR_CALL: "CIRCULAR_CALL",
|
|
20
|
+
CALL_FREQUENCY_EXCEEDED: "CALL_FREQUENCY_EXCEEDED",
|
|
21
|
+
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
22
|
+
MODULE_TIMEOUT: "MODULE_TIMEOUT",
|
|
23
|
+
MODULE_LOAD_ERROR: "MODULE_LOAD_ERROR",
|
|
24
|
+
MODULE_EXECUTE_ERROR: "MODULE_EXECUTE_ERROR",
|
|
25
|
+
GENERAL_INVALID_INPUT: "GENERAL_INVALID_INPUT",
|
|
26
|
+
});
|
|
27
|
+
/** Valid module ID pattern. No hyphens allowed. */
|
|
28
|
+
export const MODULE_ID_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/;
|
|
9
29
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,gFAAgF;AAEhF,qCAAqC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;CAChB,CAAC,CAAC;AAEZ,iDAAiD;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IACtC,gBAAgB,EAAE,kBAAkB;IACpC,uBAAuB,EAAE,yBAAyB;IAClD,UAAU,EAAE,YAAY;IACxB,mBAAmB,EAAE,qBAAqB;IAC1C,aAAa,EAAE,eAAe;IAC9B,uBAAuB,EAAE,yBAAyB;IAClD,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,iBAAiB,EAAE,mBAAmB;IACtC,oBAAoB,EAAE,sBAAsB;IAC5C,qBAAqB,EAAE,uBAAuB;CACtC,CAAC,CAAC;AAEZ,mDAAmD;AACnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,uCAAuC,CAAC"}
|