@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,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for the MCP evaluation harness.
|
|
3
|
+
*
|
|
4
|
+
* Each eval suite defines a set of cases that exercise MCP tools against the
|
|
5
|
+
* live Dimensions API and verify response correctness with assertions.
|
|
6
|
+
* @module test/integration/types
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** A single assertion to run against a tool result. */
|
|
10
|
+
export interface Assertion {
|
|
11
|
+
/** Human-readable label shown in reports. */
|
|
12
|
+
readonly label: string;
|
|
13
|
+
/**
|
|
14
|
+
* Evaluates the assertion against parsed tool output.
|
|
15
|
+
* @param data - Parsed JSON from the tool result
|
|
16
|
+
* @returns `true` if the assertion passes, or an error message string
|
|
17
|
+
*/
|
|
18
|
+
readonly check: (data: unknown) => true | string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A single evaluation case — one tool call plus its expected assertions. */
|
|
22
|
+
export interface EvalCase {
|
|
23
|
+
/** Short descriptive name for the case (e.g., "CRISPR DOI lookup"). */
|
|
24
|
+
readonly name: string;
|
|
25
|
+
/** MCP tool name to invoke. */
|
|
26
|
+
readonly tool: string;
|
|
27
|
+
/** Arguments passed to the tool. */
|
|
28
|
+
readonly args: Record<string, unknown>;
|
|
29
|
+
/** Assertions that must all pass for the case to succeed. */
|
|
30
|
+
readonly assertions: readonly Assertion[];
|
|
31
|
+
/** Optional tags for filtering (e.g., "slow", "optional-api-key"). */
|
|
32
|
+
readonly tags?: readonly string[];
|
|
33
|
+
/** Timeout in ms for the tool call (default: 30_000). */
|
|
34
|
+
readonly timeout?: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** An evaluation suite — a named group of related cases. */
|
|
38
|
+
export interface EvalSuite {
|
|
39
|
+
/** Suite name (e.g., "search", "lookup"). */
|
|
40
|
+
readonly name: string;
|
|
41
|
+
/** Suite description. */
|
|
42
|
+
readonly description: string;
|
|
43
|
+
/** Eval cases in this suite. */
|
|
44
|
+
readonly cases: readonly EvalCase[];
|
|
45
|
+
/**
|
|
46
|
+
* Optional API keys this suite requires beyond the base Dimensions key.
|
|
47
|
+
* If any are missing from the environment, the suite is skipped.
|
|
48
|
+
*/
|
|
49
|
+
readonly requiredEnvVars?: readonly string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Result of a single assertion check. */
|
|
53
|
+
export interface AssertionResult {
|
|
54
|
+
readonly label: string;
|
|
55
|
+
readonly passed: boolean;
|
|
56
|
+
readonly error?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Result of a single eval case. */
|
|
60
|
+
export interface CaseResult {
|
|
61
|
+
readonly suiteName: string;
|
|
62
|
+
readonly caseName: string;
|
|
63
|
+
readonly tool: string;
|
|
64
|
+
readonly passed: boolean;
|
|
65
|
+
readonly assertions: readonly AssertionResult[];
|
|
66
|
+
/** Wall-clock duration in ms. */
|
|
67
|
+
readonly durationMs: number;
|
|
68
|
+
/** Set if the tool call itself failed (threw or returned isError). */
|
|
69
|
+
readonly toolError?: string;
|
|
70
|
+
/** Whether the case was skipped (e.g., missing env var). */
|
|
71
|
+
readonly skipped?: boolean;
|
|
72
|
+
readonly skipReason?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Aggregate result for an entire suite. */
|
|
76
|
+
export interface SuiteResult {
|
|
77
|
+
readonly name: string;
|
|
78
|
+
readonly cases: readonly CaseResult[];
|
|
79
|
+
readonly passed: number;
|
|
80
|
+
readonly failed: number;
|
|
81
|
+
readonly skipped: number;
|
|
82
|
+
readonly durationMs: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Aggregate result for the full eval run. */
|
|
86
|
+
export interface EvalRunResult {
|
|
87
|
+
readonly suites: readonly SuiteResult[];
|
|
88
|
+
readonly totalPassed: number;
|
|
89
|
+
readonly totalFailed: number;
|
|
90
|
+
readonly totalSkipped: number;
|
|
91
|
+
readonly durationMs: number;
|
|
92
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Live verification of docs/USAGE.md natural-language scenarios.
|
|
4
|
+
* Run: node --import tsx apps/mcp/test/integration/verify-usage-scenarios.ts
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
8
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
9
|
+
import { USAGE_SCENARIOS } from "../../src/mcp/examples/usage-scenarios.js";
|
|
10
|
+
import { buildServerInstructions, createMcpServerAsync } from "../../src/mcp/server.js";
|
|
11
|
+
|
|
12
|
+
interface Row {
|
|
13
|
+
id: string;
|
|
14
|
+
tool: string;
|
|
15
|
+
ok: boolean;
|
|
16
|
+
summary: string;
|
|
17
|
+
note?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function summarize(tool: string, data: Record<string, unknown>): string {
|
|
21
|
+
if (data.error) return `error: ${String(data.error)}`;
|
|
22
|
+
switch (tool) {
|
|
23
|
+
case "search_publications":
|
|
24
|
+
case "search_grants":
|
|
25
|
+
case "search_researchers":
|
|
26
|
+
return `totalCount=${data.totalCount}, returned=${data.returnedCount}`;
|
|
27
|
+
case "facet_query":
|
|
28
|
+
case "aggregate_query":
|
|
29
|
+
return `buckets=${data.totalBuckets}`;
|
|
30
|
+
case "get_by_doi":
|
|
31
|
+
return data.found
|
|
32
|
+
? `found: ${(data.publication as { title?: string })?.title ?? "ok"}`
|
|
33
|
+
: `not found`;
|
|
34
|
+
case "citation_trend": {
|
|
35
|
+
const series = data.citationsPerYear as unknown[] | undefined;
|
|
36
|
+
return `years=${series?.length ?? 0}`;
|
|
37
|
+
}
|
|
38
|
+
case "execute_dsl":
|
|
39
|
+
return "ok";
|
|
40
|
+
default:
|
|
41
|
+
return "ok";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function callTool(client: Client, tool: string, args: Record<string, unknown>) {
|
|
46
|
+
const result = await client.callTool({ name: tool, arguments: args });
|
|
47
|
+
if ("isError" in result && result.isError) {
|
|
48
|
+
const text = result.content.find((c) => c.type === "text" && "text" in c)?.text;
|
|
49
|
+
const parsed = text ? (JSON.parse(text) as Record<string, unknown>) : {};
|
|
50
|
+
return { ok: false, data: parsed };
|
|
51
|
+
}
|
|
52
|
+
const text = result.content.find((c) => c.type === "text" && "text" in c)?.text;
|
|
53
|
+
if (!text) return { ok: false, data: { error: "no text content" } };
|
|
54
|
+
const data = JSON.parse(text) as Record<string, unknown>;
|
|
55
|
+
return { ok: true, data };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function main() {
|
|
59
|
+
const apiKey = process.env.DIMENSIONS_API_KEY;
|
|
60
|
+
if (!apiKey) {
|
|
61
|
+
console.error("DIMENSIONS_API_KEY required");
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const { server, schemaStore } = await createMcpServerAsync({ apiKey });
|
|
66
|
+
const instructions = buildServerInstructions(schemaStore);
|
|
67
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
68
|
+
const client = new Client({ name: "usage-verify", version: "1.0.0" });
|
|
69
|
+
await server.connect(serverTransport);
|
|
70
|
+
await client.connect(clientTransport);
|
|
71
|
+
|
|
72
|
+
const rows: Row[] = [];
|
|
73
|
+
|
|
74
|
+
for (const scenario of USAGE_SCENARIOS) {
|
|
75
|
+
const { ok, data } = await callTool(client, scenario.tool, scenario.args);
|
|
76
|
+
rows.push({
|
|
77
|
+
id: scenario.id,
|
|
78
|
+
tool: scenario.tool,
|
|
79
|
+
ok,
|
|
80
|
+
summary: summarize(scenario.tool, data),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Extra checks for documented edge cases
|
|
85
|
+
const extras: Array<{ id: string; tool: string; args: Record<string, unknown> }> = [
|
|
86
|
+
{
|
|
87
|
+
id: "nih-acronym-grants",
|
|
88
|
+
tool: "search_grants",
|
|
89
|
+
args: {
|
|
90
|
+
query: "cancer immunotherapy",
|
|
91
|
+
startYearFrom: 2020,
|
|
92
|
+
funderOrgName: "NIH",
|
|
93
|
+
limit: 5,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: "stanford-org-search",
|
|
98
|
+
tool: "search_organizations",
|
|
99
|
+
args: { query: "Stanford University", limit: 10 },
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: "topic-on-search-researchers",
|
|
103
|
+
tool: "search_researchers",
|
|
104
|
+
args: { query: "quantum computing", limit: 5 },
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "funder-facet-funder_orgs",
|
|
108
|
+
tool: "aggregate_query",
|
|
109
|
+
args: {
|
|
110
|
+
entityType: "grants",
|
|
111
|
+
facetField: "funder_orgs",
|
|
112
|
+
indicators: ["funding"],
|
|
113
|
+
query: "climate adaptation",
|
|
114
|
+
limit: 5,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: "funder-facet-funder_org_name",
|
|
119
|
+
tool: "aggregate_query",
|
|
120
|
+
args: {
|
|
121
|
+
entityType: "grants",
|
|
122
|
+
facetField: "funder_org_name",
|
|
123
|
+
indicators: ["funding"],
|
|
124
|
+
query: "climate adaptation",
|
|
125
|
+
limit: 5,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
for (const extra of extras) {
|
|
131
|
+
const { ok, data } = await callTool(client, extra.tool, extra.args);
|
|
132
|
+
rows.push({
|
|
133
|
+
id: extra.id,
|
|
134
|
+
tool: extra.tool,
|
|
135
|
+
ok,
|
|
136
|
+
summary: summarize(extra.tool, data),
|
|
137
|
+
note: "edge-case",
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
await client.close();
|
|
142
|
+
await server.close();
|
|
143
|
+
|
|
144
|
+
console.log("\n=== Server instructions (routing excerpt) ===");
|
|
145
|
+
const routingLine = instructions.split("\n\n").find((p) => p.startsWith("Routing:"));
|
|
146
|
+
console.log(routingLine ?? "(no routing section)");
|
|
147
|
+
|
|
148
|
+
console.log("\n=== USAGE.md scenario verification ===");
|
|
149
|
+
for (const row of rows) {
|
|
150
|
+
const status = row.ok ? "PASS" : "FAIL";
|
|
151
|
+
const tag = row.note ? ` [${row.note}]` : "";
|
|
152
|
+
console.log(`${status} ${row.id} → ${row.tool}: ${row.summary}${tag}`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const failed = rows.filter((r) => !r.ok).length;
|
|
156
|
+
process.exit(failed > 0 ? 1 : 0);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
main().catch((err) => {
|
|
160
|
+
console.error(err);
|
|
161
|
+
process.exit(1);
|
|
162
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for batch export formatting helpers.
|
|
3
|
+
* @module test/mcp/export-format
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import {
|
|
8
|
+
deriveCsvColumns,
|
|
9
|
+
escapeCsvCell,
|
|
10
|
+
formatRowsForExport,
|
|
11
|
+
resolveExportFormat,
|
|
12
|
+
} from "../../src/mcp/export-format.js";
|
|
13
|
+
|
|
14
|
+
describe("export-format", () => {
|
|
15
|
+
describe("resolveExportFormat", () => {
|
|
16
|
+
it("infers CSV from .csv extension", () => {
|
|
17
|
+
expect(resolveExportFormat("/tmp/results.csv")).toBe("csv");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("defaults to JSONL for other extensions", () => {
|
|
21
|
+
expect(resolveExportFormat("/tmp/results.jsonl")).toBe("jsonl");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("prefers explicit format", () => {
|
|
25
|
+
expect(resolveExportFormat("/tmp/results.jsonl", "csv")).toBe("csv");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("escapeCsvCell", () => {
|
|
30
|
+
it("quotes values with commas", () => {
|
|
31
|
+
expect(escapeCsvCell("a,b")).toBe('"a,b"');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("JSON-stringifies nested values", () => {
|
|
35
|
+
expect(escapeCsvCell({ id: "pub.1" })).toBe('"{""id"":""pub.1""}"');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("formatRowsForExport", () => {
|
|
40
|
+
it("writes CSV with header and preferred field order", () => {
|
|
41
|
+
const { text } = formatRowsForExport(
|
|
42
|
+
[
|
|
43
|
+
{ id: "pub.1", title: "Alpha", year: 2024 },
|
|
44
|
+
{ id: "pub.2", title: "Beta", journal: "Nature" },
|
|
45
|
+
],
|
|
46
|
+
"csv",
|
|
47
|
+
{ preferredFields: ["title", "id"], includeHeader: true },
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(text).toBe("title,id,journal,year\n" + "Alpha,pub.1,,2024\n" + "Beta,pub.2,Nature,\n");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("writes JSONL lines", () => {
|
|
54
|
+
const { text } = formatRowsForExport([{ id: "pub.1" }], "jsonl");
|
|
55
|
+
expect(text).toBe('{"id":"pub.1"}\n');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe("deriveCsvColumns", () => {
|
|
60
|
+
it("reuses existing columns on resume", () => {
|
|
61
|
+
expect(deriveCsvColumns([{ id: "pub.2", extra: true }], ["title"], ["id", "title"])).toEqual([
|
|
62
|
+
"id",
|
|
63
|
+
"title",
|
|
64
|
+
]);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smoke tests for hosted HTTP MCP server.
|
|
3
|
+
* @module test/mcp/http-server
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
7
|
+
import type { HostedEnvConfig } from "../../src/client/deployment-config.js";
|
|
8
|
+
import { AuthenticationError } from "../../src/client/errors.js";
|
|
9
|
+
import { startHostedHttpServer } from "../../src/mcp/http-server.js";
|
|
10
|
+
|
|
11
|
+
const HOSTED: HostedEnvConfig = {
|
|
12
|
+
deploymentMode: "hosted",
|
|
13
|
+
radarAuthUrl: "https://app.example.com",
|
|
14
|
+
internal: {
|
|
15
|
+
serviceUrl: "https://dsl.example.com",
|
|
16
|
+
username: "svc",
|
|
17
|
+
password: "secret",
|
|
18
|
+
dslSchema: "external",
|
|
19
|
+
host: "app.example.com",
|
|
20
|
+
variant: "standard",
|
|
21
|
+
},
|
|
22
|
+
httpPort: 8080,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
vi.mock("../../src/mcp/server.js", () => ({
|
|
26
|
+
warmHostedSchemaCache: vi.fn().mockResolvedValue({}),
|
|
27
|
+
createMcpServerAsync: vi.fn().mockResolvedValue({
|
|
28
|
+
server: {
|
|
29
|
+
connect: vi.fn().mockResolvedValue(undefined),
|
|
30
|
+
close: vi.fn().mockResolvedValue(undefined),
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
vi.mock("../../src/client/resolve-api-key-user.js", async (importOriginal) => {
|
|
36
|
+
const actual = await importOriginal<typeof import("../../src/client/resolve-api-key-user.js")>();
|
|
37
|
+
return {
|
|
38
|
+
...actual,
|
|
39
|
+
resolveUserFromApiKey: vi.fn().mockResolvedValue("user@example.com"),
|
|
40
|
+
parseBearerToken: vi.fn((header?: string) => {
|
|
41
|
+
if (!header?.startsWith("Bearer ")) {
|
|
42
|
+
throw new AuthenticationError("Missing Authorization header");
|
|
43
|
+
}
|
|
44
|
+
return header.slice("Bearer ".length);
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("startHostedHttpServer", () => {
|
|
50
|
+
let handle: ReturnType<typeof startHostedHttpServer> | undefined;
|
|
51
|
+
|
|
52
|
+
afterEach(async () => {
|
|
53
|
+
if (handle) {
|
|
54
|
+
await handle.close();
|
|
55
|
+
handle = undefined;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("serves GET /health", async () => {
|
|
60
|
+
handle = startHostedHttpServer({ hosted: HOSTED, port: 0 });
|
|
61
|
+
const port = await handle.ready;
|
|
62
|
+
|
|
63
|
+
const response = await fetch(`http://127.0.0.1:${port}/health`);
|
|
64
|
+
expect(response.status).toBe(200);
|
|
65
|
+
expect(await response.json()).toEqual({ status: "ok" });
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("returns 401 when Authorization header is missing", async () => {
|
|
69
|
+
handle = startHostedHttpServer({ hosted: HOSTED, port: 0 });
|
|
70
|
+
const port = await handle.ready;
|
|
71
|
+
|
|
72
|
+
const response = await fetch(`http://127.0.0.1:${port}/mcp`, {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: { "Content-Type": "application/json" },
|
|
75
|
+
body: JSON.stringify({ jsonrpc: "2.0", method: "initialize", id: 1, params: {} }),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(response.status).toBe(401);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
buildReverseAliasMap,
|
|
5
|
+
ENTITY_ALIASES,
|
|
6
|
+
resolveFacetFieldName,
|
|
7
|
+
resolveFieldName,
|
|
8
|
+
resolveFieldNames,
|
|
9
|
+
withFieldAliases,
|
|
10
|
+
} from "../../src/mcp/middleware/field-aliases.js";
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// resolveFieldName
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
describe("resolveFieldName", () => {
|
|
17
|
+
it("resolves a known alias to its DSL name", () => {
|
|
18
|
+
expect(resolveFieldName("publications", "total_citations")).toBe("times_cited");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("passes through raw DSL field names unchanged", () => {
|
|
22
|
+
expect(resolveFieldName("publications", "times_cited")).toBe("times_cited");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("passes through unknown names unchanged (backward compat)", () => {
|
|
26
|
+
expect(resolveFieldName("publications", "some_unknown_field")).toBe("some_unknown_field");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("resolves grant aliases", () => {
|
|
30
|
+
expect(resolveFieldName("grants", "funding_amount_usd")).toBe("funding_usd");
|
|
31
|
+
expect(resolveFieldName("grants", "funder_name")).toBe("funder_org_name");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("resolves grant facet field aliases separately from filter fields", () => {
|
|
35
|
+
expect(resolveFacetFieldName("grants", "funders")).toBe("funder_orgs");
|
|
36
|
+
expect(resolveFacetFieldName("grants", "funder_org_name")).toBe("funder_org_name");
|
|
37
|
+
expect(resolveFieldName("grants", "funder_name")).toBe("funder_org_name");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("resolves researcher aliases", () => {
|
|
41
|
+
expect(resolveFieldName("researchers", "orcid")).toBe("orcid_id");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("resolves indicator aliases", () => {
|
|
45
|
+
expect(resolveFieldName("publications", "field_citation_ratio_avg")).toBe("fcr_gavg");
|
|
46
|
+
expect(resolveFieldName("publications", "relative_citation_ratio_avg")).toBe("rcr_avg");
|
|
47
|
+
expect(resolveFieldName("publications", "average_citations")).toBe("citations_avg");
|
|
48
|
+
expect(resolveFieldName("grants", "total_funding")).toBe("funding");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("does not resolve an alias from a different entity", () => {
|
|
52
|
+
// total_citations is a publications alias, not a grants alias
|
|
53
|
+
expect(resolveFieldName("grants", "total_citations")).toBe("total_citations");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("returns name unchanged for an unknown entity type", () => {
|
|
57
|
+
// Simulates dynamic entity source receiving unvalidated user input
|
|
58
|
+
expect(resolveFieldName("unknown_entity" as never, "some_field")).toBe("some_field");
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
// resolveFieldNames
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
describe("resolveFieldNames", () => {
|
|
67
|
+
it("resolves an array mixing aliases and DSL names", () => {
|
|
68
|
+
const result = resolveFieldNames("publications", [
|
|
69
|
+
"total_citations",
|
|
70
|
+
"title",
|
|
71
|
+
"citation_ratio",
|
|
72
|
+
]);
|
|
73
|
+
expect(result).toEqual(["times_cited", "title", "field_citation_ratio"]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("returns empty array for empty input", () => {
|
|
77
|
+
expect(resolveFieldNames("publications", [])).toEqual([]);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("returns names unchanged for an unknown entity type", () => {
|
|
81
|
+
expect(resolveFieldNames("unknown_entity" as never, ["a", "b"])).toEqual(["a", "b"]);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// ENTITY_ALIASES registry
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
describe("ENTITY_ALIASES", () => {
|
|
90
|
+
const ALL_ENTITIES = [
|
|
91
|
+
"publications",
|
|
92
|
+
"grants",
|
|
93
|
+
"patents",
|
|
94
|
+
"clinical_trials",
|
|
95
|
+
"datasets",
|
|
96
|
+
"policy_documents",
|
|
97
|
+
"researchers",
|
|
98
|
+
"organizations",
|
|
99
|
+
] as const;
|
|
100
|
+
|
|
101
|
+
it("has an entry for every entity type", () => {
|
|
102
|
+
for (const entity of ALL_ENTITIES) {
|
|
103
|
+
expect(ENTITY_ALIASES[entity]).toBeDefined();
|
|
104
|
+
expect(typeof ENTITY_ALIASES[entity]).toBe("object");
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("has no alias that collides with a DSL name from another entity's aliases", () => {
|
|
109
|
+
// Collect all alias keys across all entities
|
|
110
|
+
const aliasToEntity = new Map<string, string[]>();
|
|
111
|
+
for (const entity of ALL_ENTITIES) {
|
|
112
|
+
for (const alias of Object.keys(ENTITY_ALIASES[entity])) {
|
|
113
|
+
const entities = aliasToEntity.get(alias) ?? [];
|
|
114
|
+
entities.push(entity);
|
|
115
|
+
aliasToEntity.set(alias, entities);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Each alias should only appear on one entity (or on multiple where it maps to the same concept)
|
|
119
|
+
for (const [alias, entities] of aliasToEntity) {
|
|
120
|
+
if (entities.length > 1) {
|
|
121
|
+
// Verify they all map to the same DSL name
|
|
122
|
+
const targets = new Set(
|
|
123
|
+
entities.map((e) => ENTITY_ALIASES[e as keyof typeof ENTITY_ALIASES][alias]),
|
|
124
|
+
);
|
|
125
|
+
expect(targets.size).toBe(1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// ---------------------------------------------------------------------------
|
|
132
|
+
// buildReverseAliasMap
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
describe("buildReverseAliasMap", () => {
|
|
136
|
+
it("maps DSL name to its aliases", () => {
|
|
137
|
+
const reverse = buildReverseAliasMap("publications");
|
|
138
|
+
expect(reverse.get("times_cited")).toEqual(["total_citations"]);
|
|
139
|
+
expect(reverse.get("field_citation_ratio")).toEqual(["citation_ratio"]);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("returns empty map for entities with no aliases", () => {
|
|
143
|
+
const reverse = buildReverseAliasMap("patents");
|
|
144
|
+
expect(reverse.size).toBe(0);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
// withFieldAliases HOF
|
|
150
|
+
// ---------------------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
describe("withFieldAliases", () => {
|
|
153
|
+
/** Helper to create a handler that captures its received args. */
|
|
154
|
+
function createCapturingHandler() {
|
|
155
|
+
let capturedArgs: Record<string, unknown> = {};
|
|
156
|
+
const handler = (args: Record<string, unknown>) => {
|
|
157
|
+
capturedArgs = args;
|
|
158
|
+
return { content: [{ type: "text" as const, text: "{}" }] } satisfies CallToolResult;
|
|
159
|
+
};
|
|
160
|
+
return { handler, getCapturedArgs: () => capturedArgs };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
it("resolves fieldArrayArgs (e.g., fields)", () => {
|
|
164
|
+
const { handler, getCapturedArgs } = createCapturingHandler();
|
|
165
|
+
const wrapped = withFieldAliases(
|
|
166
|
+
{
|
|
167
|
+
entitySource: { kind: "static", entity: "publications" },
|
|
168
|
+
fieldArrayArgs: ["fields"],
|
|
169
|
+
},
|
|
170
|
+
handler,
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
wrapped({ fields: ["total_citations", "title", "doi"] }, {});
|
|
174
|
+
expect(getCapturedArgs().fields).toEqual(["times_cited", "title", "doi"]);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("resolves fieldStringArgs (e.g., sortBy)", () => {
|
|
178
|
+
const { handler, getCapturedArgs } = createCapturingHandler();
|
|
179
|
+
const wrapped = withFieldAliases(
|
|
180
|
+
{
|
|
181
|
+
entitySource: { kind: "static", entity: "publications" },
|
|
182
|
+
fieldStringArgs: ["sortBy"],
|
|
183
|
+
},
|
|
184
|
+
handler,
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
wrapped({ sortBy: "total_citations" }, {});
|
|
188
|
+
expect(getCapturedArgs().sortBy).toBe("times_cited");
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("resolves filterArrayArgs (e.g., filters[].field)", () => {
|
|
192
|
+
const { handler, getCapturedArgs } = createCapturingHandler();
|
|
193
|
+
const wrapped = withFieldAliases(
|
|
194
|
+
{
|
|
195
|
+
entitySource: { kind: "static", entity: "publications" },
|
|
196
|
+
filterArrayArgs: ["filters"],
|
|
197
|
+
},
|
|
198
|
+
handler,
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
wrapped(
|
|
202
|
+
{
|
|
203
|
+
filters: [
|
|
204
|
+
{ field: "total_citations", operator: ">=", value: 10 },
|
|
205
|
+
{ field: "year", operator: ">=", value: 2020 },
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
{},
|
|
209
|
+
);
|
|
210
|
+
const filters = getCapturedArgs().filters as Array<Record<string, unknown>>;
|
|
211
|
+
expect(filters[0].field).toBe("times_cited");
|
|
212
|
+
expect(filters[1].field).toBe("year"); // pass-through
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("handles dynamic entitySource from args", () => {
|
|
216
|
+
const { handler, getCapturedArgs } = createCapturingHandler();
|
|
217
|
+
const wrapped = withFieldAliases(
|
|
218
|
+
{
|
|
219
|
+
entitySource: { kind: "dynamic", argName: "entityType" },
|
|
220
|
+
fieldArrayArgs: ["fields"],
|
|
221
|
+
},
|
|
222
|
+
handler,
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
wrapped({ entityType: "grants", fields: ["funding_amount_usd"] }, {});
|
|
226
|
+
expect(getCapturedArgs().fields).toEqual(["funding_usd"]);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("leaves non-field args untouched", () => {
|
|
230
|
+
const { handler, getCapturedArgs } = createCapturingHandler();
|
|
231
|
+
const wrapped = withFieldAliases(
|
|
232
|
+
{
|
|
233
|
+
entitySource: { kind: "static", entity: "publications" },
|
|
234
|
+
fieldArrayArgs: ["fields"],
|
|
235
|
+
},
|
|
236
|
+
handler,
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
wrapped({ query: "CRISPR", limit: 50, fields: ["title"] }, {});
|
|
240
|
+
expect(getCapturedArgs().query).toBe("CRISPR");
|
|
241
|
+
expect(getCapturedArgs().limit).toBe(50);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it("handles undefined/missing optional args gracefully", () => {
|
|
245
|
+
const { handler, getCapturedArgs } = createCapturingHandler();
|
|
246
|
+
const wrapped = withFieldAliases(
|
|
247
|
+
{
|
|
248
|
+
entitySource: { kind: "static", entity: "publications" },
|
|
249
|
+
fieldArrayArgs: ["fields"],
|
|
250
|
+
fieldStringArgs: ["sortBy"],
|
|
251
|
+
filterArrayArgs: ["filters"],
|
|
252
|
+
},
|
|
253
|
+
handler,
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
wrapped({ query: "test" }, {});
|
|
257
|
+
expect(getCapturedArgs().fields).toBeUndefined();
|
|
258
|
+
expect(getCapturedArgs().sortBy).toBeUndefined();
|
|
259
|
+
expect(getCapturedArgs().filters).toBeUndefined();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it("preserves the return value from the inner handler", () => {
|
|
263
|
+
const result: CallToolResult = {
|
|
264
|
+
content: [{ type: "text", text: '{"count":42}' }],
|
|
265
|
+
};
|
|
266
|
+
const handler = () => result;
|
|
267
|
+
const wrapped = withFieldAliases(
|
|
268
|
+
{ entitySource: { kind: "static", entity: "publications" } },
|
|
269
|
+
handler,
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
expect(wrapped({}, {})).toBe(result);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it("preserves async handler behavior", async () => {
|
|
276
|
+
const result: CallToolResult = {
|
|
277
|
+
content: [{ type: "text", text: '{"count":42}' }],
|
|
278
|
+
};
|
|
279
|
+
const handler = async () => result;
|
|
280
|
+
const wrapped = withFieldAliases(
|
|
281
|
+
{ entitySource: { kind: "static", entity: "publications" } },
|
|
282
|
+
handler,
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
expect(await wrapped({}, {})).toBe(result);
|
|
286
|
+
});
|
|
287
|
+
});
|