@kya-os/mcp-i 1.2.6 → 1.2.8
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/compiler/compiler-context.d.ts +2 -0
- package/dist/compiler/config/index.d.ts +33 -0
- package/dist/compiler/config/index.js +1 -0
- package/dist/compiler/config/injection.d.ts +5 -1
- package/dist/compiler/config/injection.js +47 -8
- package/dist/compiler/config/schemas/identity.d.ts +24 -0
- package/dist/compiler/config/schemas/identity.js +22 -0
- package/dist/compiler/config/schemas/index.d.ts +1 -0
- package/dist/compiler/config/schemas/index.js +3 -1
- package/dist/compiler/get-webpack-config/get-injected-variables.js +3 -1
- package/dist/compiler/get-webpack-config/index.js +1 -1
- package/dist/compiler/get-webpack-config/plugins.js +3 -3
- package/dist/compiler/index.js +1 -0
- package/dist/runtime/adapter-express.js +1 -1
- package/dist/runtime/adapter-nextjs.js +1 -1
- package/dist/runtime/adapters/nextjs/index.js +6 -1
- package/dist/runtime/demo.js +3 -3
- package/dist/runtime/http.js +1 -1
- package/dist/runtime/identity.js +16 -4
- package/dist/runtime/mcpi-runtime.d.ts +1 -1
- package/dist/runtime/mcpi-runtime.js +7 -7
- package/dist/runtime/stdio.js +1 -1
- package/dist/runtime/transports/stdio/index.js +3 -3
- package/dist/runtime/utils/server.d.ts +9 -7
- package/dist/runtime/utils/server.js +51 -10
- package/dist/runtime/utils/tools.d.ts +18 -1
- package/dist/runtime/utils/tools.js +93 -2
- package/package.json +1 -1
|
@@ -3,6 +3,8 @@ import { XmcpConfigOuputSchema } from "./config";
|
|
|
3
3
|
interface CompilerContext {
|
|
4
4
|
/** The mode of the compiler. */
|
|
5
5
|
mode: CompilerMode;
|
|
6
|
+
/** The project root directory (absolute path). */
|
|
7
|
+
projectRoot: string;
|
|
6
8
|
/** Whether the adapter is enabled. */
|
|
7
9
|
adapter?: boolean;
|
|
8
10
|
/** The platforms to build for. */
|
|
@@ -163,6 +163,25 @@ export declare const configSchema: z.ZodObject<{
|
|
|
163
163
|
tools?: string | undefined;
|
|
164
164
|
}>>;
|
|
165
165
|
webpack: z.ZodOptional<z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodAny>>>;
|
|
166
|
+
identity: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
167
|
+
enabled: z.ZodBoolean;
|
|
168
|
+
environment: z.ZodOptional<z.ZodEnum<["development", "production"]>>;
|
|
169
|
+
devIdentityPath: z.ZodOptional<z.ZodString>;
|
|
170
|
+
privacyMode: z.ZodOptional<z.ZodBoolean>;
|
|
171
|
+
debug: z.ZodOptional<z.ZodBoolean>;
|
|
172
|
+
}, "strip", z.ZodTypeAny, {
|
|
173
|
+
enabled: boolean;
|
|
174
|
+
debug?: boolean | undefined;
|
|
175
|
+
environment?: "development" | "production" | undefined;
|
|
176
|
+
devIdentityPath?: string | undefined;
|
|
177
|
+
privacyMode?: boolean | undefined;
|
|
178
|
+
}, {
|
|
179
|
+
enabled: boolean;
|
|
180
|
+
debug?: boolean | undefined;
|
|
181
|
+
environment?: "development" | "production" | undefined;
|
|
182
|
+
devIdentityPath?: string | undefined;
|
|
183
|
+
privacyMode?: boolean | undefined;
|
|
184
|
+
}>>>;
|
|
166
185
|
}, "strip", z.ZodTypeAny, {
|
|
167
186
|
stdio?: boolean | {
|
|
168
187
|
debug: boolean;
|
|
@@ -203,6 +222,13 @@ export declare const configSchema: z.ZodObject<{
|
|
|
203
222
|
tools: string;
|
|
204
223
|
} | undefined;
|
|
205
224
|
webpack?: ((args_0: any, ...args: unknown[]) => any) | undefined;
|
|
225
|
+
identity?: {
|
|
226
|
+
enabled: boolean;
|
|
227
|
+
debug?: boolean | undefined;
|
|
228
|
+
environment?: "development" | "production" | undefined;
|
|
229
|
+
devIdentityPath?: string | undefined;
|
|
230
|
+
privacyMode?: boolean | undefined;
|
|
231
|
+
} | undefined;
|
|
206
232
|
}, {
|
|
207
233
|
stdio?: boolean | {
|
|
208
234
|
debug?: boolean | undefined;
|
|
@@ -243,6 +269,13 @@ export declare const configSchema: z.ZodObject<{
|
|
|
243
269
|
tools?: string | undefined;
|
|
244
270
|
} | undefined;
|
|
245
271
|
webpack?: ((args_0: any, ...args: unknown[]) => any) | undefined;
|
|
272
|
+
identity?: {
|
|
273
|
+
enabled: boolean;
|
|
274
|
+
debug?: boolean | undefined;
|
|
275
|
+
environment?: "development" | "production" | undefined;
|
|
276
|
+
devIdentityPath?: string | undefined;
|
|
277
|
+
privacyMode?: boolean | undefined;
|
|
278
|
+
} | undefined;
|
|
246
279
|
}>;
|
|
247
280
|
type WebpackConfig = {
|
|
248
281
|
webpack?: (config: Configuration) => Configuration;
|
|
@@ -12,4 +12,5 @@ exports.configSchema = zod_1.z.object({
|
|
|
12
12
|
experimental: schemas_1.experimentalConfigSchema.optional(),
|
|
13
13
|
paths: schemas_1.pathsConfigSchema.optional(),
|
|
14
14
|
webpack: schemas_1.webpackConfigSchema.optional(),
|
|
15
|
+
identity: schemas_1.identityConfigSchema.optional(),
|
|
15
16
|
});
|
|
@@ -23,4 +23,8 @@ export declare function injectStdioVariables(stdioConfig: any): {
|
|
|
23
23
|
STDIO_CONFIG: string;
|
|
24
24
|
};
|
|
25
25
|
export type StdioVariables = ReturnType<typeof injectStdioVariables>;
|
|
26
|
-
export
|
|
26
|
+
export declare function injectIdentityVariables(identityConfig: any, mode: string, projectRoot: string): {
|
|
27
|
+
IDENTITY_CONFIG: string;
|
|
28
|
+
};
|
|
29
|
+
export type IdentityVariables = ReturnType<typeof injectIdentityVariables>;
|
|
30
|
+
export type InjectedVariables = HttpVariables | CorsVariables | OAuthVariables | PathsVariables | StdioVariables | IdentityVariables;
|
|
@@ -5,54 +5,93 @@ exports.injectCorsVariables = injectCorsVariables;
|
|
|
5
5
|
exports.injectOAuthVariables = injectOAuthVariables;
|
|
6
6
|
exports.injectPathsVariables = injectPathsVariables;
|
|
7
7
|
exports.injectStdioVariables = injectStdioVariables;
|
|
8
|
+
exports.injectIdentityVariables = injectIdentityVariables;
|
|
8
9
|
const utils_1 = require("./utils");
|
|
9
10
|
function injectHttpVariables(httpConfig, mode) {
|
|
10
11
|
const resolvedConfig = (0, utils_1.getResolvedHttpConfig)(httpConfig);
|
|
11
12
|
if (!resolvedConfig)
|
|
12
13
|
return {};
|
|
14
|
+
// Double-stringify for webpack DefinePlugin - it replaces the variable with the raw value,
|
|
15
|
+
// so we need to stringify twice to inject an actual string literal
|
|
13
16
|
return {
|
|
14
|
-
HTTP_CONFIG: JSON.stringify({
|
|
17
|
+
HTTP_CONFIG: JSON.stringify(JSON.stringify({
|
|
15
18
|
port: resolvedConfig.port,
|
|
16
19
|
host: resolvedConfig.host,
|
|
17
20
|
bodySizeLimit: resolvedConfig.bodySizeLimit,
|
|
18
21
|
endpoint: resolvedConfig.endpoint,
|
|
19
22
|
stateless: true,
|
|
20
23
|
debug: mode === "development",
|
|
21
|
-
}),
|
|
24
|
+
})),
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
27
|
function injectCorsVariables(httpConfig) {
|
|
25
28
|
const corsConfig = (0, utils_1.getResolvedCorsConfig)(httpConfig);
|
|
29
|
+
// Double-stringify for webpack DefinePlugin
|
|
26
30
|
return {
|
|
27
|
-
HTTP_CORS_CONFIG: JSON.stringify({
|
|
31
|
+
HTTP_CORS_CONFIG: JSON.stringify(JSON.stringify({
|
|
28
32
|
origin: corsConfig.origin ?? "",
|
|
29
33
|
methods: corsConfig.methods ?? "",
|
|
30
34
|
allowedHeaders: corsConfig.allowedHeaders ?? "",
|
|
31
35
|
exposedHeaders: corsConfig.exposedHeaders ?? "",
|
|
32
36
|
credentials: corsConfig.credentials ?? false,
|
|
33
37
|
maxAge: corsConfig.maxAge ?? 0,
|
|
34
|
-
}),
|
|
38
|
+
})),
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
41
|
function injectOAuthVariables(userConfig) {
|
|
38
42
|
const oauthConfig = (0, utils_1.getResolvedOAuthConfig)(userConfig);
|
|
43
|
+
// Double-stringify for webpack DefinePlugin
|
|
39
44
|
return {
|
|
40
|
-
OAUTH_CONFIG: JSON.stringify(oauthConfig),
|
|
45
|
+
OAUTH_CONFIG: JSON.stringify(JSON.stringify(oauthConfig)),
|
|
41
46
|
};
|
|
42
47
|
}
|
|
43
48
|
function injectPathsVariables(userConfig) {
|
|
44
49
|
const pathsConfig = (0, utils_1.getResolvedPathsConfig)(userConfig);
|
|
50
|
+
// Double-stringify for webpack DefinePlugin
|
|
45
51
|
return {
|
|
46
|
-
TOOLS_PATH: JSON.stringify(pathsConfig.tools),
|
|
52
|
+
TOOLS_PATH: JSON.stringify(JSON.stringify(pathsConfig.tools)),
|
|
47
53
|
};
|
|
48
54
|
}
|
|
49
55
|
function injectStdioVariables(stdioConfig) {
|
|
50
56
|
if (!stdioConfig)
|
|
51
57
|
return {};
|
|
52
58
|
const debug = typeof stdioConfig === "object" ? stdioConfig.debug : false;
|
|
59
|
+
// Double-stringify for webpack DefinePlugin
|
|
53
60
|
return {
|
|
54
|
-
STDIO_CONFIG: JSON.stringify({
|
|
61
|
+
STDIO_CONFIG: JSON.stringify(JSON.stringify({
|
|
55
62
|
debug,
|
|
56
|
-
}),
|
|
63
|
+
})),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function injectIdentityVariables(identityConfig, mode, projectRoot) {
|
|
67
|
+
if (!identityConfig || !identityConfig.enabled) {
|
|
68
|
+
// Double-stringify for webpack DefinePlugin
|
|
69
|
+
return {
|
|
70
|
+
IDENTITY_CONFIG: JSON.stringify(JSON.stringify({
|
|
71
|
+
enabled: false,
|
|
72
|
+
})),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// Resolve devIdentityPath to absolute path at compile time
|
|
76
|
+
// This ensures the bundle can find the identity file regardless of CWD at runtime
|
|
77
|
+
const path = require("path");
|
|
78
|
+
const devIdentityPath = identityConfig.devIdentityPath || ".mcpi/identity.json";
|
|
79
|
+
const absoluteIdentityPath = path.isAbsolute(devIdentityPath)
|
|
80
|
+
? devIdentityPath
|
|
81
|
+
: path.join(projectRoot, devIdentityPath);
|
|
82
|
+
// Debug: log the resolved path
|
|
83
|
+
console.log("[COMPILER] Identity path resolution:");
|
|
84
|
+
console.log(" projectRoot:", projectRoot);
|
|
85
|
+
console.log(" devIdentityPath:", devIdentityPath);
|
|
86
|
+
console.log(" absoluteIdentityPath:", absoluteIdentityPath);
|
|
87
|
+
// Double-stringify for webpack DefinePlugin
|
|
88
|
+
return {
|
|
89
|
+
IDENTITY_CONFIG: JSON.stringify(JSON.stringify({
|
|
90
|
+
enabled: true,
|
|
91
|
+
environment: identityConfig.environment || mode,
|
|
92
|
+
devIdentityPath: absoluteIdentityPath,
|
|
93
|
+
privacyMode: identityConfig.privacyMode || false,
|
|
94
|
+
debug: identityConfig.debug || mode === "development",
|
|
95
|
+
})),
|
|
57
96
|
};
|
|
58
97
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Identity configuration schema
|
|
4
|
+
*/
|
|
5
|
+
export declare const identityConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
6
|
+
enabled: z.ZodBoolean;
|
|
7
|
+
environment: z.ZodOptional<z.ZodEnum<["development", "production"]>>;
|
|
8
|
+
devIdentityPath: z.ZodOptional<z.ZodString>;
|
|
9
|
+
privacyMode: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
debug: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
debug?: boolean | undefined;
|
|
14
|
+
environment?: "development" | "production" | undefined;
|
|
15
|
+
devIdentityPath?: string | undefined;
|
|
16
|
+
privacyMode?: boolean | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
debug?: boolean | undefined;
|
|
20
|
+
environment?: "development" | "production" | undefined;
|
|
21
|
+
devIdentityPath?: string | undefined;
|
|
22
|
+
privacyMode?: boolean | undefined;
|
|
23
|
+
}>>;
|
|
24
|
+
export type IdentityConfig = z.infer<typeof identityConfigSchema>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.identityConfigSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Identity configuration schema
|
|
7
|
+
*/
|
|
8
|
+
exports.identityConfigSchema = zod_1.z
|
|
9
|
+
.object({
|
|
10
|
+
enabled: zod_1.z.boolean().describe("Enable MCP-I identity layer"),
|
|
11
|
+
environment: zod_1.z
|
|
12
|
+
.enum(["development", "production"])
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Runtime environment"),
|
|
15
|
+
devIdentityPath: zod_1.z.string().optional().describe("Custom identity file path"),
|
|
16
|
+
privacyMode: zod_1.z
|
|
17
|
+
.boolean()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Enable privacy mode (per-client DIDs)"),
|
|
20
|
+
debug: zod_1.z.boolean().optional().describe("Enable debug logging for identity"),
|
|
21
|
+
})
|
|
22
|
+
.optional();
|
|
@@ -4,3 +4,4 @@ export { oauthConfigSchema, type OAuthConfig } from "./experimental/oauth";
|
|
|
4
4
|
export { experimentalConfigSchema, type ExperimentalConfig, } from "./experimental";
|
|
5
5
|
export { pathsConfigSchema, type PathsConfig } from "./paths";
|
|
6
6
|
export { webpackConfigSchema, type WebpackConfig } from "./webpack";
|
|
7
|
+
export { identityConfigSchema, type IdentityConfig } from "./identity";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.webpackConfigSchema = exports.pathsConfigSchema = exports.experimentalConfigSchema = exports.oauthConfigSchema = exports.stdioTransportConfigSchema = exports.corsConfigSchema = exports.httpTransportConfigSchema = void 0;
|
|
3
|
+
exports.identityConfigSchema = exports.webpackConfigSchema = exports.pathsConfigSchema = exports.experimentalConfigSchema = exports.oauthConfigSchema = exports.stdioTransportConfigSchema = exports.corsConfigSchema = exports.httpTransportConfigSchema = void 0;
|
|
4
4
|
// re export
|
|
5
5
|
var http_1 = require("./transport/http");
|
|
6
6
|
Object.defineProperty(exports, "httpTransportConfigSchema", { enumerable: true, get: function () { return http_1.httpTransportConfigSchema; } });
|
|
@@ -15,3 +15,5 @@ var paths_1 = require("./paths");
|
|
|
15
15
|
Object.defineProperty(exports, "pathsConfigSchema", { enumerable: true, get: function () { return paths_1.pathsConfigSchema; } });
|
|
16
16
|
var webpack_1 = require("./webpack");
|
|
17
17
|
Object.defineProperty(exports, "webpackConfigSchema", { enumerable: true, get: function () { return webpack_1.webpackConfigSchema; } });
|
|
18
|
+
var identity_1 = require("./identity");
|
|
19
|
+
Object.defineProperty(exports, "identityConfigSchema", { enumerable: true, get: function () { return identity_1.identityConfigSchema; } });
|
|
@@ -9,17 +9,19 @@ const injection_1 = require("../config/injection");
|
|
|
9
9
|
* This utility will define those variables based on the user's config.
|
|
10
10
|
*/
|
|
11
11
|
function getInjectedVariables(xmcpConfig) {
|
|
12
|
-
const { mode } = compiler_context_1.compilerContext.getContext();
|
|
12
|
+
const { mode, projectRoot } = compiler_context_1.compilerContext.getContext();
|
|
13
13
|
const httpVariables = (0, injection_1.injectHttpVariables)(xmcpConfig.http, mode);
|
|
14
14
|
const corsVariables = (0, injection_1.injectCorsVariables)(xmcpConfig.http);
|
|
15
15
|
const oauthVariables = (0, injection_1.injectOAuthVariables)(xmcpConfig);
|
|
16
16
|
const pathsVariables = (0, injection_1.injectPathsVariables)(xmcpConfig);
|
|
17
17
|
const stdioVariables = (0, injection_1.injectStdioVariables)(xmcpConfig.stdio);
|
|
18
|
+
const identityVariables = (0, injection_1.injectIdentityVariables)(xmcpConfig.identity, mode, projectRoot);
|
|
18
19
|
return {
|
|
19
20
|
...httpVariables,
|
|
20
21
|
...corsVariables,
|
|
21
22
|
...oauthVariables,
|
|
22
23
|
...pathsVariables,
|
|
23
24
|
...stdioVariables,
|
|
25
|
+
...identityVariables,
|
|
24
26
|
};
|
|
25
27
|
}
|
|
@@ -27,7 +27,7 @@ function getWebpackConfig(xmcpConfig) {
|
|
|
27
27
|
const config = {
|
|
28
28
|
mode,
|
|
29
29
|
watch: mode === "development",
|
|
30
|
-
devtool:
|
|
30
|
+
devtool: false,
|
|
31
31
|
output: {
|
|
32
32
|
filename: outputFilename,
|
|
33
33
|
path: outputPath,
|
|
@@ -51,9 +51,9 @@ const getDefaultRuntimeFiles = () => {
|
|
|
51
51
|
}
|
|
52
52
|
return runtimeFiles;
|
|
53
53
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
// IMPORTANT: Always use getDefaultRuntimeFiles() to ensure we get the latest runtime files
|
|
55
|
+
// DefinePlugin embedding was causing stale file issues
|
|
56
|
+
exports.runtimeFiles = getDefaultRuntimeFiles();
|
|
57
57
|
class InjectRuntimePlugin {
|
|
58
58
|
apply(compiler) {
|
|
59
59
|
let hasRun = false;
|
package/dist/compiler/index.js
CHANGED
|
@@ -47,6 +47,7 @@ async function compile({ onBuild } = {}) {
|
|
|
47
47
|
return new Promise((resolve, reject) => {
|
|
48
48
|
(0, compiler_context_1.compilerContextProvider)({
|
|
49
49
|
mode,
|
|
50
|
+
projectRoot: process.cwd(),
|
|
50
51
|
platforms: {},
|
|
51
52
|
}, () => {
|
|
52
53
|
compileInternal({ onBuild }).then(resolve).catch(reject);
|