mcp-creatio 0.3.6 → 0.3.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/README.md +52 -20
- package/dist/cli.js +9 -5
- package/dist/cli.js.map +1 -1
- package/dist/log.d.ts +3 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +39 -0
- package/dist/log.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +22 -18
- package/src/log.ts +65 -23
package/README.md
CHANGED
|
@@ -20,27 +20,31 @@ Model Context Protocol (MCP) server for Creatio (https://www.creatio.com/) - con
|
|
|
20
20
|
- **Built-in OAuth server**: Automatic MCP client authentication
|
|
21
21
|
- **Docker ready**: Multi-arch images available
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## Run Modes
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
2. Run: `npm start` or use Docker
|
|
25
|
+
This project supports two runtime modes:
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
### 1. CLI Mode (`stdio`)
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
Use this mode for MCP clients that launch a command directly (VS Code MCP, Claude Desktop, etc.).
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
- No HTTP endpoint needed
|
|
32
|
+
- Easiest local setup
|
|
33
|
+
- Supports Legacy auth and OAuth2 Client Credentials
|
|
34
|
+
- OAuth2 Authorization Code is **not** supported in `stdio` mode
|
|
35
|
+
|
|
36
|
+
Run directly from npm:
|
|
33
37
|
|
|
34
38
|
```bash
|
|
35
39
|
npx -y mcp-creatio \
|
|
36
40
|
--base-url https://your-creatio.com \
|
|
37
|
-
--login
|
|
38
|
-
--password
|
|
41
|
+
--login your_login \
|
|
42
|
+
--password your_password
|
|
39
43
|
```
|
|
40
44
|
|
|
41
|
-
|
|
45
|
+
`stdio` logs are disabled by default. To enable them, set `MCP_CREATIO_LOG_LEVEL` or pass `--log-level info`.
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
VS Code MCP config (command-based):
|
|
44
48
|
|
|
45
49
|
```json
|
|
46
50
|
{
|
|
@@ -52,18 +56,43 @@ Default transport for CLI is `stdio`.
|
|
|
52
56
|
"--base-url",
|
|
53
57
|
"https://your-creatio.com",
|
|
54
58
|
"--login",
|
|
55
|
-
"
|
|
59
|
+
"your_login",
|
|
56
60
|
"--password",
|
|
57
|
-
"
|
|
61
|
+
"your_password"
|
|
58
62
|
]
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
```
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
Local repo command (without publishing):
|
|
64
68
|
|
|
65
69
|
```bash
|
|
66
|
-
npm run start:stdio -- --base-url https://your-creatio.com --login
|
|
70
|
+
npm run start:stdio -- --base-url https://your-creatio.com --login your_login --password your_password
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 2. Server Mode (`http`)
|
|
74
|
+
|
|
75
|
+
Use this mode when your client connects by URL (for example `http://localhost:3000/mcp`).
|
|
76
|
+
|
|
77
|
+
- Exposes HTTP endpoint: `/mcp`
|
|
78
|
+
- Required for OAuth2 Authorization Code flow
|
|
79
|
+
- Works well with Docker and remote deployments
|
|
80
|
+
|
|
81
|
+
Start server:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm start
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Then connect using URL:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"creatio": {
|
|
92
|
+
"type": "http",
|
|
93
|
+
"url": "http://localhost:3000/mcp"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
67
96
|
```
|
|
68
97
|
|
|
69
98
|
## Configuration
|
|
@@ -77,10 +106,11 @@ npm run start:stdio -- --base-url https://your-creatio.com --login YourLogin --p
|
|
|
77
106
|
| `CREATIO_CLIENT_SECRET` | OAuth2 client credentials secret |
|
|
78
107
|
| `CREATIO_ID_BASE_URL` | Identity Service URL (if separate from main Creatio instance) |
|
|
79
108
|
| `CREATIO_CODE_CLIENT_ID` | OAuth2 authorization code client ID |
|
|
80
|
-
| `CREATIO_CODE_CLIENT_SECRET` | OAuth2 authorization code client secret |
|
|
81
|
-
| `CREATIO_CODE_REDIRECT_URI` | OAuth2 redirect URI (e.g. `http://localhost:3000/oauth/callback`) |
|
|
82
|
-
| `CREATIO_CODE_SCOPE` | OAuth2 scope (e.g. `offline_access ApplicationAccess_yourappguid`) |
|
|
83
|
-
| `READONLY_MODE` | Set `true` to disable create/update/delete operations |
|
|
109
|
+
| `CREATIO_CODE_CLIENT_SECRET` | OAuth2 authorization code client secret |
|
|
110
|
+
| `CREATIO_CODE_REDIRECT_URI` | OAuth2 redirect URI (e.g. `http://localhost:3000/oauth/callback`) |
|
|
111
|
+
| `CREATIO_CODE_SCOPE` | OAuth2 scope (e.g. `offline_access ApplicationAccess_yourappguid`) |
|
|
112
|
+
| `READONLY_MODE` | Set `true` to disable create/update/delete operations |
|
|
113
|
+
| `MCP_CREATIO_LOG_LEVEL` | Log verbosity: `silent` (default), `error`, `warn`, `info` |
|
|
84
114
|
|
|
85
115
|
## Authentication Modes
|
|
86
116
|
|
|
@@ -113,11 +143,13 @@ CREATIO_CODE_REDIRECT_URI=http://localhost:3000/oauth/callback
|
|
|
113
143
|
CREATIO_CODE_SCOPE="offline_access ApplicationAccess_yourappguid"
|
|
114
144
|
```
|
|
115
145
|
|
|
116
|
-
**Note**: Currently uses in-memory storage for OAuth tokens. Tokens will be lost on server restart.
|
|
146
|
+
**Note**: Currently uses in-memory storage for OAuth tokens. Tokens will be lost on server restart.
|
|
147
|
+
|
|
148
|
+
**Important**: OAuth2 Authorization Code requires **Server Mode (`http`)**.
|
|
117
149
|
|
|
118
150
|
**Priority**: Authorization Code > Client Credentials > Legacy
|
|
119
151
|
|
|
120
|
-
## MCP Client Authentication
|
|
152
|
+
## MCP Client Authentication (HTTP Mode)
|
|
121
153
|
|
|
122
154
|
The server includes OAuth 2.1 Authorization Server for MCP clients (Claude Desktop, etc.). No additional setup required - clients authenticate automatically through standard OAuth flow.
|
|
123
155
|
|
package/dist/cli.js
CHANGED
|
@@ -22,11 +22,13 @@ Options:
|
|
|
22
22
|
--url <url> Alias for --base-url
|
|
23
23
|
--login <value> Creatio login (legacy auth)
|
|
24
24
|
--password <value> Creatio password (legacy auth)
|
|
25
|
-
--client-id <value> OAuth2 client credentials client_id
|
|
26
|
-
--client-secret <value> OAuth2 client credentials client_secret
|
|
27
|
-
--id-base-url <url> Creatio Identity base URL
|
|
28
|
-
--readonly <true|false> Enable readonly mode
|
|
29
|
-
-
|
|
25
|
+
--client-id <value> OAuth2 client credentials client_id
|
|
26
|
+
--client-secret <value> OAuth2 client credentials client_secret
|
|
27
|
+
--id-base-url <url> Creatio Identity base URL
|
|
28
|
+
--readonly <true|false> Enable readonly mode
|
|
29
|
+
--log-level <silent|error|warn|info>
|
|
30
|
+
Log verbosity (default: silent)
|
|
31
|
+
-h, --help Show this help
|
|
30
32
|
|
|
31
33
|
Examples:
|
|
32
34
|
mcp-creatio --base-url https://tenant.creatio.com --login your_login --password your_password
|
|
@@ -78,6 +80,7 @@ function applyCliEnv(opts) {
|
|
|
78
80
|
setEnvIfDefined('CREATIO_CLIENT_SECRET', opts['client-secret']);
|
|
79
81
|
setEnvIfDefined('CREATIO_ID_BASE_URL', opts['id-base-url']);
|
|
80
82
|
setEnvIfDefined('READONLY_MODE', opts.readonly);
|
|
83
|
+
setEnvIfDefined('MCP_CREATIO_LOG_LEVEL', opts['log-level']);
|
|
81
84
|
}
|
|
82
85
|
async function startStdio(server) {
|
|
83
86
|
const mcp = await server.startMcp();
|
|
@@ -105,6 +108,7 @@ async function main() {
|
|
|
105
108
|
printHelp();
|
|
106
109
|
return;
|
|
107
110
|
}
|
|
111
|
+
log_1.default.useStderrOnlyLogs();
|
|
108
112
|
applyCliEnv(opts);
|
|
109
113
|
const cfg = (0, config_builder_1.getCreatioClientConfig)();
|
|
110
114
|
if (cfg.auth.kind === creatio_1.AuthProviderType.OAuth2Code) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,wEAAiF;AAEjF,qDAA0D;AAC1D,uCAA0F;AAC1F,gDAAwB;AACxB,qCAAkC;AAClC,mCAAkC;AAQlC,SAAS,SAAS;IACjB,MAAM,IAAI,GAAG
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,wEAAiF;AAEjF,qDAA0D;AAC1D,uCAA0F;AAC1F,gDAAwB;AACxB,qCAAkC;AAClC,mCAAkC;AAQlC,SAAS,SAAS;IACjB,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBb,CAAC,IAAI,EAAE,CAAC;IACR,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,SAAS,CAAC,IAAc;IAChC,MAAM,IAAI,GAAe,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACtC,SAAS;QACV,CAAC;QAED,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1C,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;YACnB,SAAS;QACV,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,SAAS;QACV,CAAC;QAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,IAA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AE;IACpB,aAAG,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
package/dist/log.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type LogLevel = 'info' | 'warn' | 'error';
|
|
2
|
+
export type LogVerbosity = LogLevel | 'silent';
|
|
2
3
|
export type CreatioAuthKind = 'legacy' | 'oauth2' | 'oauth2_code';
|
|
3
4
|
export interface LogConfig {
|
|
4
5
|
level?: LogLevel;
|
|
@@ -6,6 +7,7 @@ export interface LogConfig {
|
|
|
6
7
|
export declare function setCorrelationId(correlationId: string): void;
|
|
7
8
|
export declare function getCorrelationId(): string | undefined;
|
|
8
9
|
export declare function clearCorrelationId(): void;
|
|
10
|
+
export declare function useStderrOnlyLogs(): void;
|
|
9
11
|
export declare function info(msg: string, meta?: Record<string, any>): void;
|
|
10
12
|
export declare function warn(msg: string, meta?: Record<string, any>): void;
|
|
11
13
|
export declare function error(msg: string, meta?: Record<string, any>): void;
|
|
@@ -28,6 +30,7 @@ declare const _default: {
|
|
|
28
30
|
info: typeof info;
|
|
29
31
|
warn: typeof warn;
|
|
30
32
|
error: typeof error;
|
|
33
|
+
useStderrOnlyLogs: typeof useStderrOnlyLogs;
|
|
31
34
|
appStart: typeof appStart;
|
|
32
35
|
appStop: typeof appStop;
|
|
33
36
|
serverStart: typeof serverStart;
|
package/dist/log.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACjD,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,aAAa,CAAC;AAElE,MAAM,WAAW,SAA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ACxB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAG1B;AACD,wBAAgB,YAAY,CAC3B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAO1B;;;;;;;;;;;;;;;;;;;;;;;;;AAED,wBAuBE"}
|
package/dist/log.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setCorrelationId = setCorrelationId;
|
|
4
4
|
exports.getCorrelationId = getCorrelationId;
|
|
5
5
|
exports.clearCorrelationId = clearCorrelationId;
|
|
6
|
+
exports.useStderrOnlyLogs = useStderrOnlyLogs;
|
|
6
7
|
exports.info = info;
|
|
7
8
|
exports.warn = warn;
|
|
8
9
|
exports.error = error;
|
|
@@ -22,6 +23,33 @@ exports.httpResponse = httpResponse;
|
|
|
22
23
|
exports.httpError = httpError;
|
|
23
24
|
exports.logOperation = logOperation;
|
|
24
25
|
let _correlationId;
|
|
26
|
+
let _stderrOnly = false;
|
|
27
|
+
function resolveLogVerbosity() {
|
|
28
|
+
const raw = (process.env.MCP_CREATIO_LOG_LEVEL || 'silent').toLowerCase();
|
|
29
|
+
if (raw === 'info') {
|
|
30
|
+
return 'info';
|
|
31
|
+
}
|
|
32
|
+
if (raw === 'warn' || raw === 'warning') {
|
|
33
|
+
return 'warn';
|
|
34
|
+
}
|
|
35
|
+
if (raw === 'error') {
|
|
36
|
+
return 'error';
|
|
37
|
+
}
|
|
38
|
+
return 'silent';
|
|
39
|
+
}
|
|
40
|
+
function shouldLog(level) {
|
|
41
|
+
const verbosity = resolveLogVerbosity();
|
|
42
|
+
if (verbosity === 'silent') {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (verbosity === 'error') {
|
|
46
|
+
return level === 'error';
|
|
47
|
+
}
|
|
48
|
+
if (verbosity === 'warn') {
|
|
49
|
+
return level === 'warn' || level === 'error';
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
25
53
|
function setCorrelationId(correlationId) {
|
|
26
54
|
_correlationId = correlationId;
|
|
27
55
|
}
|
|
@@ -35,6 +63,9 @@ function timestamp() {
|
|
|
35
63
|
return new Date().toISOString();
|
|
36
64
|
}
|
|
37
65
|
function output(level, msg, meta) {
|
|
66
|
+
if (!shouldLog(level)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
38
69
|
const entry = { ts: timestamp(), level, msg };
|
|
39
70
|
if (_correlationId) {
|
|
40
71
|
entry.correlationId = _correlationId;
|
|
@@ -43,6 +74,10 @@ function output(level, msg, meta) {
|
|
|
43
74
|
entry.meta = meta;
|
|
44
75
|
}
|
|
45
76
|
const line = JSON.stringify(entry);
|
|
77
|
+
if (_stderrOnly) {
|
|
78
|
+
process.stderr.write(line + '\n');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
46
81
|
if (level === 'error') {
|
|
47
82
|
console.error(line);
|
|
48
83
|
}
|
|
@@ -53,6 +88,9 @@ function output(level, msg, meta) {
|
|
|
53
88
|
console.log(line);
|
|
54
89
|
}
|
|
55
90
|
}
|
|
91
|
+
function useStderrOnlyLogs() {
|
|
92
|
+
_stderrOnly = true;
|
|
93
|
+
}
|
|
56
94
|
function info(msg, meta) {
|
|
57
95
|
output('info', msg, meta);
|
|
58
96
|
}
|
|
@@ -115,6 +153,7 @@ exports.default = {
|
|
|
115
153
|
info,
|
|
116
154
|
warn,
|
|
117
155
|
error,
|
|
156
|
+
useStderrOnlyLogs,
|
|
118
157
|
appStart,
|
|
119
158
|
appStop,
|
|
120
159
|
serverStart,
|
package/dist/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"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AChE,CAAC;AACD,SAAgB,YAAY,CAC3B,SAAiB,EACjB,QAAgB,EAChB,OAAgB,EAChB,IAA0B;IAE1B,IAAI,CAAC,aAAa,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE;QACnD,SAAS;QACT,QAAQ;QACR,GAAG,IAAI;KACP,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe;IACd,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,iBAAiB;IACjB,QAAQ;IACR,OAAO;IACP,WAAW;IACX,UAAU;IACV,SAAS;IACT,QAAQ;IACR,cAAc;IACd,iBAAiB;IACjB,gBAAgB;IAChB,aAAa;IACb,iBAAiB;IACjB,WAAW;IACX,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,gBAAgB;IAChB,gBAAgB;IAChB,kBAAkB;CAClB,CAAC"}
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -26,11 +26,13 @@ Options:
|
|
|
26
26
|
--url <url> Alias for --base-url
|
|
27
27
|
--login <value> Creatio login (legacy auth)
|
|
28
28
|
--password <value> Creatio password (legacy auth)
|
|
29
|
-
--client-id <value> OAuth2 client credentials client_id
|
|
30
|
-
--client-secret <value> OAuth2 client credentials client_secret
|
|
31
|
-
--id-base-url <url> Creatio Identity base URL
|
|
32
|
-
--readonly <true|false> Enable readonly mode
|
|
33
|
-
-
|
|
29
|
+
--client-id <value> OAuth2 client credentials client_id
|
|
30
|
+
--client-secret <value> OAuth2 client credentials client_secret
|
|
31
|
+
--id-base-url <url> Creatio Identity base URL
|
|
32
|
+
--readonly <true|false> Enable readonly mode
|
|
33
|
+
--log-level <silent|error|warn|info>
|
|
34
|
+
Log verbosity (default: silent)
|
|
35
|
+
-h, --help Show this help
|
|
34
36
|
|
|
35
37
|
Examples:
|
|
36
38
|
mcp-creatio --base-url https://tenant.creatio.com --login your_login --password your_password
|
|
@@ -87,10 +89,11 @@ function applyCliEnv(opts: CliOptions): void {
|
|
|
87
89
|
setEnvIfDefined('CREATIO_LOGIN', opts.login);
|
|
88
90
|
setEnvIfDefined('CREATIO_PASSWORD', opts.password);
|
|
89
91
|
setEnvIfDefined('CREATIO_CLIENT_ID', opts['client-id']);
|
|
90
|
-
setEnvIfDefined('CREATIO_CLIENT_SECRET', opts['client-secret']);
|
|
91
|
-
setEnvIfDefined('CREATIO_ID_BASE_URL', opts['id-base-url']);
|
|
92
|
-
setEnvIfDefined('READONLY_MODE', opts.readonly);
|
|
93
|
-
|
|
92
|
+
setEnvIfDefined('CREATIO_CLIENT_SECRET', opts['client-secret']);
|
|
93
|
+
setEnvIfDefined('CREATIO_ID_BASE_URL', opts['id-base-url']);
|
|
94
|
+
setEnvIfDefined('READONLY_MODE', opts.readonly);
|
|
95
|
+
setEnvIfDefined('MCP_CREATIO_LOG_LEVEL', opts['log-level']);
|
|
96
|
+
}
|
|
94
97
|
|
|
95
98
|
async function startStdio(server: Server): Promise<void> {
|
|
96
99
|
const mcp = await server.startMcp();
|
|
@@ -114,15 +117,16 @@ async function shutdown(signal: string, state: RuntimeState): Promise<void> {
|
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
119
|
|
|
117
|
-
async function main(): Promise<void> {
|
|
118
|
-
const opts = parseArgs(process.argv.slice(2));
|
|
119
|
-
if (opts.help === 'true') {
|
|
120
|
-
printHelp();
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
async function main(): Promise<void> {
|
|
121
|
+
const opts = parseArgs(process.argv.slice(2));
|
|
122
|
+
if (opts.help === 'true') {
|
|
123
|
+
printHelp();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
log.useStderrOnlyLogs();
|
|
128
|
+
applyCliEnv(opts);
|
|
129
|
+
const cfg = getCreatioClientConfig();
|
|
126
130
|
|
|
127
131
|
if (cfg.auth.kind === AuthProviderType.OAuth2Code) {
|
|
128
132
|
throw new Error(
|
package/src/log.ts
CHANGED
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
export type LogLevel = 'info' | 'warn' | 'error';
|
|
2
|
-
export type
|
|
1
|
+
export type LogLevel = 'info' | 'warn' | 'error';
|
|
2
|
+
export type LogVerbosity = LogLevel | 'silent';
|
|
3
|
+
export type CreatioAuthKind = 'legacy' | 'oauth2' | 'oauth2_code';
|
|
3
4
|
|
|
4
|
-
export interface LogConfig {
|
|
5
|
-
level?: LogLevel;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
let _correlationId: string | undefined;
|
|
5
|
+
export interface LogConfig {
|
|
6
|
+
level?: LogLevel;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let _correlationId: string | undefined;
|
|
10
|
+
let _stderrOnly = false;
|
|
11
|
+
|
|
12
|
+
function resolveLogVerbosity(): LogVerbosity {
|
|
13
|
+
const raw = (process.env.MCP_CREATIO_LOG_LEVEL || 'silent').toLowerCase();
|
|
14
|
+
if (raw === 'info') {
|
|
15
|
+
return 'info';
|
|
16
|
+
}
|
|
17
|
+
if (raw === 'warn' || raw === 'warning') {
|
|
18
|
+
return 'warn';
|
|
19
|
+
}
|
|
20
|
+
if (raw === 'error') {
|
|
21
|
+
return 'error';
|
|
22
|
+
}
|
|
23
|
+
return 'silent';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function shouldLog(level: LogLevel): boolean {
|
|
27
|
+
const verbosity = resolveLogVerbosity();
|
|
28
|
+
if (verbosity === 'silent') {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (verbosity === 'error') {
|
|
32
|
+
return level === 'error';
|
|
33
|
+
}
|
|
34
|
+
if (verbosity === 'warn') {
|
|
35
|
+
return level === 'warn' || level === 'error';
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
9
39
|
|
|
10
40
|
export function setCorrelationId(correlationId: string) {
|
|
11
41
|
_correlationId = correlationId;
|
|
@@ -23,23 +53,34 @@ function timestamp() {
|
|
|
23
53
|
return new Date().toISOString();
|
|
24
54
|
}
|
|
25
55
|
|
|
26
|
-
function output(level: LogLevel, msg: string, meta?: Record<string, any>) {
|
|
27
|
-
|
|
56
|
+
function output(level: LogLevel, msg: string, meta?: Record<string, any>) {
|
|
57
|
+
if (!shouldLog(level)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const entry: any = { ts: timestamp(), level, msg };
|
|
28
61
|
if (_correlationId) {
|
|
29
62
|
entry.correlationId = _correlationId;
|
|
30
63
|
}
|
|
31
64
|
if (meta && Object.keys(meta).length) {
|
|
32
65
|
entry.meta = meta;
|
|
33
66
|
}
|
|
34
|
-
const line = JSON.stringify(entry);
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
console.
|
|
41
|
-
}
|
|
42
|
-
|
|
67
|
+
const line = JSON.stringify(entry);
|
|
68
|
+
if (_stderrOnly) {
|
|
69
|
+
process.stderr.write(line + '\n');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (level === 'error') {
|
|
73
|
+
console.error(line);
|
|
74
|
+
} else if (level === 'warn') {
|
|
75
|
+
console.warn(line);
|
|
76
|
+
} else {
|
|
77
|
+
console.log(line);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function useStderrOnlyLogs() {
|
|
82
|
+
_stderrOnly = true;
|
|
83
|
+
}
|
|
43
84
|
|
|
44
85
|
export function info(msg: string, meta?: Record<string, any>) {
|
|
45
86
|
output('info', msg, meta);
|
|
@@ -116,11 +157,12 @@ export function logOperation(
|
|
|
116
157
|
});
|
|
117
158
|
}
|
|
118
159
|
|
|
119
|
-
export default {
|
|
120
|
-
info,
|
|
121
|
-
warn,
|
|
122
|
-
error,
|
|
123
|
-
|
|
160
|
+
export default {
|
|
161
|
+
info,
|
|
162
|
+
warn,
|
|
163
|
+
error,
|
|
164
|
+
useStderrOnlyLogs,
|
|
165
|
+
appStart,
|
|
124
166
|
appStop,
|
|
125
167
|
serverStart,
|
|
126
168
|
serverStop,
|