@ffschrattenecker/tm1-mcp-server 6.0.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/CHANGELOG.md +1211 -0
- package/LICENSE +21 -0
- package/NOTICE +34 -0
- package/README.md +276 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.js +238 -0
- package/dist/http-transport.d.ts +8 -0
- package/dist/http-transport.js +132 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +164 -0
- package/dist/lib/callgraph/callGraph.d.ts +124 -0
- package/dist/lib/callgraph/callGraph.js +334 -0
- package/dist/lib/callgraph/choreGraph.d.ts +23 -0
- package/dist/lib/callgraph/choreGraph.js +102 -0
- package/dist/lib/callgraph/dataFlow.d.ts +74 -0
- package/dist/lib/callgraph/dataFlow.js +271 -0
- package/dist/lib/callgraph/datasourceMembership.d.ts +31 -0
- package/dist/lib/callgraph/datasourceMembership.js +142 -0
- package/dist/lib/callgraph/lintTypes.d.ts +28 -0
- package/dist/lib/callgraph/lintTypes.js +2 -0
- package/dist/lib/callgraph/mdxMembers.d.ts +29 -0
- package/dist/lib/callgraph/mdxMembers.js +97 -0
- package/dist/lib/callgraph/referenceIndex.d.ts +179 -0
- package/dist/lib/callgraph/referenceIndex.js +584 -0
- package/dist/lib/callgraph/rulesLinter.d.ts +55 -0
- package/dist/lib/callgraph/rulesLinter.js +776 -0
- package/dist/lib/callgraph/rulesParser.d.ts +26 -0
- package/dist/lib/callgraph/rulesParser.js +71 -0
- package/dist/lib/callgraph/subsetUsage.d.ts +16 -0
- package/dist/lib/callgraph/subsetUsage.js +134 -0
- package/dist/lib/callgraph/tiParser.d.ts +21 -0
- package/dist/lib/callgraph/tiParser.js +672 -0
- package/dist/lib/callgraph/tiSignatures.d.ts +32 -0
- package/dist/lib/callgraph/tiSignatures.js +6185 -0
- package/dist/lib/callgraph/tm1-adapter.d.ts +32 -0
- package/dist/lib/callgraph/tm1-adapter.js +159 -0
- package/dist/lib/callgraph/types.d.ts +53 -0
- package/dist/lib/callgraph/types.js +2 -0
- package/dist/lib/callgraph/variableEnv.d.ts +86 -0
- package/dist/lib/callgraph/variableEnv.js +214 -0
- package/dist/lib/cell-address.d.ts +12 -0
- package/dist/lib/cell-address.js +71 -0
- package/dist/lib/complexity/antipatterns.d.ts +22 -0
- package/dist/lib/complexity/antipatterns.js +302 -0
- package/dist/lib/complexity/comment-classifier.d.ts +24 -0
- package/dist/lib/complexity/comment-classifier.js +43 -0
- package/dist/lib/complexity/cross-process.d.ts +78 -0
- package/dist/lib/complexity/cross-process.js +114 -0
- package/dist/lib/complexity/process-metrics.d.ts +78 -0
- package/dist/lib/complexity/process-metrics.js +278 -0
- package/dist/lib/complexity/rules-metrics.d.ts +31 -0
- package/dist/lib/complexity/rules-metrics.js +99 -0
- package/dist/lib/concurrency.d.ts +11 -0
- package/dist/lib/concurrency.js +27 -0
- package/dist/lib/control-name.d.ts +10 -0
- package/dist/lib/control-name.js +10 -0
- package/dist/lib/coordinate-error.d.ts +3 -0
- package/dist/lib/coordinate-error.js +29 -0
- package/dist/lib/credential-format.d.ts +23 -0
- package/dist/lib/credential-format.js +25 -0
- package/dist/lib/cube-stats/fetcher.d.ts +106 -0
- package/dist/lib/cube-stats/fetcher.js +194 -0
- package/dist/lib/feeders/brackets.d.ts +47 -0
- package/dist/lib/feeders/brackets.js +195 -0
- package/dist/lib/feeders/element-type-cache.d.ts +42 -0
- package/dist/lib/feeders/element-type-cache.js +86 -0
- package/dist/lib/feeders/static-heuristics.d.ts +101 -0
- package/dist/lib/feeders/static-heuristics.js +202 -0
- package/dist/lib/git-process.d.ts +67 -0
- package/dist/lib/git-process.js +243 -0
- package/dist/lib/mask-secrets.d.ts +10 -0
- package/dist/lib/mask-secrets.js +99 -0
- package/dist/lib/mdx.d.ts +3 -0
- package/dist/lib/mdx.js +13 -0
- package/dist/lib/naming/odata-filter.d.ts +15 -0
- package/dist/lib/naming/odata-filter.js +81 -0
- package/dist/lib/naming/rules.d.ts +34 -0
- package/dist/lib/naming/rules.js +215 -0
- package/dist/lib/pro-parser.d.ts +19 -0
- package/dist/lib/pro-parser.js +260 -0
- package/dist/lib/pro-serializer.d.ts +19 -0
- package/dist/lib/pro-serializer.js +170 -0
- package/dist/lib/process-parts-schema.d.ts +45 -0
- package/dist/lib/process-parts-schema.js +46 -0
- package/dist/lib/process-refs.d.ts +88 -0
- package/dist/lib/process-refs.js +441 -0
- package/dist/lib/rules-outline.d.ts +29 -0
- package/dist/lib/rules-outline.js +68 -0
- package/dist/lib/rules-patch.d.ts +6 -0
- package/dist/lib/rules-patch.js +59 -0
- package/dist/lib/safe-regex.d.ts +15 -0
- package/dist/lib/safe-regex.js +37 -0
- package/dist/lib/sample-cells.d.ts +48 -0
- package/dist/lib/sample-cells.js +146 -0
- package/dist/lib/slim-json-schema.d.ts +20 -0
- package/dist/lib/slim-json-schema.js +68 -0
- package/dist/lib/strip-comments.d.ts +23 -0
- package/dist/lib/strip-comments.js +61 -0
- package/dist/lib/tm1-events.d.ts +16 -0
- package/dist/lib/tm1-events.js +29 -0
- package/dist/lib/v12-compat/deprecated-ti.d.ts +17 -0
- package/dist/lib/v12-compat/deprecated-ti.js +257 -0
- package/dist/lib/v12-compat/scanner.d.ts +10 -0
- package/dist/lib/v12-compat/scanner.js +43 -0
- package/dist/lib/variables-ui-data.d.ts +26 -0
- package/dist/lib/variables-ui-data.js +77 -0
- package/dist/load-env.d.ts +2 -0
- package/dist/load-env.js +29 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.js +60 -0
- package/dist/prompts/index.d.ts +3 -0
- package/dist/prompts/index.js +141 -0
- package/dist/resources/index.d.ts +5 -0
- package/dist/resources/index.js +237 -0
- package/dist/resources/list-handler.d.ts +40 -0
- package/dist/resources/list-handler.js +86 -0
- package/dist/resources/subscriptions.d.ts +19 -0
- package/dist/resources/subscriptions.js +80 -0
- package/dist/schemas/cells.d.ts +17 -0
- package/dist/schemas/cells.js +13 -0
- package/dist/schemas/common.d.ts +16 -0
- package/dist/schemas/common.js +14 -0
- package/dist/schemas/index.d.ts +10 -0
- package/dist/schemas/index.js +23 -0
- package/dist/schemas/metadata.d.ts +70 -0
- package/dist/schemas/metadata.js +47 -0
- package/dist/schemas/monitoring.d.ts +95 -0
- package/dist/schemas/monitoring.js +69 -0
- package/dist/schemas/processes.d.ts +74 -0
- package/dist/schemas/processes.js +66 -0
- package/dist/schemas/scheduling.d.ts +13 -0
- package/dist/schemas/scheduling.js +13 -0
- package/dist/schemas/security.d.ts +19 -0
- package/dist/schemas/security.js +16 -0
- package/dist/schemas/subsets.d.ts +12 -0
- package/dist/schemas/subsets.js +12 -0
- package/dist/schemas/views.d.ts +9 -0
- package/dist/schemas/views.js +9 -0
- package/dist/session-manager.d.ts +79 -0
- package/dist/session-manager.js +281 -0
- package/dist/tm1-client/connection/profile.d.ts +13 -0
- package/dist/tm1-client/connection/profile.js +99 -0
- package/dist/tm1-client/dispatcher.d.ts +5 -0
- package/dist/tm1-client/dispatcher.js +31 -0
- package/dist/tm1-client/http.d.ts +81 -0
- package/dist/tm1-client/http.js +547 -0
- package/dist/tm1-client/services/batch-service.d.ts +123 -0
- package/dist/tm1-client/services/batch-service.js +455 -0
- package/dist/tm1-client/services/cell-service.d.ts +71 -0
- package/dist/tm1-client/services/cell-service.js +333 -0
- package/dist/tm1-client/services/cellset-transform.d.ts +26 -0
- package/dist/tm1-client/services/cellset-transform.js +80 -0
- package/dist/tm1-client/services/chore-service.d.ts +68 -0
- package/dist/tm1-client/services/chore-service.js +179 -0
- package/dist/tm1-client/services/chore-status.d.ts +11 -0
- package/dist/tm1-client/services/chore-status.js +127 -0
- package/dist/tm1-client/services/cube-service.d.ts +134 -0
- package/dist/tm1-client/services/cube-service.js +294 -0
- package/dist/tm1-client/services/dimension-service.d.ts +118 -0
- package/dist/tm1-client/services/dimension-service.js +249 -0
- package/dist/tm1-client/services/element-service.d.ts +245 -0
- package/dist/tm1-client/services/element-service.js +809 -0
- package/dist/tm1-client/services/fallback.d.ts +44 -0
- package/dist/tm1-client/services/fallback.js +72 -0
- package/dist/tm1-client/services/file-service.d.ts +53 -0
- package/dist/tm1-client/services/file-service.js +218 -0
- package/dist/tm1-client/services/hierarchy-service.d.ts +129 -0
- package/dist/tm1-client/services/hierarchy-service.js +332 -0
- package/dist/tm1-client/services/monitoring-service.d.ts +34 -0
- package/dist/tm1-client/services/monitoring-service.js +123 -0
- package/dist/tm1-client/services/odata-page.d.ts +71 -0
- package/dist/tm1-client/services/odata-page.js +87 -0
- package/dist/tm1-client/services/process-service.d.ts +278 -0
- package/dist/tm1-client/services/process-service.js +874 -0
- package/dist/tm1-client/services/process-status.d.ts +21 -0
- package/dist/tm1-client/services/process-status.js +89 -0
- package/dist/tm1-client/services/security-service.d.ts +50 -0
- package/dist/tm1-client/services/security-service.js +93 -0
- package/dist/tm1-client/services/server-service.d.ts +116 -0
- package/dist/tm1-client/services/server-service.js +504 -0
- package/dist/tm1-client/services/subset-service.d.ts +37 -0
- package/dist/tm1-client/services/subset-service.js +122 -0
- package/dist/tm1-client/services/view-service.d.ts +46 -0
- package/dist/tm1-client/services/view-service.js +287 -0
- package/dist/tm1-client.d.ts +56 -0
- package/dist/tm1-client.js +126 -0
- package/dist/tools/analysis/analyze-callgraph.d.ts +28 -0
- package/dist/tools/analysis/analyze-callgraph.js +350 -0
- package/dist/tools/analysis/analyze-chore-graph.d.ts +2 -0
- package/dist/tools/analysis/analyze-chore-graph.js +148 -0
- package/dist/tools/analysis/analyze-object-usage.d.ts +2 -0
- package/dist/tools/analysis/analyze-object-usage.js +143 -0
- package/dist/tools/analysis/audit-complexity.d.ts +2 -0
- package/dist/tools/analysis/audit-complexity.js +255 -0
- package/dist/tools/analysis/audit-feeders.d.ts +2 -0
- package/dist/tools/analysis/audit-feeders.js +417 -0
- package/dist/tools/analysis/audit-naming.d.ts +2 -0
- package/dist/tools/analysis/audit-naming.js +379 -0
- package/dist/tools/analysis/check-v12-readiness.d.ts +2 -0
- package/dist/tools/analysis/check-v12-readiness.js +136 -0
- package/dist/tools/analysis/find-orphan-dimensions.d.ts +2 -0
- package/dist/tools/analysis/find-orphan-dimensions.js +55 -0
- package/dist/tools/analysis/invalidate-callgraph-cache.d.ts +2 -0
- package/dist/tools/analysis/invalidate-callgraph-cache.js +40 -0
- package/dist/tools/analysis/trace-data-flow.d.ts +2 -0
- package/dist/tools/analysis/trace-data-flow.js +138 -0
- package/dist/tools/annotations.d.ts +12 -0
- package/dist/tools/annotations.js +61 -0
- package/dist/tools/celldata/check-feeders.d.ts +2 -0
- package/dist/tools/celldata/check-feeders.js +48 -0
- package/dist/tools/celldata/check-writable-coords.d.ts +2 -0
- package/dist/tools/celldata/check-writable-coords.js +126 -0
- package/dist/tools/celldata/execute-mdx.d.ts +17 -0
- package/dist/tools/celldata/execute-mdx.js +126 -0
- package/dist/tools/celldata/get-cell-value.d.ts +2 -0
- package/dist/tools/celldata/get-cell-value.js +30 -0
- package/dist/tools/celldata/get-view-definition.d.ts +2 -0
- package/dist/tools/celldata/get-view-definition.js +29 -0
- package/dist/tools/celldata/get-view.d.ts +2 -0
- package/dist/tools/celldata/get-view.js +55 -0
- package/dist/tools/celldata/sample-cells.d.ts +2 -0
- package/dist/tools/celldata/sample-cells.js +101 -0
- package/dist/tools/celldata/trace-cell-calculation.d.ts +2 -0
- package/dist/tools/celldata/trace-cell-calculation.js +53 -0
- package/dist/tools/celldata/trace-feeders.d.ts +2 -0
- package/dist/tools/celldata/trace-feeders.js +44 -0
- package/dist/tools/celldata/write-cells.d.ts +2 -0
- package/dist/tools/celldata/write-cells.js +65 -0
- package/dist/tools/confirm.d.ts +10 -0
- package/dist/tools/confirm.js +64 -0
- package/dist/tools/define-tool.d.ts +51 -0
- package/dist/tools/define-tool.js +49 -0
- package/dist/tools/dimension-management/bulk-upsert-elements.d.ts +2 -0
- package/dist/tools/dimension-management/bulk-upsert-elements.js +103 -0
- package/dist/tools/dimension-management/create-dimension.d.ts +2 -0
- package/dist/tools/dimension-management/create-dimension.js +22 -0
- package/dist/tools/dimension-management/create-element-attribute.d.ts +2 -0
- package/dist/tools/dimension-management/create-element-attribute.js +26 -0
- package/dist/tools/dimension-management/create-element.d.ts +2 -0
- package/dist/tools/dimension-management/create-element.js +31 -0
- package/dist/tools/dimension-management/create-hierarchy.d.ts +2 -0
- package/dist/tools/dimension-management/create-hierarchy.js +22 -0
- package/dist/tools/dimension-management/delete-dimension.d.ts +2 -0
- package/dist/tools/dimension-management/delete-dimension.js +25 -0
- package/dist/tools/dimension-management/delete-element.d.ts +2 -0
- package/dist/tools/dimension-management/delete-element.js +26 -0
- package/dist/tools/dimension-management/delete-elements.d.ts +2 -0
- package/dist/tools/dimension-management/delete-elements.js +44 -0
- package/dist/tools/dimension-management/delete-hierarchy.d.ts +2 -0
- package/dist/tools/dimension-management/delete-hierarchy.js +35 -0
- package/dist/tools/dimension-management/get-element-attribute-values.d.ts +2 -0
- package/dist/tools/dimension-management/get-element-attribute-values.js +77 -0
- package/dist/tools/dimension-management/list-element-attributes.d.ts +2 -0
- package/dist/tools/dimension-management/list-element-attributes.js +31 -0
- package/dist/tools/dimension-management/move-element.d.ts +2 -0
- package/dist/tools/dimension-management/move-element.js +28 -0
- package/dist/tools/dimension-management/update-element-attribute-value.d.ts +2 -0
- package/dist/tools/dimension-management/update-element-attribute-value.js +80 -0
- package/dist/tools/dimension-management/update-element.d.ts +2 -0
- package/dist/tools/dimension-management/update-element.js +35 -0
- package/dist/tools/error-format.d.ts +22 -0
- package/dist/tools/error-format.js +130 -0
- package/dist/tools/fileops/delete-file.d.ts +2 -0
- package/dist/tools/fileops/delete-file.js +32 -0
- package/dist/tools/fileops/get-file-content.d.ts +2 -0
- package/dist/tools/fileops/get-file-content.js +76 -0
- package/dist/tools/fileops/list-files.d.ts +2 -0
- package/dist/tools/fileops/list-files.js +43 -0
- package/dist/tools/fileops/search-files.d.ts +2 -0
- package/dist/tools/fileops/search-files.js +76 -0
- package/dist/tools/fileops/upload-file.d.ts +2 -0
- package/dist/tools/fileops/upload-file.js +69 -0
- package/dist/tools/format.d.ts +57 -0
- package/dist/tools/format.js +157 -0
- package/dist/tools/hierarchy.d.ts +6 -0
- package/dist/tools/hierarchy.js +27 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.js +263 -0
- package/dist/tools/local-file.d.ts +16 -0
- package/dist/tools/local-file.js +88 -0
- package/dist/tools/metadata/get-ancestors.d.ts +2 -0
- package/dist/tools/metadata/get-ancestors.js +36 -0
- package/dist/tools/metadata/get-descendants.d.ts +2 -0
- package/dist/tools/metadata/get-descendants.js +64 -0
- package/dist/tools/metadata/get-hierarchy.d.ts +2 -0
- package/dist/tools/metadata/get-hierarchy.js +130 -0
- package/dist/tools/metadata/list-chores.d.ts +2 -0
- package/dist/tools/metadata/list-chores.js +62 -0
- package/dist/tools/metadata/list-cubes.d.ts +2 -0
- package/dist/tools/metadata/list-cubes.js +128 -0
- package/dist/tools/metadata/list-dimensions.d.ts +2 -0
- package/dist/tools/metadata/list-dimensions.js +131 -0
- package/dist/tools/metadata/list-processes-grouped.d.ts +2 -0
- package/dist/tools/metadata/list-processes-grouped.js +96 -0
- package/dist/tools/metadata/list-processes.d.ts +2 -0
- package/dist/tools/metadata/list-processes.js +108 -0
- package/dist/tools/metadata/resolve-default-members.d.ts +2 -0
- package/dist/tools/metadata/resolve-default-members.js +46 -0
- package/dist/tools/model-building/check-cube-rule.d.ts +2 -0
- package/dist/tools/model-building/check-cube-rule.js +51 -0
- package/dist/tools/model-building/clear-cube.d.ts +2 -0
- package/dist/tools/model-building/clear-cube.js +46 -0
- package/dist/tools/model-building/create-cube.d.ts +2 -0
- package/dist/tools/model-building/create-cube.js +34 -0
- package/dist/tools/model-building/delete-cube.d.ts +2 -0
- package/dist/tools/model-building/delete-cube.js +27 -0
- package/dist/tools/model-building/get-all-cube-rules.d.ts +2 -0
- package/dist/tools/model-building/get-all-cube-rules.js +149 -0
- package/dist/tools/model-building/get-cube-rules.d.ts +2 -0
- package/dist/tools/model-building/get-cube-rules.js +69 -0
- package/dist/tools/model-building/rules-source.d.ts +21 -0
- package/dist/tools/model-building/rules-source.js +49 -0
- package/dist/tools/model-building/search-rules.d.ts +2 -0
- package/dist/tools/model-building/search-rules.js +132 -0
- package/dist/tools/model-building/set-cube-rules.d.ts +2 -0
- package/dist/tools/model-building/set-cube-rules.js +81 -0
- package/dist/tools/model-building/unload-cube.d.ts +2 -0
- package/dist/tools/model-building/unload-cube.js +23 -0
- package/dist/tools/operations/diagnose-process-error.d.ts +2 -0
- package/dist/tools/operations/diagnose-process-error.js +178 -0
- package/dist/tools/operations/error-log-helpers.d.ts +25 -0
- package/dist/tools/operations/error-log-helpers.js +57 -0
- package/dist/tools/operations/get-audit-log.d.ts +2 -0
- package/dist/tools/operations/get-audit-log.js +70 -0
- package/dist/tools/operations/get-cube-stats.d.ts +2 -0
- package/dist/tools/operations/get-cube-stats.js +107 -0
- package/dist/tools/operations/get-error-log-content.d.ts +2 -0
- package/dist/tools/operations/get-error-log-content.js +164 -0
- package/dist/tools/operations/get-jobs.d.ts +3 -0
- package/dist/tools/operations/get-jobs.js +51 -0
- package/dist/tools/operations/get-message-log.d.ts +2 -0
- package/dist/tools/operations/get-message-log.js +63 -0
- package/dist/tools/operations/get-server-info.d.ts +2 -0
- package/dist/tools/operations/get-server-info.js +180 -0
- package/dist/tools/operations/get-server-state.d.ts +2 -0
- package/dist/tools/operations/get-server-state.js +129 -0
- package/dist/tools/operations/get-sessions.d.ts +2 -0
- package/dist/tools/operations/get-sessions.js +76 -0
- package/dist/tools/operations/get-threads.d.ts +3 -0
- package/dist/tools/operations/get-threads.js +50 -0
- package/dist/tools/operations/get-transaction-log.d.ts +2 -0
- package/dist/tools/operations/get-transaction-log.js +63 -0
- package/dist/tools/operations/list-error-logs.d.ts +8 -0
- package/dist/tools/operations/list-error-logs.js +157 -0
- package/dist/tools/operations/save-data.d.ts +2 -0
- package/dist/tools/operations/save-data.js +50 -0
- package/dist/tools/pagination.d.ts +32 -0
- package/dist/tools/pagination.js +116 -0
- package/dist/tools/scheduling/create-chore.d.ts +2 -0
- package/dist/tools/scheduling/create-chore.js +93 -0
- package/dist/tools/scheduling/delete-chore.d.ts +2 -0
- package/dist/tools/scheduling/delete-chore.js +22 -0
- package/dist/tools/scheduling/execute-chore.d.ts +2 -0
- package/dist/tools/scheduling/execute-chore.js +52 -0
- package/dist/tools/scheduling/toggle-chore.d.ts +2 -0
- package/dist/tools/scheduling/toggle-chore.js +22 -0
- package/dist/tools/scheduling/update-chore.d.ts +2 -0
- package/dist/tools/scheduling/update-chore.js +71 -0
- package/dist/tools/schemas/common.d.ts +10 -0
- package/dist/tools/schemas/common.js +23 -0
- package/dist/tools/schemas/items-analysis.d.ts +394 -0
- package/dist/tools/schemas/items-analysis.js +419 -0
- package/dist/tools/schemas/items-cells.d.ts +70 -0
- package/dist/tools/schemas/items-cells.js +65 -0
- package/dist/tools/schemas/items-common.d.ts +18 -0
- package/dist/tools/schemas/items-common.js +39 -0
- package/dist/tools/schemas/items-fileops.d.ts +11 -0
- package/dist/tools/schemas/items-fileops.js +13 -0
- package/dist/tools/schemas/items-metadata.d.ts +262 -0
- package/dist/tools/schemas/items-metadata.js +184 -0
- package/dist/tools/schemas/items-monitoring.d.ts +79 -0
- package/dist/tools/schemas/items-monitoring.js +78 -0
- package/dist/tools/schemas/items-processes.d.ts +279 -0
- package/dist/tools/schemas/items-processes.js +235 -0
- package/dist/tools/schemas/items-scheduling.d.ts +25 -0
- package/dist/tools/schemas/items-scheduling.js +26 -0
- package/dist/tools/schemas/items-security.d.ts +19 -0
- package/dist/tools/schemas/items-security.js +12 -0
- package/dist/tools/schemas/items-subsets.d.ts +2 -0
- package/dist/tools/schemas/items-subsets.js +4 -0
- package/dist/tools/schemas/items-views.d.ts +38 -0
- package/dist/tools/schemas/items-views.js +26 -0
- package/dist/tools/schemas/items.d.ts +12 -0
- package/dist/tools/schemas/items.js +23 -0
- package/dist/tools/schemas/markdown-capable.d.ts +21 -0
- package/dist/tools/schemas/markdown-capable.js +58 -0
- package/dist/tools/schemas/output-schema.d.ts +24 -0
- package/dist/tools/schemas/output-schema.js +25 -0
- package/dist/tools/security/assign-client-group.d.ts +2 -0
- package/dist/tools/security/assign-client-group.js +20 -0
- package/dist/tools/security/create-client.d.ts +2 -0
- package/dist/tools/security/create-client.js +28 -0
- package/dist/tools/security/delete-client.d.ts +2 -0
- package/dist/tools/security/delete-client.js +22 -0
- package/dist/tools/security/get-client.d.ts +2 -0
- package/dist/tools/security/get-client.js +20 -0
- package/dist/tools/security/list-clients.d.ts +2 -0
- package/dist/tools/security/list-clients.js +86 -0
- package/dist/tools/security/list-groups.d.ts +2 -0
- package/dist/tools/security/list-groups.js +43 -0
- package/dist/tools/security/remove-client-group.d.ts +2 -0
- package/dist/tools/security/remove-client-group.js +27 -0
- package/dist/tools/security/update-client.d.ts +2 -0
- package/dist/tools/security/update-client.js +22 -0
- package/dist/tools/subsets/create-subset.d.ts +2 -0
- package/dist/tools/subsets/create-subset.js +44 -0
- package/dist/tools/subsets/delete-subset.d.ts +2 -0
- package/dist/tools/subsets/delete-subset.js +26 -0
- package/dist/tools/subsets/get-subset.d.ts +2 -0
- package/dist/tools/subsets/get-subset.js +29 -0
- package/dist/tools/subsets/list-subsets.d.ts +2 -0
- package/dist/tools/subsets/list-subsets.js +36 -0
- package/dist/tools/subsets/update-subset.d.ts +2 -0
- package/dist/tools/subsets/update-subset.js +33 -0
- package/dist/tools/ti-development/check-process-code.d.ts +2 -0
- package/dist/tools/ti-development/check-process-code.js +96 -0
- package/dist/tools/ti-development/compile-process.d.ts +2 -0
- package/dist/tools/ti-development/compile-process.js +32 -0
- package/dist/tools/ti-development/copy-process.d.ts +2 -0
- package/dist/tools/ti-development/copy-process.js +32 -0
- package/dist/tools/ti-development/delete-process.d.ts +2 -0
- package/dist/tools/ti-development/delete-process.js +26 -0
- package/dist/tools/ti-development/diff-process-with-file.d.ts +2 -0
- package/dist/tools/ti-development/diff-process-with-file.js +208 -0
- package/dist/tools/ti-development/diff-processes.d.ts +2 -0
- package/dist/tools/ti-development/diff-processes.js +312 -0
- package/dist/tools/ti-development/execute-process.d.ts +8 -0
- package/dist/tools/ti-development/execute-process.js +109 -0
- package/dist/tools/ti-development/export-process-to-git.d.ts +2 -0
- package/dist/tools/ti-development/export-process-to-git.js +113 -0
- package/dist/tools/ti-development/export-process-to-pro.d.ts +2 -0
- package/dist/tools/ti-development/export-process-to-pro.js +117 -0
- package/dist/tools/ti-development/get-all-processes-code.d.ts +2 -0
- package/dist/tools/ti-development/get-all-processes-code.js +131 -0
- package/dist/tools/ti-development/get-process-code.d.ts +2 -0
- package/dist/tools/ti-development/get-process-code.js +100 -0
- package/dist/tools/ti-development/get-process-datasource.d.ts +2 -0
- package/dist/tools/ti-development/get-process-datasource.js +20 -0
- package/dist/tools/ti-development/get-process-parameters.d.ts +2 -0
- package/dist/tools/ti-development/get-process-parameters.js +25 -0
- package/dist/tools/ti-development/get-process-variables.d.ts +2 -0
- package/dist/tools/ti-development/get-process-variables.js +38 -0
- package/dist/tools/ti-development/get-process.d.ts +2 -0
- package/dist/tools/ti-development/get-process.js +163 -0
- package/dist/tools/ti-development/import-pro-file.d.ts +2 -0
- package/dist/tools/ti-development/import-pro-file.js +153 -0
- package/dist/tools/ti-development/import-process-from-git.d.ts +2 -0
- package/dist/tools/ti-development/import-process-from-git.js +198 -0
- package/dist/tools/ti-development/install-pro-bundle.d.ts +2 -0
- package/dist/tools/ti-development/install-pro-bundle.js +288 -0
- package/dist/tools/ti-development/preflight.d.ts +39 -0
- package/dist/tools/ti-development/preflight.js +56 -0
- package/dist/tools/ti-development/process-backup.d.ts +29 -0
- package/dist/tools/ti-development/process-backup.js +118 -0
- package/dist/tools/ti-development/search-code.d.ts +2 -0
- package/dist/tools/ti-development/search-code.js +208 -0
- package/dist/tools/ti-development/upsert-process.d.ts +2 -0
- package/dist/tools/ti-development/upsert-process.js +167 -0
- package/dist/tools/ti-development/validate-process-refs.d.ts +2 -0
- package/dist/tools/ti-development/validate-process-refs.js +73 -0
- package/dist/tools/views/create-mdx-view.d.ts +2 -0
- package/dist/tools/views/create-mdx-view.js +21 -0
- package/dist/tools/views/create-native-view.d.ts +2 -0
- package/dist/tools/views/create-native-view.js +81 -0
- package/dist/tools/views/delete-view.d.ts +2 -0
- package/dist/tools/views/delete-view.js +23 -0
- package/dist/tools/views/list-views.d.ts +2 -0
- package/dist/tools/views/list-views.js +32 -0
- package/dist/tools/with-annotations.d.ts +6 -0
- package/dist/tools/with-annotations.js +339 -0
- package/dist/types.d.ts +409 -0
- package/dist/types.js +91 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.js +18 -0
- package/package.json +107 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { actionResponse } from "../format.js";
|
|
3
|
+
import { MutationResultSchema } from "../schemas/items.js";
|
|
4
|
+
import { WRITE } from "../annotations.js";
|
|
5
|
+
import { defineTool } from "../define-tool.js";
|
|
6
|
+
const AXIS_SPEC = z.object({
|
|
7
|
+
dimension: z.string().describe("Dimension name"),
|
|
8
|
+
hierarchy: z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe("Hierarchy name (default: same-named hierarchy as the dimension)"),
|
|
12
|
+
subset: z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Registered subset name. Exactly one of subset/expression/elements per axis entry."),
|
|
16
|
+
expression: z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("MDX set expression for an anonymous subset, e.g. '{TM1SUBSETALL([Region])}'"),
|
|
20
|
+
elements: z
|
|
21
|
+
.array(z.string())
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("Explicit element list for an anonymous subset"),
|
|
24
|
+
});
|
|
25
|
+
const TITLE_SPEC = AXIS_SPEC.extend({
|
|
26
|
+
selected: z
|
|
27
|
+
.string()
|
|
28
|
+
.describe("Element shown as the title's selection; must be in the subset. Required — TM1 rejects title subsets without a selected element."),
|
|
29
|
+
});
|
|
30
|
+
export const registerCreateNativeView = defineTool({
|
|
31
|
+
name: "tm1_create_native_view",
|
|
32
|
+
description: "Create a public native (subset-based) view on a cube — the classic view type used as TI process datasource " +
|
|
33
|
+
"(TM1CubeView) and for zero-suppressed exports. Every cube dimension must appear in exactly one of " +
|
|
34
|
+
"columns/rows/titles, each axis entry with exactly one subset source: a registered subset name, an MDX " +
|
|
35
|
+
"expression, or an explicit element list (the latter two create anonymous subsets). " +
|
|
36
|
+
"For MDX-defined views use tm1_create_mdx_view instead.",
|
|
37
|
+
annotations: WRITE,
|
|
38
|
+
output: MutationResultSchema,
|
|
39
|
+
input: {
|
|
40
|
+
cubeName: z.string().describe("Cube the view belongs to"),
|
|
41
|
+
viewName: z.string().describe("New view name"),
|
|
42
|
+
columns: z
|
|
43
|
+
.array(AXIS_SPEC)
|
|
44
|
+
.min(1)
|
|
45
|
+
.describe("Column axis, one entry per dimension"),
|
|
46
|
+
rows: z
|
|
47
|
+
.array(AXIS_SPEC)
|
|
48
|
+
.min(1)
|
|
49
|
+
.describe("Row axis, one entry per dimension"),
|
|
50
|
+
titles: z
|
|
51
|
+
.array(TITLE_SPEC)
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Title (context) dimensions, each with a required selected element"),
|
|
54
|
+
suppressEmptyColumns: z
|
|
55
|
+
.boolean()
|
|
56
|
+
.optional()
|
|
57
|
+
.default(false)
|
|
58
|
+
.describe("Suppress columns where all cells are empty/zero"),
|
|
59
|
+
suppressEmptyRows: z
|
|
60
|
+
.boolean()
|
|
61
|
+
.optional()
|
|
62
|
+
.default(false)
|
|
63
|
+
.describe("Suppress rows where all cells are empty/zero"),
|
|
64
|
+
formatString: z
|
|
65
|
+
.string()
|
|
66
|
+
.optional()
|
|
67
|
+
.describe("Cell format string, e.g. '0.#########'"),
|
|
68
|
+
},
|
|
69
|
+
handler: async ({ cubeName, viewName, columns, rows, titles, suppressEmptyColumns, suppressEmptyRows, formatString, }, tm1Client) => {
|
|
70
|
+
await tm1Client.views.createNative(cubeName, viewName, {
|
|
71
|
+
columns,
|
|
72
|
+
rows,
|
|
73
|
+
titles,
|
|
74
|
+
suppressEmptyColumns,
|
|
75
|
+
suppressEmptyRows,
|
|
76
|
+
formatString,
|
|
77
|
+
});
|
|
78
|
+
return actionResponse({ success: true, cubeName, viewName });
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=create-native-view.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CONFIRM_SCHEMA, requireConfirm } from "../confirm.js";
|
|
3
|
+
import { actionResponse } from "../format.js";
|
|
4
|
+
import { DESTRUCTIVE } from "../annotations.js";
|
|
5
|
+
import { MutationResultSchema } from "../schemas/items.js";
|
|
6
|
+
import { defineTool } from "../define-tool.js";
|
|
7
|
+
export const registerDeleteView = defineTool({
|
|
8
|
+
name: "tm1_delete_view",
|
|
9
|
+
description: "Delete a public view from a cube. Irreversible — pass confirm=<view name verbatim>.",
|
|
10
|
+
annotations: DESTRUCTIVE,
|
|
11
|
+
output: MutationResultSchema,
|
|
12
|
+
input: {
|
|
13
|
+
cubeName: z.string().describe("Cube name"),
|
|
14
|
+
viewName: z.string().describe("View name to delete"),
|
|
15
|
+
...CONFIRM_SCHEMA,
|
|
16
|
+
},
|
|
17
|
+
handler: async ({ cubeName, viewName, confirm }, tm1Client) => {
|
|
18
|
+
requireConfirm(confirm, viewName, "view");
|
|
19
|
+
await tm1Client.views.delete(cubeName, viewName);
|
|
20
|
+
return actionResponse({ success: true, cubeName, viewName });
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=delete-view.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PAGINATION_SCHEMA, paginate } from "../pagination.js";
|
|
3
|
+
import { FORMAT_SCHEMA, pageResponse, columnsOf } from "../format.js";
|
|
4
|
+
import { READ_ONLY } from "../annotations.js";
|
|
5
|
+
import { ViewItemSchema } from "../schemas/items.js";
|
|
6
|
+
import { defineTool } from "../define-tool.js";
|
|
7
|
+
import { pageShapeFor } from "../schemas/common.js";
|
|
8
|
+
export const registerListViews = defineTool({
|
|
9
|
+
name: "tm1_list_views",
|
|
10
|
+
description: "List public and private views defined on a cube. Returns view name, visibility, and MDX (when available). Paginated (default 50/page).",
|
|
11
|
+
annotations: READ_ONLY,
|
|
12
|
+
output: pageShapeFor(ViewItemSchema),
|
|
13
|
+
input: {
|
|
14
|
+
cubeName: z.string().describe("Cube name"),
|
|
15
|
+
...PAGINATION_SCHEMA,
|
|
16
|
+
...FORMAT_SCHEMA,
|
|
17
|
+
},
|
|
18
|
+
handler: async ({ cubeName, limit, offset, fetchAll, format }, tm1Client) => {
|
|
19
|
+
const views = await tm1Client.views.list(cubeName);
|
|
20
|
+
const page = paginate(views, limit, offset, fetchAll);
|
|
21
|
+
const columns = columnsOf([
|
|
22
|
+
"name",
|
|
23
|
+
{ header: "scope", get: (v) => (v.private ? "private" : "public") },
|
|
24
|
+
"mdx",
|
|
25
|
+
]);
|
|
26
|
+
return pageResponse(page, format, {
|
|
27
|
+
title: `Views of ${cubeName}`,
|
|
28
|
+
columns,
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=list-views.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type pino from "pino";
|
|
2
|
+
import { type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
export declare function deriveTitle(toolName: string): string;
|
|
4
|
+
export declare function narrowingHint(inputKeys: ReadonlySet<string>): string;
|
|
5
|
+
export declare function withAnnotations(server: McpServer, logger: pino.Logger, mode: "readwrite" | "readonly", responseMode?: "legacy" | "structured", maxResponseChars?: number): McpServer;
|
|
6
|
+
//# sourceMappingURL=with-annotations.d.ts.map
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { slimJsonSchema } from "../lib/slim-json-schema.js";
|
|
4
|
+
import { specFor } from "./define-tool.js";
|
|
5
|
+
import { DEFAULT_MAX_RESPONSE_CHARS } from "../config.js";
|
|
6
|
+
import { TM1Error, TM1ErrorCode } from "../types.js";
|
|
7
|
+
import { strictVariants } from "./schemas/markdown-capable.js";
|
|
8
|
+
import { formatTm1ErrorResult, normalizeErrorResult, } from "./error-format.js";
|
|
9
|
+
// Words whose display casing differs from simple capitalization.
|
|
10
|
+
const TITLE_CASING = {
|
|
11
|
+
mdx: "MDX",
|
|
12
|
+
ti: "TI",
|
|
13
|
+
v12: "v12",
|
|
14
|
+
v11: "v11",
|
|
15
|
+
};
|
|
16
|
+
// Derive a human-readable title from a snake_case tool name:
|
|
17
|
+
// "tm1_get_process_code" → "Get Process Code". Single point of derivation —
|
|
18
|
+
// no per-tool overrides in ANNOTATION_MAP.
|
|
19
|
+
export function deriveTitle(toolName) {
|
|
20
|
+
return toolName
|
|
21
|
+
.replace(/^tm1_/, "")
|
|
22
|
+
.split("_")
|
|
23
|
+
.filter((w) => w.length > 0)
|
|
24
|
+
.map((w) => TITLE_CASING[w] ?? w.charAt(0).toUpperCase() + w.slice(1))
|
|
25
|
+
.join(" ");
|
|
26
|
+
}
|
|
27
|
+
// OUTPUT_SCHEMA_MAP entries are either a raw shape or a full Zod schema
|
|
28
|
+
// (passthrough/catchall). Normalize to a parseable schema.
|
|
29
|
+
function isZodSchema(entry) {
|
|
30
|
+
return "_def" in entry;
|
|
31
|
+
}
|
|
32
|
+
function asZodSchema(entry) {
|
|
33
|
+
return isZodSchema(entry) ? entry : z.object(entry);
|
|
34
|
+
}
|
|
35
|
+
// A markdown response carries exactly one key. Anything else is the JSON path.
|
|
36
|
+
function isMarkdownPayload(value) {
|
|
37
|
+
if (typeof value !== "object" || value === null)
|
|
38
|
+
return false;
|
|
39
|
+
const keys = Object.keys(value);
|
|
40
|
+
return (keys.length === 1 &&
|
|
41
|
+
keys[0] === "markdown" &&
|
|
42
|
+
typeof value.markdown === "string");
|
|
43
|
+
}
|
|
44
|
+
// Characters the client receives for a successful result: the text blocks, or
|
|
45
|
+
// the serialized structuredContent when "structured" mode emptied content[].
|
|
46
|
+
function responseChars(result) {
|
|
47
|
+
const text = (result.content ?? []).reduce((n, c) => n + (typeof c.text === "string" ? c.text.length : 0), 0);
|
|
48
|
+
if (text > 0 || result.structuredContent === undefined)
|
|
49
|
+
return text;
|
|
50
|
+
return JSON.stringify(result.structuredContent).length;
|
|
51
|
+
}
|
|
52
|
+
// How to narrow a call, derived from the tool's own input keys so a new tool
|
|
53
|
+
// gets a correct hint without a per-tool table to keep in step.
|
|
54
|
+
export function narrowingHint(inputKeys) {
|
|
55
|
+
const ways = [];
|
|
56
|
+
if (inputKeys.has("outline"))
|
|
57
|
+
ways.push("outline=true to see the sections, then lineRange for a slice");
|
|
58
|
+
else if (inputKeys.has("lineRange"))
|
|
59
|
+
ways.push("lineRange for a slice");
|
|
60
|
+
if (inputKeys.has("countOnly"))
|
|
61
|
+
ways.push("countOnly=true to size it first");
|
|
62
|
+
if (inputKeys.has("limit"))
|
|
63
|
+
ways.push("a smaller limit, walking on with offset/next_offset");
|
|
64
|
+
else if (inputKeys.has("topN"))
|
|
65
|
+
ways.push("a smaller topN, walking on with offset");
|
|
66
|
+
if (inputKeys.has("maxBytes") || inputKeys.has("headLines"))
|
|
67
|
+
ways.push("a smaller maxBytes or headLines");
|
|
68
|
+
if (inputKeys.has("summary"))
|
|
69
|
+
ways.push("summary=true");
|
|
70
|
+
if (inputKeys.has("compact"))
|
|
71
|
+
ways.push("compact=true");
|
|
72
|
+
const tail = ways.length > 0
|
|
73
|
+
? `Use ${ways.join("; or ")}.`
|
|
74
|
+
: "Narrow the request (filters, fewer objects) and retry.";
|
|
75
|
+
return `${tail} Raise TM1_MAX_RESPONSE_CHARS only if the client can take the full payload.`;
|
|
76
|
+
}
|
|
77
|
+
// Rewrite a tools/list response so every advertised schema is slimmed.
|
|
78
|
+
function slimToolsListResult(result) {
|
|
79
|
+
if (!result || typeof result !== "object")
|
|
80
|
+
return result;
|
|
81
|
+
const listing = result;
|
|
82
|
+
if (!Array.isArray(listing.tools))
|
|
83
|
+
return result;
|
|
84
|
+
// Array.isArray widens an `unknown` to `any[]`; name the element type so the
|
|
85
|
+
// map below stays checked.
|
|
86
|
+
const tools = listing.tools;
|
|
87
|
+
return {
|
|
88
|
+
...listing,
|
|
89
|
+
tools: tools.map((entry) => {
|
|
90
|
+
if (!entry || typeof entry !== "object")
|
|
91
|
+
return entry;
|
|
92
|
+
const tool = {
|
|
93
|
+
...entry,
|
|
94
|
+
};
|
|
95
|
+
if (tool.inputSchema !== undefined) {
|
|
96
|
+
tool.inputSchema = slimJsonSchema(tool.inputSchema);
|
|
97
|
+
}
|
|
98
|
+
if (tool.outputSchema !== undefined) {
|
|
99
|
+
tool.outputSchema = slimJsonSchema(tool.outputSchema);
|
|
100
|
+
}
|
|
101
|
+
return tool;
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// SDK REACH — isolated here on purpose.
|
|
106
|
+
//
|
|
107
|
+
// The zod→JSON-Schema conversion happens inside the SDK: McpServer's
|
|
108
|
+
// setToolRequestHandlers() serializes tool.inputSchema/outputSchema at
|
|
109
|
+
// tools/list time, and it is installed lazily on the FIRST registerTool call.
|
|
110
|
+
// There is no public hook between that conversion and the wire, so the only
|
|
111
|
+
// place to slim the payload is the tools/list handler itself.
|
|
112
|
+
//
|
|
113
|
+
// Rather than dig into the handler registry (a private Map), we intercept the
|
|
114
|
+
// SDK's own `setRequestHandler` call on the low-level Server and wrap the
|
|
115
|
+
// handler it is trying to install. Public method, public request schema
|
|
116
|
+
// (imported from the SDK, matched by reference — same module instance the SDK
|
|
117
|
+
// itself imports), no private state touched. Must be installed BEFORE the first
|
|
118
|
+
// tool registration, which is why it runs inside withAnnotations().
|
|
119
|
+
//
|
|
120
|
+
// If a future SDK stops routing tools/list through setRequestHandler, or hands
|
|
121
|
+
// it a different schema object, this becomes a silent no-op — the sentinels
|
|
122
|
+
// would simply reappear on the wire. tests/unit/slim-json-schema.test.ts does a
|
|
123
|
+
// real end-to-end tools/list over an in-memory transport and fails loudly in
|
|
124
|
+
// that case.
|
|
125
|
+
function installToolsListSlimming(server) {
|
|
126
|
+
const lowLevel = server.server;
|
|
127
|
+
const originalSetRequestHandler = lowLevel.setRequestHandler.bind(lowLevel);
|
|
128
|
+
lowLevel.setRequestHandler = (schema, handler) => {
|
|
129
|
+
if (schema !== ListToolsRequestSchema) {
|
|
130
|
+
originalSetRequestHandler(schema, handler);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
originalSetRequestHandler(schema, async (...args) => slimToolsListResult(await handler(...args)));
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
// Wrap McpServer so every server.tool(name, desc, schema, cb) call:
|
|
137
|
+
// 1) injects the annotation declared in the tool's defineTool() spec
|
|
138
|
+
// 2) wraps the callback so thrown errors become uniform JSON results
|
|
139
|
+
// and existing isError results get reshaped to include `hint`
|
|
140
|
+
// 3) when the tool declares an outputSchema, attaches it
|
|
141
|
+
// 4) when mode="readonly", silently skips tools without readOnlyHint
|
|
142
|
+
// Also installs the tools/list schema slimmer (see installToolsListSlimming) —
|
|
143
|
+
// it has to be in place before the first registration triggers the SDK's lazy
|
|
144
|
+
// handler setup.
|
|
145
|
+
export function withAnnotations(server, logger, mode,
|
|
146
|
+
// Matches the shipped default (config.responseMode, see config.ts), so direct
|
|
147
|
+
// callers — the live harness and the unit tests, which read content[0].text —
|
|
148
|
+
// exercise the same wire shape real clients get.
|
|
149
|
+
responseMode = "legacy", maxResponseChars = DEFAULT_MAX_RESPONSE_CHARS) {
|
|
150
|
+
installToolsListSlimming(server);
|
|
151
|
+
const originalRegisterTool = server.registerTool.bind(server);
|
|
152
|
+
// Handlers return their payload as a JSON string in content[0].text. Parsing
|
|
153
|
+
// it into structuredContent is what satisfies the declared outputSchema — but
|
|
154
|
+
// leaving the text block in place means the identical JSON crosses the wire
|
|
155
|
+
// TWICE. Every tool declares an outputSchema, so in "legacy" mode that
|
|
156
|
+
// doubling applies to every successful response.
|
|
157
|
+
//
|
|
158
|
+
// In "structured" mode the now-redundant text block is dropped. That is
|
|
159
|
+
// spec-legal only because an outputSchema is declared: CallToolResult.content
|
|
160
|
+
// "may be empty" then (see CallToolResultSchema in the SDK). It is NOT the
|
|
161
|
+
// default, and must not become one — the spec says a tool returning
|
|
162
|
+
// structured content SHOULD also return the serialized JSON in a TextContent
|
|
163
|
+
// block, and clients take that literally. Kiro's MCP layer (bundled TS SDK,
|
|
164
|
+
// protocolVersion 2025-11-25, clientInfo {name:"kiro"}) parses results with
|
|
165
|
+
// const items = Array.isArray(r.content) ? r.content : []
|
|
166
|
+
// and never reads structuredContent, so an empty content array renders as no
|
|
167
|
+
// output at all.
|
|
168
|
+
//
|
|
169
|
+
// Dropping the text block also buys nothing on the clients that do read
|
|
170
|
+
// structuredContent: Claude Code de-duplicates, so an identical payload sent
|
|
171
|
+
// both ways costs exactly one copy of context (measured byte-identical
|
|
172
|
+
// tool_result at 1 KB and at 23 KB, and the >25k-token offload-to-file path
|
|
173
|
+
// behaves the same either way). The saving is real only for clients that
|
|
174
|
+
// serialize the whole CallToolResult into the model prompt — Q DEV CLI /
|
|
175
|
+
// Kiro CLI do this — which is who this mode is still here for.
|
|
176
|
+
//
|
|
177
|
+
// A non-JSON text block (markdown mode, where the handler already attached
|
|
178
|
+
// structuredContent itself) is left alone in both modes: there the text is
|
|
179
|
+
// the point, not a duplicate.
|
|
180
|
+
const attachStructured = (result) => {
|
|
181
|
+
const first = result.content?.[0];
|
|
182
|
+
if (!first || first.type !== "text" || typeof first.text !== "string") {
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
const raw = first.text.trim();
|
|
186
|
+
if (!raw.startsWith("{") && !raw.startsWith("["))
|
|
187
|
+
return result;
|
|
188
|
+
try {
|
|
189
|
+
// Deliberately not narrowed to an object: a handler may serialize a
|
|
190
|
+
// top-level array, and this wrapper's job is to pass the payload
|
|
191
|
+
// through unchanged, not to re-decide its shape.
|
|
192
|
+
const parsed = JSON.parse(raw);
|
|
193
|
+
return responseMode === "structured"
|
|
194
|
+
? { ...result, content: [], structuredContent: parsed }
|
|
195
|
+
: { ...result, structuredContent: parsed };
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
const SLOW_TOOL_MS = 5000;
|
|
202
|
+
// Replace an oversized success with an error that says how to narrow the
|
|
203
|
+
// call. Never truncate: a cut JSON payload is worse than none.
|
|
204
|
+
const guardSize = (toolName, result, hint) => {
|
|
205
|
+
const size = responseChars(result);
|
|
206
|
+
if (size <= maxResponseChars)
|
|
207
|
+
return result;
|
|
208
|
+
logger.warn({ tool: toolName, size, maxResponseChars }, "response too large");
|
|
209
|
+
return formatTm1ErrorResult(new TM1Error({
|
|
210
|
+
code: TM1ErrorCode.RESPONSE_TOO_LARGE,
|
|
211
|
+
message: `${toolName} produced ${size} characters, over the ${maxResponseChars}-character response limit. Nothing was returned.`,
|
|
212
|
+
hint,
|
|
213
|
+
details: JSON.stringify({ size, limit: maxResponseChars }),
|
|
214
|
+
}));
|
|
215
|
+
};
|
|
216
|
+
const wrapCb = (toolName, cb, outputSchema, sizeHint) => {
|
|
217
|
+
// Normalize once per tool, not per call.
|
|
218
|
+
const schema = outputSchema ? asZodSchema(outputSchema) : undefined;
|
|
219
|
+
// Tools offering format:"markdown" publish a loosened schema (top-level
|
|
220
|
+
// keys optional, plus `markdown`) because the SDK cannot express "either
|
|
221
|
+
// shape" — see ./schemas/markdown-capable.ts. Validating against that
|
|
222
|
+
// loosened schema would forfeit top-level drift detection on the JSON
|
|
223
|
+
// path, so we pick the matching strict variant per response instead.
|
|
224
|
+
const variants = strictVariants(outputSchema);
|
|
225
|
+
return async (...cbArgs) => {
|
|
226
|
+
const start = Date.now();
|
|
227
|
+
try {
|
|
228
|
+
const result = (await cb(...cbArgs));
|
|
229
|
+
const durationMs = Date.now() - start;
|
|
230
|
+
if (durationMs >= SLOW_TOOL_MS) {
|
|
231
|
+
void server.server
|
|
232
|
+
.sendLoggingMessage({
|
|
233
|
+
level: "warning",
|
|
234
|
+
logger: "tm1-mcp",
|
|
235
|
+
data: {
|
|
236
|
+
tool: toolName,
|
|
237
|
+
durationMs,
|
|
238
|
+
message: `slow tool call: ${toolName} took ${durationMs}ms`,
|
|
239
|
+
},
|
|
240
|
+
})
|
|
241
|
+
.catch(() => undefined);
|
|
242
|
+
}
|
|
243
|
+
if (result && result.isError) {
|
|
244
|
+
return normalizeErrorResult(result);
|
|
245
|
+
}
|
|
246
|
+
if (result && schema) {
|
|
247
|
+
const withStructured = attachStructured(result);
|
|
248
|
+
if (withStructured.structuredContent !== undefined) {
|
|
249
|
+
// Pre-validate against the outputSchema HERE so drift surfaces as
|
|
250
|
+
// a graceful isError result. The SDK validates structuredContent
|
|
251
|
+
// AFTER the callback returns and turns a mismatch into a raw
|
|
252
|
+
// JSON-RPC protocol error; it skips that validation for isError
|
|
253
|
+
// results (validateToolOutput returns early on result.isError),
|
|
254
|
+
// so the error envelope below — which carries no
|
|
255
|
+
// structuredContent — passes through cleanly.
|
|
256
|
+
//
|
|
257
|
+
// COVERAGE BOUNDARY: this guard only bites schemas that can actually
|
|
258
|
+
// fail safeParse. A `.passthrough()` object or a `z.unknown()` field
|
|
259
|
+
// accepts anything, so tools whose OUTPUT_SCHEMA_MAP entry is
|
|
260
|
+
// permissive (e.g. MutationResultSchema.passthrough(), audit/feeder
|
|
261
|
+
// schemas) get no structural drift protection here — extra/renamed
|
|
262
|
+
// fields slip through silently. Prefer a strict, fully-modelled
|
|
263
|
+
// schema for any new output whose shape you want enforced (the
|
|
264
|
+
// callgraph tree was tightened for exactly this reason).
|
|
265
|
+
//
|
|
266
|
+
// Variant pick is made from the RESPONSE, not from the requested
|
|
267
|
+
// `format`: a handler may legitimately fall back to JSON while
|
|
268
|
+
// format:"markdown" was asked for (unavailable stats, empty
|
|
269
|
+
// result), and branching on the input would reject that. No JSON
|
|
270
|
+
// payload in OUTPUT_SCHEMA_MAP carries a top-level `markdown`
|
|
271
|
+
// string, so the discriminator is unambiguous.
|
|
272
|
+
const effectiveSchema = variants
|
|
273
|
+
? isMarkdownPayload(withStructured.structuredContent)
|
|
274
|
+
? variants.markdown
|
|
275
|
+
: variants.json
|
|
276
|
+
: schema;
|
|
277
|
+
const parsed = effectiveSchema.safeParse(withStructured.structuredContent);
|
|
278
|
+
if (!parsed.success) {
|
|
279
|
+
const issue = parsed.error.issues[0];
|
|
280
|
+
const detail = issue
|
|
281
|
+
? `${issue.path.join(".") || "(root)"}: ${issue.message}`
|
|
282
|
+
: "unknown issue";
|
|
283
|
+
logger.warn({ tool: toolName, issues: parsed.error.issues.slice(0, 5) }, "output schema drift");
|
|
284
|
+
return formatTm1ErrorResult(new Error(`output schema drift in ${toolName}: ${detail}`));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return guardSize(toolName, withStructured, sizeHint);
|
|
288
|
+
}
|
|
289
|
+
return result ? guardSize(toolName, result, sizeHint) : result;
|
|
290
|
+
}
|
|
291
|
+
catch (err) {
|
|
292
|
+
logger.error({ err, tool: toolName }, "Tool handler threw");
|
|
293
|
+
return formatTm1ErrorResult(err);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
return new Proxy(server, {
|
|
298
|
+
get(target, prop, receiver) {
|
|
299
|
+
if (prop !== "tool")
|
|
300
|
+
return Reflect.get(target, prop, receiver);
|
|
301
|
+
return (...args) => {
|
|
302
|
+
const isFourArg = args.length === 4 &&
|
|
303
|
+
typeof args[0] === "string" &&
|
|
304
|
+
typeof args[1] === "string" &&
|
|
305
|
+
typeof args[3] === "function";
|
|
306
|
+
if (!isFourArg) {
|
|
307
|
+
throw new Error("withAnnotations Proxy expects server.tool(name, description, inputSchema, cb). " +
|
|
308
|
+
"Other tool() overloads are deprecated and not supported here.");
|
|
309
|
+
}
|
|
310
|
+
const name = args[0];
|
|
311
|
+
const description = args[1];
|
|
312
|
+
const inputSchema = args[2];
|
|
313
|
+
const spec = specFor(name);
|
|
314
|
+
const annot = spec?.annotations;
|
|
315
|
+
if (!annot) {
|
|
316
|
+
throw new Error(`Tool "${name}" registered without a spec — build it with defineTool() (src/tools/define-tool.ts) instead of calling server.tool directly.`);
|
|
317
|
+
}
|
|
318
|
+
if (mode === "readonly" && !annot.readOnlyHint) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const outputSchema = spec.outputSchema;
|
|
322
|
+
const inputKeys = new Set(inputSchema && typeof inputSchema === "object"
|
|
323
|
+
? Object.keys(inputSchema)
|
|
324
|
+
: []);
|
|
325
|
+
const wrappedCb = wrapCb(name, args[3], outputSchema, narrowingHint(inputKeys));
|
|
326
|
+
const config = {
|
|
327
|
+
title: deriveTitle(name),
|
|
328
|
+
description,
|
|
329
|
+
inputSchema,
|
|
330
|
+
annotations: annot,
|
|
331
|
+
};
|
|
332
|
+
if (outputSchema)
|
|
333
|
+
config.outputSchema = outputSchema;
|
|
334
|
+
return originalRegisterTool(name, config, wrappedCb);
|
|
335
|
+
};
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=with-annotations.js.map
|