mcp-creatio 0.3.6
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/.dockerignore +12 -0
- package/.editorconfig +14 -0
- package/.eslintrc.cjs +18 -0
- package/.gitattributes +8 -0
- package/.github/workflows/docker-publish.yml +50 -0
- package/.prettierignore +3 -0
- package/.prettierrc +9 -0
- package/.vscode/launch.json +23 -0
- package/.vscode/mcp.json +13 -0
- package/.vscode/settings.json +16 -0
- package/Agent.md +187 -0
- package/Debug.md +32 -0
- package/Dockerfile +23 -0
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +135 -0
- package/dist/cli.js.map +1 -0
- package/dist/config-builder.d.ts +3 -0
- package/dist/config-builder.d.ts.map +1 -0
- package/dist/config-builder.js +66 -0
- package/dist/config-builder.js.map +1 -0
- package/dist/consts.d.ts +2 -0
- package/dist/consts.d.ts.map +1 -0
- package/dist/consts.js +6 -0
- package/dist/consts.js.map +1 -0
- package/dist/creatio/auth/auth-manager.d.ts +9 -0
- package/dist/creatio/auth/auth-manager.d.ts.map +1 -0
- package/dist/creatio/auth/auth-manager.js +29 -0
- package/dist/creatio/auth/auth-manager.js.map +1 -0
- package/dist/creatio/auth/auth.d.ts +16 -0
- package/dist/creatio/auth/auth.d.ts.map +1 -0
- package/dist/creatio/auth/auth.js +20 -0
- package/dist/creatio/auth/auth.js.map +1 -0
- package/dist/creatio/auth/index.d.ts +4 -0
- package/dist/creatio/auth/index.d.ts.map +1 -0
- package/dist/creatio/auth/index.js +21 -0
- package/dist/creatio/auth/index.js.map +1 -0
- package/dist/creatio/auth/providers/base-oauth2-provider.d.ts +17 -0
- package/dist/creatio/auth/providers/base-oauth2-provider.d.ts.map +1 -0
- package/dist/creatio/auth/providers/base-oauth2-provider.js +49 -0
- package/dist/creatio/auth/providers/base-oauth2-provider.js.map +1 -0
- package/dist/creatio/auth/providers/base-provider.d.ts +15 -0
- package/dist/creatio/auth/providers/base-provider.d.ts.map +1 -0
- package/dist/creatio/auth/providers/base-provider.js +32 -0
- package/dist/creatio/auth/providers/base-provider.js.map +1 -0
- package/dist/creatio/auth/providers/index.d.ts +5 -0
- package/dist/creatio/auth/providers/index.d.ts.map +1 -0
- package/dist/creatio/auth/providers/index.js +21 -0
- package/dist/creatio/auth/providers/index.js.map +1 -0
- package/dist/creatio/auth/providers/legacy-provider.d.ts +10 -0
- package/dist/creatio/auth/providers/legacy-provider.d.ts.map +1 -0
- package/dist/creatio/auth/providers/legacy-provider.js +73 -0
- package/dist/creatio/auth/providers/legacy-provider.js.map +1 -0
- package/dist/creatio/auth/providers/oauth2-code-provider.d.ts +18 -0
- package/dist/creatio/auth/providers/oauth2-code-provider.d.ts.map +1 -0
- package/dist/creatio/auth/providers/oauth2-code-provider.js +245 -0
- package/dist/creatio/auth/providers/oauth2-code-provider.js.map +1 -0
- package/dist/creatio/auth/providers/oauth2-provider.d.ts +9 -0
- package/dist/creatio/auth/providers/oauth2-provider.d.ts.map +1 -0
- package/dist/creatio/auth/providers/oauth2-provider.js +86 -0
- package/dist/creatio/auth/providers/oauth2-provider.js.map +1 -0
- package/dist/creatio/auth/providers/type.d.ts +6 -0
- package/dist/creatio/auth/providers/type.d.ts.map +1 -0
- package/dist/creatio/auth/providers/type.js +10 -0
- package/dist/creatio/auth/providers/type.js.map +1 -0
- package/dist/creatio/client-config.d.ts +29 -0
- package/dist/creatio/client-config.d.ts.map +1 -0
- package/dist/creatio/client-config.js +3 -0
- package/dist/creatio/client-config.js.map +1 -0
- package/dist/creatio/engines/crud/crud-engine.d.ts +15 -0
- package/dist/creatio/engines/crud/crud-engine.d.ts.map +1 -0
- package/dist/creatio/engines/crud/crud-engine.js +33 -0
- package/dist/creatio/engines/crud/crud-engine.js.map +1 -0
- package/dist/creatio/engines/engine-manager.d.ts +33 -0
- package/dist/creatio/engines/engine-manager.d.ts.map +1 -0
- package/dist/creatio/engines/engine-manager.js +54 -0
- package/dist/creatio/engines/engine-manager.js.map +1 -0
- package/dist/creatio/engines/engine-registry.d.ts +15 -0
- package/dist/creatio/engines/engine-registry.d.ts.map +1 -0
- package/dist/creatio/engines/engine-registry.js +35 -0
- package/dist/creatio/engines/engine-registry.js.map +1 -0
- package/dist/creatio/engines/engine.d.ts +4 -0
- package/dist/creatio/engines/engine.d.ts.map +1 -0
- package/dist/creatio/engines/engine.js +3 -0
- package/dist/creatio/engines/engine.js.map +1 -0
- package/dist/creatio/engines/index.d.ts +8 -0
- package/dist/creatio/engines/index.d.ts.map +1 -0
- package/dist/creatio/engines/index.js +24 -0
- package/dist/creatio/engines/index.js.map +1 -0
- package/dist/creatio/engines/process/process-engine.d.ts +10 -0
- package/dist/creatio/engines/process/process-engine.d.ts.map +1 -0
- package/dist/creatio/engines/process/process-engine.js +18 -0
- package/dist/creatio/engines/process/process-engine.js.map +1 -0
- package/dist/creatio/engines/sys-settings/sys-settings-engine.d.ts +13 -0
- package/dist/creatio/engines/sys-settings/sys-settings-engine.d.ts.map +1 -0
- package/dist/creatio/engines/sys-settings/sys-settings-engine.js +27 -0
- package/dist/creatio/engines/sys-settings/sys-settings-engine.js.map +1 -0
- package/dist/creatio/engines/user/user-engine.d.ts +10 -0
- package/dist/creatio/engines/user/user-engine.d.ts.map +1 -0
- package/dist/creatio/engines/user/user-engine.js +18 -0
- package/dist/creatio/engines/user/user-engine.js.map +1 -0
- package/dist/creatio/index.d.ts +7 -0
- package/dist/creatio/index.d.ts.map +1 -0
- package/dist/creatio/index.js +23 -0
- package/dist/creatio/index.js.map +1 -0
- package/dist/creatio/provider-context.d.ts +10 -0
- package/dist/creatio/provider-context.d.ts.map +1 -0
- package/dist/creatio/provider-context.js +3 -0
- package/dist/creatio/provider-context.js.map +1 -0
- package/dist/creatio/providers/crud-provider.d.ts +40 -0
- package/dist/creatio/providers/crud-provider.d.ts.map +1 -0
- package/dist/creatio/providers/crud-provider.js +3 -0
- package/dist/creatio/providers/crud-provider.js.map +1 -0
- package/dist/creatio/providers/index.d.ts +5 -0
- package/dist/creatio/providers/index.d.ts.map +1 -0
- package/dist/creatio/providers/index.js +21 -0
- package/dist/creatio/providers/index.js.map +1 -0
- package/dist/creatio/providers/process-provider.d.ts +14 -0
- package/dist/creatio/providers/process-provider.d.ts.map +1 -0
- package/dist/creatio/providers/process-provider.js +3 -0
- package/dist/creatio/providers/process-provider.js.map +1 -0
- package/dist/creatio/providers/sys-settings-provider.d.ts +58 -0
- package/dist/creatio/providers/sys-settings-provider.d.ts.map +1 -0
- package/dist/creatio/providers/sys-settings-provider.js +3 -0
- package/dist/creatio/providers/sys-settings-provider.js.map +1 -0
- package/dist/creatio/providers/user-provider.d.ts +12 -0
- package/dist/creatio/providers/user-provider.d.ts.map +1 -0
- package/dist/creatio/providers/user-provider.js +3 -0
- package/dist/creatio/providers/user-provider.js.map +1 -0
- package/dist/creatio/services/creatio-service-context.d.ts +17 -0
- package/dist/creatio/services/creatio-service-context.d.ts.map +1 -0
- package/dist/creatio/services/creatio-service-context.js +35 -0
- package/dist/creatio/services/creatio-service-context.js.map +1 -0
- package/dist/creatio/services/http-client.d.ts +29 -0
- package/dist/creatio/services/http-client.d.ts.map +1 -0
- package/dist/creatio/services/http-client.js +136 -0
- package/dist/creatio/services/http-client.js.map +1 -0
- package/dist/creatio/services/index.d.ts +8 -0
- package/dist/creatio/services/index.d.ts.map +1 -0
- package/dist/creatio/services/index.js +24 -0
- package/dist/creatio/services/index.js.map +1 -0
- package/dist/creatio/services/metadata-store.d.ts +20 -0
- package/dist/creatio/services/metadata-store.d.ts.map +1 -0
- package/dist/creatio/services/metadata-store.js +162 -0
- package/dist/creatio/services/metadata-store.js.map +1 -0
- package/dist/creatio/services/odata-crud-provider.d.ts +21 -0
- package/dist/creatio/services/odata-crud-provider.d.ts.map +1 -0
- package/dist/creatio/services/odata-crud-provider.js +145 -0
- package/dist/creatio/services/odata-crud-provider.js.map +1 -0
- package/dist/creatio/services/process-service-provider.d.ts +11 -0
- package/dist/creatio/services/process-service-provider.d.ts.map +1 -0
- package/dist/creatio/services/process-service-provider.js +52 -0
- package/dist/creatio/services/process-service-provider.js.map +1 -0
- package/dist/creatio/services/sys-settings-service-provider.d.ts +19 -0
- package/dist/creatio/services/sys-settings-service-provider.d.ts.map +1 -0
- package/dist/creatio/services/sys-settings-service-provider.js +107 -0
- package/dist/creatio/services/sys-settings-service-provider.js.map +1 -0
- package/dist/creatio/services/user-info-provider.d.ts +10 -0
- package/dist/creatio/services/user-info-provider.d.ts.map +1 -0
- package/dist/creatio/services/user-info-provider.js +26 -0
- package/dist/creatio/services/user-info-provider.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +51 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +137 -0
- package/dist/log.js.map +1 -0
- package/dist/server/http/creatio-oauth-handlers.d.ts +14 -0
- package/dist/server/http/creatio-oauth-handlers.d.ts.map +1 -0
- package/dist/server/http/creatio-oauth-handlers.js +137 -0
- package/dist/server/http/creatio-oauth-handlers.js.map +1 -0
- package/dist/server/http/httpServer.d.ts +23 -0
- package/dist/server/http/httpServer.d.ts.map +1 -0
- package/dist/server/http/httpServer.js +131 -0
- package/dist/server/http/httpServer.js.map +1 -0
- package/dist/server/http/index.d.ts +6 -0
- package/dist/server/http/index.d.ts.map +1 -0
- package/dist/server/http/index.js +22 -0
- package/dist/server/http/index.js.map +1 -0
- package/dist/server/http/mcp-handlers.d.ts +10 -0
- package/dist/server/http/mcp-handlers.d.ts.map +1 -0
- package/dist/server/http/mcp-handlers.js +82 -0
- package/dist/server/http/mcp-handlers.js.map +1 -0
- package/dist/server/http/mcp-oauth-handlers.d.ts +11 -0
- package/dist/server/http/mcp-oauth-handlers.d.ts.map +1 -0
- package/dist/server/http/mcp-oauth-handlers.js +106 -0
- package/dist/server/http/mcp-oauth-handlers.js.map +1 -0
- package/dist/server/http/middleware.d.ts +11 -0
- package/dist/server/http/middleware.d.ts.map +1 -0
- package/dist/server/http/middleware.js +88 -0
- package/dist/server/http/middleware.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +19 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/mcp/filters.d.ts +2 -0
- package/dist/server/mcp/filters.d.ts.map +1 -0
- package/dist/server/mcp/filters.js +94 -0
- package/dist/server/mcp/filters.js.map +1 -0
- package/dist/server/mcp/index.d.ts +2 -0
- package/dist/server/mcp/index.d.ts.map +1 -0
- package/dist/server/mcp/index.js +18 -0
- package/dist/server/mcp/index.js.map +1 -0
- package/dist/server/mcp/prompts-data.d.ts +147 -0
- package/dist/server/mcp/prompts-data.d.ts.map +1 -0
- package/dist/server/mcp/prompts-data.js +884 -0
- package/dist/server/mcp/prompts-data.js.map +1 -0
- package/dist/server/mcp/server.d.ts +25 -0
- package/dist/server/mcp/server.d.ts.map +1 -0
- package/dist/server/mcp/server.js +233 -0
- package/dist/server/mcp/server.js.map +1 -0
- package/dist/server/mcp/tools-data.d.ts +165 -0
- package/dist/server/mcp/tools-data.d.ts.map +1 -0
- package/dist/server/mcp/tools-data.js +466 -0
- package/dist/server/mcp/tools-data.js.map +1 -0
- package/dist/server/oauth/client-manager.d.ts +6 -0
- package/dist/server/oauth/client-manager.d.ts.map +1 -0
- package/dist/server/oauth/client-manager.js +52 -0
- package/dist/server/oauth/client-manager.js.map +1 -0
- package/dist/server/oauth/index.d.ts +7 -0
- package/dist/server/oauth/index.d.ts.map +1 -0
- package/dist/server/oauth/index.js +23 -0
- package/dist/server/oauth/index.js.map +1 -0
- package/dist/server/oauth/oauth-server.d.ts +21 -0
- package/dist/server/oauth/oauth-server.d.ts.map +1 -0
- package/dist/server/oauth/oauth-server.js +146 -0
- package/dist/server/oauth/oauth-server.js.map +1 -0
- package/dist/server/oauth/storage.d.ts +31 -0
- package/dist/server/oauth/storage.d.ts.map +1 -0
- package/dist/server/oauth/storage.js +73 -0
- package/dist/server/oauth/storage.js.map +1 -0
- package/dist/server/oauth/token-manager.d.ts +13 -0
- package/dist/server/oauth/token-manager.d.ts.map +1 -0
- package/dist/server/oauth/token-manager.js +69 -0
- package/dist/server/oauth/token-manager.js.map +1 -0
- package/dist/server/oauth/types.d.ts +51 -0
- package/dist/server/oauth/types.d.ts.map +1 -0
- package/dist/server/oauth/types.js +3 -0
- package/dist/server/oauth/types.js.map +1 -0
- package/dist/server/oauth/validators.d.ts +7 -0
- package/dist/server/oauth/validators.d.ts.map +1 -0
- package/dist/server/oauth/validators.js +51 -0
- package/dist/server/oauth/validators.js.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +19 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/session-context.d.ts +57 -0
- package/dist/services/session-context.d.ts.map +1 -0
- package/dist/services/session-context.js +182 -0
- package/dist/services/session-context.js.map +1 -0
- package/dist/services/token-refresh-scheduler.d.ts +16 -0
- package/dist/services/token-refresh-scheduler.d.ts.map +1 -0
- package/dist/services/token-refresh-scheduler.js +66 -0
- package/dist/services/token-refresh-scheduler.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/network.d.ts +7 -0
- package/dist/types/network.d.ts.map +1 -0
- package/dist/types/network.js +6 -0
- package/dist/types/network.js.map +1 -0
- package/dist/utils/context.d.ts +10 -0
- package/dist/utils/context.d.ts.map +1 -0
- package/dist/utils/context.js +44 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/env.d.ts +3 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +16 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/mcp.d.ts +3 -0
- package/dist/utils/mcp.d.ts.map +1 -0
- package/dist/utils/mcp.js +7 -0
- package/dist/utils/mcp.js.map +1 -0
- package/dist/utils/network.d.ts +7 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +63 -0
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/pkce.d.ts +7 -0
- package/dist/utils/pkce.d.ts.map +1 -0
- package/dist/utils/pkce.js +43 -0
- package/dist/utils/pkce.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +10 -0
- package/dist/version.js.map +1 -0
- package/docs/coding-style.md +30 -0
- package/ecosystem.config.json +17 -0
- package/eslint.config.cjs +95 -0
- package/package.json +54 -0
- package/src/cli.ts +158 -0
- package/src/config-builder.ts +76 -0
- package/src/consts.ts +3 -0
- package/src/creatio/auth/auth-manager.ts +27 -0
- package/src/creatio/auth/auth.ts +31 -0
- package/src/creatio/auth/index.ts +3 -0
- package/src/creatio/auth/providers/base-oauth2-provider.ts +62 -0
- package/src/creatio/auth/providers/base-provider.ts +42 -0
- package/src/creatio/auth/providers/index.ts +4 -0
- package/src/creatio/auth/providers/legacy-provider.ts +70 -0
- package/src/creatio/auth/providers/oauth2-code-provider.ts +252 -0
- package/src/creatio/auth/providers/oauth2-provider.ts +91 -0
- package/src/creatio/auth/providers/type.ts +5 -0
- package/src/creatio/client-config.ts +34 -0
- package/src/creatio/engines/crud/crud-engine.ts +47 -0
- package/src/creatio/engines/engine-manager.ts +102 -0
- package/src/creatio/engines/engine-registry.ts +36 -0
- package/src/creatio/engines/engine.ts +3 -0
- package/src/creatio/engines/index.ts +7 -0
- package/src/creatio/engines/process/process-engine.ts +20 -0
- package/src/creatio/engines/sys-settings/sys-settings-engine.ts +41 -0
- package/src/creatio/engines/user/user-engine.ts +20 -0
- package/src/creatio/index.ts +6 -0
- package/src/creatio/provider-context.ts +10 -0
- package/src/creatio/providers/crud-provider.ts +45 -0
- package/src/creatio/providers/index.ts +4 -0
- package/src/creatio/providers/process-provider.ts +15 -0
- package/src/creatio/providers/sys-settings-provider.ts +63 -0
- package/src/creatio/providers/user-provider.ts +12 -0
- package/src/creatio/services/creatio-service-context.ts +38 -0
- package/src/creatio/services/http-client.ts +174 -0
- package/src/creatio/services/index.ts +7 -0
- package/src/creatio/services/metadata-store.ts +181 -0
- package/src/creatio/services/odata-crud-provider.ts +210 -0
- package/src/creatio/services/process-service-provider.ts +76 -0
- package/src/creatio/services/sys-settings-service-provider.ts +192 -0
- package/src/creatio/services/user-info-provider.ts +41 -0
- package/src/index.ts +44 -0
- package/src/log.ts +141 -0
- package/src/server/http/creatio-oauth-handlers.ts +146 -0
- package/src/server/http/httpServer.ts +150 -0
- package/src/server/http/index.ts +5 -0
- package/src/server/http/mcp-handlers.ts +92 -0
- package/src/server/http/mcp-oauth-handlers.ts +108 -0
- package/src/server/http/middleware.ts +91 -0
- package/src/server/index.ts +2 -0
- package/src/server/mcp/filters.ts +97 -0
- package/src/server/mcp/index.ts +1 -0
- package/src/server/mcp/prompts-data.ts +896 -0
- package/src/server/mcp/server.ts +331 -0
- package/src/server/mcp/tools-data.ts +592 -0
- package/src/server/oauth/client-manager.ts +47 -0
- package/src/server/oauth/index.ts +6 -0
- package/src/server/oauth/oauth-server.ts +185 -0
- package/src/server/oauth/storage.ts +106 -0
- package/src/server/oauth/token-manager.ts +80 -0
- package/src/server/oauth/types.ts +55 -0
- package/src/server/oauth/validators.ts +56 -0
- package/src/services/index.ts +2 -0
- package/src/services/session-context.ts +232 -0
- package/src/services/token-refresh-scheduler.ts +68 -0
- package/src/types/index.ts +1 -0
- package/src/types/network.ts +7 -0
- package/src/utils/context.ts +49 -0
- package/src/utils/env.ts +12 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/mcp.ts +8 -0
- package/src/utils/network.ts +65 -0
- package/src/utils/pkce.ts +39 -0
- package/src/version.ts +15 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const CRITICAL_WARNINGS = {
|
|
4
|
+
FILTER_SELECT_SYNC:
|
|
5
|
+
'⚠️ CRITICAL: When using $filter with $select:\n' +
|
|
6
|
+
'- ALWAYS include filtered fields in $select array\n' +
|
|
7
|
+
"- Example: filter by AccountId → select=['Id','AccountId',...]\n" +
|
|
8
|
+
'- Creatio returns error "Column by path X not found" if field filtered but not selected\n' +
|
|
9
|
+
'- This does NOT apply to expanded entities - those are separate',
|
|
10
|
+
GUID_NO_QUOTES:
|
|
11
|
+
'⚠️ IMPORTANT GUID SYNTAX:\n' +
|
|
12
|
+
'- GUID fields (Id, AccountId, ContactId, etc.): NO quotes, NO guid prefix!\n' +
|
|
13
|
+
' ✅ CORRECT: AccountId eq 8ecab4a1-0ca3-4515-9399-efe0a19390bd\n' +
|
|
14
|
+
" ❌ WRONG: AccountId eq guid'...' or AccountId eq '...'\n" +
|
|
15
|
+
"- String/Text fields: WITH single quotes! Example: Name eq 'John'\n" +
|
|
16
|
+
"- Navigation properties: WITH single quotes! Example: Type/Name eq 'Employee'",
|
|
17
|
+
TIME_CONVERSION:
|
|
18
|
+
'⏰ TIME CONVERSION CRITICAL:\nWhen updating StartDate/DueDate, convert local time to UTC!',
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
const DATA_TYPES_DESC = {
|
|
22
|
+
BASIC:
|
|
23
|
+
'DATA TYPES:\n' +
|
|
24
|
+
'- Strings: "John Doe", "john@example.com"\n' +
|
|
25
|
+
'- Numbers: 1000, 25.99\n' +
|
|
26
|
+
'- Booleans: true, false\n' +
|
|
27
|
+
'- Dates: ISO 8601 format with Z for UTC: "2025-10-08T19:00:00Z"\n' +
|
|
28
|
+
'- GUIDs (lookups): "8ecab4a1-0ca3-4515-9399-efe0a19390bd" (no quotes in value!)',
|
|
29
|
+
LOOKUPS:
|
|
30
|
+
'LOOKUP FIELDS:\n' +
|
|
31
|
+
'- Use field name ending with Id: AccountId, ContactId, TypeId, etc.\n' +
|
|
32
|
+
'- Value must be valid GUID from related entity\n' +
|
|
33
|
+
'- Example: AccountId: "8ecab4a1-0ca3-4515-9399-efe0a19390bd"',
|
|
34
|
+
DATES:
|
|
35
|
+
'⏰ DATES & TIME:\n' +
|
|
36
|
+
'- Always use UTC time with Z suffix\n' +
|
|
37
|
+
'- Convert local time to UTC: subtract timezone offset\n' +
|
|
38
|
+
'- Format: "YYYY-MM-DDTHH:mm:ssZ"\n' +
|
|
39
|
+
'- Example: "2025-10-08T19:00:00Z" for 22:00 local (UTC+3)',
|
|
40
|
+
} as const;
|
|
41
|
+
|
|
42
|
+
function makeToolDescriptor(opts: {
|
|
43
|
+
title: string;
|
|
44
|
+
description: string;
|
|
45
|
+
inputShape: Record<string, z.ZodTypeAny>;
|
|
46
|
+
}) {
|
|
47
|
+
return {
|
|
48
|
+
title: opts.title,
|
|
49
|
+
description: opts.description,
|
|
50
|
+
inputSchema: opts.inputShape,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const getCurrentUserInfoInputShape = {};
|
|
55
|
+
export const getCurrentUserInfoInput = z.object(getCurrentUserInfoInputShape);
|
|
56
|
+
|
|
57
|
+
export const getCurrentUserInfoDescriptor = makeToolDescriptor({
|
|
58
|
+
title: '🔑 Get Current User Info - CALL THIS FIRST!',
|
|
59
|
+
description:
|
|
60
|
+
'⚠️⚠️⚠️ MANDATORY FIRST STEP ⚠️⚠️⚠️\n\n' +
|
|
61
|
+
'🚨 YOU MUST CALL THIS TOOL FIRST before creating ANY Activity, Lead, Opportunity, Case, or other CRM record!\n\n' +
|
|
62
|
+
'WHY CALL FIRST:\n' +
|
|
63
|
+
'- Returns the ContactId needed for OwnerId and AuthorId fields\n' +
|
|
64
|
+
'- Without this, you CANNOT create activities or CRM records correctly\n' +
|
|
65
|
+
'- Activities MUST have valid OwnerId and AuthorId (both = ContactId)\n' +
|
|
66
|
+
'- By default, ALL activities/leads/tasks are created FOR THE CURRENT USER\n\n' +
|
|
67
|
+
'📋 REQUIRED WORKFLOW:\n' +
|
|
68
|
+
'Step 1: Call get-current-user-info (no parameters) ← DO THIS NOW!\n' +
|
|
69
|
+
'Step 2: Extract contactId from response\n' +
|
|
70
|
+
'Step 3: Store contactId in memory for this conversation\n' +
|
|
71
|
+
'Step 4: Use contactId as OwnerId and AuthorId in ALL create operations\n\n' +
|
|
72
|
+
'Returns:\n' +
|
|
73
|
+
'{\n' +
|
|
74
|
+
' "userId": "410006e1-ca4e-4502-a9ec-e54d922d2c00",\n' +
|
|
75
|
+
' "contactId": "76929f8c-7e15-4c64-bdb0-adc62d383727", // ← SAVE THIS!\n' +
|
|
76
|
+
' "userName": "Current User",\n' +
|
|
77
|
+
' "cultureName": "en-US"\n' +
|
|
78
|
+
'}\n\n' +
|
|
79
|
+
'USE CASES (when to call):\n' +
|
|
80
|
+
'✅ User asks to create activity/meeting/task/call → CALL THIS FIRST!\n' +
|
|
81
|
+
'✅ User asks to create lead/opportunity/case → CALL THIS FIRST!\n' +
|
|
82
|
+
'✅ User asks who they are → CALL THIS!\n' +
|
|
83
|
+
'✅ Beginning of ANY CRM workflow → CALL THIS FIRST!\n' +
|
|
84
|
+
'❌ Simple queries (read/search) → Not required\n\n' +
|
|
85
|
+
'CRITICAL RULES:\n' +
|
|
86
|
+
'- ContactId (NOT userId) goes into OwnerId/AuthorId fields\n' +
|
|
87
|
+
"- Cache the ContactId - don't call repeatedly\n" +
|
|
88
|
+
'- Default assumption: create records FOR current user\n' +
|
|
89
|
+
'- Only change owner if user explicitly says "for [someone else]"\n\n' +
|
|
90
|
+
'Example usage:\n' +
|
|
91
|
+
'User: "Create a meeting for tomorrow"\n' +
|
|
92
|
+
'YOU: 1) Call get-current-user-info\n' +
|
|
93
|
+
' 2) Use contactId for OwnerId and AuthorId\n' +
|
|
94
|
+
' 3) Create activity with those IDs',
|
|
95
|
+
inputShape: getCurrentUserInfoInputShape,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const op = z.enum(['eq', 'ne', 'gt', 'ge', 'lt', 'le', 'contains', 'startswith', 'endswith']);
|
|
99
|
+
|
|
100
|
+
const value = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
|
101
|
+
|
|
102
|
+
const baseCondition = z.object({
|
|
103
|
+
field: z
|
|
104
|
+
.string()
|
|
105
|
+
.min(1)
|
|
106
|
+
.describe(
|
|
107
|
+
'Field to filter on. For lookups use navigation like Type/Name; for GUID columns use TypeId or Id.',
|
|
108
|
+
),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const compareCondition = baseCondition.extend({
|
|
112
|
+
op: op.describe(
|
|
113
|
+
'Comparison operators: eq, ne, gt, ge, lt, le, contains, startswith, endswith.',
|
|
114
|
+
),
|
|
115
|
+
value: value.describe(
|
|
116
|
+
"Value to compare with. Strings are escaped; GUIDs formatted as guid'...'.",
|
|
117
|
+
),
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const inCondition = baseCondition.extend({
|
|
121
|
+
in: z
|
|
122
|
+
.array(z.union([z.string(), z.number(), z.boolean()]))
|
|
123
|
+
.min(1)
|
|
124
|
+
.describe(
|
|
125
|
+
"Set of values (IN emulation with OR). GUIDs auto-formatted to guid'...' when applicable.",
|
|
126
|
+
),
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const condition = z.union([compareCondition, inCondition]);
|
|
130
|
+
|
|
131
|
+
const filtersShape = z
|
|
132
|
+
.object({
|
|
133
|
+
all: z
|
|
134
|
+
.array(condition)
|
|
135
|
+
.min(1)
|
|
136
|
+
.optional()
|
|
137
|
+
.describe(
|
|
138
|
+
'All conditions (AND). Example: [{ field:"TypeId", op:"eq", value:"<GUID>" }]',
|
|
139
|
+
),
|
|
140
|
+
any: z
|
|
141
|
+
.array(condition)
|
|
142
|
+
.min(1)
|
|
143
|
+
.optional()
|
|
144
|
+
.describe(
|
|
145
|
+
'Any condition (OR). Example: [{ field:"Type/Name", op:"eq", value:"Employee" }, { field:"Type/Name", op:"eq", value:"Manager" }]',
|
|
146
|
+
),
|
|
147
|
+
})
|
|
148
|
+
.describe(
|
|
149
|
+
'Structured filters - alternative to raw $filter. Automatically handles OData syntax, escaping, etc.\n' +
|
|
150
|
+
'Tip: For lookups, prefer navigation properties (Field/Name) over IDs for better readability.\n\n' +
|
|
151
|
+
'Examples:\n' +
|
|
152
|
+
'- Lookup by name: { all:[{ field:"Type/Name", op:"eq", value:"Employee" }] }\n' +
|
|
153
|
+
'- By GUID: { all:[{ field:"TypeId", op:"eq", value:"60733efc-..." }] }\n' +
|
|
154
|
+
'- Multiple AND: { all:[{ field:"IsActive", op:"eq", value:true }, { field:"Name", op:"contains", value:"John" }] }\n' +
|
|
155
|
+
'- Multiple OR: { any:[{ field:"Status/Name", op:"eq", value:"Active" }, { field:"Status/Name", op:"eq", value:"Pending" }] }',
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const readInputShape = {
|
|
159
|
+
entity: z
|
|
160
|
+
.string()
|
|
161
|
+
.min(1)
|
|
162
|
+
.describe(
|
|
163
|
+
'Creatio OData entity set to query (e.g., Contact, Account, Activity). Tip: call "list-entities" first, then "describe-entity" to confirm fields before reading.',
|
|
164
|
+
),
|
|
165
|
+
filter: z
|
|
166
|
+
.preprocess(
|
|
167
|
+
(v) => (typeof v === 'string' && v.trim() === '' ? undefined : v),
|
|
168
|
+
z.string().min(1).optional(),
|
|
169
|
+
)
|
|
170
|
+
.describe(
|
|
171
|
+
"OData $filter clause. Use single quotes for strings and escape embedded ' as ''.\n" +
|
|
172
|
+
'Operators: eq, ne, gt, ge, lt, le, and, or, not, contains, startswith, endswith.\n\n' +
|
|
173
|
+
CRITICAL_WARNINGS.GUID_NO_QUOTES +
|
|
174
|
+
'\n\n' +
|
|
175
|
+
'⚠️ IMPORTANT: When using $filter with $select:\n' +
|
|
176
|
+
'- Include ALL fields from filter in $select if possible\n' +
|
|
177
|
+
'- Example: filter by AccountId? Include AccountId in select array\n' +
|
|
178
|
+
'- Creatio may fail if filtered field is not in select list\n\n' +
|
|
179
|
+
'Examples:\n' +
|
|
180
|
+
'- By GUID: AccountId eq 8ecab4a1-0ca3-4515-9399-efe0a19390bd\n' +
|
|
181
|
+
"- Text search: contains(Name,'Acme')\n" +
|
|
182
|
+
"- Multiple: contains(Name,'Baker') and IsActive eq true\n" +
|
|
183
|
+
"- Lookup by name: Type/Name eq 'Employee' (RECOMMENDED!)\n\n" +
|
|
184
|
+
'💡 BEST PRACTICE: Use structured filters parameter instead of raw $filter - it handles syntax automatically!',
|
|
185
|
+
),
|
|
186
|
+
filters: filtersShape
|
|
187
|
+
.optional()
|
|
188
|
+
.describe(
|
|
189
|
+
'Structured filters (alternative to raw $filter). Automatically handles proper OData syntax including GUID formatting.\n' +
|
|
190
|
+
'System automatically removes quotes from GUID values for Id fields.\n\n' +
|
|
191
|
+
'⚠️ IMPORTANT: When using filters with select parameter:\n' +
|
|
192
|
+
'- ALWAYS include filtered fields in select array\n' +
|
|
193
|
+
'- Creatio OData may fail if field is in filter but not in select\n\n' +
|
|
194
|
+
'Examples:\n' +
|
|
195
|
+
"- By GUID: { all:[{ field:'AccountId', op:'eq', value:'60733efc-f36b-1410-a883-16d83cab0980' }] }\n" +
|
|
196
|
+
"- By lookup name: { all:[{ field:'Type/Name', op:'eq', value:'Employee' }] } (RECOMMENDED!)\n" +
|
|
197
|
+
"- Multiple AND: { all:[{ field:'IsActive', op:'eq', value:true }, { field:'Name', op:'contains', value:'John' }] }\n" +
|
|
198
|
+
"- Multiple OR: { any:[{ field:'StatusId', op:'eq', value:'guid1' }, { field:'StatusId', op:'eq', value:'guid2' }] }\n\n" +
|
|
199
|
+
'💡 If filtering by AccountId, ContactId, etc - include that field in select!',
|
|
200
|
+
),
|
|
201
|
+
select: z
|
|
202
|
+
.preprocess(
|
|
203
|
+
(v) => (Array.isArray(v) && v.length === 0 ? undefined : v),
|
|
204
|
+
z.array(z.string()).optional(),
|
|
205
|
+
)
|
|
206
|
+
.describe(
|
|
207
|
+
'Fields to return from the main entity. Strongly recommended for performance.\n\n' +
|
|
208
|
+
'⚠️ IMPORTANT: $select works ONLY for direct properties of the entity!\n' +
|
|
209
|
+
"- ✅ CORRECT: select=['Id','Name','AccountId','Email']\n" +
|
|
210
|
+
"- ❌ WRONG: select=['Account/Name'] - navigation paths NOT supported\n\n" +
|
|
211
|
+
CRITICAL_WARNINGS.FILTER_SELECT_SYNC +
|
|
212
|
+
'\n\n' +
|
|
213
|
+
'💡 TO GET RELATED DATA: Use expand parameter (RECOMMENDED)!\n' +
|
|
214
|
+
"- expand=['Account'] loads full Account object automatically\n" +
|
|
215
|
+
'- No need to include expanded fields in select\n' +
|
|
216
|
+
'- Much better than making separate requests\n\n' +
|
|
217
|
+
"Use 'describe-entity' to discover available field names.",
|
|
218
|
+
),
|
|
219
|
+
expand: z
|
|
220
|
+
.preprocess(
|
|
221
|
+
(v) => (Array.isArray(v) && v.length === 0 ? undefined : v),
|
|
222
|
+
z.array(z.string()).optional(),
|
|
223
|
+
)
|
|
224
|
+
.describe(
|
|
225
|
+
'Navigation properties to expand (load related entities in one request).\n\n' +
|
|
226
|
+
'This is the OData $expand parameter. Loads related entity objects.\n' +
|
|
227
|
+
'Very useful to get complete data without multiple requests!\n\n' +
|
|
228
|
+
'✅ HOW TO USE:\n' +
|
|
229
|
+
"- Find field ending with 'Id' (e.g., AccountId, ContactId, OwnerId)\n" +
|
|
230
|
+
"- Remove 'Id' suffix to get navigation name: AccountId → Account\n" +
|
|
231
|
+
"- Add to expand array: expand=['Account']\n\n" +
|
|
232
|
+
'� EXAMPLES:\n' +
|
|
233
|
+
"- Get orders with account info: expand=['Account']\n" +
|
|
234
|
+
"- Get contacts with account info: expand=['Account']\n" +
|
|
235
|
+
"- Multiple relations: expand=['Account','Owner']\n" +
|
|
236
|
+
"- Nested expansion: expand=['Account($expand=PrimaryContact)']\n\n" +
|
|
237
|
+
'💡 EXAMPLE REQUEST:\n' +
|
|
238
|
+
" entity: 'Order'\n" +
|
|
239
|
+
" expand: ['Account']\n" +
|
|
240
|
+
" select: ['Id','Number','Amount','AccountId']\n" +
|
|
241
|
+
'Result includes full Account object with all its fields for each order!\n\n' +
|
|
242
|
+
'⚠️ NOTE: When combining $expand with $filter:\n' +
|
|
243
|
+
'- Still include filtered fields in select if using $select\n' +
|
|
244
|
+
'- Expanded entities are added to response, not to select',
|
|
245
|
+
),
|
|
246
|
+
orderBy: z
|
|
247
|
+
.preprocess(
|
|
248
|
+
(v) => (typeof v === 'string' && v.trim() === '' ? undefined : v),
|
|
249
|
+
z.string().optional(),
|
|
250
|
+
)
|
|
251
|
+
.describe(
|
|
252
|
+
'OData $orderby clause for sorting results.\n\n' +
|
|
253
|
+
'Syntax: "FieldName asc" or "FieldName desc"\n' +
|
|
254
|
+
'Multiple fields: "Field1 asc, Field2 desc"\n\n' +
|
|
255
|
+
'✅ EXAMPLES:\n' +
|
|
256
|
+
'- orderBy: "Name asc" - sort by name ascending\n' +
|
|
257
|
+
'- orderBy: "CreatedOn desc" - newest first\n' +
|
|
258
|
+
'- orderBy: "Amount desc" - highest amount first\n' +
|
|
259
|
+
'- orderBy: "Name asc, Amount desc" - sort by multiple fields\n\n' +
|
|
260
|
+
'⚠️ NOTE: You can only sort by direct properties of the entity.\n' +
|
|
261
|
+
'Sorting by navigation properties (like Account/Name) is NOT supported in Creatio OData.',
|
|
262
|
+
),
|
|
263
|
+
top: z.coerce
|
|
264
|
+
.number()
|
|
265
|
+
.int()
|
|
266
|
+
.positive()
|
|
267
|
+
.max(1000)
|
|
268
|
+
.optional()
|
|
269
|
+
.describe('Max rows to return (suggest 25\u2013200 for responsiveness).'),
|
|
270
|
+
} as const;
|
|
271
|
+
export const readInput = z.object(readInputShape);
|
|
272
|
+
|
|
273
|
+
export const readDescriptor = makeToolDescriptor({
|
|
274
|
+
title: 'Read records in Creatio',
|
|
275
|
+
description:
|
|
276
|
+
'Query Creatio records. Workflow: 1) list-entities 2) describe-entity 3) read with select, optional expand, filters/orderBy/top. ' +
|
|
277
|
+
'Key params: select (fields to return), filters or filter (conditions), expand (related entities), orderBy (sorting), top (limit). ' +
|
|
278
|
+
'Always include fields used in filters in select when select is provided. Use structured filters over raw $filter when possible. ' +
|
|
279
|
+
"Use expand to load related entities in one request (e.g. expand:['Account']). " +
|
|
280
|
+
'For date/time filtering see /datetime-guide prompt. For Contact/Owner filtering see /contactid-guide prompt. ' +
|
|
281
|
+
"Example: entity:'Order', select:['Id','Number','Amount','AccountId'], filters:{ all:[{ field:'AccountId', op:'eq', value:'<guid>' }] }, expand:['Account'], orderBy:'Amount desc', top:10",
|
|
282
|
+
inputShape: readInputShape,
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
const createInputShape = {
|
|
286
|
+
entity: z
|
|
287
|
+
.string()
|
|
288
|
+
.min(1)
|
|
289
|
+
.describe(
|
|
290
|
+
'Entity set to create a record in (e.g., Contact, Account). Tip: use "describe-entity" to find required fields and types before creating.',
|
|
291
|
+
),
|
|
292
|
+
data: z
|
|
293
|
+
.record(z.string(), z.any())
|
|
294
|
+
.describe(
|
|
295
|
+
'Field map for new record.\n\n' +
|
|
296
|
+
DATA_TYPES_DESC.BASIC +
|
|
297
|
+
'\n\n' +
|
|
298
|
+
DATA_TYPES_DESC.LOOKUPS +
|
|
299
|
+
'\n\n' +
|
|
300
|
+
DATA_TYPES_DESC.DATES +
|
|
301
|
+
'\n\n' +
|
|
302
|
+
"💡 TIP: Call 'describe-entity' first to see required fields and their types!",
|
|
303
|
+
),
|
|
304
|
+
} as const;
|
|
305
|
+
export const createInput = z.object(createInputShape);
|
|
306
|
+
|
|
307
|
+
export const createDescriptor = makeToolDescriptor({
|
|
308
|
+
title: 'Create record in Creatio',
|
|
309
|
+
description:
|
|
310
|
+
"Create a single Creatio record. Use 'describe-entity' first to confirm required fields & types. " +
|
|
311
|
+
'Provide entity and data map. Only include fields you need. ' +
|
|
312
|
+
'ALL DATE/TIME FIELDS: For ANY date/time field (StartDate, DueDate, RemindToOwnerDate, CreatedOn overrides, custom date columns) ALWAYS use /datetime-guide for UTC conversion & formatting. ' +
|
|
313
|
+
'ALL CONTACT / USER LOOKUP FIELDS: For ANY field pointing to a user/contact (OwnerId, AuthorId, CreatedById, ModifiedById, ResponsibleId, ManagerId, SupervisorId, and similar *Id fields referencing sys users) use /contactid-guide to resolve correct ContactId. Avoid guessing IDs. ' +
|
|
314
|
+
'🎯 DEFAULT OWNER/AUTHOR: Activities and tasks are ALWAYS created for the CURRENT USER by default! Set OwnerId and AuthorId to current user\'s ContactId (from get-current-user-info or SysAdminUnit.ContactId) unless user EXPLICITLY says "for [another person]". Don\'t ask "for whom?" - default to current user! ' +
|
|
315
|
+
'Activities (Task/Meeting/Call/Email): HARD RULE → Always set TypeId to Task (fbe0acdc-cfc0-df11-b00f-001d60e938c6) and vary only ActivityCategoryId for meeting/call/email intent unless user explicitly says phrases like: "real meeting type", "true call type", "not a task", "use Visit type". Do NOT look up ActivityType for ordinary meeting/call/email requests. To intentionally allow a non-Task type, caller must add meta flag __allowNonTaskType=true. See /create-activity-guide prompt. ' +
|
|
316
|
+
'Tagging: use /tagging-guide prompt. ' +
|
|
317
|
+
"Examples: Account → data={ Name:'Acme Corp', Phone:'+1-234-567' }; Contact → data={ Name:'John Doe', Email:'john@example.com' }",
|
|
318
|
+
inputShape: createInputShape,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
const updateInputShape = {
|
|
322
|
+
entity: z.string().min(1).describe('Entity set to update (e.g., Contact, Account).'),
|
|
323
|
+
id: z
|
|
324
|
+
.string()
|
|
325
|
+
.min(1)
|
|
326
|
+
.describe(
|
|
327
|
+
'Primary key of the record. Pass GUIDs as-is (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). Non-GUID strings will be quoted automatically.',
|
|
328
|
+
),
|
|
329
|
+
data: z
|
|
330
|
+
.record(z.string(), z.any())
|
|
331
|
+
.describe(
|
|
332
|
+
'Partial fields to change. Only include properties that should be updated.\n\n' +
|
|
333
|
+
DATA_TYPES_DESC.BASIC +
|
|
334
|
+
' (same as create)\n\n' +
|
|
335
|
+
DATA_TYPES_DESC.DATES +
|
|
336
|
+
'\n\n' +
|
|
337
|
+
'COMMON UPDATE SCENARIOS:\n' +
|
|
338
|
+
'- Change Activity time: { StartDate: "2025-10-09T14:00:00Z" }\n' +
|
|
339
|
+
'- Update status: { StatusId: "<GUID from ActivityStatus>" }\n' +
|
|
340
|
+
'- Reschedule with reminder: { StartDate: "...", RemindToOwnerDate: "..." }\n' +
|
|
341
|
+
'- Change account: { AccountId: "guid..." }\n\n' +
|
|
342
|
+
'💡 For Activities: Query lookup tables (ActivityStatus, ActivityPriority) to get new IDs dynamically!',
|
|
343
|
+
),
|
|
344
|
+
} as const;
|
|
345
|
+
export const updateInput = z.object(updateInputShape);
|
|
346
|
+
|
|
347
|
+
export const updateDescriptor = makeToolDescriptor({
|
|
348
|
+
title: 'Update record in Creatio',
|
|
349
|
+
description:
|
|
350
|
+
'Update a record by Id (PATCH). Supply entity, id, and partial data containing only changed fields. ' +
|
|
351
|
+
"Examples: Account → data={ Name:'Updated Name' }; Contact → data={ Email:'new@example.com' }. " +
|
|
352
|
+
'DATE/TIME: For ANY date/time modifications (reschedule StartDate, set DueDate, reminders, custom date columns, CreatedOn override when allowed) consult /datetime-guide prompt (always send UTC). ' +
|
|
353
|
+
'CONTACT/USER FIELDS: When changing OwnerId, AuthorId, ModifiedById (rare), ResponsibleId, ManagerId, etc use /contactid-guide prompt to resolve valid ContactId. Do NOT invent or reuse unrelated IDs. ' +
|
|
354
|
+
'Activities: /create-activity-guide prompt (overall), /datetime-guide prompt (time changes), /contactid-guide prompt (participants/Owner).',
|
|
355
|
+
inputShape: updateInputShape,
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
const deleteInputShape = {
|
|
359
|
+
entity: z.string().min(1).describe('Entity set to delete from (e.g., Contact, Account).'),
|
|
360
|
+
id: z
|
|
361
|
+
.string()
|
|
362
|
+
.min(1)
|
|
363
|
+
.describe(
|
|
364
|
+
'Primary key of the record to delete. GUIDs can be passed as-is; non-GUID strings will be quoted automatically.',
|
|
365
|
+
),
|
|
366
|
+
} as const;
|
|
367
|
+
export const deleteInput = z.object(deleteInputShape);
|
|
368
|
+
|
|
369
|
+
export const deleteDescriptor = makeToolDescriptor({
|
|
370
|
+
title: 'Delete record in Creatio',
|
|
371
|
+
description:
|
|
372
|
+
'Delete a single record by Id.\n\n' +
|
|
373
|
+
'⚠️ ALWAYS confirm with user before deleting!\n' +
|
|
374
|
+
'1. Show what will be deleted (entity, ID, identifying info)\n' +
|
|
375
|
+
'2. Ask: "Are you sure you want to delete this record?"\n' +
|
|
376
|
+
'3. Wait for explicit confirmation\n\n' +
|
|
377
|
+
'💡 SAFER ALTERNATIVE - Soft Delete:\n' +
|
|
378
|
+
'Instead of permanent deletion, update status: IsActive=false, IsDeleted=true\n' +
|
|
379
|
+
"Example: Use 'update' tool with data={ IsActive: false }",
|
|
380
|
+
inputShape: deleteInputShape,
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
export const listEntitiesInput = z.object({});
|
|
384
|
+
|
|
385
|
+
export const listEntitiesDescriptor = makeToolDescriptor({
|
|
386
|
+
title: 'Get entities from Creatio',
|
|
387
|
+
description:
|
|
388
|
+
'Return all available Creatio OData entity sets. Start here, then use "describe-entity" to inspect fields and keys before performing CRUD.',
|
|
389
|
+
inputShape: {},
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
const describeEntityInputShape = {
|
|
393
|
+
entitySet: z
|
|
394
|
+
.string()
|
|
395
|
+
.min(1)
|
|
396
|
+
.describe(
|
|
397
|
+
'Entity set name to describe (e.g., Contact, Account). Returns entity type, key fields, and properties with types/nullable. Use this to plan subsequent read/create/update/delete.',
|
|
398
|
+
),
|
|
399
|
+
} as const;
|
|
400
|
+
export const describeEntityInput = z.object(describeEntityInputShape);
|
|
401
|
+
|
|
402
|
+
export const describeEntityDescriptor = makeToolDescriptor({
|
|
403
|
+
title: 'Get entity description from Creatio',
|
|
404
|
+
description:
|
|
405
|
+
'Inspect schema for the given entity set: entity type, primary key(s), and properties with types/nullable. Use this before CRUD to avoid invalid fields.',
|
|
406
|
+
inputShape: describeEntityInputShape,
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
const executeProcessInputShape = {
|
|
410
|
+
processName: z
|
|
411
|
+
.string()
|
|
412
|
+
.min(1)
|
|
413
|
+
.describe(
|
|
414
|
+
'REQUIRED: Schema name of the Creatio business process (e.g., "RunActualizeProcess").\n' +
|
|
415
|
+
'IMPORTANT: This parameter accepts ONLY schema names, NOT display names/captions.\n' +
|
|
416
|
+
'If user provides a display name/caption (e.g., "Actualize Process"), you MUST first use the "read" tool to find the corresponding schema name in VwProcessLib table:\n' +
|
|
417
|
+
"- Use filter: contains(Caption,'user_provided_name')\n" +
|
|
418
|
+
'- Select fields: ["Name", "Caption"]\n' +
|
|
419
|
+
'- Use the "Name" field value as processName parameter.',
|
|
420
|
+
),
|
|
421
|
+
parameters: z
|
|
422
|
+
.record(z.string(), z.any())
|
|
423
|
+
.optional()
|
|
424
|
+
.describe(
|
|
425
|
+
'Parameters to pass to the business process as key-value pairs. Parameter names typically start with uppercase letter. Examples:\n' +
|
|
426
|
+
'- ContactId: "2ad0270b-dc4c-4fbf-9219-df32ce4c34fc" (GUID values)\n' +
|
|
427
|
+
'- Amount: 1000 (numeric values)\n' +
|
|
428
|
+
'- Text: "SomeText" (string values)\n' +
|
|
429
|
+
'- BoolParam: true (boolean values)\n' +
|
|
430
|
+
'Common parameter patterns: ContactId, AccountId, OpportunityId, Amount, Description, etc.',
|
|
431
|
+
),
|
|
432
|
+
} as const;
|
|
433
|
+
export const executeProcessInput = z.object(executeProcessInputShape);
|
|
434
|
+
|
|
435
|
+
export const executeProcessDescriptor = makeToolDescriptor({
|
|
436
|
+
title: 'Execute Creatio Business Process',
|
|
437
|
+
description:
|
|
438
|
+
'Execute a Creatio CRM business process with optional parameters. This tool runs server-side business processes in Creatio platform.\n\n' +
|
|
439
|
+
'WORKFLOW FOR LLM:\n' +
|
|
440
|
+
'1. If user provides display name/caption (e.g., "Lead Qualification Process"):\n' +
|
|
441
|
+
' - First use "read" tool on VwProcessLib entity\n' +
|
|
442
|
+
" - Filter: contains(Caption,'user_provided_name')\n" +
|
|
443
|
+
' - Select: ["Name", "Caption"]\n' +
|
|
444
|
+
' - Use the "Name" field value as processName parameter\n' +
|
|
445
|
+
'2. If user provides schema name directly (e.g., "UsrLeadQualificationProcess"):\n' +
|
|
446
|
+
' - Use it directly as processName parameter\n\n' +
|
|
447
|
+
'Process Identification:\n' +
|
|
448
|
+
'- This tool accepts ONLY schema names (e.g., "RunActualizeProcess")\n' +
|
|
449
|
+
'- Schema names are technical identifiers stored in VwProcessLib.Name column\n' +
|
|
450
|
+
'- Display names/captions are user-friendly names in VwProcessLib.Caption column\n\n' +
|
|
451
|
+
'Parameters:\n' +
|
|
452
|
+
'- Passed as object with key-value pairs\n' +
|
|
453
|
+
'- Parameter names typically start with uppercase letter\n' +
|
|
454
|
+
'- Supports all JSON types: strings, numbers, booleans, GUIDs\n\n' +
|
|
455
|
+
'Common Parameter Patterns:\n' +
|
|
456
|
+
'- Entity IDs: ContactId, AccountId, OpportunityId, LeadId, CaseId\n' +
|
|
457
|
+
'- Amounts: Amount, Price, Sum, Cost\n' +
|
|
458
|
+
'- Text fields: Description, Notes, Text, Comment, Title\n' +
|
|
459
|
+
'- Flags: IsActive, IsCompleted, SendEmail, CreateActivity\n' +
|
|
460
|
+
'- Dates: StartDate, EndDate, DueDate (ISO format)\n\n' +
|
|
461
|
+
'GUID & Date Helpers: /datetime-guide prompt applies to EVERY date/time parameter (convert to UTC). /contactid-guide prompt applies to EVERY user/contact participant parameter (OwnerId, AuthorId, AssigneeId, ResponsibleId, CreatedById overrides, etc).\n\n' +
|
|
462
|
+
'Example:\n' +
|
|
463
|
+
'{\n' +
|
|
464
|
+
' "processName": "Lead Management Process",\n' +
|
|
465
|
+
' "parameters": {\n' +
|
|
466
|
+
' "ContactId": "2ad0270b-dc4c-4fbf-9219-df32ce4c34fc",\n' +
|
|
467
|
+
' "Amount": 15000,\n' +
|
|
468
|
+
' "Description": "High priority lead",\n' +
|
|
469
|
+
' "SendNotification": true\n' +
|
|
470
|
+
' }\n' +
|
|
471
|
+
'}\n\n' +
|
|
472
|
+
'Uses Creatio ProcessEngineService.svc/Execute endpoint for execution.',
|
|
473
|
+
inputShape: executeProcessInputShape,
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
const querySysSettingsInputShape = {
|
|
477
|
+
sysSettingCodes: z
|
|
478
|
+
.array(z.string().min(1))
|
|
479
|
+
.min(1)
|
|
480
|
+
.describe(
|
|
481
|
+
'List of system setting codes to query. Provide at least one Creatio sys setting code (e.g., "EmailDefSendName", "SupportEmail").',
|
|
482
|
+
),
|
|
483
|
+
} as const;
|
|
484
|
+
|
|
485
|
+
export const querySysSettingsInput = z.object(querySysSettingsInputShape);
|
|
486
|
+
|
|
487
|
+
export const querySysSettingsDescriptor = makeToolDescriptor({
|
|
488
|
+
title: 'Query system settings in Creatio',
|
|
489
|
+
description:
|
|
490
|
+
'Retrieve the current values and metadata for one or more Creatio system settings using the QuerySysSettings endpoint. Returns the raw response including success flag, values map, and notFoundSettings array (if any).',
|
|
491
|
+
inputShape: querySysSettingsInputShape,
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
const SYS_SETTING_VALUE_TYPE_DESC =
|
|
495
|
+
'Creatio data value type name. See /sys-settings-guide prompt for the table of supported valueTypeName values (Binary, Boolean, DateTime, etc.) and always send the raw value string.';
|
|
496
|
+
|
|
497
|
+
const SYS_SETTING_REFERENCE_SCHEMA_DESC =
|
|
498
|
+
'EntitySchema UId for lookup system settings. Required only when valueTypeName="Lookup". See /sys-settings-guide prompt for the recommended VwWorkspaceObjects query to retrieve this UId.';
|
|
499
|
+
|
|
500
|
+
const sysSettingDefinitionFieldShape = {
|
|
501
|
+
code: z
|
|
502
|
+
.string()
|
|
503
|
+
.min(1)
|
|
504
|
+
.describe(
|
|
505
|
+
'Unique system setting code (e.g., "TestSetting"). Must follow Creatio naming rules.',
|
|
506
|
+
),
|
|
507
|
+
name: z.string().min(1).describe('Display name rendered in Creatio UI (e.g., "Test setting").'),
|
|
508
|
+
valueTypeName: z.string().min(1).describe(SYS_SETTING_VALUE_TYPE_DESC),
|
|
509
|
+
description: z.string().optional(),
|
|
510
|
+
isCacheable: z.boolean().optional(),
|
|
511
|
+
isPersonal: z.boolean().optional(),
|
|
512
|
+
isSSPAvailable: z.boolean().optional(),
|
|
513
|
+
referenceSchemaUId: z.string().optional().describe(SYS_SETTING_REFERENCE_SCHEMA_DESC),
|
|
514
|
+
dataValueType: z.union([z.string(), z.number()]).optional(),
|
|
515
|
+
} as const;
|
|
516
|
+
|
|
517
|
+
const sysSettingDefinitionSchema = z.object(sysSettingDefinitionFieldShape);
|
|
518
|
+
|
|
519
|
+
const createSysSettingDefinitionSchema = sysSettingDefinitionSchema.extend({
|
|
520
|
+
id: z
|
|
521
|
+
.string()
|
|
522
|
+
.uuid()
|
|
523
|
+
.optional()
|
|
524
|
+
.describe('Optional GUID for the sys setting record. Auto-generated when omitted.'),
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
const updateSysSettingDefinitionSchema = sysSettingDefinitionSchema.partial().extend({
|
|
528
|
+
code: sysSettingDefinitionFieldShape.code,
|
|
529
|
+
name: sysSettingDefinitionFieldShape.name,
|
|
530
|
+
valueTypeName: sysSettingDefinitionFieldShape.valueTypeName,
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
const createSysSettingInputShape = {
|
|
534
|
+
definition: createSysSettingDefinitionSchema,
|
|
535
|
+
initialValue: z
|
|
536
|
+
.any()
|
|
537
|
+
.optional()
|
|
538
|
+
.describe('Optional initial value to write immediately after creating the system setting.'),
|
|
539
|
+
} as const;
|
|
540
|
+
|
|
541
|
+
export const createSysSettingInput = z.object(createSysSettingInputShape);
|
|
542
|
+
|
|
543
|
+
export const createSysSettingDescriptor = makeToolDescriptor({
|
|
544
|
+
title: 'Create a new system setting in Creatio',
|
|
545
|
+
description:
|
|
546
|
+
'Creates a brand-new system setting (metadata record) using InsertSysSettingRequest and optionally assigns an initial value via PostSysSettingsValues. For full guidance on supported valueTypeName strings and lookup reference resolution, see the /sys-settings-guide prompt.',
|
|
547
|
+
inputShape: createSysSettingInputShape,
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
const setSysSettingsValueInputShape = {
|
|
551
|
+
sysSettingsValues: z
|
|
552
|
+
.record(z.string(), z.any())
|
|
553
|
+
.describe(
|
|
554
|
+
'Map of system setting codes to their new values. Accepts any JSON-compatible types (string, number, boolean, object, array).\n\n' +
|
|
555
|
+
'Examples:\n' +
|
|
556
|
+
"- Single setting: { 'SettingCode': 'value' }\n" +
|
|
557
|
+
"- Multiple settings: { 'SettingCode1': 'value1', 'SettingCode2': 123, 'SettingCode3': true }\n" +
|
|
558
|
+
"- Mixed types: { 'EmailEnabled': true, 'MaxRetries': 5, 'ApiKey': 'secret' }",
|
|
559
|
+
),
|
|
560
|
+
} as const;
|
|
561
|
+
|
|
562
|
+
export const setSysSettingsValueInput = z.object(setSysSettingsValueInputShape);
|
|
563
|
+
|
|
564
|
+
export const setSysSettingsValueDescriptor = makeToolDescriptor({
|
|
565
|
+
title: 'Set system settings values in Creatio',
|
|
566
|
+
description:
|
|
567
|
+
'Update one or more system settings in Creatio in a single request.\n\n' +
|
|
568
|
+
'Parameters:\n' +
|
|
569
|
+
'- sysSettingsValues: A map/object of system setting codes to their new values. Supports any JSON-compatible types (string, number, boolean, object, array).\n\n' +
|
|
570
|
+
'USAGE:\n' +
|
|
571
|
+
'- Update single setting: { "SettingCode": "value" }\n' +
|
|
572
|
+
'- Update multiple settings at once: { "SettingCode1": "value1", "SettingCode2": 123, "SettingCode3": true }\n' +
|
|
573
|
+
'- Mixed data types: { "EmailEnabled": true, "MaxRetries": 5, "ApiKey": "secret" }\n\n' +
|
|
574
|
+
'Returns the result from the system settings update endpoint.',
|
|
575
|
+
inputShape: setSysSettingsValueInputShape,
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
const updateSysSettingDefinitionInputShape = {
|
|
579
|
+
id: z.string().uuid().describe('Existing SysSetting Id (Guid) to update.'),
|
|
580
|
+
definition: updateSysSettingDefinitionSchema.describe(
|
|
581
|
+
'Creatio requires Code, Name, and valueTypeName on every UpdateSysSettingRequest. Always include those fields (existing values are OK) plus any other properties that need updating.',
|
|
582
|
+
),
|
|
583
|
+
} as const;
|
|
584
|
+
|
|
585
|
+
export const updateSysSettingDefinitionInput = z.object(updateSysSettingDefinitionInputShape);
|
|
586
|
+
|
|
587
|
+
export const updateSysSettingDefinitionDescriptor = makeToolDescriptor({
|
|
588
|
+
title: 'Update existing system setting definition',
|
|
589
|
+
description:
|
|
590
|
+
'Calls the UpdateSysSettingRequest endpoint to modify metadata such as name, description, valueTypeName, cache flags, personalization flags, and lookup reference schema. IMPORTANT: Creatio validates that Code, Name, and valueTypeName are present on every update, even if they are unchanged—copy the current values when needed. See the /sys-settings-guide prompt for allowed value types and lookup resolution tips.',
|
|
591
|
+
inputShape: updateSysSettingDefinitionInputShape,
|
|
592
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
|
|
3
|
+
import log from '../../log';
|
|
4
|
+
|
|
5
|
+
import type { OAuthClient } from './types';
|
|
6
|
+
|
|
7
|
+
export class OAuthClientManager {
|
|
8
|
+
public static autoRegisterClient(client_id: string, redirect_uri: string): OAuthClient {
|
|
9
|
+
let clientName = 'Unknown MCP Client';
|
|
10
|
+
const redirectUris = [redirect_uri];
|
|
11
|
+
if (client_id.includes('claude')) {
|
|
12
|
+
clientName = 'Claude Desktop';
|
|
13
|
+
} else if (client_id.includes('vscode')) {
|
|
14
|
+
clientName = 'VS Code';
|
|
15
|
+
} else if (client_id.includes('cursor')) {
|
|
16
|
+
clientName = 'Cursor';
|
|
17
|
+
}
|
|
18
|
+
const client: OAuthClient = {
|
|
19
|
+
client_id,
|
|
20
|
+
redirect_uris: redirectUris,
|
|
21
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
22
|
+
response_types: ['code'],
|
|
23
|
+
token_endpoint_auth_method: 'none',
|
|
24
|
+
created_at: Date.now(),
|
|
25
|
+
};
|
|
26
|
+
log.info('oauth.client.auto_registered', {
|
|
27
|
+
client_id,
|
|
28
|
+
client_name: clientName,
|
|
29
|
+
redirect_uris: redirectUris,
|
|
30
|
+
});
|
|
31
|
+
return client;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public static createClient(redirect_uris: string[]): OAuthClient {
|
|
35
|
+
const client_id = crypto.randomUUID();
|
|
36
|
+
const client: OAuthClient = {
|
|
37
|
+
client_id,
|
|
38
|
+
redirect_uris,
|
|
39
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
40
|
+
response_types: ['code'],
|
|
41
|
+
token_endpoint_auth_method: 'none',
|
|
42
|
+
created_at: Date.now(),
|
|
43
|
+
};
|
|
44
|
+
log.info('oauth.client.registered', { client_id, redirect_uris });
|
|
45
|
+
return client;
|
|
46
|
+
}
|
|
47
|
+
}
|