@digital-science-dsl/dimensions-analytics-mcp 0.5.3
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 +61 -0
- package/README.md +152 -0
- package/bin/dimensions-analytics-mcp-http.js +2 -0
- package/bin/dimensions-analytics-mcp.js +2 -0
- package/dist/client/auth/config-loaders.d.ts +22 -0
- package/dist/client/auth/config-loaders.d.ts.map +1 -0
- package/dist/client/auth/config-loaders.js +68 -0
- package/dist/client/auth/config-loaders.js.map +1 -0
- package/dist/client/auth/decorators/index.d.ts +7 -0
- package/dist/client/auth/decorators/index.d.ts.map +1 -0
- package/dist/client/auth/decorators/index.js +6 -0
- package/dist/client/auth/decorators/index.js.map +1 -0
- package/dist/client/auth/decorators/with-caching.d.ts +81 -0
- package/dist/client/auth/decorators/with-caching.d.ts.map +1 -0
- package/dist/client/auth/decorators/with-caching.js +168 -0
- package/dist/client/auth/decorators/with-caching.js.map +1 -0
- package/dist/client/auth/factory.d.ts +13 -0
- package/dist/client/auth/factory.d.ts.map +1 -0
- package/dist/client/auth/factory.js +29 -0
- package/dist/client/auth/factory.js.map +1 -0
- package/dist/client/auth/index.d.ts +7 -0
- package/dist/client/auth/index.d.ts.map +1 -0
- package/dist/client/auth/index.js +6 -0
- package/dist/client/auth/index.js.map +1 -0
- package/dist/client/auth/jwt-utils.d.ts +17 -0
- package/dist/client/auth/jwt-utils.d.ts.map +1 -0
- package/dist/client/auth/jwt-utils.js +33 -0
- package/dist/client/auth/jwt-utils.js.map +1 -0
- package/dist/client/auth/node.d.ts +16 -0
- package/dist/client/auth/node.d.ts.map +1 -0
- package/dist/client/auth/node.js +15 -0
- package/dist/client/auth/node.js.map +1 -0
- package/dist/client/auth/providers/index.d.ts +2 -0
- package/dist/client/auth/providers/index.d.ts.map +1 -0
- package/dist/client/auth/providers/index.js +2 -0
- package/dist/client/auth/providers/index.js.map +1 -0
- package/dist/client/auth/providers/jwt-auth-provider.d.ts +70 -0
- package/dist/client/auth/providers/jwt-auth-provider.d.ts.map +1 -0
- package/dist/client/auth/providers/jwt-auth-provider.js +134 -0
- package/dist/client/auth/providers/jwt-auth-provider.js.map +1 -0
- package/dist/client/auth/schemas.d.ts +19 -0
- package/dist/client/auth/schemas.d.ts.map +1 -0
- package/dist/client/auth/schemas.js +23 -0
- package/dist/client/auth/schemas.js.map +1 -0
- package/dist/client/auth/types.d.ts +25 -0
- package/dist/client/auth/types.d.ts.map +1 -0
- package/dist/client/auth/types.js +9 -0
- package/dist/client/auth/types.js.map +1 -0
- package/dist/client/command.d.ts +44 -0
- package/dist/client/command.d.ts.map +1 -0
- package/dist/client/command.js +23 -0
- package/dist/client/command.js.map +1 -0
- package/dist/client/config/index.d.ts +11 -0
- package/dist/client/config/index.d.ts.map +1 -0
- package/dist/client/config/index.js +8 -0
- package/dist/client/config/index.js.map +1 -0
- package/dist/client/config/loader.d.ts +27 -0
- package/dist/client/config/loader.d.ts.map +1 -0
- package/dist/client/config/loader.js +128 -0
- package/dist/client/config/loader.js.map +1 -0
- package/dist/client/config/node.d.ts +18 -0
- package/dist/client/config/node.d.ts.map +1 -0
- package/dist/client/config/node.js +17 -0
- package/dist/client/config/node.js.map +1 -0
- package/dist/client/config/schemas.d.ts +23 -0
- package/dist/client/config/schemas.d.ts.map +1 -0
- package/dist/client/config/schemas.js +24 -0
- package/dist/client/config/schemas.js.map +1 -0
- package/dist/client/config/types.d.ts +37 -0
- package/dist/client/config/types.d.ts.map +1 -0
- package/dist/client/config/types.js +6 -0
- package/dist/client/config/types.js.map +1 -0
- package/dist/client/config/unified-loader.d.ts +41 -0
- package/dist/client/config/unified-loader.d.ts.map +1 -0
- package/dist/client/config/unified-loader.js +86 -0
- package/dist/client/config/unified-loader.js.map +1 -0
- package/dist/client/config.d.ts +43 -0
- package/dist/client/config.d.ts.map +1 -0
- package/dist/client/config.js +56 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/deployment-config.d.ts +36 -0
- package/dist/client/deployment-config.d.ts.map +1 -0
- package/dist/client/deployment-config.js +79 -0
- package/dist/client/deployment-config.js.map +1 -0
- package/dist/client/errors.d.ts +180 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +253 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/http-client.d.ts +215 -0
- package/dist/client/http-client.d.ts.map +1 -0
- package/dist/client/http-client.js +419 -0
- package/dist/client/http-client.js.map +1 -0
- package/dist/client/index.d.ts +28 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +18 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/internal-dsl-client.d.ts +30 -0
- package/dist/client/internal-dsl-client.d.ts.map +1 -0
- package/dist/client/internal-dsl-client.js +101 -0
- package/dist/client/internal-dsl-client.js.map +1 -0
- package/dist/client/rate-limiter.d.ts +79 -0
- package/dist/client/rate-limiter.d.ts.map +1 -0
- package/dist/client/rate-limiter.js +118 -0
- package/dist/client/rate-limiter.js.map +1 -0
- package/dist/client/resolve-api-key-user.d.ts +24 -0
- package/dist/client/resolve-api-key-user.d.ts.map +1 -0
- package/dist/client/resolve-api-key-user.js +80 -0
- package/dist/client/resolve-api-key-user.js.map +1 -0
- package/dist/client/types.d.ts +44 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +10 -0
- package/dist/client/types.js.map +1 -0
- package/dist/dsl/client.d.ts +330 -0
- package/dist/dsl/client.d.ts.map +1 -0
- package/dist/dsl/client.js +433 -0
- package/dist/dsl/client.js.map +1 -0
- package/dist/dsl/commands/apply-filters.d.ts +15 -0
- package/dist/dsl/commands/apply-filters.d.ts.map +1 -0
- package/dist/dsl/commands/apply-filters.js +29 -0
- package/dist/dsl/commands/apply-filters.js.map +1 -0
- package/dist/dsl/commands/facet/index.d.ts +6 -0
- package/dist/dsl/commands/facet/index.d.ts.map +1 -0
- package/dist/dsl/commands/facet/index.js +6 -0
- package/dist/dsl/commands/facet/index.js.map +1 -0
- package/dist/dsl/commands/facet/schemas.d.ts +71 -0
- package/dist/dsl/commands/facet/schemas.d.ts.map +1 -0
- package/dist/dsl/commands/facet/schemas.js +84 -0
- package/dist/dsl/commands/facet/schemas.js.map +1 -0
- package/dist/dsl/commands/functions/ClassifyCommand.d.ts +96 -0
- package/dist/dsl/commands/functions/ClassifyCommand.d.ts.map +1 -0
- package/dist/dsl/commands/functions/ClassifyCommand.js +95 -0
- package/dist/dsl/commands/functions/ClassifyCommand.js.map +1 -0
- package/dist/dsl/commands/functions/ExtractAffiliationsCommand.d.ts +86 -0
- package/dist/dsl/commands/functions/ExtractAffiliationsCommand.d.ts.map +1 -0
- package/dist/dsl/commands/functions/ExtractAffiliationsCommand.js +131 -0
- package/dist/dsl/commands/functions/ExtractAffiliationsCommand.js.map +1 -0
- package/dist/dsl/commands/functions/ExtractConceptsCommand.d.ts +73 -0
- package/dist/dsl/commands/functions/ExtractConceptsCommand.d.ts.map +1 -0
- package/dist/dsl/commands/functions/ExtractConceptsCommand.js +110 -0
- package/dist/dsl/commands/functions/ExtractConceptsCommand.js.map +1 -0
- package/dist/dsl/commands/functions/ExtractGrantsCommand.d.ts +66 -0
- package/dist/dsl/commands/functions/ExtractGrantsCommand.d.ts.map +1 -0
- package/dist/dsl/commands/functions/ExtractGrantsCommand.js +87 -0
- package/dist/dsl/commands/functions/ExtractGrantsCommand.js.map +1 -0
- package/dist/dsl/commands/functions/index.d.ts +10 -0
- package/dist/dsl/commands/functions/index.d.ts.map +1 -0
- package/dist/dsl/commands/functions/index.js +10 -0
- package/dist/dsl/commands/functions/index.js.map +1 -0
- package/dist/dsl/commands/index.d.ts +8 -0
- package/dist/dsl/commands/index.d.ts.map +1 -0
- package/dist/dsl/commands/index.js +7 -0
- package/dist/dsl/commands/index.js.map +1 -0
- package/dist/dsl/commands/validate-input.d.ts +18 -0
- package/dist/dsl/commands/validate-input.d.ts.map +1 -0
- package/dist/dsl/commands/validate-input.js +27 -0
- package/dist/dsl/commands/validate-input.js.map +1 -0
- package/dist/dsl/create-client.d.ts +32 -0
- package/dist/dsl/create-client.d.ts.map +1 -0
- package/dist/dsl/create-client.js +58 -0
- package/dist/dsl/create-client.js.map +1 -0
- package/dist/dsl/fluent-query-builder.d.ts +439 -0
- package/dist/dsl/fluent-query-builder.d.ts.map +1 -0
- package/dist/dsl/fluent-query-builder.js +534 -0
- package/dist/dsl/fluent-query-builder.js.map +1 -0
- package/dist/dsl/index.d.ts +32 -0
- package/dist/dsl/index.d.ts.map +1 -0
- package/dist/dsl/index.js +31 -0
- package/dist/dsl/index.js.map +1 -0
- package/dist/dsl/pagination.d.ts +82 -0
- package/dist/dsl/pagination.d.ts.map +1 -0
- package/dist/dsl/pagination.js +135 -0
- package/dist/dsl/pagination.js.map +1 -0
- package/dist/dsl/query-builder.d.ts +456 -0
- package/dist/dsl/query-builder.d.ts.map +1 -0
- package/dist/dsl/query-builder.js +994 -0
- package/dist/dsl/query-builder.js.map +1 -0
- package/dist/dsl/response-parser.d.ts +111 -0
- package/dist/dsl/response-parser.d.ts.map +1 -0
- package/dist/dsl/response-parser.js +210 -0
- package/dist/dsl/response-parser.js.map +1 -0
- package/dist/dsl/schema/cache.d.ts +52 -0
- package/dist/dsl/schema/cache.d.ts.map +1 -0
- package/dist/dsl/schema/cache.js +97 -0
- package/dist/dsl/schema/cache.js.map +1 -0
- package/dist/dsl/schema/extract.d.ts +18 -0
- package/dist/dsl/schema/extract.d.ts.map +1 -0
- package/dist/dsl/schema/extract.js +41 -0
- package/dist/dsl/schema/extract.js.map +1 -0
- package/dist/dsl/schema/index.d.ts +13 -0
- package/dist/dsl/schema/index.d.ts.map +1 -0
- package/dist/dsl/schema/index.js +12 -0
- package/dist/dsl/schema/index.js.map +1 -0
- package/dist/dsl/schema/load.d.ts +41 -0
- package/dist/dsl/schema/load.d.ts.map +1 -0
- package/dist/dsl/schema/load.js +119 -0
- package/dist/dsl/schema/load.js.map +1 -0
- package/dist/dsl/schema/store.d.ts +137 -0
- package/dist/dsl/schema/store.d.ts.map +1 -0
- package/dist/dsl/schema/store.js +204 -0
- package/dist/dsl/schema/store.js.map +1 -0
- package/dist/dsl/schema/structured-entities.d.ts +21 -0
- package/dist/dsl/schema/structured-entities.d.ts.map +1 -0
- package/dist/dsl/schema/structured-entities.js +39 -0
- package/dist/dsl/schema/structured-entities.js.map +1 -0
- package/dist/dsl/schema/summary.d.ts +51 -0
- package/dist/dsl/schema/summary.d.ts.map +1 -0
- package/dist/dsl/schema/summary.js +61 -0
- package/dist/dsl/schema/summary.js.map +1 -0
- package/dist/dsl/schema/types.d.ts +36 -0
- package/dist/dsl/schema/types.d.ts.map +1 -0
- package/dist/dsl/schema/types.js +6 -0
- package/dist/dsl/schema/types.js.map +1 -0
- package/dist/dsl/schema/validation.d.ts +21 -0
- package/dist/dsl/schema/validation.d.ts.map +1 -0
- package/dist/dsl/schema/validation.js +44 -0
- package/dist/dsl/schema/validation.js.map +1 -0
- package/dist/dsl/types/buckets.d.ts +18 -0
- package/dist/dsl/types/buckets.d.ts.map +1 -0
- package/dist/dsl/types/buckets.js +6 -0
- package/dist/dsl/types/buckets.js.map +1 -0
- package/dist/dsl/types/common.d.ts +91 -0
- package/dist/dsl/types/common.d.ts.map +1 -0
- package/dist/dsl/types/common.js +6 -0
- package/dist/dsl/types/common.js.map +1 -0
- package/dist/dsl/types/entities.d.ts +35 -0
- package/dist/dsl/types/entities.d.ts.map +1 -0
- package/dist/dsl/types/entities.js +11 -0
- package/dist/dsl/types/entities.js.map +1 -0
- package/dist/dsl/types/index.d.ts +12 -0
- package/dist/dsl/types/index.d.ts.map +1 -0
- package/dist/dsl/types/index.js +7 -0
- package/dist/dsl/types/index.js.map +1 -0
- package/dist/dsl/types/return-clauses.d.ts +107 -0
- package/dist/dsl/types/return-clauses.d.ts.map +1 -0
- package/dist/dsl/types/return-clauses.js +22 -0
- package/dist/dsl/types/return-clauses.js.map +1 -0
- package/dist/dsl/types/special-functions.d.ts +175 -0
- package/dist/dsl/types/special-functions.d.ts.map +1 -0
- package/dist/dsl/types/special-functions.js +25 -0
- package/dist/dsl/types/special-functions.js.map +1 -0
- package/dist/dsl/types/vocabulary.d.ts +21 -0
- package/dist/dsl/types/vocabulary.d.ts.map +1 -0
- package/dist/dsl/types/vocabulary.js +44 -0
- package/dist/dsl/types/vocabulary.js.map +1 -0
- package/dist/dsl/usage-policy.d.ts +87 -0
- package/dist/dsl/usage-policy.d.ts.map +1 -0
- package/dist/dsl/usage-policy.js +133 -0
- package/dist/dsl/usage-policy.js.map +1 -0
- package/dist/dsl/utils/escape.d.ts +24 -0
- package/dist/dsl/utils/escape.d.ts.map +1 -0
- package/dist/dsl/utils/escape.js +124 -0
- package/dist/dsl/utils/escape.js.map +1 -0
- package/dist/dsl/utils/sanitize.d.ts +13 -0
- package/dist/dsl/utils/sanitize.d.ts.map +1 -0
- package/dist/dsl/utils/sanitize.js +19 -0
- package/dist/dsl/utils/sanitize.js.map +1 -0
- package/dist/dsl/utils/string-utils.d.ts +35 -0
- package/dist/dsl/utils/string-utils.d.ts.map +1 -0
- package/dist/dsl/utils/string-utils.js +145 -0
- package/dist/dsl/utils/string-utils.js.map +1 -0
- package/dist/dsl/utils/validate-field-name.d.ts +11 -0
- package/dist/dsl/utils/validate-field-name.d.ts.map +1 -0
- package/dist/dsl/utils/validate-field-name.js +18 -0
- package/dist/dsl/utils/validate-field-name.js.map +1 -0
- package/dist/examples/dsl-examples.d.ts +11 -0
- package/dist/examples/dsl-examples.d.ts.map +1 -0
- package/dist/examples/dsl-examples.js +49 -0
- package/dist/examples/dsl-examples.js.map +1 -0
- package/dist/examples/usage-scenarios.d.ts +22 -0
- package/dist/examples/usage-scenarios.d.ts.map +1 -0
- package/dist/examples/usage-scenarios.js +173 -0
- package/dist/examples/usage-scenarios.js.map +1 -0
- package/dist/funder-org-names.d.ts +12 -0
- package/dist/funder-org-names.d.ts.map +1 -0
- package/dist/funder-org-names.js +30 -0
- package/dist/funder-org-names.js.map +1 -0
- package/dist/http-main.d.ts +7 -0
- package/dist/http-main.d.ts.map +1 -0
- package/dist/http-main.js +36 -0
- package/dist/http-main.js.map +1 -0
- package/dist/http.d.ts +29 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +173 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/kwq/build-query.d.ts +26 -0
- package/dist/kwq/build-query.d.ts.map +1 -0
- package/dist/kwq/build-query.js +37 -0
- package/dist/kwq/build-query.js.map +1 -0
- package/dist/kwq/concept-groups.d.ts +49 -0
- package/dist/kwq/concept-groups.d.ts.map +1 -0
- package/dist/kwq/concept-groups.js +55 -0
- package/dist/kwq/concept-groups.js.map +1 -0
- package/dist/kwq/dsl-assembler.d.ts +28 -0
- package/dist/kwq/dsl-assembler.d.ts.map +1 -0
- package/dist/kwq/dsl-assembler.js +124 -0
- package/dist/kwq/dsl-assembler.js.map +1 -0
- package/dist/kwq/ensemble.d.ts +38 -0
- package/dist/kwq/ensemble.d.ts.map +1 -0
- package/dist/kwq/ensemble.js +107 -0
- package/dist/kwq/ensemble.js.map +1 -0
- package/dist/kwq/index.d.ts +16 -0
- package/dist/kwq/index.d.ts.map +1 -0
- package/dist/kwq/index.js +14 -0
- package/dist/kwq/index.js.map +1 -0
- package/dist/kwq/types.d.ts +120 -0
- package/dist/kwq/types.d.ts.map +1 -0
- package/dist/kwq/types.js +11 -0
- package/dist/kwq/types.js.map +1 -0
- package/dist/lambda.d.ts +10 -0
- package/dist/lambda.d.ts.map +1 -0
- package/dist/lambda.js +4 -0
- package/dist/lambda.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +33 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp/batch-fetch.d.ts +89 -0
- package/dist/mcp/batch-fetch.d.ts.map +1 -0
- package/dist/mcp/batch-fetch.js +178 -0
- package/dist/mcp/batch-fetch.js.map +1 -0
- package/dist/mcp/examples/dsl-examples.d.ts +21 -0
- package/dist/mcp/examples/dsl-examples.d.ts.map +1 -0
- package/dist/mcp/examples/dsl-examples.js +61 -0
- package/dist/mcp/examples/dsl-examples.js.map +1 -0
- package/dist/mcp/examples/usage-scenarios.d.ts +20 -0
- package/dist/mcp/examples/usage-scenarios.d.ts.map +1 -0
- package/dist/mcp/examples/usage-scenarios.js +169 -0
- package/dist/mcp/examples/usage-scenarios.js.map +1 -0
- package/dist/mcp/export-format.d.ts +43 -0
- package/dist/mcp/export-format.d.ts.map +1 -0
- package/dist/mcp/export-format.js +92 -0
- package/dist/mcp/export-format.js.map +1 -0
- package/dist/mcp/funder-org-names.d.ts +12 -0
- package/dist/mcp/funder-org-names.d.ts.map +1 -0
- package/dist/mcp/funder-org-names.js +30 -0
- package/dist/mcp/funder-org-names.js.map +1 -0
- package/dist/mcp/http-server.d.ts +20 -0
- package/dist/mcp/http-server.d.ts.map +1 -0
- package/dist/mcp/http-server.js +118 -0
- package/dist/mcp/http-server.js.map +1 -0
- package/dist/mcp/middleware/field-aliases.d.ts +97 -0
- package/dist/mcp/middleware/field-aliases.d.ts.map +1 -0
- package/dist/mcp/middleware/field-aliases.js +208 -0
- package/dist/mcp/middleware/field-aliases.js.map +1 -0
- package/dist/mcp/resources/schema.d.ts +13 -0
- package/dist/mcp/resources/schema.d.ts.map +1 -0
- package/dist/mcp/resources/schema.js +262 -0
- package/dist/mcp/resources/schema.js.map +1 -0
- package/dist/mcp/schema/context.d.ts +10 -0
- package/dist/mcp/schema/context.d.ts.map +1 -0
- package/dist/mcp/schema/context.js +6 -0
- package/dist/mcp/schema/context.js.map +1 -0
- package/dist/mcp/schema/index.d.ts +8 -0
- package/dist/mcp/schema/index.d.ts.map +1 -0
- package/dist/mcp/schema/index.js +6 -0
- package/dist/mcp/schema/index.js.map +1 -0
- package/dist/mcp/server.d.ts +56 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +168 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/shared-schema.d.ts +13 -0
- package/dist/mcp/shared-schema.d.ts.map +1 -0
- package/dist/mcp/shared-schema.js +28 -0
- package/dist/mcp/shared-schema.js.map +1 -0
- package/dist/mcp/tools/analytics-filters.d.ts +18 -0
- package/dist/mcp/tools/analytics-filters.d.ts.map +1 -0
- package/dist/mcp/tools/analytics-filters.js +35 -0
- package/dist/mcp/tools/analytics-filters.js.map +1 -0
- package/dist/mcp/tools/analytics.d.ts +16 -0
- package/dist/mcp/tools/analytics.d.ts.map +1 -0
- package/dist/mcp/tools/analytics.js +381 -0
- package/dist/mcp/tools/analytics.js.map +1 -0
- package/dist/mcp/tools/concept-profile.d.ts +14 -0
- package/dist/mcp/tools/concept-profile.d.ts.map +1 -0
- package/dist/mcp/tools/concept-profile.js +130 -0
- package/dist/mcp/tools/concept-profile.js.map +1 -0
- package/dist/mcp/tools/dataset-profile.d.ts +15 -0
- package/dist/mcp/tools/dataset-profile.d.ts.map +1 -0
- package/dist/mcp/tools/dataset-profile.js +194 -0
- package/dist/mcp/tools/dataset-profile.js.map +1 -0
- package/dist/mcp/tools/fetch-search-pages.d.ts +15 -0
- package/dist/mcp/tools/fetch-search-pages.d.ts.map +1 -0
- package/dist/mcp/tools/fetch-search-pages.js +237 -0
- package/dist/mcp/tools/fetch-search-pages.js.map +1 -0
- package/dist/mcp/tools/functions.d.ts +14 -0
- package/dist/mcp/tools/functions.d.ts.map +1 -0
- package/dist/mcp/tools/functions.js +87 -0
- package/dist/mcp/tools/functions.js.map +1 -0
- package/dist/mcp/tools/impact-chain.d.ts +15 -0
- package/dist/mcp/tools/impact-chain.d.ts.map +1 -0
- package/dist/mcp/tools/impact-chain.js +96 -0
- package/dist/mcp/tools/impact-chain.js.map +1 -0
- package/dist/mcp/tools/kwq.d.ts +19 -0
- package/dist/mcp/tools/kwq.d.ts.map +1 -0
- package/dist/mcp/tools/kwq.js +156 -0
- package/dist/mcp/tools/kwq.js.map +1 -0
- package/dist/mcp/tools/lookup.d.ts +14 -0
- package/dist/mcp/tools/lookup.d.ts.map +1 -0
- package/dist/mcp/tools/lookup.js +146 -0
- package/dist/mcp/tools/lookup.js.map +1 -0
- package/dist/mcp/tools/policy-profile.d.ts +15 -0
- package/dist/mcp/tools/policy-profile.d.ts.map +1 -0
- package/dist/mcp/tools/policy-profile.js +174 -0
- package/dist/mcp/tools/policy-profile.js.map +1 -0
- package/dist/mcp/tools/profile.d.ts +14 -0
- package/dist/mcp/tools/profile.d.ts.map +1 -0
- package/dist/mcp/tools/profile.js +349 -0
- package/dist/mcp/tools/profile.js.map +1 -0
- package/dist/mcp/tools/query.d.ts +16 -0
- package/dist/mcp/tools/query.d.ts.map +1 -0
- package/dist/mcp/tools/query.js +75 -0
- package/dist/mcp/tools/query.js.map +1 -0
- package/dist/mcp/tools/schema.d.ts +23 -0
- package/dist/mcp/tools/schema.d.ts.map +1 -0
- package/dist/mcp/tools/schema.js +124 -0
- package/dist/mcp/tools/schema.js.map +1 -0
- package/dist/mcp/tools/search-entity-metadata.d.ts +18 -0
- package/dist/mcp/tools/search-entity-metadata.d.ts.map +1 -0
- package/dist/mcp/tools/search-entity-metadata.js +221 -0
- package/dist/mcp/tools/search-entity-metadata.js.map +1 -0
- package/dist/mcp/tools/search-input.d.ts +58 -0
- package/dist/mcp/tools/search-input.d.ts.map +1 -0
- package/dist/mcp/tools/search-input.js +76 -0
- package/dist/mcp/tools/search-input.js.map +1 -0
- package/dist/mcp/tools/search.d.ts +24 -0
- package/dist/mcp/tools/search.d.ts.map +1 -0
- package/dist/mcp/tools/search.js +115 -0
- package/dist/mcp/tools/search.js.map +1 -0
- package/dist/mcp/utils.d.ts +82 -0
- package/dist/mcp/utils.d.ts.map +1 -0
- package/dist/mcp/utils.js +126 -0
- package/dist/mcp/utils.js.map +1 -0
- package/dist/middleware/field-aliases.d.ts +97 -0
- package/dist/middleware/field-aliases.d.ts.map +1 -0
- package/dist/middleware/field-aliases.js +208 -0
- package/dist/middleware/field-aliases.js.map +1 -0
- package/dist/resources/schema.d.ts +13 -0
- package/dist/resources/schema.d.ts.map +1 -0
- package/dist/resources/schema.js +204 -0
- package/dist/resources/schema.js.map +1 -0
- package/dist/schema/context.d.ts +10 -0
- package/dist/schema/context.d.ts.map +1 -0
- package/dist/schema/context.js +6 -0
- package/dist/schema/context.js.map +1 -0
- package/dist/schema/index.d.ts +9 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +6 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/load.d.ts +43 -0
- package/dist/schema/load.d.ts.map +1 -0
- package/dist/schema/load.js +139 -0
- package/dist/schema/load.js.map +1 -0
- package/dist/schema/store.d.ts +112 -0
- package/dist/schema/store.d.ts.map +1 -0
- package/dist/schema/store.js +173 -0
- package/dist/schema/store.js.map +1 -0
- package/dist/schema/structured-entities.d.ts +21 -0
- package/dist/schema/structured-entities.d.ts.map +1 -0
- package/dist/schema/structured-entities.js +39 -0
- package/dist/schema/structured-entities.js.map +1 -0
- package/dist/schema/types.d.ts +36 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +6 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/server.d.ts +57 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +144 -0
- package/dist/server.js.map +1 -0
- package/dist/telemetry.d.ts +172 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +233 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/tools/analytics-filters.d.ts +18 -0
- package/dist/tools/analytics-filters.d.ts.map +1 -0
- package/dist/tools/analytics-filters.js +35 -0
- package/dist/tools/analytics-filters.js.map +1 -0
- package/dist/tools/analytics.d.ts +16 -0
- package/dist/tools/analytics.d.ts.map +1 -0
- package/dist/tools/analytics.js +381 -0
- package/dist/tools/analytics.js.map +1 -0
- package/dist/tools/concept-profile.d.ts +14 -0
- package/dist/tools/concept-profile.d.ts.map +1 -0
- package/dist/tools/concept-profile.js +130 -0
- package/dist/tools/concept-profile.js.map +1 -0
- package/dist/tools/dataset-profile.d.ts +15 -0
- package/dist/tools/dataset-profile.d.ts.map +1 -0
- package/dist/tools/dataset-profile.js +194 -0
- package/dist/tools/dataset-profile.js.map +1 -0
- package/dist/tools/functions.d.ts +14 -0
- package/dist/tools/functions.d.ts.map +1 -0
- package/dist/tools/functions.js +294 -0
- package/dist/tools/functions.js.map +1 -0
- package/dist/tools/impact-chain.d.ts +15 -0
- package/dist/tools/impact-chain.d.ts.map +1 -0
- package/dist/tools/impact-chain.js +96 -0
- package/dist/tools/impact-chain.js.map +1 -0
- package/dist/tools/kwq.d.ts +19 -0
- package/dist/tools/kwq.d.ts.map +1 -0
- package/dist/tools/kwq.js +156 -0
- package/dist/tools/kwq.js.map +1 -0
- package/dist/tools/lookup.d.ts +14 -0
- package/dist/tools/lookup.d.ts.map +1 -0
- package/dist/tools/lookup.js +213 -0
- package/dist/tools/lookup.js.map +1 -0
- package/dist/tools/policy-profile.d.ts +15 -0
- package/dist/tools/policy-profile.d.ts.map +1 -0
- package/dist/tools/policy-profile.js +174 -0
- package/dist/tools/policy-profile.js.map +1 -0
- package/dist/tools/profile.d.ts +14 -0
- package/dist/tools/profile.d.ts.map +1 -0
- package/dist/tools/profile.js +349 -0
- package/dist/tools/profile.js.map +1 -0
- package/dist/tools/query.d.ts +16 -0
- package/dist/tools/query.d.ts.map +1 -0
- package/dist/tools/query.js +53 -0
- package/dist/tools/query.js.map +1 -0
- package/dist/tools/schema.d.ts +23 -0
- package/dist/tools/schema.d.ts.map +1 -0
- package/dist/tools/schema.js +124 -0
- package/dist/tools/schema.js.map +1 -0
- package/dist/tools/search-entity-metadata.d.ts +18 -0
- package/dist/tools/search-entity-metadata.d.ts.map +1 -0
- package/dist/tools/search-entity-metadata.js +221 -0
- package/dist/tools/search-entity-metadata.js.map +1 -0
- package/dist/tools/search.d.ts +23 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +110 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/solr-fields.d.ts +39 -0
- package/dist/tools/solr-fields.d.ts.map +1 -0
- package/dist/tools/solr-fields.js +40 -0
- package/dist/tools/solr-fields.js.map +1 -0
- package/dist/utils.d.ts +70 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +104 -0
- package/dist/utils.js.map +1 -0
- package/package.json +41 -0
- package/src/client/auth/config-loaders.ts +81 -0
- package/src/client/auth/decorators/index.ts +7 -0
- package/src/client/auth/decorators/with-caching.ts +237 -0
- package/src/client/auth/factory.ts +34 -0
- package/src/client/auth/index.ts +6 -0
- package/src/client/auth/jwt-utils.ts +36 -0
- package/src/client/auth/node.ts +16 -0
- package/src/client/auth/providers/index.ts +1 -0
- package/src/client/auth/providers/jwt-auth-provider.ts +153 -0
- package/src/client/auth/schemas.ts +25 -0
- package/src/client/auth/types.ts +30 -0
- package/src/client/command.ts +54 -0
- package/src/client/config/index.ts +15 -0
- package/src/client/config/loader.ts +155 -0
- package/src/client/config/node.ts +22 -0
- package/src/client/config/schemas.ts +28 -0
- package/src/client/config/types.ts +39 -0
- package/src/client/config/unified-loader.ts +118 -0
- package/src/client/config.ts +69 -0
- package/src/client/deployment-config.ts +98 -0
- package/src/client/errors.ts +295 -0
- package/src/client/http-client.ts +577 -0
- package/src/client/index.ts +68 -0
- package/src/client/internal-dsl-client.ts +128 -0
- package/src/client/rate-limiter.ts +139 -0
- package/src/client/resolve-api-key-user.ts +99 -0
- package/src/client/types.ts +44 -0
- package/src/dsl/client.ts +538 -0
- package/src/dsl/commands/apply-filters.ts +35 -0
- package/src/dsl/commands/facet/index.ts +12 -0
- package/src/dsl/commands/facet/schemas.ts +101 -0
- package/src/dsl/commands/functions/ClassifyCommand.ts +129 -0
- package/src/dsl/commands/functions/ExtractAffiliationsCommand.ts +163 -0
- package/src/dsl/commands/functions/ExtractConceptsCommand.ts +141 -0
- package/src/dsl/commands/functions/ExtractGrantsCommand.ts +112 -0
- package/src/dsl/commands/functions/index.ts +31 -0
- package/src/dsl/commands/index.ts +29 -0
- package/src/dsl/commands/validate-input.ts +29 -0
- package/src/dsl/create-client.ts +80 -0
- package/src/dsl/fluent-query-builder.ts +684 -0
- package/src/dsl/index.ts +206 -0
- package/src/dsl/pagination.ts +202 -0
- package/src/dsl/query-builder.ts +1120 -0
- package/src/dsl/response-parser.ts +299 -0
- package/src/dsl/schema/cache.ts +124 -0
- package/src/dsl/schema/extract.ts +44 -0
- package/src/dsl/schema/index.ts +50 -0
- package/src/dsl/schema/load.ts +160 -0
- package/src/dsl/schema/store.ts +253 -0
- package/src/dsl/schema/structured-entities.ts +44 -0
- package/src/dsl/schema/summary.ts +94 -0
- package/src/dsl/schema/types.ts +40 -0
- package/src/dsl/schema/validation.ts +56 -0
- package/src/dsl/types/buckets.ts +22 -0
- package/src/dsl/types/common.ts +99 -0
- package/src/dsl/types/entities.ts +43 -0
- package/src/dsl/types/index.ts +63 -0
- package/src/dsl/types/return-clauses.ts +147 -0
- package/src/dsl/types/special-functions.ts +220 -0
- package/src/dsl/types/vocabulary.ts +82 -0
- package/src/dsl/usage-policy.ts +219 -0
- package/src/dsl/utils/escape.ts +123 -0
- package/src/dsl/utils/sanitize.ts +21 -0
- package/src/dsl/utils/string-utils.ts +147 -0
- package/src/dsl/utils/validate-field-name.ts +19 -0
- package/src/http-main.ts +41 -0
- package/src/index.ts +14 -0
- package/src/main.ts +40 -0
- package/src/mcp/batch-fetch.ts +255 -0
- package/src/mcp/examples/dsl-examples.ts +66 -0
- package/src/mcp/examples/usage-scenarios.ts +185 -0
- package/src/mcp/export-format.ts +113 -0
- package/src/mcp/funder-org-names.ts +30 -0
- package/src/mcp/http-server.ts +148 -0
- package/src/mcp/middleware/field-aliases.ts +274 -0
- package/src/mcp/resources/schema.ts +364 -0
- package/src/mcp/schema/context.ts +11 -0
- package/src/mcp/schema/index.ts +38 -0
- package/src/mcp/server.ts +247 -0
- package/src/mcp/shared-schema.ts +34 -0
- package/src/mcp/tools/analytics-filters.ts +46 -0
- package/src/mcp/tools/analytics.ts +453 -0
- package/src/mcp/tools/fetch-search-pages.ts +329 -0
- package/src/mcp/tools/functions.ts +105 -0
- package/src/mcp/tools/lookup.ts +182 -0
- package/src/mcp/tools/query.ts +91 -0
- package/src/mcp/tools/schema.ts +147 -0
- package/src/mcp/tools/search-entity-metadata.ts +253 -0
- package/src/mcp/tools/search-input.ts +87 -0
- package/src/mcp/tools/search.ts +168 -0
- package/src/mcp/utils.ts +199 -0
- package/test/client/auth/config-loaders.test.ts +92 -0
- package/test/client/auth/decorators/with-caching.test.ts +482 -0
- package/test/client/auth/factory.test.ts +68 -0
- package/test/client/auth/providers/jwt-auth-provider.test.ts +398 -0
- package/test/client/auth/types.test.ts +18 -0
- package/test/client/command.test.ts +163 -0
- package/test/client/config/loader.test.ts +377 -0
- package/test/client/config/unified-loader.test.ts +136 -0
- package/test/client/deployment-config.test.ts +69 -0
- package/test/client/errors/index.test.ts +408 -0
- package/test/client/helpers/mock-fetch.ts +42 -0
- package/test/client/http-client.test.ts +1148 -0
- package/test/client/integration/auth-providers.integration.test.ts +186 -0
- package/test/client/internal-dsl-client.test.ts +76 -0
- package/test/client/rate-limiter.test.ts +204 -0
- package/test/client/resolve-api-key-user.test.ts +87 -0
- package/test/dsl/client.special-functions.test.ts +387 -0
- package/test/dsl/client.test.ts +457 -0
- package/test/dsl/commands/apply-filters.test.ts +147 -0
- package/test/dsl/commands/functions/ClassifyCommand.test.ts +170 -0
- package/test/dsl/commands/functions/ExtractAffiliationsCommand.test.ts +306 -0
- package/test/dsl/commands/functions/ExtractConceptsCommand.test.ts +136 -0
- package/test/dsl/commands/functions/ExtractGrantsCommand.test.ts +202 -0
- package/test/dsl/commands/search/filters.test.ts +42 -0
- package/test/dsl/fluent-query-builder.test.ts +865 -0
- package/test/dsl/integration/client.integration.test.ts +294 -0
- package/test/dsl/integration/facet-api.integration.test.ts +276 -0
- package/test/dsl/integration/field-existence.integration.test.ts +148 -0
- package/test/dsl/integration/fluent-api-docs-examples.integration.test.ts +988 -0
- package/test/dsl/integration/fluent-api.integration.test.ts +615 -0
- package/test/dsl/integration/search-helpers.ts +27 -0
- package/test/dsl/integration/special-functions.integration.test.ts +224 -0
- package/test/dsl/integration/test-config.ts +52 -0
- package/test/dsl/pagination.test.ts +86 -0
- package/test/dsl/query-builder.test.ts +1775 -0
- package/test/dsl/response-parser.test.ts +520 -0
- package/test/dsl/schema/cache.test.ts +53 -0
- package/test/dsl/schema/load.test.ts +165 -0
- package/test/dsl/schema/summary.test.ts +61 -0
- package/test/dsl/schema/validation.test.ts +46 -0
- package/test/dsl/time-series.test.ts +135 -0
- package/test/dsl/unnest.test.ts +151 -0
- package/test/dsl/usage-policy.test.ts +100 -0
- package/test/dsl/utils/escape.property.test.ts +109 -0
- package/test/dsl/utils/escape.test.ts +140 -0
- package/test/dsl/utils/validate-field-name.property.test.ts +99 -0
- package/test/dsl/utils/validate-field-name.test.ts +55 -0
- package/test/examples/dsl-examples.test.ts +29 -0
- package/test/examples/usage-scenarios.test.ts +90 -0
- package/test/fixtures/describe-schema.json +4000 -0
- package/test/funder-org-names.test.ts +20 -0
- package/test/helpers/schema-fixture.ts +18 -0
- package/test/helpers/tool-test-harness.ts +114 -0
- package/test/integration/assertions.ts +263 -0
- package/test/integration/env.ts +108 -0
- package/test/integration/harness.ts +307 -0
- package/test/integration/hosted-client.ts +56 -0
- package/test/integration/hosted-mocks.ts +81 -0
- package/test/integration/hosted-run.ts +86 -0
- package/test/integration/hosted.e2e.test.ts +101 -0
- package/test/integration/reporter.ts +100 -0
- package/test/integration/run.ts +74 -0
- package/test/integration/suites/analytics.integration.ts +72 -0
- package/test/integration/suites/functions.integration.ts +37 -0
- package/test/integration/suites/hosted-smoke.integration.ts +38 -0
- package/test/integration/suites/index.ts +22 -0
- package/test/integration/suites/lookup.integration.ts +57 -0
- package/test/integration/suites/query.integration.ts +49 -0
- package/test/integration/suites/resources.integration.ts +68 -0
- package/test/integration/suites/search.integration.ts +80 -0
- package/test/integration/types.ts +92 -0
- package/test/integration/verify-usage-scenarios.ts +162 -0
- package/test/mcp/export-format.test.ts +67 -0
- package/test/mcp/http-server.test.ts +80 -0
- package/test/middleware/field-aliases.test.ts +287 -0
- package/test/resources/schema.test.ts +28 -0
- package/test/schema/describe-contract.test.ts +24 -0
- package/test/schema/store.test.ts +45 -0
- package/test/server.test.ts +170 -0
- package/test/tools/analytics-filters.test.ts +35 -0
- package/test/tools/analytics.test.ts +419 -0
- package/test/tools/fetch-search-pages.test.ts +200 -0
- package/test/tools/functions.test.ts +153 -0
- package/test/tools/lookup.test.ts +296 -0
- package/test/tools/query.test.ts +100 -0
- package/test/tools/schema.test.ts +37 -0
- package/test/tools/search.test.ts +415 -0
- package/test/utils.test.ts +45 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-page search fetch tool for Dimensions DSL queries.
|
|
3
|
+
* Supports single-page, aggregate, and JSONL file export modes.
|
|
4
|
+
* @module mcp/tools/fetch-search-pages
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { ValidationError } from "../../client/index.js";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_BATCH_MAX_PAGES,
|
|
12
|
+
type DimensionsClient,
|
|
13
|
+
HARD_MAX_BATCH_PAGES,
|
|
14
|
+
parseEntityResponse,
|
|
15
|
+
resolveSkipAndLimit,
|
|
16
|
+
SCHEMA_LIMITS,
|
|
17
|
+
type SchemaStore,
|
|
18
|
+
STRUCTURED_ENTITY_TYPES,
|
|
19
|
+
type StructuredEntityType,
|
|
20
|
+
searchResultKey,
|
|
21
|
+
validateBatchPagination,
|
|
22
|
+
validateSearchPaginationPolicy,
|
|
23
|
+
} from "../../dsl/index.js";
|
|
24
|
+
import { queryHashFromDsl, runAggregateFetch, runFileFetch } from "../batch-fetch.js";
|
|
25
|
+
import { resolveExportFormat } from "../export-format.js";
|
|
26
|
+
import { withFieldAliases } from "../middleware/field-aliases.js";
|
|
27
|
+
import {
|
|
28
|
+
formatErrorResult,
|
|
29
|
+
formatToolResult,
|
|
30
|
+
READ_ONLY_API_ANNOTATIONS,
|
|
31
|
+
withSearchPagination,
|
|
32
|
+
} from "../utils.js";
|
|
33
|
+
import { buildStructuredSearchDsl } from "./search.js";
|
|
34
|
+
import { SEARCH_ENTITY_METADATA } from "./search-entity-metadata.js";
|
|
35
|
+
import { PAGINATION_OUTPUT_SCHEMA, SHARED_SEARCH_INPUT } from "./search-input.js";
|
|
36
|
+
|
|
37
|
+
/** Merged optional convenience filters from all entity search tools. */
|
|
38
|
+
const MERGED_ENTITY_INPUT = Object.assign(
|
|
39
|
+
{},
|
|
40
|
+
...SEARCH_ENTITY_METADATA.map((m) => m.extraInputSchema),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
/** Shared search fields without `limit` — fetch uses `pageSize` to avoid Zod default conflicts. */
|
|
44
|
+
const { limit: _searchLimit, ...FETCH_SEARCH_INPUT } = SHARED_SEARCH_INPUT;
|
|
45
|
+
|
|
46
|
+
const FETCH_MODE_SCHEMA = z
|
|
47
|
+
.enum(["page", "aggregate", "file"])
|
|
48
|
+
.default("page")
|
|
49
|
+
.describe(
|
|
50
|
+
"page: return one page in the tool response; aggregate: fetch multiple pages and return summary only; file: stream JSONL or CSV to outputPath (not returned in chat)",
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
/** Parsed input for fetch_search_pages (after MCP SDK validation). */
|
|
54
|
+
type FetchSearchPagesArgs = {
|
|
55
|
+
entityType: StructuredEntityType;
|
|
56
|
+
mode?: "page" | "aggregate" | "file";
|
|
57
|
+
query?: string;
|
|
58
|
+
skip?: number;
|
|
59
|
+
page?: number;
|
|
60
|
+
pageSize?: number;
|
|
61
|
+
startPage?: number;
|
|
62
|
+
maxPages?: number;
|
|
63
|
+
maxRecords?: number;
|
|
64
|
+
outputPath?: string;
|
|
65
|
+
outputFormat?: "jsonl" | "csv";
|
|
66
|
+
resumeFromMeta?: boolean;
|
|
67
|
+
confirmLargeFetch?: boolean;
|
|
68
|
+
fields?: string[];
|
|
69
|
+
filters?: unknown[];
|
|
70
|
+
sortBy?: string;
|
|
71
|
+
[key: string]: unknown;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Registers the fetch_search_pages tool.
|
|
76
|
+
* @param server - MCP server instance
|
|
77
|
+
* @param client - Dimensions client instance
|
|
78
|
+
* @param schemaStore - Loaded describe schema
|
|
79
|
+
*/
|
|
80
|
+
export function registerFetchSearchPagesTools(
|
|
81
|
+
server: McpServer,
|
|
82
|
+
client: DimensionsClient,
|
|
83
|
+
schemaStore: SchemaStore,
|
|
84
|
+
): void {
|
|
85
|
+
const entityList = schemaStore.structuredEntityTypes().join(", ");
|
|
86
|
+
|
|
87
|
+
server.registerTool(
|
|
88
|
+
"fetch_search_pages",
|
|
89
|
+
{
|
|
90
|
+
description:
|
|
91
|
+
`Fetch paginated search results with rate-limit-aware batching (max ${SCHEMA_LIMITS.maxLimit}/page, ` +
|
|
92
|
+
`${SCHEMA_LIMITS.maxPages} pages, ${SCHEMA_LIMITS.maxOffset} records total). ` +
|
|
93
|
+
"Default mode returns one page. Use aggregate for ID counts/sums without full rows. " +
|
|
94
|
+
"Use file mode to stream JSONL or CSV locally — never for bulk mirroring of Dimensions data. " +
|
|
95
|
+
`Entities: ${entityList}.`,
|
|
96
|
+
inputSchema: {
|
|
97
|
+
entityType: z
|
|
98
|
+
.enum(STRUCTURED_ENTITY_TYPES)
|
|
99
|
+
.describe("Dimensions source to search (same as search_* tools)"),
|
|
100
|
+
mode: FETCH_MODE_SCHEMA,
|
|
101
|
+
...FETCH_SEARCH_INPUT,
|
|
102
|
+
...MERGED_ENTITY_INPUT,
|
|
103
|
+
pageSize: z
|
|
104
|
+
.number()
|
|
105
|
+
.int()
|
|
106
|
+
.min(1)
|
|
107
|
+
.max(SCHEMA_LIMITS.maxLimit)
|
|
108
|
+
.optional()
|
|
109
|
+
.describe(
|
|
110
|
+
`Records per page (page mode default 100, aggregate/file default 1000; max ${SCHEMA_LIMITS.maxLimit})`,
|
|
111
|
+
),
|
|
112
|
+
startPage: z
|
|
113
|
+
.number()
|
|
114
|
+
.int()
|
|
115
|
+
.min(0)
|
|
116
|
+
.max(SCHEMA_LIMITS.maxPages - 1)
|
|
117
|
+
.optional()
|
|
118
|
+
.describe("Starting page for aggregate/file modes (0-based, default 0)"),
|
|
119
|
+
maxPages: z
|
|
120
|
+
.number()
|
|
121
|
+
.int()
|
|
122
|
+
.min(1)
|
|
123
|
+
.max(HARD_MAX_BATCH_PAGES)
|
|
124
|
+
.default(DEFAULT_BATCH_MAX_PAGES)
|
|
125
|
+
.describe(
|
|
126
|
+
`Pages to fetch in aggregate/file modes (default ${DEFAULT_BATCH_MAX_PAGES}, max ${HARD_MAX_BATCH_PAGES}). Ignored in page mode.`,
|
|
127
|
+
),
|
|
128
|
+
maxRecords: z
|
|
129
|
+
.number()
|
|
130
|
+
.int()
|
|
131
|
+
.min(1)
|
|
132
|
+
.max(SCHEMA_LIMITS.maxOffset)
|
|
133
|
+
.optional()
|
|
134
|
+
.describe("Stop after this many records across pages"),
|
|
135
|
+
outputPath: z
|
|
136
|
+
.string()
|
|
137
|
+
.optional()
|
|
138
|
+
.describe("Required for file mode — local output path (.jsonl or .csv)"),
|
|
139
|
+
outputFormat: z
|
|
140
|
+
.enum(["jsonl", "csv"])
|
|
141
|
+
.optional()
|
|
142
|
+
.describe(
|
|
143
|
+
"File format for file mode (default: infer from outputPath extension, else JSONL)",
|
|
144
|
+
),
|
|
145
|
+
resumeFromMeta: z
|
|
146
|
+
.boolean()
|
|
147
|
+
.optional()
|
|
148
|
+
.default(false)
|
|
149
|
+
.describe("Resume file export from existing outputPath.meta.json sidecar"),
|
|
150
|
+
confirmLargeFetch: z
|
|
151
|
+
.boolean()
|
|
152
|
+
.optional()
|
|
153
|
+
.default(false)
|
|
154
|
+
.describe(
|
|
155
|
+
"Required when maxPages > 5 or planned records > 5000. Acknowledges reasonable-use policy.",
|
|
156
|
+
),
|
|
157
|
+
},
|
|
158
|
+
outputSchema: {
|
|
159
|
+
mode: z.string(),
|
|
160
|
+
entityType: z.string(),
|
|
161
|
+
totalCount: z.number().optional(),
|
|
162
|
+
returnedCount: z.number().optional(),
|
|
163
|
+
pagesFetched: z.number().optional(),
|
|
164
|
+
...PAGINATION_OUTPUT_SCHEMA,
|
|
165
|
+
outputPath: z.string().optional(),
|
|
166
|
+
outputFormat: z.string().optional(),
|
|
167
|
+
metaPath: z.string().optional(),
|
|
168
|
+
recordsWritten: z.number().optional(),
|
|
169
|
+
resumed: z.boolean().optional(),
|
|
170
|
+
aggregate: z
|
|
171
|
+
.object({
|
|
172
|
+
ids: z.array(z.string()),
|
|
173
|
+
idsTruncated: z.boolean(),
|
|
174
|
+
totalFundingUsd: z.number().optional(),
|
|
175
|
+
})
|
|
176
|
+
.optional(),
|
|
177
|
+
},
|
|
178
|
+
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
179
|
+
},
|
|
180
|
+
withFieldAliases(
|
|
181
|
+
{
|
|
182
|
+
entitySource: { kind: "dynamic", argName: "entityType" },
|
|
183
|
+
fieldArrayArgs: ["fields"],
|
|
184
|
+
fieldStringArgs: ["sortBy"],
|
|
185
|
+
filterArrayArgs: ["filters"],
|
|
186
|
+
},
|
|
187
|
+
async (args: FetchSearchPagesArgs) => {
|
|
188
|
+
try {
|
|
189
|
+
const entityType = args.entityType;
|
|
190
|
+
const mode = args.mode ?? "page";
|
|
191
|
+
const pageSize = args.pageSize ?? (mode === "page" ? 100 : 1000);
|
|
192
|
+
const startPage = args.page ?? args.startPage ?? 0;
|
|
193
|
+
const maxPages = mode === "page" ? 1 : (args.maxPages ?? DEFAULT_BATCH_MAX_PAGES);
|
|
194
|
+
|
|
195
|
+
validateBatchPagination({
|
|
196
|
+
startPage,
|
|
197
|
+
maxPages,
|
|
198
|
+
pageSize,
|
|
199
|
+
maxRecords: args.maxRecords,
|
|
200
|
+
confirmLargeFetch: args.confirmLargeFetch,
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
if (mode === "page") {
|
|
204
|
+
const pageSkip =
|
|
205
|
+
args.skip !== undefined || args.page !== undefined
|
|
206
|
+
? resolveSkipAndLimit({
|
|
207
|
+
skip: args.skip,
|
|
208
|
+
page: args.page,
|
|
209
|
+
limit: pageSize,
|
|
210
|
+
}).skip
|
|
211
|
+
: startPage * pageSize;
|
|
212
|
+
validateSearchPaginationPolicy({
|
|
213
|
+
skip: pageSkip,
|
|
214
|
+
limit: pageSize,
|
|
215
|
+
confirmLargeFetch: args.confirmLargeFetch,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const buildDsl = (skip: number, limit: number) =>
|
|
220
|
+
buildStructuredSearchDsl(client, entityType, {
|
|
221
|
+
...args,
|
|
222
|
+
skip,
|
|
223
|
+
limit,
|
|
224
|
+
pageSize: limit,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
if (mode === "file") {
|
|
228
|
+
if (!args.outputPath) {
|
|
229
|
+
return formatErrorResult(
|
|
230
|
+
new ValidationError("outputPath is required for file mode", { mode: "file" }),
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
const outputFormat = resolveExportFormat(args.outputPath, args.outputFormat);
|
|
234
|
+
const sampleDsl = buildDsl(startPage * pageSize, pageSize);
|
|
235
|
+
const hash = queryHashFromDsl(sampleDsl);
|
|
236
|
+
const fileResult = await runFileFetch(client, entityType, buildDsl, args.outputPath, {
|
|
237
|
+
startPage,
|
|
238
|
+
maxPages,
|
|
239
|
+
pageSize,
|
|
240
|
+
maxRecords: args.maxRecords,
|
|
241
|
+
queryHash: hash,
|
|
242
|
+
format: outputFormat,
|
|
243
|
+
preferredFields: args.fields,
|
|
244
|
+
resumeFromMeta: args.resumeFromMeta,
|
|
245
|
+
});
|
|
246
|
+
return formatToolResult({
|
|
247
|
+
mode: "file",
|
|
248
|
+
entityType,
|
|
249
|
+
totalCount: fileResult.totalCount,
|
|
250
|
+
pagesFetched: fileResult.pagesFetched,
|
|
251
|
+
recordsWritten: fileResult.recordsWritten,
|
|
252
|
+
outputPath: fileResult.outputPath,
|
|
253
|
+
outputFormat: fileResult.format,
|
|
254
|
+
metaPath: fileResult.metaPath,
|
|
255
|
+
resumed: fileResult.resumed,
|
|
256
|
+
largeResultWarning:
|
|
257
|
+
fileResult.totalCount > 10_000
|
|
258
|
+
? `${fileResult.totalCount} total matches — export may require many requests at ${SCHEMA_LIMITS.requestsPerMinute}/min.`
|
|
259
|
+
: undefined,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (mode === "aggregate") {
|
|
264
|
+
const summary = await runAggregateFetch(client, entityType, buildDsl, {
|
|
265
|
+
startPage,
|
|
266
|
+
maxPages,
|
|
267
|
+
pageSize,
|
|
268
|
+
maxRecords: args.maxRecords,
|
|
269
|
+
});
|
|
270
|
+
return formatToolResult({
|
|
271
|
+
mode: "aggregate",
|
|
272
|
+
entityType,
|
|
273
|
+
totalCount: summary.totalCount,
|
|
274
|
+
returnedCount: summary.recordsFetched,
|
|
275
|
+
pagesFetched: summary.pagesFetched,
|
|
276
|
+
aggregate: {
|
|
277
|
+
ids: summary.ids,
|
|
278
|
+
idsTruncated: summary.idsTruncated,
|
|
279
|
+
...(summary.totalFundingUsd !== undefined
|
|
280
|
+
? { totalFundingUsd: summary.totalFundingUsd }
|
|
281
|
+
: {}),
|
|
282
|
+
},
|
|
283
|
+
truncated: summary.totalCount > summary.recordsFetched,
|
|
284
|
+
truncationWarning:
|
|
285
|
+
summary.totalCount > summary.recordsFetched
|
|
286
|
+
? `Fetched ${summary.recordsFetched} of ${summary.totalCount} records across ${summary.pagesFetched} page(s). Increase maxPages or use file mode for full export.`
|
|
287
|
+
: undefined,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// mode === "page"
|
|
292
|
+
const { skip, limit } = resolveSkipAndLimit(
|
|
293
|
+
args.skip !== undefined || args.page !== undefined
|
|
294
|
+
? {
|
|
295
|
+
skip: args.skip,
|
|
296
|
+
page: args.page,
|
|
297
|
+
limit: pageSize,
|
|
298
|
+
}
|
|
299
|
+
: { skip: startPage * pageSize, limit: pageSize },
|
|
300
|
+
);
|
|
301
|
+
const dsl = buildDsl(skip, limit);
|
|
302
|
+
const response = (await client.rawQuery(dsl)) as Record<string, unknown>;
|
|
303
|
+
const parsed = parseEntityResponse(response, entityType);
|
|
304
|
+
const rows = parsed.data as Record<string, unknown>[];
|
|
305
|
+
const resultKey = searchResultKey(entityType);
|
|
306
|
+
|
|
307
|
+
return formatToolResult(
|
|
308
|
+
withSearchPagination(
|
|
309
|
+
{
|
|
310
|
+
mode: "page",
|
|
311
|
+
entityType,
|
|
312
|
+
totalCount: parsed.totalCount,
|
|
313
|
+
returnedCount: rows.length,
|
|
314
|
+
pagesFetched: 1,
|
|
315
|
+
[resultKey]: rows,
|
|
316
|
+
},
|
|
317
|
+
parsed.totalCount,
|
|
318
|
+
rows.length,
|
|
319
|
+
skip,
|
|
320
|
+
limit,
|
|
321
|
+
),
|
|
322
|
+
);
|
|
323
|
+
} catch (error) {
|
|
324
|
+
return formatErrorResult(error);
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
),
|
|
328
|
+
);
|
|
329
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Special function tools for the MCP server.
|
|
3
|
+
* Entity resolution helpers (affiliations, grants).
|
|
4
|
+
* @module mcp/tools/functions
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import type { DimensionsClient } from "../../dsl/index.js";
|
|
10
|
+
import { formatErrorResult, formatToolResult, READ_ONLY_API_ANNOTATIONS } from "../utils.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Registers special function tools with the MCP server.
|
|
14
|
+
* @param server - MCP server instance
|
|
15
|
+
* @param client - Dimensions client instance
|
|
16
|
+
*/
|
|
17
|
+
export function registerFunctionTools(server: McpServer, client: DimensionsClient): void {
|
|
18
|
+
server.registerTool(
|
|
19
|
+
"extract_affiliations",
|
|
20
|
+
{
|
|
21
|
+
description:
|
|
22
|
+
"Resolve and disambiguate organization affiliations using Dimensions entity resolution. " +
|
|
23
|
+
"Takes freetext affiliation strings or structured organization data and returns matched " +
|
|
24
|
+
"organizations with GRID/ROR identifiers and confidence scores.",
|
|
25
|
+
inputSchema: {
|
|
26
|
+
affiliations: z
|
|
27
|
+
.array(
|
|
28
|
+
z.object({
|
|
29
|
+
affiliation: z
|
|
30
|
+
.string()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("Freetext affiliation string (e.g., 'University of Oxford, UK')"),
|
|
33
|
+
name: z.string().optional().describe("Organization name"),
|
|
34
|
+
city: z.string().optional().describe("City"),
|
|
35
|
+
state: z.string().optional().describe("State/province"),
|
|
36
|
+
country: z.string().optional().describe("Country"),
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
.min(1)
|
|
40
|
+
.describe(
|
|
41
|
+
"Array of affiliations to resolve. Each must have either 'affiliation' or 'name'",
|
|
42
|
+
),
|
|
43
|
+
},
|
|
44
|
+
outputSchema: {
|
|
45
|
+
matchCount: z.number().describe("Number of resolved affiliations"),
|
|
46
|
+
affiliations: z.array(z.record(z.string(), z.unknown())).describe("Resolved affiliations"),
|
|
47
|
+
},
|
|
48
|
+
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
49
|
+
},
|
|
50
|
+
async (args) => {
|
|
51
|
+
try {
|
|
52
|
+
const result = await client.extractAffiliations(args.affiliations);
|
|
53
|
+
|
|
54
|
+
return formatToolResult({
|
|
55
|
+
matchCount: result.extracted_affiliations.length,
|
|
56
|
+
affiliations: result.extracted_affiliations,
|
|
57
|
+
});
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return formatErrorResult(error);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
server.registerTool(
|
|
65
|
+
"extract_grants",
|
|
66
|
+
{
|
|
67
|
+
description:
|
|
68
|
+
"Resolve grant numbers to Dimensions grant records. " +
|
|
69
|
+
"Takes a grant number and optional funder information to find matching grants " +
|
|
70
|
+
"with full metadata including funding amounts, dates, and funder details.",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
grant_number: z.string().min(1).describe("Grant number to look up (e.g., 'R01HL117329')"),
|
|
73
|
+
fundref: z
|
|
74
|
+
.string()
|
|
75
|
+
.optional()
|
|
76
|
+
.describe("FundRef ID of the funder (e.g., '100000050' for NIH)"),
|
|
77
|
+
funder_name: z
|
|
78
|
+
.string()
|
|
79
|
+
.optional()
|
|
80
|
+
.describe("Funder name as alternative to FundRef ID (e.g., 'NIH')"),
|
|
81
|
+
},
|
|
82
|
+
outputSchema: {
|
|
83
|
+
matchCount: z.number().describe("Number of matched grants"),
|
|
84
|
+
grants: z.array(z.record(z.string(), z.unknown())).describe("Matched grant records"),
|
|
85
|
+
},
|
|
86
|
+
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
87
|
+
},
|
|
88
|
+
async (args) => {
|
|
89
|
+
try {
|
|
90
|
+
const result = await client.extractGrants({
|
|
91
|
+
grantNumber: args.grant_number,
|
|
92
|
+
fundref: args.fundref,
|
|
93
|
+
funderName: args.funder_name,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return formatToolResult({
|
|
97
|
+
matchCount: result.grant_id ? 1 : 0,
|
|
98
|
+
grants: result.grant_id ? [{ grant_id: result.grant_id }] : [],
|
|
99
|
+
});
|
|
100
|
+
} catch (error) {
|
|
101
|
+
return formatErrorResult(error);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lookup tools for the MCP server.
|
|
3
|
+
* Provides direct lookup by identifiers (DOI, PMID, Dimensions ID).
|
|
4
|
+
* @module mcp/tools/lookup
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { type DimensionsClient, EntitySchema, type EntityType } from "../../dsl/index.js";
|
|
10
|
+
import { withFieldAliases } from "../middleware/field-aliases.js";
|
|
11
|
+
import {
|
|
12
|
+
asArray,
|
|
13
|
+
formatErrorResult,
|
|
14
|
+
formatToolResult,
|
|
15
|
+
READ_ONLY_API_ANNOTATIONS,
|
|
16
|
+
} from "../utils.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Registers all lookup tools with the MCP server.
|
|
20
|
+
* @param server - MCP server instance
|
|
21
|
+
* @param client - Dimensions client instance
|
|
22
|
+
*/
|
|
23
|
+
export function registerLookupTools(server: McpServer, client: DimensionsClient): void {
|
|
24
|
+
// Get publication by DOI
|
|
25
|
+
server.registerTool(
|
|
26
|
+
"get_by_doi",
|
|
27
|
+
{
|
|
28
|
+
description:
|
|
29
|
+
"Retrieve a publication by its Digital Object Identifier (DOI). Returns full publication details including abstract, citations, and authors.",
|
|
30
|
+
inputSchema: {
|
|
31
|
+
doi: z.string().describe("The DOI to look up (e.g., '10.1038/nature12373')"),
|
|
32
|
+
fields: z
|
|
33
|
+
.array(z.string())
|
|
34
|
+
.optional()
|
|
35
|
+
.describe("Fields to return (e.g., ['id', 'title', 'abstract', 'times_cited'])"),
|
|
36
|
+
},
|
|
37
|
+
outputSchema: {
|
|
38
|
+
found: z.boolean().describe("Whether the entity was found"),
|
|
39
|
+
publication: z.record(z.string(), z.unknown()).optional().describe("The found entity"),
|
|
40
|
+
message: z.string().optional().describe("Message when not found"),
|
|
41
|
+
},
|
|
42
|
+
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
43
|
+
},
|
|
44
|
+
withFieldAliases(
|
|
45
|
+
{ entitySource: { kind: "static", entity: "publications" }, fieldArrayArgs: ["fields"] },
|
|
46
|
+
async (args) => {
|
|
47
|
+
try {
|
|
48
|
+
const qb = client
|
|
49
|
+
.createQueryBuilder()
|
|
50
|
+
.search("publications")
|
|
51
|
+
.where("doi", "=", args.doi)
|
|
52
|
+
.limit(1);
|
|
53
|
+
if (args.fields?.length) qb.fields(args.fields);
|
|
54
|
+
const dsl = qb.build();
|
|
55
|
+
|
|
56
|
+
const response = await client.rawQuery(dsl);
|
|
57
|
+
const publications = asArray(response.publications);
|
|
58
|
+
|
|
59
|
+
if (publications.length === 0) {
|
|
60
|
+
return formatToolResult({
|
|
61
|
+
found: false,
|
|
62
|
+
message: `No publication found with DOI: ${args.doi}`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return formatToolResult({
|
|
67
|
+
found: true,
|
|
68
|
+
publication: publications[0],
|
|
69
|
+
});
|
|
70
|
+
} catch (error) {
|
|
71
|
+
return formatErrorResult(error);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// Get publication by PubMed ID
|
|
78
|
+
server.registerTool(
|
|
79
|
+
"get_by_pmid",
|
|
80
|
+
{
|
|
81
|
+
description:
|
|
82
|
+
"Retrieve a publication by its PubMed ID (PMID). Returns full publication details from Dimensions.",
|
|
83
|
+
inputSchema: {
|
|
84
|
+
pmid: z.string().describe("The PubMed ID to look up (e.g., '23846567')"),
|
|
85
|
+
fields: z
|
|
86
|
+
.array(z.string())
|
|
87
|
+
.optional()
|
|
88
|
+
.describe("Fields to return (e.g., ['id', 'title', 'abstract', 'times_cited'])"),
|
|
89
|
+
},
|
|
90
|
+
outputSchema: {
|
|
91
|
+
found: z.boolean().describe("Whether the entity was found"),
|
|
92
|
+
publication: z.record(z.string(), z.unknown()).optional().describe("The found entity"),
|
|
93
|
+
message: z.string().optional().describe("Message when not found"),
|
|
94
|
+
},
|
|
95
|
+
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
96
|
+
},
|
|
97
|
+
withFieldAliases(
|
|
98
|
+
{ entitySource: { kind: "static", entity: "publications" }, fieldArrayArgs: ["fields"] },
|
|
99
|
+
async (args) => {
|
|
100
|
+
try {
|
|
101
|
+
const qb = client
|
|
102
|
+
.createQueryBuilder()
|
|
103
|
+
.search("publications")
|
|
104
|
+
.where("pmid", "=", args.pmid)
|
|
105
|
+
.limit(1);
|
|
106
|
+
if (args.fields?.length) qb.fields(args.fields);
|
|
107
|
+
const dsl = qb.build();
|
|
108
|
+
|
|
109
|
+
const response = await client.rawQuery(dsl);
|
|
110
|
+
const publications = asArray(response.publications);
|
|
111
|
+
|
|
112
|
+
if (publications.length === 0) {
|
|
113
|
+
return formatToolResult({
|
|
114
|
+
found: false,
|
|
115
|
+
message: `No publication found with PMID: ${args.pmid}`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return formatToolResult({
|
|
120
|
+
found: true,
|
|
121
|
+
publication: publications[0],
|
|
122
|
+
});
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return formatErrorResult(error);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// Get entity by Dimensions ID
|
|
131
|
+
server.registerTool(
|
|
132
|
+
"get_by_id",
|
|
133
|
+
{
|
|
134
|
+
description:
|
|
135
|
+
"Retrieve any entity by its Dimensions ID. Supports publications, grants, patents, clinical trials, datasets, policy documents, researchers, and organizations.",
|
|
136
|
+
inputSchema: {
|
|
137
|
+
entityType: EntitySchema.describe("The type of entity to look up"),
|
|
138
|
+
id: z.string().describe("The Dimensions ID to look up"),
|
|
139
|
+
fields: z.array(z.string()).optional().describe("Fields to return"),
|
|
140
|
+
},
|
|
141
|
+
outputSchema: {
|
|
142
|
+
found: z.boolean().describe("Whether the entity was found"),
|
|
143
|
+
entity: z.record(z.string(), z.unknown()).optional().describe("The found entity"),
|
|
144
|
+
entityType: z.string().optional().describe("The type of the found entity"),
|
|
145
|
+
message: z.string().optional().describe("Message when not found"),
|
|
146
|
+
},
|
|
147
|
+
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
148
|
+
},
|
|
149
|
+
withFieldAliases(
|
|
150
|
+
{ entitySource: { kind: "dynamic", argName: "entityType" }, fieldArrayArgs: ["fields"] },
|
|
151
|
+
async (args) => {
|
|
152
|
+
try {
|
|
153
|
+
const qb = client
|
|
154
|
+
.createQueryBuilder()
|
|
155
|
+
.search(args.entityType as EntityType)
|
|
156
|
+
.where("id", "=", args.id)
|
|
157
|
+
.limit(1);
|
|
158
|
+
if (args.fields?.length) qb.fields(args.fields);
|
|
159
|
+
const dsl = qb.build();
|
|
160
|
+
|
|
161
|
+
const response = await client.rawQuery(dsl);
|
|
162
|
+
const entities = asArray(response[args.entityType]);
|
|
163
|
+
|
|
164
|
+
if (entities.length === 0) {
|
|
165
|
+
return formatToolResult({
|
|
166
|
+
found: false,
|
|
167
|
+
message: `No ${args.entityType.slice(0, -1)} found with ID: ${args.id}`,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return formatToolResult({
|
|
172
|
+
found: true,
|
|
173
|
+
entity: entities[0],
|
|
174
|
+
entityType: args.entityType,
|
|
175
|
+
});
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return formatErrorResult(error);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
),
|
|
181
|
+
);
|
|
182
|
+
}
|