@posthog/agent 1.24.2 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/additionalItems.js +4 -0
- package/dist/_virtual/additionalItems.js.map +1 -0
- package/dist/_virtual/additionalProperties.js +4 -0
- package/dist/_virtual/additionalProperties.js.map +1 -0
- package/dist/_virtual/ajv.js +4 -0
- package/dist/_virtual/ajv.js.map +1 -0
- package/dist/_virtual/allOf.js +4 -0
- package/dist/_virtual/allOf.js.map +1 -0
- package/dist/_virtual/anyOf.js +4 -0
- package/dist/_virtual/anyOf.js.map +1 -0
- package/dist/_virtual/applicability.js +4 -0
- package/dist/_virtual/applicability.js.map +1 -0
- package/dist/_virtual/boolSchema.js +4 -0
- package/dist/_virtual/boolSchema.js.map +1 -0
- package/dist/_virtual/code.js +4 -0
- package/dist/_virtual/code.js.map +1 -0
- package/dist/_virtual/code2.js +4 -0
- package/dist/_virtual/code2.js.map +1 -0
- package/dist/_virtual/const.js +4 -0
- package/dist/_virtual/const.js.map +1 -0
- package/dist/_virtual/contains.js +4 -0
- package/dist/_virtual/contains.js.map +1 -0
- package/dist/_virtual/core.js +4 -0
- package/dist/_virtual/core.js.map +1 -0
- package/dist/_virtual/dataType.js +4 -0
- package/dist/_virtual/dataType.js.map +1 -0
- package/dist/_virtual/defaults.js +4 -0
- package/dist/_virtual/defaults.js.map +1 -0
- package/dist/_virtual/dependencies.js +4 -0
- package/dist/_virtual/dependencies.js.map +1 -0
- package/dist/_virtual/draft7.js +4 -0
- package/dist/_virtual/draft7.js.map +1 -0
- package/dist/_virtual/enum.js +4 -0
- package/dist/_virtual/enum.js.map +1 -0
- package/dist/_virtual/equal.js +4 -0
- package/dist/_virtual/equal.js.map +1 -0
- package/dist/_virtual/errors.js +4 -0
- package/dist/_virtual/errors.js.map +1 -0
- package/dist/_virtual/format.js +4 -0
- package/dist/_virtual/format.js.map +1 -0
- package/dist/_virtual/formats.js +4 -0
- package/dist/_virtual/formats.js.map +1 -0
- package/dist/_virtual/id.js +4 -0
- package/dist/_virtual/id.js.map +1 -0
- package/dist/_virtual/if.js +4 -0
- package/dist/_virtual/if.js.map +1 -0
- package/dist/_virtual/index.js +4 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index10.js +4 -0
- package/dist/_virtual/index10.js.map +1 -0
- package/dist/_virtual/index11.js +4 -0
- package/dist/_virtual/index11.js.map +1 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/index3.js +4 -0
- package/dist/_virtual/index3.js.map +1 -0
- package/dist/_virtual/index4.js +4 -0
- package/dist/_virtual/index4.js.map +1 -0
- package/dist/_virtual/index5.js +4 -0
- package/dist/_virtual/index5.js.map +1 -0
- package/dist/_virtual/index6.js +4 -0
- package/dist/_virtual/index6.js.map +1 -0
- package/dist/_virtual/index7.js +4 -0
- package/dist/_virtual/index7.js.map +1 -0
- package/dist/_virtual/index8.js +4 -0
- package/dist/_virtual/index8.js.map +1 -0
- package/dist/_virtual/index9.js +4 -0
- package/dist/_virtual/index9.js.map +1 -0
- package/dist/_virtual/items.js +4 -0
- package/dist/_virtual/items.js.map +1 -0
- package/dist/_virtual/items2020.js +4 -0
- package/dist/_virtual/items2020.js.map +1 -0
- package/dist/_virtual/keyword.js +4 -0
- package/dist/_virtual/keyword.js.map +1 -0
- package/dist/_virtual/limit.js +4 -0
- package/dist/_virtual/limit.js.map +1 -0
- package/dist/_virtual/limitItems.js +4 -0
- package/dist/_virtual/limitItems.js.map +1 -0
- package/dist/_virtual/limitLength.js +4 -0
- package/dist/_virtual/limitLength.js.map +1 -0
- package/dist/_virtual/limitNumber.js +4 -0
- package/dist/_virtual/limitNumber.js.map +1 -0
- package/dist/_virtual/limitProperties.js +4 -0
- package/dist/_virtual/limitProperties.js.map +1 -0
- package/dist/_virtual/metadata.js +4 -0
- package/dist/_virtual/metadata.js.map +1 -0
- package/dist/_virtual/multipleOf.js +4 -0
- package/dist/_virtual/multipleOf.js.map +1 -0
- package/dist/_virtual/names.js +4 -0
- package/dist/_virtual/names.js.map +1 -0
- package/dist/_virtual/not.js +4 -0
- package/dist/_virtual/not.js.map +1 -0
- package/dist/_virtual/oneOf.js +4 -0
- package/dist/_virtual/oneOf.js.map +1 -0
- package/dist/_virtual/pattern.js +4 -0
- package/dist/_virtual/pattern.js.map +1 -0
- package/dist/_virtual/patternProperties.js +4 -0
- package/dist/_virtual/patternProperties.js.map +1 -0
- package/dist/_virtual/prefixItems.js +4 -0
- package/dist/_virtual/prefixItems.js.map +1 -0
- package/dist/_virtual/properties.js +4 -0
- package/dist/_virtual/properties.js.map +1 -0
- package/dist/_virtual/propertyNames.js +4 -0
- package/dist/_virtual/propertyNames.js.map +1 -0
- package/dist/_virtual/ref.js +4 -0
- package/dist/_virtual/ref.js.map +1 -0
- package/dist/_virtual/ref_error.js +4 -0
- package/dist/_virtual/ref_error.js.map +1 -0
- package/dist/_virtual/required.js +4 -0
- package/dist/_virtual/required.js.map +1 -0
- package/dist/_virtual/resolve.js +4 -0
- package/dist/_virtual/resolve.js.map +1 -0
- package/dist/_virtual/rules.js +4 -0
- package/dist/_virtual/rules.js.map +1 -0
- package/dist/_virtual/scope.js +4 -0
- package/dist/_virtual/scope.js.map +1 -0
- package/dist/_virtual/subschema.js +4 -0
- package/dist/_virtual/subschema.js.map +1 -0
- package/dist/_virtual/thenElse.js +4 -0
- package/dist/_virtual/thenElse.js.map +1 -0
- package/dist/_virtual/types.js +4 -0
- package/dist/_virtual/types.js.map +1 -0
- package/dist/_virtual/ucs2length.js +4 -0
- package/dist/_virtual/ucs2length.js.map +1 -0
- package/dist/_virtual/uniqueItems.js +4 -0
- package/dist/_virtual/uniqueItems.js.map +1 -0
- package/dist/_virtual/uri.js +4 -0
- package/dist/_virtual/uri.js.map +1 -0
- package/dist/_virtual/util.js +4 -0
- package/dist/_virtual/util.js.map +1 -0
- package/dist/_virtual/validation_error.js +4 -0
- package/dist/_virtual/validation_error.js.map +1 -0
- package/dist/claude-cli/cli.js +2294 -2146
- package/dist/example-client.d.ts +3 -0
- package/dist/example-client.d.ts.map +1 -0
- package/dist/index.d.ts +19 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js +610 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js +875 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js.map +1 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js +66 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +23 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +331 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +717 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +221 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +56 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +440 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +94 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1610 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +91 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js +133 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js +9 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js +9 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js +112 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js +136 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js +112 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js +3297 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js +44 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js +36 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js +10 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js +657 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js +449 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js +413 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js +57 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js +38 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js +86 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js +61 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js +80 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js +52 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js +1307 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js +842 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js +335 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js +8 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js +51 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js.map +1 -0
- package/dist/node_modules/ajv/dist/ajv.js +69 -0
- package/dist/node_modules/ajv/dist/ajv.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js +169 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js +712 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js +157 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/errors.js +140 -0
- package/dist/node_modules/ajv/dist/compile/errors.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/index.js +253 -0
- package/dist/node_modules/ajv/dist/compile/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/names.js +40 -0
- package/dist/node_modules/ajv/dist/compile/names.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js +25 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js +162 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/rules.js +29 -0
- package/dist/node_modules/ajv/dist/compile/rules.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/util.js +183 -0
- package/dist/node_modules/ajv/dist/compile/util.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js +30 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +64 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js +213 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js +49 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js +544 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js +139 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js +95 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
- package/dist/node_modules/ajv/dist/core.js +639 -0
- package/dist/node_modules/ajv/dist/core.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js +31 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +254 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js +9 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js +25 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js +8 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js +22 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +53 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +112 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +14 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +99 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +93 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +70 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +77 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +57 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +37 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +29 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +64 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +80 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +15 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +61 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +42 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +16 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js +146 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js +11 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js +21 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +131 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +113 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +12 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js +28 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js +94 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js +9 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js +21 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +31 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +54 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +54 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +33 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +29 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +28 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +27 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +84 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +72 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/formats.js +212 -0
- package/dist/node_modules/ajv-formats/dist/formats.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/index.js +52 -0
- package/dist/node_modules/ajv-formats/dist/index.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/limit.js +75 -0
- package/dist/node_modules/ajv-formats/dist/limit.js.map +1 -0
- package/dist/node_modules/diff/libesm/diff/base.js +256 -0
- package/dist/node_modules/diff/libesm/diff/base.js.map +1 -0
- package/dist/node_modules/diff/libesm/diff/line.js +64 -0
- package/dist/node_modules/diff/libesm/diff/line.js.map +1 -0
- package/dist/node_modules/diff/libesm/patch/create.js +185 -0
- package/dist/node_modules/diff/libesm/patch/create.js.map +1 -0
- package/dist/node_modules/fast-deep-equal/index.js +47 -0
- package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
- package/dist/node_modules/fast-uri/index.js +347 -0
- package/dist/node_modules/fast-uri/index.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/schemes.js +255 -0
- package/dist/node_modules/fast-uri/lib/schemes.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/utils.js +334 -0
- package/dist/node_modules/fast-uri/lib/utils.js.map +1 -0
- package/dist/node_modules/json-schema-traverse/index.js +98 -0
- package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
- package/dist/node_modules/uuid/dist/rng.js +14 -0
- package/dist/node_modules/uuid/dist/rng.js.map +1 -0
- package/dist/node_modules/uuid/dist/stringify.js +29 -0
- package/dist/node_modules/uuid/dist/stringify.js.map +1 -0
- package/dist/node_modules/uuid/dist/v7.js +65 -0
- package/dist/node_modules/uuid/dist/v7.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +37 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +26 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +17 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +66 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +21 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +30 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +53 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +50 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +9 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +56 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +30 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +19 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +15 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +13 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +37 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +56 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +76 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +25 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +65 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +350 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +36 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +10 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +84 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +109 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +90 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js +42 -0
- package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js.map +1 -0
- package/dist/package.json.js +8 -0
- package/dist/package.json.js.map +1 -0
- package/dist/src/acp-extensions.d.ts +91 -0
- package/dist/src/acp-extensions.d.ts.map +1 -0
- package/dist/src/acp-extensions.js +38 -0
- package/dist/src/acp-extensions.js.map +1 -0
- package/dist/src/adapters/claude/claude.d.ts +136 -0
- package/dist/src/adapters/claude/claude.d.ts.map +1 -0
- package/dist/src/adapters/claude/claude.js +1112 -0
- package/dist/src/adapters/claude/claude.js.map +1 -0
- package/dist/src/adapters/claude/mcp-server.d.ts +30 -0
- package/dist/src/adapters/claude/mcp-server.d.ts.map +1 -0
- package/dist/src/adapters/claude/mcp-server.js +655 -0
- package/dist/src/adapters/claude/mcp-server.js.map +1 -0
- package/dist/src/adapters/claude/tools.d.ts +35 -0
- package/dist/src/adapters/claude/tools.d.ts.map +1 -0
- package/dist/src/adapters/claude/tools.js +466 -0
- package/dist/src/adapters/claude/tools.js.map +1 -0
- package/dist/src/adapters/claude/utils.d.ts +48 -0
- package/dist/src/adapters/claude/utils.d.ts.map +1 -0
- package/dist/src/adapters/claude/utils.js +158 -0
- package/dist/src/adapters/claude/utils.js.map +1 -0
- package/dist/src/agent.d.ts +18 -28
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +195 -175
- package/dist/src/agent.js.map +1 -1
- package/dist/src/agents/execution.js.map +1 -1
- package/dist/src/agents/planning.js.map +1 -1
- package/dist/src/agents/research.js.map +1 -1
- package/dist/src/file-manager.d.ts +6 -6
- package/dist/src/file-manager.d.ts.map +1 -1
- package/dist/src/file-manager.js +72 -63
- package/dist/src/file-manager.js.map +1 -1
- package/dist/src/git-manager.d.ts +2 -1
- package/dist/src/git-manager.d.ts.map +1 -1
- package/dist/src/git-manager.js +105 -70
- package/dist/src/git-manager.js.map +1 -1
- package/dist/src/posthog-api.d.ts +8 -14
- package/dist/src/posthog-api.d.ts.map +1 -1
- package/dist/src/posthog-api.js +35 -23
- package/dist/src/posthog-api.js.map +1 -1
- package/dist/src/prompt-builder.d.ts +4 -4
- package/dist/src/prompt-builder.d.ts.map +1 -1
- package/dist/src/prompt-builder.js +129 -99
- package/dist/src/prompt-builder.js.map +1 -1
- package/dist/src/schemas.d.ts +980 -0
- package/dist/src/schemas.d.ts.map +1 -0
- package/dist/src/schemas.js +196 -0
- package/dist/src/schemas.js.map +1 -0
- package/dist/src/session-store.d.ts +53 -0
- package/dist/src/session-store.d.ts.map +1 -0
- package/dist/src/session-store.js +195 -0
- package/dist/src/session-store.js.map +1 -0
- package/dist/src/task-manager.d.ts +7 -7
- package/dist/src/task-manager.d.ts.map +1 -1
- package/dist/src/task-manager.js +19 -18
- package/dist/src/task-manager.js.map +1 -1
- package/dist/src/template-manager.d.ts +1 -1
- package/dist/src/template-manager.d.ts.map +1 -1
- package/dist/src/template-manager.js +30 -28
- package/dist/src/template-manager.js.map +1 -1
- package/dist/src/todo-manager.d.ts +5 -5
- package/dist/src/todo-manager.d.ts.map +1 -1
- package/dist/src/todo-manager.js +33 -24
- package/dist/src/todo-manager.js.map +1 -1
- package/dist/src/tools/registry.d.ts +1 -1
- package/dist/src/tools/registry.js +60 -60
- package/dist/src/tools/registry.js.map +1 -1
- package/dist/src/tools/types.d.ts +31 -31
- package/dist/src/types.d.ts +62 -167
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/logger.d.ts +14 -6
- package/dist/src/utils/logger.d.ts.map +1 -1
- package/dist/src/utils/logger.js +37 -22
- package/dist/src/utils/logger.js.map +1 -1
- package/dist/src/utils/tapped-stream.d.ts +17 -0
- package/dist/src/utils/tapped-stream.d.ts.map +1 -0
- package/dist/src/utils/tapped-stream.js +45 -0
- package/dist/src/utils/tapped-stream.js.map +1 -0
- package/dist/src/workflow/config.d.ts +1 -1
- package/dist/src/workflow/config.d.ts.map +1 -1
- package/dist/src/workflow/config.js +18 -18
- package/dist/src/workflow/config.js.map +1 -1
- package/dist/src/workflow/steps/build.d.ts +1 -1
- package/dist/src/workflow/steps/build.d.ts.map +1 -1
- package/dist/src/workflow/steps/build.js +53 -39
- package/dist/src/workflow/steps/build.js.map +1 -1
- package/dist/src/workflow/steps/finalize.d.ts +1 -1
- package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
- package/dist/src/workflow/steps/finalize.js +58 -52
- package/dist/src/workflow/steps/finalize.js.map +1 -1
- package/dist/src/workflow/steps/plan.d.ts +1 -1
- package/dist/src/workflow/steps/plan.d.ts.map +1 -1
- package/dist/src/workflow/steps/plan.js +69 -47
- package/dist/src/workflow/steps/plan.js.map +1 -1
- package/dist/src/workflow/steps/research.d.ts +1 -1
- package/dist/src/workflow/steps/research.d.ts.map +1 -1
- package/dist/src/workflow/steps/research.js +86 -67
- package/dist/src/workflow/steps/research.js.map +1 -1
- package/dist/src/workflow/types.d.ts +19 -14
- package/dist/src/workflow/types.d.ts.map +1 -1
- package/dist/src/workflow/utils.d.ts +1 -1
- package/dist/src/workflow/utils.d.ts.map +1 -1
- package/dist/src/workflow/utils.js +7 -4
- package/dist/src/workflow/utils.js.map +1 -1
- package/dist/src/worktree-manager.d.ts +39 -0
- package/dist/src/worktree-manager.d.ts.map +1 -0
- package/dist/src/worktree-manager.js +810 -0
- package/dist/src/worktree-manager.js.map +1 -0
- package/package.json +20 -16
- package/src/acp-extensions.ts +117 -0
- package/src/adapters/claude/claude.ts +1498 -0
- package/src/adapters/claude/mcp-server.ts +810 -0
- package/src/adapters/claude/tools.ts +609 -0
- package/src/adapters/claude/utils.ts +267 -0
- package/src/agent.ts +511 -447
- package/src/agents/execution.ts +1 -1
- package/src/agents/planning.ts +1 -1
- package/src/agents/research.ts +0 -1
- package/src/file-manager.ts +80 -70
- package/src/git-manager.ts +164 -88
- package/src/posthog-api.ts +155 -94
- package/src/prompt-builder.ts +196 -143
- package/src/schemas.ts +241 -0
- package/src/session-store.ts +244 -0
- package/src/task-manager.ts +41 -33
- package/src/template-manager.ts +98 -45
- package/src/todo-manager.ts +43 -32
- package/src/tools/registry.ts +62 -62
- package/src/tools/types.ts +36 -36
- package/src/types.ts +130 -239
- package/src/utils/logger.ts +89 -58
- package/src/utils/tapped-stream.ts +60 -0
- package/src/workflow/config.ts +48 -48
- package/src/workflow/steps/build.ts +127 -113
- package/src/workflow/steps/finalize.ts +207 -182
- package/src/workflow/steps/plan.ts +155 -130
- package/src/workflow/steps/research.ts +207 -187
- package/src/workflow/types.ts +47 -36
- package/src/workflow/utils.ts +37 -34
- package/src/worktree-manager.ts +884 -0
- package/dist/src/adapters/claude/claude-adapter.d.ts +0 -18
- package/dist/src/adapters/claude/claude-adapter.d.ts.map +0 -1
- package/dist/src/adapters/claude/claude-adapter.js +0 -311
- package/dist/src/adapters/claude/claude-adapter.js.map +0 -1
- package/dist/src/adapters/claude/tool-mapper.d.ts +0 -19
- package/dist/src/adapters/claude/tool-mapper.d.ts.map +0 -1
- package/dist/src/adapters/claude/tool-mapper.js +0 -44
- package/dist/src/adapters/claude/tool-mapper.js.map +0 -1
- package/dist/src/adapters/types.d.ts +0 -33
- package/dist/src/adapters/types.d.ts.map +0 -1
- package/dist/src/task-progress-reporter.d.ts +0 -43
- package/dist/src/task-progress-reporter.d.ts.map +0 -1
- package/dist/src/task-progress-reporter.js +0 -393
- package/dist/src/task-progress-reporter.js.map +0 -1
- package/src/adapters/claude/claude-adapter.ts +0 -338
- package/src/adapters/claude/tool-mapper.ts +0 -46
- package/src/adapters/types.ts +0 -37
- package/src/task-progress-reporter.ts +0 -443
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
import { Server } from './index.js';
|
|
2
|
+
import { normalizeObjectSchema, safeParseAsync, getParseErrorMessage, getObjectShape, objectFromShape, getLiteralValue, getSchemaDescription, isSchemaOptional } from './zod-compat.js';
|
|
3
|
+
import { toJsonSchemaCompat } from './zod-json-schema-compat.js';
|
|
4
|
+
import { ListToolsRequestSchema, CallToolRequestSchema, McpError, ErrorCode, CompleteRequestSchema, assertCompleteRequestResourceTemplate, assertCompleteRequestPrompt, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema } from '../types.js';
|
|
5
|
+
import { isCompletable, getCompleter } from './completable.js';
|
|
6
|
+
import { validateAndWarnToolName } from '../shared/toolNameValidation.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* High-level MCP server that provides a simpler API for working with resources, tools, and prompts.
|
|
10
|
+
* For advanced usage (like sending notifications or setting custom request handlers), use the underlying
|
|
11
|
+
* Server instance available via the `server` property.
|
|
12
|
+
*/
|
|
13
|
+
class McpServer {
|
|
14
|
+
constructor(serverInfo, options) {
|
|
15
|
+
this._registeredResources = {};
|
|
16
|
+
this._registeredResourceTemplates = {};
|
|
17
|
+
this._registeredTools = {};
|
|
18
|
+
this._registeredPrompts = {};
|
|
19
|
+
this._toolHandlersInitialized = false;
|
|
20
|
+
this._completionHandlerInitialized = false;
|
|
21
|
+
this._resourceHandlersInitialized = false;
|
|
22
|
+
this._promptHandlersInitialized = false;
|
|
23
|
+
this.server = new Server(serverInfo, options);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Attaches to the given transport, starts it, and starts listening for messages.
|
|
27
|
+
*
|
|
28
|
+
* The `server` object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
|
|
29
|
+
*/
|
|
30
|
+
async connect(transport) {
|
|
31
|
+
return await this.server.connect(transport);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Closes the connection.
|
|
35
|
+
*/
|
|
36
|
+
async close() {
|
|
37
|
+
await this.server.close();
|
|
38
|
+
}
|
|
39
|
+
setToolRequestHandlers() {
|
|
40
|
+
if (this._toolHandlersInitialized) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.server.assertCanSetRequestHandler(getMethodValue(ListToolsRequestSchema));
|
|
44
|
+
this.server.assertCanSetRequestHandler(getMethodValue(CallToolRequestSchema));
|
|
45
|
+
this.server.registerCapabilities({
|
|
46
|
+
tools: {
|
|
47
|
+
listChanged: true
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
this.server.setRequestHandler(ListToolsRequestSchema, () => ({
|
|
51
|
+
tools: Object.entries(this._registeredTools)
|
|
52
|
+
.filter(([, tool]) => tool.enabled)
|
|
53
|
+
.map(([name, tool]) => {
|
|
54
|
+
const toolDefinition = {
|
|
55
|
+
name,
|
|
56
|
+
title: tool.title,
|
|
57
|
+
description: tool.description,
|
|
58
|
+
inputSchema: (() => {
|
|
59
|
+
const obj = normalizeObjectSchema(tool.inputSchema);
|
|
60
|
+
return obj
|
|
61
|
+
? toJsonSchemaCompat(obj, {
|
|
62
|
+
strictUnions: true,
|
|
63
|
+
pipeStrategy: 'input'
|
|
64
|
+
})
|
|
65
|
+
: EMPTY_OBJECT_JSON_SCHEMA;
|
|
66
|
+
})(),
|
|
67
|
+
annotations: tool.annotations,
|
|
68
|
+
_meta: tool._meta
|
|
69
|
+
};
|
|
70
|
+
if (tool.outputSchema) {
|
|
71
|
+
const obj = normalizeObjectSchema(tool.outputSchema);
|
|
72
|
+
if (obj) {
|
|
73
|
+
toolDefinition.outputSchema = toJsonSchemaCompat(obj, {
|
|
74
|
+
strictUnions: true,
|
|
75
|
+
pipeStrategy: 'output'
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return toolDefinition;
|
|
80
|
+
})
|
|
81
|
+
}));
|
|
82
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
83
|
+
const tool = this._registeredTools[request.params.name];
|
|
84
|
+
let result;
|
|
85
|
+
try {
|
|
86
|
+
if (!tool) {
|
|
87
|
+
throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
|
|
88
|
+
}
|
|
89
|
+
if (!tool.enabled) {
|
|
90
|
+
throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
|
|
91
|
+
}
|
|
92
|
+
if (tool.inputSchema) {
|
|
93
|
+
const cb = tool.callback;
|
|
94
|
+
// Try to normalize to object schema first (for raw shapes and object schemas)
|
|
95
|
+
// If that fails, use the schema directly (for union/intersection/etc)
|
|
96
|
+
const inputObj = normalizeObjectSchema(tool.inputSchema);
|
|
97
|
+
const schemaToParse = inputObj !== null && inputObj !== void 0 ? inputObj : tool.inputSchema;
|
|
98
|
+
const parseResult = await safeParseAsync(schemaToParse, request.params.arguments);
|
|
99
|
+
if (!parseResult.success) {
|
|
100
|
+
throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${request.params.name}: ${getParseErrorMessage(parseResult.error)}`);
|
|
101
|
+
}
|
|
102
|
+
const args = parseResult.data;
|
|
103
|
+
result = await Promise.resolve(cb(args, extra));
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const cb = tool.callback;
|
|
107
|
+
result = await Promise.resolve(cb(extra));
|
|
108
|
+
}
|
|
109
|
+
if (tool.outputSchema && !result.isError) {
|
|
110
|
+
if (!result.structuredContent) {
|
|
111
|
+
throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${request.params.name} has an output schema but no structured content was provided`);
|
|
112
|
+
}
|
|
113
|
+
// if the tool has an output schema, validate structured content
|
|
114
|
+
const outputObj = normalizeObjectSchema(tool.outputSchema);
|
|
115
|
+
const parseResult = await safeParseAsync(outputObj, result.structuredContent);
|
|
116
|
+
if (!parseResult.success) {
|
|
117
|
+
throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${request.params.name}: ${getParseErrorMessage(parseResult.error)}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (error instanceof McpError) {
|
|
123
|
+
if (error.code === ErrorCode.UrlElicitationRequired) {
|
|
124
|
+
throw error; // Return the error to the caller without wrapping in CallToolResult
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return this.createToolError(error instanceof Error ? error.message : String(error));
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
});
|
|
131
|
+
this._toolHandlersInitialized = true;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Creates a tool error result.
|
|
135
|
+
*
|
|
136
|
+
* @param errorMessage - The error message.
|
|
137
|
+
* @returns The tool error result.
|
|
138
|
+
*/
|
|
139
|
+
createToolError(errorMessage) {
|
|
140
|
+
return {
|
|
141
|
+
content: [
|
|
142
|
+
{
|
|
143
|
+
type: 'text',
|
|
144
|
+
text: errorMessage
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
isError: true
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
setCompletionRequestHandler() {
|
|
151
|
+
if (this._completionHandlerInitialized) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.server.assertCanSetRequestHandler(getMethodValue(CompleteRequestSchema));
|
|
155
|
+
this.server.registerCapabilities({
|
|
156
|
+
completions: {}
|
|
157
|
+
});
|
|
158
|
+
this.server.setRequestHandler(CompleteRequestSchema, async (request) => {
|
|
159
|
+
switch (request.params.ref.type) {
|
|
160
|
+
case 'ref/prompt':
|
|
161
|
+
assertCompleteRequestPrompt(request);
|
|
162
|
+
return this.handlePromptCompletion(request, request.params.ref);
|
|
163
|
+
case 'ref/resource':
|
|
164
|
+
assertCompleteRequestResourceTemplate(request);
|
|
165
|
+
return this.handleResourceCompletion(request, request.params.ref);
|
|
166
|
+
default:
|
|
167
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid completion reference: ${request.params.ref}`);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
this._completionHandlerInitialized = true;
|
|
171
|
+
}
|
|
172
|
+
async handlePromptCompletion(request, ref) {
|
|
173
|
+
const prompt = this._registeredPrompts[ref.name];
|
|
174
|
+
if (!prompt) {
|
|
175
|
+
throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} not found`);
|
|
176
|
+
}
|
|
177
|
+
if (!prompt.enabled) {
|
|
178
|
+
throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} disabled`);
|
|
179
|
+
}
|
|
180
|
+
if (!prompt.argsSchema) {
|
|
181
|
+
return EMPTY_COMPLETION_RESULT;
|
|
182
|
+
}
|
|
183
|
+
const promptShape = getObjectShape(prompt.argsSchema);
|
|
184
|
+
const field = promptShape === null || promptShape === void 0 ? void 0 : promptShape[request.params.argument.name];
|
|
185
|
+
if (!isCompletable(field)) {
|
|
186
|
+
return EMPTY_COMPLETION_RESULT;
|
|
187
|
+
}
|
|
188
|
+
const completer = getCompleter(field);
|
|
189
|
+
if (!completer) {
|
|
190
|
+
return EMPTY_COMPLETION_RESULT;
|
|
191
|
+
}
|
|
192
|
+
const suggestions = await completer(request.params.argument.value, request.params.context);
|
|
193
|
+
return createCompletionResult(suggestions);
|
|
194
|
+
}
|
|
195
|
+
async handleResourceCompletion(request, ref) {
|
|
196
|
+
const template = Object.values(this._registeredResourceTemplates).find(t => t.resourceTemplate.uriTemplate.toString() === ref.uri);
|
|
197
|
+
if (!template) {
|
|
198
|
+
if (this._registeredResources[ref.uri]) {
|
|
199
|
+
// Attempting to autocomplete a fixed resource URI is not an error in the spec (but probably should be).
|
|
200
|
+
return EMPTY_COMPLETION_RESULT;
|
|
201
|
+
}
|
|
202
|
+
throw new McpError(ErrorCode.InvalidParams, `Resource template ${request.params.ref.uri} not found`);
|
|
203
|
+
}
|
|
204
|
+
const completer = template.resourceTemplate.completeCallback(request.params.argument.name);
|
|
205
|
+
if (!completer) {
|
|
206
|
+
return EMPTY_COMPLETION_RESULT;
|
|
207
|
+
}
|
|
208
|
+
const suggestions = await completer(request.params.argument.value, request.params.context);
|
|
209
|
+
return createCompletionResult(suggestions);
|
|
210
|
+
}
|
|
211
|
+
setResourceRequestHandlers() {
|
|
212
|
+
if (this._resourceHandlersInitialized) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
this.server.assertCanSetRequestHandler(getMethodValue(ListResourcesRequestSchema));
|
|
216
|
+
this.server.assertCanSetRequestHandler(getMethodValue(ListResourceTemplatesRequestSchema));
|
|
217
|
+
this.server.assertCanSetRequestHandler(getMethodValue(ReadResourceRequestSchema));
|
|
218
|
+
this.server.registerCapabilities({
|
|
219
|
+
resources: {
|
|
220
|
+
listChanged: true
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
this.server.setRequestHandler(ListResourcesRequestSchema, async (request, extra) => {
|
|
224
|
+
const resources = Object.entries(this._registeredResources)
|
|
225
|
+
.filter(([_, resource]) => resource.enabled)
|
|
226
|
+
.map(([uri, resource]) => ({
|
|
227
|
+
uri,
|
|
228
|
+
name: resource.name,
|
|
229
|
+
...resource.metadata
|
|
230
|
+
}));
|
|
231
|
+
const templateResources = [];
|
|
232
|
+
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
233
|
+
if (!template.resourceTemplate.listCallback) {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const result = await template.resourceTemplate.listCallback(extra);
|
|
237
|
+
for (const resource of result.resources) {
|
|
238
|
+
templateResources.push({
|
|
239
|
+
...template.metadata,
|
|
240
|
+
// the defined resource metadata should override the template metadata if present
|
|
241
|
+
...resource
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return { resources: [...resources, ...templateResources] };
|
|
246
|
+
});
|
|
247
|
+
this.server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => {
|
|
248
|
+
const resourceTemplates = Object.entries(this._registeredResourceTemplates).map(([name, template]) => ({
|
|
249
|
+
name,
|
|
250
|
+
uriTemplate: template.resourceTemplate.uriTemplate.toString(),
|
|
251
|
+
...template.metadata
|
|
252
|
+
}));
|
|
253
|
+
return { resourceTemplates };
|
|
254
|
+
});
|
|
255
|
+
this.server.setRequestHandler(ReadResourceRequestSchema, async (request, extra) => {
|
|
256
|
+
const uri = new URL(request.params.uri);
|
|
257
|
+
// First check for exact resource match
|
|
258
|
+
const resource = this._registeredResources[uri.toString()];
|
|
259
|
+
if (resource) {
|
|
260
|
+
if (!resource.enabled) {
|
|
261
|
+
throw new McpError(ErrorCode.InvalidParams, `Resource ${uri} disabled`);
|
|
262
|
+
}
|
|
263
|
+
return resource.readCallback(uri, extra);
|
|
264
|
+
}
|
|
265
|
+
// Then check templates
|
|
266
|
+
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
267
|
+
const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
|
|
268
|
+
if (variables) {
|
|
269
|
+
return template.readCallback(uri, variables, extra);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
throw new McpError(ErrorCode.InvalidParams, `Resource ${uri} not found`);
|
|
273
|
+
});
|
|
274
|
+
this.setCompletionRequestHandler();
|
|
275
|
+
this._resourceHandlersInitialized = true;
|
|
276
|
+
}
|
|
277
|
+
setPromptRequestHandlers() {
|
|
278
|
+
if (this._promptHandlersInitialized) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
this.server.assertCanSetRequestHandler(getMethodValue(ListPromptsRequestSchema));
|
|
282
|
+
this.server.assertCanSetRequestHandler(getMethodValue(GetPromptRequestSchema));
|
|
283
|
+
this.server.registerCapabilities({
|
|
284
|
+
prompts: {
|
|
285
|
+
listChanged: true
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
this.server.setRequestHandler(ListPromptsRequestSchema, () => ({
|
|
289
|
+
prompts: Object.entries(this._registeredPrompts)
|
|
290
|
+
.filter(([, prompt]) => prompt.enabled)
|
|
291
|
+
.map(([name, prompt]) => {
|
|
292
|
+
return {
|
|
293
|
+
name,
|
|
294
|
+
title: prompt.title,
|
|
295
|
+
description: prompt.description,
|
|
296
|
+
arguments: prompt.argsSchema ? promptArgumentsFromSchema(prompt.argsSchema) : undefined
|
|
297
|
+
};
|
|
298
|
+
})
|
|
299
|
+
}));
|
|
300
|
+
this.server.setRequestHandler(GetPromptRequestSchema, async (request, extra) => {
|
|
301
|
+
const prompt = this._registeredPrompts[request.params.name];
|
|
302
|
+
if (!prompt) {
|
|
303
|
+
throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.name} not found`);
|
|
304
|
+
}
|
|
305
|
+
if (!prompt.enabled) {
|
|
306
|
+
throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.name} disabled`);
|
|
307
|
+
}
|
|
308
|
+
if (prompt.argsSchema) {
|
|
309
|
+
const argsObj = normalizeObjectSchema(prompt.argsSchema);
|
|
310
|
+
const parseResult = await safeParseAsync(argsObj, request.params.arguments);
|
|
311
|
+
if (!parseResult.success) {
|
|
312
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request.params.name}: ${getParseErrorMessage(parseResult.error)}`);
|
|
313
|
+
}
|
|
314
|
+
const args = parseResult.data;
|
|
315
|
+
const cb = prompt.callback;
|
|
316
|
+
return await Promise.resolve(cb(args, extra));
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
const cb = prompt.callback;
|
|
320
|
+
return await Promise.resolve(cb(extra));
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
this.setCompletionRequestHandler();
|
|
324
|
+
this._promptHandlersInitialized = true;
|
|
325
|
+
}
|
|
326
|
+
resource(name, uriOrTemplate, ...rest) {
|
|
327
|
+
let metadata;
|
|
328
|
+
if (typeof rest[0] === 'object') {
|
|
329
|
+
metadata = rest.shift();
|
|
330
|
+
}
|
|
331
|
+
const readCallback = rest[0];
|
|
332
|
+
if (typeof uriOrTemplate === 'string') {
|
|
333
|
+
if (this._registeredResources[uriOrTemplate]) {
|
|
334
|
+
throw new Error(`Resource ${uriOrTemplate} is already registered`);
|
|
335
|
+
}
|
|
336
|
+
const registeredResource = this._createRegisteredResource(name, undefined, uriOrTemplate, metadata, readCallback);
|
|
337
|
+
this.setResourceRequestHandlers();
|
|
338
|
+
this.sendResourceListChanged();
|
|
339
|
+
return registeredResource;
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
if (this._registeredResourceTemplates[name]) {
|
|
343
|
+
throw new Error(`Resource template ${name} is already registered`);
|
|
344
|
+
}
|
|
345
|
+
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, undefined, uriOrTemplate, metadata, readCallback);
|
|
346
|
+
this.setResourceRequestHandlers();
|
|
347
|
+
this.sendResourceListChanged();
|
|
348
|
+
return registeredResourceTemplate;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
registerResource(name, uriOrTemplate, config, readCallback) {
|
|
352
|
+
if (typeof uriOrTemplate === 'string') {
|
|
353
|
+
if (this._registeredResources[uriOrTemplate]) {
|
|
354
|
+
throw new Error(`Resource ${uriOrTemplate} is already registered`);
|
|
355
|
+
}
|
|
356
|
+
const registeredResource = this._createRegisteredResource(name, config.title, uriOrTemplate, config, readCallback);
|
|
357
|
+
this.setResourceRequestHandlers();
|
|
358
|
+
this.sendResourceListChanged();
|
|
359
|
+
return registeredResource;
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
if (this._registeredResourceTemplates[name]) {
|
|
363
|
+
throw new Error(`Resource template ${name} is already registered`);
|
|
364
|
+
}
|
|
365
|
+
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config.title, uriOrTemplate, config, readCallback);
|
|
366
|
+
this.setResourceRequestHandlers();
|
|
367
|
+
this.sendResourceListChanged();
|
|
368
|
+
return registeredResourceTemplate;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
_createRegisteredResource(name, title, uri, metadata, readCallback) {
|
|
372
|
+
const registeredResource = {
|
|
373
|
+
name,
|
|
374
|
+
title,
|
|
375
|
+
metadata,
|
|
376
|
+
readCallback,
|
|
377
|
+
enabled: true,
|
|
378
|
+
disable: () => registeredResource.update({ enabled: false }),
|
|
379
|
+
enable: () => registeredResource.update({ enabled: true }),
|
|
380
|
+
remove: () => registeredResource.update({ uri: null }),
|
|
381
|
+
update: updates => {
|
|
382
|
+
if (typeof updates.uri !== 'undefined' && updates.uri !== uri) {
|
|
383
|
+
delete this._registeredResources[uri];
|
|
384
|
+
if (updates.uri)
|
|
385
|
+
this._registeredResources[updates.uri] = registeredResource;
|
|
386
|
+
}
|
|
387
|
+
if (typeof updates.name !== 'undefined')
|
|
388
|
+
registeredResource.name = updates.name;
|
|
389
|
+
if (typeof updates.title !== 'undefined')
|
|
390
|
+
registeredResource.title = updates.title;
|
|
391
|
+
if (typeof updates.metadata !== 'undefined')
|
|
392
|
+
registeredResource.metadata = updates.metadata;
|
|
393
|
+
if (typeof updates.callback !== 'undefined')
|
|
394
|
+
registeredResource.readCallback = updates.callback;
|
|
395
|
+
if (typeof updates.enabled !== 'undefined')
|
|
396
|
+
registeredResource.enabled = updates.enabled;
|
|
397
|
+
this.sendResourceListChanged();
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
this._registeredResources[uri] = registeredResource;
|
|
401
|
+
return registeredResource;
|
|
402
|
+
}
|
|
403
|
+
_createRegisteredResourceTemplate(name, title, template, metadata, readCallback) {
|
|
404
|
+
const registeredResourceTemplate = {
|
|
405
|
+
resourceTemplate: template,
|
|
406
|
+
title,
|
|
407
|
+
metadata,
|
|
408
|
+
readCallback,
|
|
409
|
+
enabled: true,
|
|
410
|
+
disable: () => registeredResourceTemplate.update({ enabled: false }),
|
|
411
|
+
enable: () => registeredResourceTemplate.update({ enabled: true }),
|
|
412
|
+
remove: () => registeredResourceTemplate.update({ name: null }),
|
|
413
|
+
update: updates => {
|
|
414
|
+
if (typeof updates.name !== 'undefined' && updates.name !== name) {
|
|
415
|
+
delete this._registeredResourceTemplates[name];
|
|
416
|
+
if (updates.name)
|
|
417
|
+
this._registeredResourceTemplates[updates.name] = registeredResourceTemplate;
|
|
418
|
+
}
|
|
419
|
+
if (typeof updates.title !== 'undefined')
|
|
420
|
+
registeredResourceTemplate.title = updates.title;
|
|
421
|
+
if (typeof updates.template !== 'undefined')
|
|
422
|
+
registeredResourceTemplate.resourceTemplate = updates.template;
|
|
423
|
+
if (typeof updates.metadata !== 'undefined')
|
|
424
|
+
registeredResourceTemplate.metadata = updates.metadata;
|
|
425
|
+
if (typeof updates.callback !== 'undefined')
|
|
426
|
+
registeredResourceTemplate.readCallback = updates.callback;
|
|
427
|
+
if (typeof updates.enabled !== 'undefined')
|
|
428
|
+
registeredResourceTemplate.enabled = updates.enabled;
|
|
429
|
+
this.sendResourceListChanged();
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
this._registeredResourceTemplates[name] = registeredResourceTemplate;
|
|
433
|
+
return registeredResourceTemplate;
|
|
434
|
+
}
|
|
435
|
+
_createRegisteredPrompt(name, title, description, argsSchema, callback) {
|
|
436
|
+
const registeredPrompt = {
|
|
437
|
+
title,
|
|
438
|
+
description,
|
|
439
|
+
argsSchema: argsSchema === undefined ? undefined : objectFromShape(argsSchema),
|
|
440
|
+
callback,
|
|
441
|
+
enabled: true,
|
|
442
|
+
disable: () => registeredPrompt.update({ enabled: false }),
|
|
443
|
+
enable: () => registeredPrompt.update({ enabled: true }),
|
|
444
|
+
remove: () => registeredPrompt.update({ name: null }),
|
|
445
|
+
update: updates => {
|
|
446
|
+
if (typeof updates.name !== 'undefined' && updates.name !== name) {
|
|
447
|
+
delete this._registeredPrompts[name];
|
|
448
|
+
if (updates.name)
|
|
449
|
+
this._registeredPrompts[updates.name] = registeredPrompt;
|
|
450
|
+
}
|
|
451
|
+
if (typeof updates.title !== 'undefined')
|
|
452
|
+
registeredPrompt.title = updates.title;
|
|
453
|
+
if (typeof updates.description !== 'undefined')
|
|
454
|
+
registeredPrompt.description = updates.description;
|
|
455
|
+
if (typeof updates.argsSchema !== 'undefined')
|
|
456
|
+
registeredPrompt.argsSchema = objectFromShape(updates.argsSchema);
|
|
457
|
+
if (typeof updates.callback !== 'undefined')
|
|
458
|
+
registeredPrompt.callback = updates.callback;
|
|
459
|
+
if (typeof updates.enabled !== 'undefined')
|
|
460
|
+
registeredPrompt.enabled = updates.enabled;
|
|
461
|
+
this.sendPromptListChanged();
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
this._registeredPrompts[name] = registeredPrompt;
|
|
465
|
+
return registeredPrompt;
|
|
466
|
+
}
|
|
467
|
+
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta, callback) {
|
|
468
|
+
// Validate tool name according to SEP specification
|
|
469
|
+
validateAndWarnToolName(name);
|
|
470
|
+
const registeredTool = {
|
|
471
|
+
title,
|
|
472
|
+
description,
|
|
473
|
+
inputSchema: getZodSchemaObject(inputSchema),
|
|
474
|
+
outputSchema: getZodSchemaObject(outputSchema),
|
|
475
|
+
annotations,
|
|
476
|
+
_meta,
|
|
477
|
+
callback,
|
|
478
|
+
enabled: true,
|
|
479
|
+
disable: () => registeredTool.update({ enabled: false }),
|
|
480
|
+
enable: () => registeredTool.update({ enabled: true }),
|
|
481
|
+
remove: () => registeredTool.update({ name: null }),
|
|
482
|
+
update: updates => {
|
|
483
|
+
if (typeof updates.name !== 'undefined' && updates.name !== name) {
|
|
484
|
+
if (typeof updates.name === 'string') {
|
|
485
|
+
validateAndWarnToolName(updates.name);
|
|
486
|
+
}
|
|
487
|
+
delete this._registeredTools[name];
|
|
488
|
+
if (updates.name)
|
|
489
|
+
this._registeredTools[updates.name] = registeredTool;
|
|
490
|
+
}
|
|
491
|
+
if (typeof updates.title !== 'undefined')
|
|
492
|
+
registeredTool.title = updates.title;
|
|
493
|
+
if (typeof updates.description !== 'undefined')
|
|
494
|
+
registeredTool.description = updates.description;
|
|
495
|
+
if (typeof updates.paramsSchema !== 'undefined')
|
|
496
|
+
registeredTool.inputSchema = objectFromShape(updates.paramsSchema);
|
|
497
|
+
if (typeof updates.callback !== 'undefined')
|
|
498
|
+
registeredTool.callback = updates.callback;
|
|
499
|
+
if (typeof updates.annotations !== 'undefined')
|
|
500
|
+
registeredTool.annotations = updates.annotations;
|
|
501
|
+
if (typeof updates._meta !== 'undefined')
|
|
502
|
+
registeredTool._meta = updates._meta;
|
|
503
|
+
if (typeof updates.enabled !== 'undefined')
|
|
504
|
+
registeredTool.enabled = updates.enabled;
|
|
505
|
+
this.sendToolListChanged();
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
this._registeredTools[name] = registeredTool;
|
|
509
|
+
this.setToolRequestHandlers();
|
|
510
|
+
this.sendToolListChanged();
|
|
511
|
+
return registeredTool;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* tool() implementation. Parses arguments passed to overrides defined above.
|
|
515
|
+
*/
|
|
516
|
+
tool(name, ...rest) {
|
|
517
|
+
if (this._registeredTools[name]) {
|
|
518
|
+
throw new Error(`Tool ${name} is already registered`);
|
|
519
|
+
}
|
|
520
|
+
let description;
|
|
521
|
+
let inputSchema;
|
|
522
|
+
let outputSchema;
|
|
523
|
+
let annotations;
|
|
524
|
+
// Tool properties are passed as separate arguments, with omissions allowed.
|
|
525
|
+
// Support for this style is frozen as of protocol version 2025-03-26. Future additions
|
|
526
|
+
// to tool definition should *NOT* be added.
|
|
527
|
+
if (typeof rest[0] === 'string') {
|
|
528
|
+
description = rest.shift();
|
|
529
|
+
}
|
|
530
|
+
// Handle the different overload combinations
|
|
531
|
+
if (rest.length > 1) {
|
|
532
|
+
// We have at least one more arg before the callback
|
|
533
|
+
const firstArg = rest[0];
|
|
534
|
+
if (isZodRawShape(firstArg)) {
|
|
535
|
+
// We have a params schema as the first arg
|
|
536
|
+
inputSchema = rest.shift();
|
|
537
|
+
// Check if the next arg is potentially annotations
|
|
538
|
+
if (rest.length > 1 && typeof rest[0] === 'object' && rest[0] !== null && !isZodRawShape(rest[0])) {
|
|
539
|
+
// Case: tool(name, paramsSchema, annotations, cb)
|
|
540
|
+
// Or: tool(name, description, paramsSchema, annotations, cb)
|
|
541
|
+
annotations = rest.shift();
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
else if (typeof firstArg === 'object' && firstArg !== null) {
|
|
545
|
+
// Not a ZodRawShape, so must be annotations in this position
|
|
546
|
+
// Case: tool(name, annotations, cb)
|
|
547
|
+
// Or: tool(name, description, annotations, cb)
|
|
548
|
+
annotations = rest.shift();
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const callback = rest[0];
|
|
552
|
+
return this._createRegisteredTool(name, undefined, description, inputSchema, outputSchema, annotations, undefined, callback);
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Registers a tool with a config object and callback.
|
|
556
|
+
*/
|
|
557
|
+
registerTool(name, config, cb) {
|
|
558
|
+
if (this._registeredTools[name]) {
|
|
559
|
+
throw new Error(`Tool ${name} is already registered`);
|
|
560
|
+
}
|
|
561
|
+
const { title, description, inputSchema, outputSchema, annotations, _meta } = config;
|
|
562
|
+
return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta, cb);
|
|
563
|
+
}
|
|
564
|
+
prompt(name, ...rest) {
|
|
565
|
+
if (this._registeredPrompts[name]) {
|
|
566
|
+
throw new Error(`Prompt ${name} is already registered`);
|
|
567
|
+
}
|
|
568
|
+
let description;
|
|
569
|
+
if (typeof rest[0] === 'string') {
|
|
570
|
+
description = rest.shift();
|
|
571
|
+
}
|
|
572
|
+
let argsSchema;
|
|
573
|
+
if (rest.length > 1) {
|
|
574
|
+
argsSchema = rest.shift();
|
|
575
|
+
}
|
|
576
|
+
const cb = rest[0];
|
|
577
|
+
const registeredPrompt = this._createRegisteredPrompt(name, undefined, description, argsSchema, cb);
|
|
578
|
+
this.setPromptRequestHandlers();
|
|
579
|
+
this.sendPromptListChanged();
|
|
580
|
+
return registeredPrompt;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Registers a prompt with a config object and callback.
|
|
584
|
+
*/
|
|
585
|
+
registerPrompt(name, config, cb) {
|
|
586
|
+
if (this._registeredPrompts[name]) {
|
|
587
|
+
throw new Error(`Prompt ${name} is already registered`);
|
|
588
|
+
}
|
|
589
|
+
const { title, description, argsSchema } = config;
|
|
590
|
+
const registeredPrompt = this._createRegisteredPrompt(name, title, description, argsSchema, cb);
|
|
591
|
+
this.setPromptRequestHandlers();
|
|
592
|
+
this.sendPromptListChanged();
|
|
593
|
+
return registeredPrompt;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Checks if the server is connected to a transport.
|
|
597
|
+
* @returns True if the server is connected
|
|
598
|
+
*/
|
|
599
|
+
isConnected() {
|
|
600
|
+
return this.server.transport !== undefined;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Sends a logging message to the client, if connected.
|
|
604
|
+
* Note: You only need to send the parameters object, not the entire JSON RPC message
|
|
605
|
+
* @see LoggingMessageNotification
|
|
606
|
+
* @param params
|
|
607
|
+
* @param sessionId optional for stateless and backward compatibility
|
|
608
|
+
*/
|
|
609
|
+
async sendLoggingMessage(params, sessionId) {
|
|
610
|
+
return this.server.sendLoggingMessage(params, sessionId);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Sends a resource list changed event to the client, if connected.
|
|
614
|
+
*/
|
|
615
|
+
sendResourceListChanged() {
|
|
616
|
+
if (this.isConnected()) {
|
|
617
|
+
this.server.sendResourceListChanged();
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Sends a tool list changed event to the client, if connected.
|
|
622
|
+
*/
|
|
623
|
+
sendToolListChanged() {
|
|
624
|
+
if (this.isConnected()) {
|
|
625
|
+
this.server.sendToolListChanged();
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Sends a prompt list changed event to the client, if connected.
|
|
630
|
+
*/
|
|
631
|
+
sendPromptListChanged() {
|
|
632
|
+
if (this.isConnected()) {
|
|
633
|
+
this.server.sendPromptListChanged();
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
const EMPTY_OBJECT_JSON_SCHEMA = {
|
|
638
|
+
type: 'object',
|
|
639
|
+
properties: {}
|
|
640
|
+
};
|
|
641
|
+
// Helper to check if an object is a Zod schema (ZodRawShapeCompat)
|
|
642
|
+
function isZodRawShape(obj) {
|
|
643
|
+
if (typeof obj !== 'object' || obj === null)
|
|
644
|
+
return false;
|
|
645
|
+
const isEmptyObject = Object.keys(obj).length === 0;
|
|
646
|
+
// Check if object is empty or at least one property is a ZodType instance
|
|
647
|
+
// Note: use heuristic check to avoid instanceof failure across different Zod versions
|
|
648
|
+
return isEmptyObject || Object.values(obj).some(isZodTypeLike);
|
|
649
|
+
}
|
|
650
|
+
function isZodTypeLike(value) {
|
|
651
|
+
return (value !== null &&
|
|
652
|
+
typeof value === 'object' &&
|
|
653
|
+
'parse' in value &&
|
|
654
|
+
typeof value.parse === 'function' &&
|
|
655
|
+
'safeParse' in value &&
|
|
656
|
+
typeof value.safeParse === 'function');
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Converts a provided Zod schema to a Zod object if it is a ZodRawShape,
|
|
660
|
+
* otherwise returns the schema as is.
|
|
661
|
+
*/
|
|
662
|
+
function getZodSchemaObject(schema) {
|
|
663
|
+
if (!schema) {
|
|
664
|
+
return undefined;
|
|
665
|
+
}
|
|
666
|
+
if (isZodRawShape(schema)) {
|
|
667
|
+
return objectFromShape(schema);
|
|
668
|
+
}
|
|
669
|
+
return schema;
|
|
670
|
+
}
|
|
671
|
+
function promptArgumentsFromSchema(schema) {
|
|
672
|
+
const shape = getObjectShape(schema);
|
|
673
|
+
if (!shape)
|
|
674
|
+
return [];
|
|
675
|
+
return Object.entries(shape).map(([name, field]) => {
|
|
676
|
+
// Get description - works for both v3 and v4
|
|
677
|
+
const description = getSchemaDescription(field);
|
|
678
|
+
// Check if optional - works for both v3 and v4
|
|
679
|
+
const isOptional = isSchemaOptional(field);
|
|
680
|
+
return {
|
|
681
|
+
name,
|
|
682
|
+
description,
|
|
683
|
+
required: !isOptional
|
|
684
|
+
};
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
function getMethodValue(schema) {
|
|
688
|
+
const shape = getObjectShape(schema);
|
|
689
|
+
const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
|
|
690
|
+
if (!methodSchema) {
|
|
691
|
+
throw new Error('Schema is missing a method literal');
|
|
692
|
+
}
|
|
693
|
+
// Extract literal value - works for both v3 and v4
|
|
694
|
+
const value = getLiteralValue(methodSchema);
|
|
695
|
+
if (typeof value === 'string') {
|
|
696
|
+
return value;
|
|
697
|
+
}
|
|
698
|
+
throw new Error('Schema method literal must be a string');
|
|
699
|
+
}
|
|
700
|
+
function createCompletionResult(suggestions) {
|
|
701
|
+
return {
|
|
702
|
+
completion: {
|
|
703
|
+
values: suggestions.slice(0, 100),
|
|
704
|
+
total: suggestions.length,
|
|
705
|
+
hasMore: suggestions.length > 100
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
const EMPTY_COMPLETION_RESULT = {
|
|
710
|
+
completion: {
|
|
711
|
+
values: [],
|
|
712
|
+
hasMore: false
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
export { McpServer };
|
|
717
|
+
//# sourceMappingURL=mcp.js.map
|