@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,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic MCP resources derived from runtime {@link SchemaStore}.
|
|
3
|
+
* @module mcp/resources/schema
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
+
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import {
|
|
9
|
+
buildUsagePolicy,
|
|
10
|
+
type DescribeField,
|
|
11
|
+
type EntityType,
|
|
12
|
+
SCHEMA_LIMITS,
|
|
13
|
+
type SchemaStore,
|
|
14
|
+
type StructuredEntityType,
|
|
15
|
+
searchToolName,
|
|
16
|
+
} from "../../dsl/index.js";
|
|
17
|
+
import {
|
|
18
|
+
DSL_DOCUMENTATION_URL,
|
|
19
|
+
DSL_EXAMPLE_SOURCE_NAMES,
|
|
20
|
+
DSL_EXAMPLES_BY_ENTITY,
|
|
21
|
+
DSL_EXAMPLES_BY_SOURCE_URI,
|
|
22
|
+
DSL_GENERAL_EXAMPLES,
|
|
23
|
+
getDslExamplesForSource,
|
|
24
|
+
} from "../examples/dsl-examples.js";
|
|
25
|
+
import { buildReverseAliasMap } from "../middleware/field-aliases.js";
|
|
26
|
+
import type { SchemaContext } from "../schema/context.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Registers schema MCP resources from a loaded {@link SchemaStore}.
|
|
30
|
+
* @param server - MCP server instance
|
|
31
|
+
* @param context - Mutable schema context (handlers read latest store)
|
|
32
|
+
*/
|
|
33
|
+
export function registerSchemaResources(server: McpServer, context: SchemaContext): void {
|
|
34
|
+
const schemaStore = () => context.store;
|
|
35
|
+
server.resource(
|
|
36
|
+
"schema-summary",
|
|
37
|
+
"dimensions://schema/summary",
|
|
38
|
+
{
|
|
39
|
+
description:
|
|
40
|
+
"Compact Dimensions DSL schema overview (counts, resource URIs) — start here on cold-start",
|
|
41
|
+
mimeType: "application/json",
|
|
42
|
+
},
|
|
43
|
+
async (uri) => ({
|
|
44
|
+
contents: [
|
|
45
|
+
{
|
|
46
|
+
uri: uri.href,
|
|
47
|
+
mimeType: "application/json",
|
|
48
|
+
text: JSON.stringify(schemaStore().summary(), null, 2),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
// Full schema
|
|
55
|
+
server.resource(
|
|
56
|
+
"schema-full",
|
|
57
|
+
"dimensions://schema",
|
|
58
|
+
{
|
|
59
|
+
description:
|
|
60
|
+
"Full Dimensions DSL schema (all sources and auxiliary entities). Prefer dimensions://schema/summary for discovery.",
|
|
61
|
+
mimeType: "application/json",
|
|
62
|
+
},
|
|
63
|
+
async (uri) => ({
|
|
64
|
+
contents: [
|
|
65
|
+
{
|
|
66
|
+
uri: uri.href,
|
|
67
|
+
mimeType: "application/json",
|
|
68
|
+
text: JSON.stringify(schemaStore().raw, null, 2),
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
// Version
|
|
75
|
+
server.resource(
|
|
76
|
+
"schema-version",
|
|
77
|
+
"dimensions://schema/version",
|
|
78
|
+
{
|
|
79
|
+
description: "Dimensions DSL version",
|
|
80
|
+
mimeType: "application/json",
|
|
81
|
+
},
|
|
82
|
+
async (uri) => ({
|
|
83
|
+
contents: [
|
|
84
|
+
{
|
|
85
|
+
uri: uri.href,
|
|
86
|
+
mimeType: "application/json",
|
|
87
|
+
text: JSON.stringify(
|
|
88
|
+
{ version: schemaStore().version, loadedAt: schemaStore().loadedAt.toISOString() },
|
|
89
|
+
null,
|
|
90
|
+
2,
|
|
91
|
+
),
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// Limits (static until upstream `describe limits` exists)
|
|
98
|
+
server.resource(
|
|
99
|
+
"schema-limits",
|
|
100
|
+
"dimensions://schema/limits",
|
|
101
|
+
{
|
|
102
|
+
description: "Operational limits for Dimensions DSL queries",
|
|
103
|
+
mimeType: "application/json",
|
|
104
|
+
},
|
|
105
|
+
async (uri) => ({
|
|
106
|
+
contents: [
|
|
107
|
+
{
|
|
108
|
+
uri: uri.href,
|
|
109
|
+
mimeType: "application/json",
|
|
110
|
+
text: JSON.stringify(SCHEMA_LIMITS, null, 2),
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
server.resource(
|
|
117
|
+
"schema-policy",
|
|
118
|
+
"dimensions://schema/policy",
|
|
119
|
+
{
|
|
120
|
+
description:
|
|
121
|
+
"Dimensions reasonable-use policy, MCP guardrails, and pagination recommendations",
|
|
122
|
+
mimeType: "application/json",
|
|
123
|
+
},
|
|
124
|
+
async (uri) => ({
|
|
125
|
+
contents: [
|
|
126
|
+
{
|
|
127
|
+
uri: uri.href,
|
|
128
|
+
mimeType: "application/json",
|
|
129
|
+
text: JSON.stringify(buildUsagePolicy(), null, 2),
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
}),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
server.resource(
|
|
136
|
+
"dsl-examples",
|
|
137
|
+
"dimensions://examples",
|
|
138
|
+
{
|
|
139
|
+
description: `Curated Dimensions DSL example queries. See official docs: ${DSL_DOCUMENTATION_URL}`,
|
|
140
|
+
mimeType: "application/json",
|
|
141
|
+
},
|
|
142
|
+
async (uri) => ({
|
|
143
|
+
contents: [
|
|
144
|
+
{
|
|
145
|
+
uri: uri.href,
|
|
146
|
+
mimeType: "application/json",
|
|
147
|
+
text: JSON.stringify(
|
|
148
|
+
{
|
|
149
|
+
documentation: DSL_DOCUMENTATION_URL,
|
|
150
|
+
general: DSL_GENERAL_EXAMPLES,
|
|
151
|
+
sources: DSL_EXAMPLE_SOURCE_NAMES,
|
|
152
|
+
bySource: DSL_EXAMPLES_BY_SOURCE_URI,
|
|
153
|
+
byEntity: DSL_EXAMPLES_BY_ENTITY,
|
|
154
|
+
},
|
|
155
|
+
null,
|
|
156
|
+
2,
|
|
157
|
+
),
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
}),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
server.resource(
|
|
164
|
+
"dsl-examples-by-source",
|
|
165
|
+
new ResourceTemplate("dimensions://examples/{source}", {
|
|
166
|
+
list: async () => ({
|
|
167
|
+
resources: DSL_EXAMPLE_SOURCE_NAMES.map((source) => ({
|
|
168
|
+
uri: `dimensions://examples/${source}`,
|
|
169
|
+
name: `${source} DSL examples`,
|
|
170
|
+
description: `Curated DSL example queries for ${source}`,
|
|
171
|
+
mimeType: "application/json",
|
|
172
|
+
})),
|
|
173
|
+
}),
|
|
174
|
+
complete: {
|
|
175
|
+
source: (value) => DSL_EXAMPLE_SOURCE_NAMES.filter((name) => name.startsWith(value)),
|
|
176
|
+
},
|
|
177
|
+
}),
|
|
178
|
+
{
|
|
179
|
+
description: "Per-source curated Dimensions DSL example queries",
|
|
180
|
+
mimeType: "application/json",
|
|
181
|
+
},
|
|
182
|
+
async (uri, { source }) => {
|
|
183
|
+
const sourceName = String(source);
|
|
184
|
+
const examples = getDslExamplesForSource(sourceName);
|
|
185
|
+
if (!examples) {
|
|
186
|
+
throw new Error(
|
|
187
|
+
`No examples for source: ${sourceName}. Available: ${DSL_EXAMPLE_SOURCE_NAMES.join(", ")}`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const structured = schemaStore().structuredEntityTypes();
|
|
192
|
+
const relatedResources: Record<string, string> = {
|
|
193
|
+
fields: `dimensions://fields/${sourceName}`,
|
|
194
|
+
schemaSource: `dimensions://schema/sources/${sourceName}`,
|
|
195
|
+
};
|
|
196
|
+
if (structured.includes(sourceName as StructuredEntityType)) {
|
|
197
|
+
relatedResources.searchTool = searchToolName(sourceName as StructuredEntityType);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
contents: [
|
|
202
|
+
{
|
|
203
|
+
uri: uri.href,
|
|
204
|
+
mimeType: "application/json",
|
|
205
|
+
text: JSON.stringify(
|
|
206
|
+
{
|
|
207
|
+
source: sourceName,
|
|
208
|
+
documentation: DSL_DOCUMENTATION_URL,
|
|
209
|
+
examples,
|
|
210
|
+
relatedResources,
|
|
211
|
+
},
|
|
212
|
+
null,
|
|
213
|
+
2,
|
|
214
|
+
),
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
const sourceNames = () => schemaStore().sourceNames();
|
|
222
|
+
server.resource(
|
|
223
|
+
"schema-sources",
|
|
224
|
+
new ResourceTemplate("dimensions://schema/sources/{sourceName}", {
|
|
225
|
+
list: async () => ({
|
|
226
|
+
resources: sourceNames().map((name) => ({
|
|
227
|
+
uri: `dimensions://schema/sources/${name}`,
|
|
228
|
+
name: `${name} schema`,
|
|
229
|
+
description: `Schema for source ${name}`,
|
|
230
|
+
mimeType: "application/json",
|
|
231
|
+
})),
|
|
232
|
+
}),
|
|
233
|
+
complete: {
|
|
234
|
+
sourceName: (value) => sourceNames().filter((name) => name.startsWith(value)),
|
|
235
|
+
},
|
|
236
|
+
}),
|
|
237
|
+
{
|
|
238
|
+
description: "Per-source Dimensions DSL schema",
|
|
239
|
+
mimeType: "application/json",
|
|
240
|
+
},
|
|
241
|
+
async (uri, { sourceName }) => {
|
|
242
|
+
const source = schemaStore().getSource(String(sourceName));
|
|
243
|
+
if (!source) {
|
|
244
|
+
throw new Error(`Unknown source: ${sourceName}`);
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
contents: [
|
|
248
|
+
{
|
|
249
|
+
uri: uri.href,
|
|
250
|
+
mimeType: "application/json",
|
|
251
|
+
text: JSON.stringify(source, null, 2),
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
const entityNames = () => schemaStore().entityNames();
|
|
259
|
+
server.resource(
|
|
260
|
+
"schema-entities",
|
|
261
|
+
new ResourceTemplate("dimensions://schema/entities/{entityName}", {
|
|
262
|
+
list: async () => ({
|
|
263
|
+
resources: entityNames().map((name) => ({
|
|
264
|
+
uri: `dimensions://schema/entities/${name}`,
|
|
265
|
+
name: `${name} entity schema`,
|
|
266
|
+
description: `Auxiliary entity schema for ${name}`,
|
|
267
|
+
mimeType: "application/json",
|
|
268
|
+
})),
|
|
269
|
+
}),
|
|
270
|
+
complete: {
|
|
271
|
+
entityName: (value) => entityNames().filter((name) => name.startsWith(value)),
|
|
272
|
+
},
|
|
273
|
+
}),
|
|
274
|
+
{
|
|
275
|
+
description: "Auxiliary entity schema for dot-notation filters",
|
|
276
|
+
mimeType: "application/json",
|
|
277
|
+
},
|
|
278
|
+
async (uri, { entityName }) => {
|
|
279
|
+
const entity = schemaStore().getEntity(String(entityName));
|
|
280
|
+
if (!entity) {
|
|
281
|
+
throw new Error(`Unknown entity: ${entityName}`);
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
contents: [
|
|
285
|
+
{
|
|
286
|
+
uri: uri.href,
|
|
287
|
+
mimeType: "application/json",
|
|
288
|
+
text: JSON.stringify(entity, null, 2),
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
};
|
|
292
|
+
},
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
// Compatibility view for structured search tools
|
|
296
|
+
const entityTypes = () => schemaStore().structuredEntityTypes();
|
|
297
|
+
server.resource(
|
|
298
|
+
"fields",
|
|
299
|
+
new ResourceTemplate("dimensions://fields/{entityType}", {
|
|
300
|
+
list: async () => ({
|
|
301
|
+
resources: entityTypes().map((et) => ({
|
|
302
|
+
uri: `dimensions://fields/${et}`,
|
|
303
|
+
name: `${et} fields`,
|
|
304
|
+
description: `Filterable fields for ${et}`,
|
|
305
|
+
mimeType: "application/json",
|
|
306
|
+
})),
|
|
307
|
+
}),
|
|
308
|
+
complete: {
|
|
309
|
+
entityType: (value) => entityTypes().filter((et) => et.startsWith(value)),
|
|
310
|
+
},
|
|
311
|
+
}),
|
|
312
|
+
{
|
|
313
|
+
description: "Filterable fields and aliases for a Dimensions entity type",
|
|
314
|
+
mimeType: "application/json",
|
|
315
|
+
},
|
|
316
|
+
async (uri, { entityType }) => {
|
|
317
|
+
const entity = String(entityType) as EntityType;
|
|
318
|
+
if (!entityTypes().includes(entity)) {
|
|
319
|
+
throw new Error(`Unknown entity type: ${entity}`);
|
|
320
|
+
}
|
|
321
|
+
const source = schemaStore().getSource(entity);
|
|
322
|
+
if (!source) {
|
|
323
|
+
throw new Error(`No schema loaded for entity type: ${entity}`);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const reverseAliases = buildReverseAliasMap(entity);
|
|
327
|
+
const augmentedFields: Record<string, { description: string; aliases?: string[] }> = {};
|
|
328
|
+
for (const [fieldName, field] of Object.entries(source.fields) as [string, DescribeField][]) {
|
|
329
|
+
if (field.is_filter !== true) {
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
const description = field.description ?? field.type;
|
|
333
|
+
const aliases = reverseAliases.get(fieldName);
|
|
334
|
+
augmentedFields[fieldName] = aliases ? { description, aliases } : { description };
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return {
|
|
338
|
+
contents: [
|
|
339
|
+
{
|
|
340
|
+
uri: uri.href,
|
|
341
|
+
mimeType: "application/json",
|
|
342
|
+
text: JSON.stringify(
|
|
343
|
+
{
|
|
344
|
+
entityType: entity,
|
|
345
|
+
fields: augmentedFields,
|
|
346
|
+
facets: schemaStore().facetFields(entity),
|
|
347
|
+
metrics: schemaStore().metrics(entity),
|
|
348
|
+
searchIndexes: schemaStore().searchIndexes(entity),
|
|
349
|
+
fieldsets: schemaStore().fieldsets(entity),
|
|
350
|
+
dslExamples: {
|
|
351
|
+
basicSearch: `search ${entity} for "your query" return ${entity} limit 10`,
|
|
352
|
+
withFields: `search ${entity} for "your query" return ${entity}[id+title] limit 10`,
|
|
353
|
+
withFilter: `search ${entity} for "your query" where year >= 2020 return ${entity} limit 10`,
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
null,
|
|
357
|
+
2,
|
|
358
|
+
),
|
|
359
|
+
},
|
|
360
|
+
],
|
|
361
|
+
};
|
|
362
|
+
},
|
|
363
|
+
);
|
|
364
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mutable schema context shared across MCP resources and tools.
|
|
3
|
+
* @module schema/context
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { SchemaStore } from "../../dsl/index.js";
|
|
7
|
+
|
|
8
|
+
/** Mutable holder so refresh can update the active store without re-registering resources. */
|
|
9
|
+
export type SchemaContext = {
|
|
10
|
+
store: SchemaStore;
|
|
11
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime schema loading and access for the MCP server.
|
|
3
|
+
* @module schema
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
DescribeField,
|
|
8
|
+
DescribeSchemaResponse,
|
|
9
|
+
DescribeVersionResponse,
|
|
10
|
+
EntityDescribe,
|
|
11
|
+
LoadSchemaOptions,
|
|
12
|
+
SchemaCacheEntry,
|
|
13
|
+
SchemaCacheEnvelope,
|
|
14
|
+
SchemaLoadSource,
|
|
15
|
+
SchemaSourceSummary,
|
|
16
|
+
SchemaStoreMetadata,
|
|
17
|
+
SchemaSummary,
|
|
18
|
+
SourceDescribe,
|
|
19
|
+
StructuredEntityType,
|
|
20
|
+
} from "../../dsl/index.js";
|
|
21
|
+
export {
|
|
22
|
+
buildSchemaSummary,
|
|
23
|
+
clearSchemaCache,
|
|
24
|
+
createSchemaStoreFromResponse,
|
|
25
|
+
DEFAULT_SCHEMA_CACHE_TTL_MS,
|
|
26
|
+
extractDescribeSchema,
|
|
27
|
+
extractDescribeVersion,
|
|
28
|
+
getCachedSchemaStore,
|
|
29
|
+
getOrLoadSchema,
|
|
30
|
+
loadSchema,
|
|
31
|
+
SCHEMA_LIMITS,
|
|
32
|
+
SCHEMA_RESOURCE_URIS,
|
|
33
|
+
SchemaStore,
|
|
34
|
+
STRUCTURED_ENTITY_TYPES,
|
|
35
|
+
searchResultKey,
|
|
36
|
+
searchToolName,
|
|
37
|
+
} from "../../dsl/index.js";
|
|
38
|
+
export type { SchemaContext } from "./context.js";
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dimensions Analytics MCP server for the Dimensions Analytics API.
|
|
3
|
+
* Provides tools for searching and querying the Dimensions database.
|
|
4
|
+
* @module mcp/server
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
10
|
+
import pkg from "../../package.json" with { type: "json" };
|
|
11
|
+
import { type HostedEnvConfig, loadDeploymentConfig } from "../client/index.js";
|
|
12
|
+
import { createBootstrapDimensionsClient, createDimensionsClient } from "../dsl/create-client.js";
|
|
13
|
+
import type { DimensionsClient } from "../dsl/index.js";
|
|
14
|
+
import {
|
|
15
|
+
clearSchemaCache,
|
|
16
|
+
getOrLoadSchema,
|
|
17
|
+
loadSchema,
|
|
18
|
+
type SchemaStore,
|
|
19
|
+
} from "../dsl/schema/index.js";
|
|
20
|
+
import { registerSchemaResources } from "./resources/schema.js";
|
|
21
|
+
import type { SchemaContext } from "./schema/context.js";
|
|
22
|
+
import { getSharedSchemaStore } from "./shared-schema.js";
|
|
23
|
+
import { registerAnalyticsTools } from "./tools/analytics.js";
|
|
24
|
+
import { registerFetchSearchPagesTools } from "./tools/fetch-search-pages.js";
|
|
25
|
+
import { registerFunctionTools } from "./tools/functions.js";
|
|
26
|
+
import { registerLookupTools } from "./tools/lookup.js";
|
|
27
|
+
import { registerQueryTools } from "./tools/query.js";
|
|
28
|
+
import { registerSchemaTools, validateFieldAliases } from "./tools/schema.js";
|
|
29
|
+
import { registerSearchTools } from "./tools/search.js";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Configuration options for the MCP server.
|
|
33
|
+
*/
|
|
34
|
+
export interface McpServerConfig {
|
|
35
|
+
/** Dimensions API key (required for local stdio) */
|
|
36
|
+
apiKey?: string;
|
|
37
|
+
/** Base URL for the Dimensions API (local public backend) */
|
|
38
|
+
baseUrl?: string;
|
|
39
|
+
/** Pre-loaded schema store (for tests; skips live describe fetch) */
|
|
40
|
+
schemaStore?: SchemaStore;
|
|
41
|
+
/** Deployment mode override */
|
|
42
|
+
deploymentMode?: "local" | "hosted";
|
|
43
|
+
/** Hosted deployment env (required when deploymentMode is hosted) */
|
|
44
|
+
hosted?: HostedEnvConfig;
|
|
45
|
+
/** Resolved user email for hosted dsl-service (per session) */
|
|
46
|
+
userEmail?: string;
|
|
47
|
+
/** Client IP to forward to dsl-service and auth.json */
|
|
48
|
+
clientIp?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Reads a positive integer from an environment variable with a default fallback.
|
|
53
|
+
*/
|
|
54
|
+
function readIntEnv(raw: string | undefined, fallback: number, min: number): number {
|
|
55
|
+
if (raw == null || raw.trim() === "") return fallback;
|
|
56
|
+
const value = Number.parseInt(raw, 10);
|
|
57
|
+
return Number.isFinite(value) && value >= min ? value : fallback;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function resolveDeployment(config: McpServerConfig): {
|
|
61
|
+
mode: "local" | "hosted";
|
|
62
|
+
hosted?: HostedEnvConfig;
|
|
63
|
+
} {
|
|
64
|
+
if (config.deploymentMode) {
|
|
65
|
+
return {
|
|
66
|
+
mode: config.deploymentMode,
|
|
67
|
+
hosted: config.hosted,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const loaded = loadDeploymentConfig();
|
|
71
|
+
if (loaded.deploymentMode === "hosted") {
|
|
72
|
+
return { mode: "hosted", hosted: loaded };
|
|
73
|
+
}
|
|
74
|
+
return { mode: "local" };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Builds server instructions from loaded schema.
|
|
79
|
+
*/
|
|
80
|
+
export function buildServerInstructions(schemaStore: SchemaStore): string {
|
|
81
|
+
const version = schemaStore.version ? ` DSL ${schemaStore.version}.` : "";
|
|
82
|
+
const paginationNote =
|
|
83
|
+
process.env.DEPLOYMENT_MODE === "hosted"
|
|
84
|
+
? "search_* supports skip/page; fetch_search_pages is not available on hosted MCP;"
|
|
85
|
+
: "search_* / fetch_search_pages: skip/page (max 1000/page, 50 pages, 50000 records);";
|
|
86
|
+
|
|
87
|
+
return [
|
|
88
|
+
`Dimensions Analytics API — scholarly research data.${version}`,
|
|
89
|
+
[
|
|
90
|
+
"Workflow:",
|
|
91
|
+
"(1) Discover schema — read dimensions://schema/summary, dimensions://fields/{entity}, dimensions://examples/{source}, or describe_schema;",
|
|
92
|
+
"(2) Search — search_* for keyword discovery with filters; get_by_doi, get_by_pmid, get_by_id for known identifiers;",
|
|
93
|
+
"(3) Analyze — facet_query, aggregate_query, citation_trend, funding_trend;",
|
|
94
|
+
"(4) Drill down — get_by_id, search_* with filters (e.g. researchers.id, research_orgs.id), facet_query for top researchers at an org.",
|
|
95
|
+
].join(" "),
|
|
96
|
+
[
|
|
97
|
+
"Routing:",
|
|
98
|
+
"search_researchers matches names only — topic→researcher uses facet_query (entityType publications, facetField researchers);",
|
|
99
|
+
"search_grants funderOrgName needs exact Dimensions names (NCI/NSF acronyms resolve; discover funders via facet_query/aggregate_query on facetField funder_orgs);",
|
|
100
|
+
"search_organizations for institution lookup — prefer GRID id in filters when the name is ambiguous;",
|
|
101
|
+
"facet_query supports yearFrom/yearTo for year-scoped facets.",
|
|
102
|
+
].join(" "),
|
|
103
|
+
[
|
|
104
|
+
"Query construction:",
|
|
105
|
+
"for ranked publication search (e.g. most-cited since 2020), use search_publications with query, yearFrom, sortBy (times_cited or total_citations), limit — do not hand-write execute_dsl;",
|
|
106
|
+
"use execute_dsl for boolean concept groups and DSL special functions;",
|
|
107
|
+
"use execute_dsl only when structured tools are insufficient; DSL order is return ... sort by FIELD order limit N (never limit before sort).",
|
|
108
|
+
].join(" "),
|
|
109
|
+
[
|
|
110
|
+
"Pagination & policy:",
|
|
111
|
+
"read dimensions://schema/policy before large pulls;",
|
|
112
|
+
paginationNote,
|
|
113
|
+
"confirmLargeFetch required for deep pagination (skip≥5000, page≥5) and batch pulls (>5 pages);",
|
|
114
|
+
"facets max 1000 buckets, no skip; ~30 requests/min client rate limit.",
|
|
115
|
+
].join(" "),
|
|
116
|
+
].join("\n\n");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function registerAllTools(
|
|
120
|
+
server: McpServer,
|
|
121
|
+
client: DimensionsClient,
|
|
122
|
+
schemaStore: SchemaStore,
|
|
123
|
+
schemaContext: SchemaContext,
|
|
124
|
+
deploymentMode: "local" | "hosted",
|
|
125
|
+
): void {
|
|
126
|
+
registerSchemaResources(server, schemaContext);
|
|
127
|
+
registerSearchTools(server, client, schemaStore);
|
|
128
|
+
if (deploymentMode === "local") {
|
|
129
|
+
registerFetchSearchPagesTools(server, client, schemaStore);
|
|
130
|
+
}
|
|
131
|
+
registerLookupTools(server, client);
|
|
132
|
+
registerQueryTools(server, client, schemaStore);
|
|
133
|
+
registerFunctionTools(server, client);
|
|
134
|
+
registerAnalyticsTools(server, client, schemaStore);
|
|
135
|
+
registerSchemaTools(server, client, schemaContext);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function loadSchemaForServer(
|
|
139
|
+
client: DimensionsClient,
|
|
140
|
+
config: McpServerConfig,
|
|
141
|
+
deploymentMode: "local" | "hosted",
|
|
142
|
+
): Promise<SchemaStore> {
|
|
143
|
+
if (config.schemaStore) {
|
|
144
|
+
return config.schemaStore;
|
|
145
|
+
}
|
|
146
|
+
if (deploymentMode === "hosted") {
|
|
147
|
+
return getSharedSchemaStore(client);
|
|
148
|
+
}
|
|
149
|
+
return getOrLoadSchema(client, process.env.SCHEMA_CACHE_PATH);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Warms the shared schema cache for hosted deployment (call once at process startup).
|
|
154
|
+
*/
|
|
155
|
+
export async function warmHostedSchemaCache(hosted: HostedEnvConfig): Promise<SchemaStore> {
|
|
156
|
+
const client = createBootstrapDimensionsClient(hosted);
|
|
157
|
+
return getSharedSchemaStore(client);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Creates and configures the MCP server.
|
|
162
|
+
*/
|
|
163
|
+
export async function createMcpServerAsync(config: McpServerConfig = {}): Promise<{
|
|
164
|
+
server: McpServer;
|
|
165
|
+
client: DimensionsClient;
|
|
166
|
+
schemaContext: SchemaContext;
|
|
167
|
+
schemaStore: SchemaStore;
|
|
168
|
+
}> {
|
|
169
|
+
const { mode, hosted } = resolveDeployment(config);
|
|
170
|
+
|
|
171
|
+
const client = createDimensionsClient({
|
|
172
|
+
mode,
|
|
173
|
+
hosted: hosted ?? config.hosted,
|
|
174
|
+
apiKey: config.apiKey ?? process.env.DIMENSIONS_API_KEY,
|
|
175
|
+
userEmail: config.userEmail,
|
|
176
|
+
clientIp: config.clientIp,
|
|
177
|
+
baseUrl: config.baseUrl ?? process.env.DIMENSIONS_BASE_URL,
|
|
178
|
+
maxRetries: readIntEnv(process.env.DIMENSIONS_MAX_RETRIES, 3, 0),
|
|
179
|
+
retryDelay: readIntEnv(process.env.DIMENSIONS_RETRY_DELAY_MS, 1000, 1),
|
|
180
|
+
rateLimitPerMinute: readIntEnv(process.env.DIMENSIONS_RATE_LIMIT_PER_MINUTE, 30, 1),
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const schemaStore = await loadSchemaForServer(client, config, mode);
|
|
184
|
+
client.attachSchemaStore(schemaStore);
|
|
185
|
+
|
|
186
|
+
const schemaContext: SchemaContext = { store: schemaStore };
|
|
187
|
+
validateFieldAliases(schemaStore);
|
|
188
|
+
|
|
189
|
+
const startedAt = Date.now();
|
|
190
|
+
console.error(
|
|
191
|
+
`Schema loaded: ${schemaStore.stats().sourceCount} sources, ${schemaStore.stats().entityCount} entities` +
|
|
192
|
+
(schemaStore.version ? `, DSL ${schemaStore.version}` : "") +
|
|
193
|
+
(schemaStore.stale ? " (stale cache)" : "") +
|
|
194
|
+
` [${schemaStore.loadSource}]` +
|
|
195
|
+
` (${Date.now() - startedAt}ms)`,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const server = new McpServer(
|
|
199
|
+
{
|
|
200
|
+
name: "dimensions",
|
|
201
|
+
version: pkg.version,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
capabilities: {
|
|
205
|
+
logging: {},
|
|
206
|
+
},
|
|
207
|
+
instructions: buildServerInstructions(schemaStore),
|
|
208
|
+
},
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
registerAllTools(server, client, schemaStore, schemaContext, mode);
|
|
212
|
+
|
|
213
|
+
return { server, client, schemaContext, schemaStore };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface McpServerHandle {
|
|
217
|
+
readonly close: () => Promise<void>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Starts the MCP server with the given transport (defaults to stdio).
|
|
222
|
+
*/
|
|
223
|
+
export async function startMcpServer(
|
|
224
|
+
injectedTransport?: Transport,
|
|
225
|
+
config: McpServerConfig = {},
|
|
226
|
+
): Promise<McpServerHandle> {
|
|
227
|
+
const { server } = await createMcpServerAsync(config);
|
|
228
|
+
const transport = injectedTransport ?? new StdioServerTransport();
|
|
229
|
+
|
|
230
|
+
server.server.onerror = (error: Error) => console.error(`MCP server error: ${error.message}`);
|
|
231
|
+
|
|
232
|
+
if (!injectedTransport) {
|
|
233
|
+
server.server.onclose = () => {
|
|
234
|
+
process.exit(0);
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
await server.connect(transport);
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
close: async () => {
|
|
242
|
+
await server.close();
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export { clearSchemaCache, loadSchema, McpServer };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-wide describe schema cache for hosted deployment.
|
|
3
|
+
* @module mcp/shared-schema
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { DimensionsClient } from "../dsl/index.js";
|
|
7
|
+
import { getOrLoadSchema, type SchemaStore } from "../dsl/schema/index.js";
|
|
8
|
+
|
|
9
|
+
let sharedSchemaStore: SchemaStore | undefined;
|
|
10
|
+
let sharedSchemaPromise: Promise<SchemaStore> | undefined;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns a shared SchemaStore, loading from cache/API on first call.
|
|
14
|
+
*/
|
|
15
|
+
export async function getSharedSchemaStore(client: DimensionsClient): Promise<SchemaStore> {
|
|
16
|
+
if (sharedSchemaStore) {
|
|
17
|
+
return sharedSchemaStore;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!sharedSchemaPromise) {
|
|
21
|
+
sharedSchemaPromise = getOrLoadSchema(client, process.env.SCHEMA_CACHE_PATH).then((store) => {
|
|
22
|
+
sharedSchemaStore = store;
|
|
23
|
+
return store;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return sharedSchemaPromise;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Clears the in-memory shared schema (tests). */
|
|
31
|
+
export function clearSharedSchemaStore(): void {
|
|
32
|
+
sharedSchemaStore = undefined;
|
|
33
|
+
sharedSchemaPromise = undefined;
|
|
34
|
+
}
|