@posthog/agent 1.26.0 → 1.28.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/index.d.ts +1274 -20
- package/dist/index.js +7327 -11
- package/dist/index.js.map +1 -1
- package/package.json +6 -12
- package/src/agent.ts +42 -5
- package/src/types.ts +1 -1
- package/src/worktree-manager.ts +45 -0
- package/dist/_virtual/_commonjsHelpers.js +0 -6
- package/dist/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/_virtual/_tslib.js +0 -74
- package/dist/_virtual/_tslib.js.map +0 -1
- package/dist/_virtual/additionalItems.js +0 -4
- package/dist/_virtual/additionalItems.js.map +0 -1
- package/dist/_virtual/additionalProperties.js +0 -4
- package/dist/_virtual/additionalProperties.js.map +0 -1
- package/dist/_virtual/ajv.js +0 -4
- package/dist/_virtual/ajv.js.map +0 -1
- package/dist/_virtual/allOf.js +0 -4
- package/dist/_virtual/allOf.js.map +0 -1
- package/dist/_virtual/anyOf.js +0 -4
- package/dist/_virtual/anyOf.js.map +0 -1
- package/dist/_virtual/applicability.js +0 -4
- package/dist/_virtual/applicability.js.map +0 -1
- package/dist/_virtual/boolSchema.js +0 -4
- package/dist/_virtual/boolSchema.js.map +0 -1
- package/dist/_virtual/code.js +0 -4
- package/dist/_virtual/code.js.map +0 -1
- package/dist/_virtual/code2.js +0 -4
- package/dist/_virtual/code2.js.map +0 -1
- package/dist/_virtual/const.js +0 -4
- package/dist/_virtual/const.js.map +0 -1
- package/dist/_virtual/contains.js +0 -4
- package/dist/_virtual/contains.js.map +0 -1
- package/dist/_virtual/core.js +0 -4
- package/dist/_virtual/core.js.map +0 -1
- package/dist/_virtual/dataType.js +0 -4
- package/dist/_virtual/dataType.js.map +0 -1
- package/dist/_virtual/defaults.js +0 -4
- package/dist/_virtual/defaults.js.map +0 -1
- package/dist/_virtual/dependencies.js +0 -4
- package/dist/_virtual/dependencies.js.map +0 -1
- package/dist/_virtual/draft7.js +0 -4
- package/dist/_virtual/draft7.js.map +0 -1
- package/dist/_virtual/enum.js +0 -4
- package/dist/_virtual/enum.js.map +0 -1
- package/dist/_virtual/equal.js +0 -4
- package/dist/_virtual/equal.js.map +0 -1
- package/dist/_virtual/errors.js +0 -4
- package/dist/_virtual/errors.js.map +0 -1
- package/dist/_virtual/format.js +0 -4
- package/dist/_virtual/format.js.map +0 -1
- package/dist/_virtual/formats.js +0 -4
- package/dist/_virtual/formats.js.map +0 -1
- package/dist/_virtual/id.js +0 -4
- package/dist/_virtual/id.js.map +0 -1
- package/dist/_virtual/if.js +0 -4
- package/dist/_virtual/if.js.map +0 -1
- package/dist/_virtual/index.js +0 -4
- package/dist/_virtual/index.js.map +0 -1
- package/dist/_virtual/index10.js +0 -4
- package/dist/_virtual/index10.js.map +0 -1
- package/dist/_virtual/index11.js +0 -4
- package/dist/_virtual/index11.js.map +0 -1
- package/dist/_virtual/index2.js +0 -4
- package/dist/_virtual/index2.js.map +0 -1
- package/dist/_virtual/index3.js +0 -4
- package/dist/_virtual/index3.js.map +0 -1
- package/dist/_virtual/index4.js +0 -4
- package/dist/_virtual/index4.js.map +0 -1
- package/dist/_virtual/index5.js +0 -4
- package/dist/_virtual/index5.js.map +0 -1
- package/dist/_virtual/index6.js +0 -4
- package/dist/_virtual/index6.js.map +0 -1
- package/dist/_virtual/index7.js +0 -4
- package/dist/_virtual/index7.js.map +0 -1
- package/dist/_virtual/index8.js +0 -4
- package/dist/_virtual/index8.js.map +0 -1
- package/dist/_virtual/index9.js +0 -4
- package/dist/_virtual/index9.js.map +0 -1
- package/dist/_virtual/items.js +0 -4
- package/dist/_virtual/items.js.map +0 -1
- package/dist/_virtual/items2020.js +0 -4
- package/dist/_virtual/items2020.js.map +0 -1
- package/dist/_virtual/keyword.js +0 -4
- package/dist/_virtual/keyword.js.map +0 -1
- package/dist/_virtual/limit.js +0 -4
- package/dist/_virtual/limit.js.map +0 -1
- package/dist/_virtual/limitItems.js +0 -4
- package/dist/_virtual/limitItems.js.map +0 -1
- package/dist/_virtual/limitLength.js +0 -4
- package/dist/_virtual/limitLength.js.map +0 -1
- package/dist/_virtual/limitNumber.js +0 -4
- package/dist/_virtual/limitNumber.js.map +0 -1
- package/dist/_virtual/limitProperties.js +0 -4
- package/dist/_virtual/limitProperties.js.map +0 -1
- package/dist/_virtual/metadata.js +0 -4
- package/dist/_virtual/metadata.js.map +0 -1
- package/dist/_virtual/multipleOf.js +0 -4
- package/dist/_virtual/multipleOf.js.map +0 -1
- package/dist/_virtual/names.js +0 -4
- package/dist/_virtual/names.js.map +0 -1
- package/dist/_virtual/not.js +0 -4
- package/dist/_virtual/not.js.map +0 -1
- package/dist/_virtual/oneOf.js +0 -4
- package/dist/_virtual/oneOf.js.map +0 -1
- package/dist/_virtual/pattern.js +0 -4
- package/dist/_virtual/pattern.js.map +0 -1
- package/dist/_virtual/patternProperties.js +0 -4
- package/dist/_virtual/patternProperties.js.map +0 -1
- package/dist/_virtual/prefixItems.js +0 -4
- package/dist/_virtual/prefixItems.js.map +0 -1
- package/dist/_virtual/properties.js +0 -4
- package/dist/_virtual/properties.js.map +0 -1
- package/dist/_virtual/propertyNames.js +0 -4
- package/dist/_virtual/propertyNames.js.map +0 -1
- package/dist/_virtual/ref.js +0 -4
- package/dist/_virtual/ref.js.map +0 -1
- package/dist/_virtual/ref_error.js +0 -4
- package/dist/_virtual/ref_error.js.map +0 -1
- package/dist/_virtual/required.js +0 -4
- package/dist/_virtual/required.js.map +0 -1
- package/dist/_virtual/resolve.js +0 -4
- package/dist/_virtual/resolve.js.map +0 -1
- package/dist/_virtual/rules.js +0 -4
- package/dist/_virtual/rules.js.map +0 -1
- package/dist/_virtual/scope.js +0 -4
- package/dist/_virtual/scope.js.map +0 -1
- package/dist/_virtual/subschema.js +0 -4
- package/dist/_virtual/subschema.js.map +0 -1
- package/dist/_virtual/thenElse.js +0 -4
- package/dist/_virtual/thenElse.js.map +0 -1
- package/dist/_virtual/types.js +0 -4
- package/dist/_virtual/types.js.map +0 -1
- package/dist/_virtual/ucs2length.js +0 -4
- package/dist/_virtual/ucs2length.js.map +0 -1
- package/dist/_virtual/uniqueItems.js +0 -4
- package/dist/_virtual/uniqueItems.js.map +0 -1
- package/dist/_virtual/uri.js +0 -4
- package/dist/_virtual/uri.js.map +0 -1
- package/dist/_virtual/util.js +0 -4
- package/dist/_virtual/util.js.map +0 -1
- package/dist/_virtual/validation_error.js +0 -4
- package/dist/_virtual/validation_error.js.map +0 -1
- package/dist/example-client.d.ts +0 -3
- package/dist/example-client.d.ts.map +0 -1
- package/dist/example.d.ts +0 -3
- package/dist/example.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js +0 -891
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +0 -1
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js +0 -876
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js.map +0 -1
- package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js +0 -66
- package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +0 -23
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +0 -331
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +0 -717
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +0 -221
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +0 -56
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +0 -440
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +0 -94
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +0 -1610
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +0 -91
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js +0 -133
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js +0 -9
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js +0 -9
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js +0 -112
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js +0 -136
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js +0 -112
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js +0 -3297
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js +0 -44
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js +0 -36
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js +0 -10
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js +0 -657
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js +0 -449
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js +0 -413
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js +0 -57
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js +0 -38
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js +0 -86
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js +0 -61
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js +0 -80
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js +0 -52
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js +0 -1307
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js +0 -842
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js +0 -335
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js +0 -8
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js.map +0 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js +0 -51
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js.map +0 -1
- package/dist/node_modules/ajv/dist/ajv.js +0 -69
- package/dist/node_modules/ajv/dist/ajv.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/codegen/code.js +0 -169
- package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/codegen/index.js +0 -712
- package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js +0 -157
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/errors.js +0 -140
- package/dist/node_modules/ajv/dist/compile/errors.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/index.js +0 -253
- package/dist/node_modules/ajv/dist/compile/index.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/names.js +0 -40
- package/dist/node_modules/ajv/dist/compile/names.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/ref_error.js +0 -25
- package/dist/node_modules/ajv/dist/compile/ref_error.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/resolve.js +0 -162
- package/dist/node_modules/ajv/dist/compile/resolve.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/rules.js +0 -29
- package/dist/node_modules/ajv/dist/compile/rules.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/util.js +0 -183
- package/dist/node_modules/ajv/dist/compile/util.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js +0 -30
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -64
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js +0 -213
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js +0 -49
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/validate/index.js +0 -544
- package/dist/node_modules/ajv/dist/compile/validate/index.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js +0 -139
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +0 -1
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js +0 -95
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +0 -1
- package/dist/node_modules/ajv/dist/core.js +0 -639
- package/dist/node_modules/ajv/dist/core.js.map +0 -1
- package/dist/node_modules/ajv/dist/refs/data.json.js +0 -31
- package/dist/node_modules/ajv/dist/refs/data.json.js.map +0 -1
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +0 -254
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +0 -1
- package/dist/node_modules/ajv/dist/runtime/equal.js +0 -9
- package/dist/node_modules/ajv/dist/runtime/equal.js.map +0 -1
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js +0 -25
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +0 -1
- package/dist/node_modules/ajv/dist/runtime/uri.js +0 -8
- package/dist/node_modules/ajv/dist/runtime/uri.js.map +0 -1
- package/dist/node_modules/ajv/dist/runtime/validation_error.js +0 -22
- package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -53
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -112
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -26
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -14
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -99
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -93
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -70
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -77
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -57
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -37
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -29
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -64
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -80
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -15
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -61
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -42
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -16
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/code.js +0 -146
- package/dist/node_modules/ajv/dist/vocabularies/code.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js +0 -11
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js +0 -21
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +0 -131
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -113
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -12
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js +0 -28
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js +0 -94
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js +0 -9
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js +0 -21
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +0 -31
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -54
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +0 -54
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -26
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -33
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -29
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -26
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -28
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -27
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +0 -84
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +0 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -72
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +0 -1
- package/dist/node_modules/ajv-formats/dist/formats.js +0 -212
- package/dist/node_modules/ajv-formats/dist/formats.js.map +0 -1
- package/dist/node_modules/ajv-formats/dist/index.js +0 -52
- package/dist/node_modules/ajv-formats/dist/index.js.map +0 -1
- package/dist/node_modules/ajv-formats/dist/limit.js +0 -75
- package/dist/node_modules/ajv-formats/dist/limit.js.map +0 -1
- package/dist/node_modules/diff/libesm/diff/base.js +0 -256
- package/dist/node_modules/diff/libesm/diff/base.js.map +0 -1
- package/dist/node_modules/diff/libesm/diff/line.js +0 -64
- package/dist/node_modules/diff/libesm/diff/line.js.map +0 -1
- package/dist/node_modules/diff/libesm/patch/create.js +0 -185
- package/dist/node_modules/diff/libesm/patch/create.js.map +0 -1
- package/dist/node_modules/fast-deep-equal/index.js +0 -47
- package/dist/node_modules/fast-deep-equal/index.js.map +0 -1
- package/dist/node_modules/fast-uri/index.js +0 -347
- package/dist/node_modules/fast-uri/index.js.map +0 -1
- package/dist/node_modules/fast-uri/lib/schemes.js +0 -255
- package/dist/node_modules/fast-uri/lib/schemes.js.map +0 -1
- package/dist/node_modules/fast-uri/lib/utils.js +0 -334
- package/dist/node_modules/fast-uri/lib/utils.js.map +0 -1
- package/dist/node_modules/json-schema-traverse/index.js +0 -98
- package/dist/node_modules/json-schema-traverse/index.js.map +0 -1
- package/dist/node_modules/uuid/dist/rng.js +0 -14
- package/dist/node_modules/uuid/dist/rng.js.map +0 -1
- package/dist/node_modules/uuid/dist/stringify.js +0 -29
- package/dist/node_modules/uuid/dist/stringify.js.map +0 -1
- package/dist/node_modules/uuid/dist/v7.js +0 -65
- package/dist/node_modules/uuid/dist/v7.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +0 -37
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +0 -26
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +0 -17
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +0 -11
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +0 -66
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +0 -21
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +0 -30
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +0 -53
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +0 -8
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +0 -8
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +0 -8
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +0 -50
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +0 -11
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +0 -11
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +0 -9
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +0 -56
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +0 -24
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +0 -30
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +0 -19
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +0 -15
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +0 -13
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +0 -37
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +0 -56
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +0 -76
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +0 -25
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +0 -24
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +0 -8
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +0 -8
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +0 -65
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +0 -24
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +0 -350
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +0 -36
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +0 -10
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +0 -84
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +0 -8
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +0 -109
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +0 -90
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +0 -1
- package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js +0 -42
- package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js.map +0 -1
- package/dist/package.json.js +0 -8
- package/dist/package.json.js.map +0 -1
- package/dist/src/acp-extensions.d.ts +0 -91
- package/dist/src/acp-extensions.d.ts.map +0 -1
- package/dist/src/acp-extensions.js +0 -38
- package/dist/src/acp-extensions.js.map +0 -1
- package/dist/src/adapters/claude/claude.d.ts +0 -136
- package/dist/src/adapters/claude/claude.d.ts.map +0 -1
- package/dist/src/adapters/claude/claude.js +0 -1128
- package/dist/src/adapters/claude/claude.js.map +0 -1
- package/dist/src/adapters/claude/mcp-server.d.ts +0 -30
- package/dist/src/adapters/claude/mcp-server.d.ts.map +0 -1
- package/dist/src/adapters/claude/mcp-server.js +0 -668
- package/dist/src/adapters/claude/mcp-server.js.map +0 -1
- package/dist/src/adapters/claude/tools.d.ts +0 -35
- package/dist/src/adapters/claude/tools.d.ts.map +0 -1
- package/dist/src/adapters/claude/tools.js +0 -473
- package/dist/src/adapters/claude/tools.js.map +0 -1
- package/dist/src/adapters/claude/utils.d.ts +0 -48
- package/dist/src/adapters/claude/utils.d.ts.map +0 -1
- package/dist/src/adapters/claude/utils.js +0 -158
- package/dist/src/adapters/claude/utils.js.map +0 -1
- package/dist/src/agent.d.ts +0 -58
- package/dist/src/agent.d.ts.map +0 -1
- package/dist/src/agent.js +0 -576
- package/dist/src/agent.js.map +0 -1
- package/dist/src/agents/execution.d.ts +0 -2
- package/dist/src/agents/execution.d.ts.map +0 -1
- package/dist/src/agents/execution.js +0 -40
- package/dist/src/agents/execution.js.map +0 -1
- package/dist/src/agents/planning.d.ts +0 -2
- package/dist/src/agents/planning.d.ts.map +0 -1
- package/dist/src/agents/planning.js +0 -63
- package/dist/src/agents/planning.js.map +0 -1
- package/dist/src/agents/research.d.ts +0 -2
- package/dist/src/agents/research.d.ts.map +0 -1
- package/dist/src/agents/research.js +0 -163
- package/dist/src/agents/research.js.map +0 -1
- package/dist/src/file-manager.d.ts +0 -43
- package/dist/src/file-manager.d.ts.map +0 -1
- package/dist/src/file-manager.js +0 -266
- package/dist/src/file-manager.js.map +0 -1
- package/dist/src/git-manager.d.ts +0 -79
- package/dist/src/git-manager.d.ts.map +0 -1
- package/dist/src/git-manager.js +0 -454
- package/dist/src/git-manager.js.map +0 -1
- package/dist/src/posthog-api.d.ts +0 -48
- package/dist/src/posthog-api.d.ts.map +0 -1
- package/dist/src/posthog-api.js +0 -260
- package/dist/src/posthog-api.js.map +0 -1
- package/dist/src/prompt-builder.d.ts +0 -49
- package/dist/src/prompt-builder.d.ts.map +0 -1
- package/dist/src/prompt-builder.js +0 -397
- package/dist/src/prompt-builder.js.map +0 -1
- package/dist/src/schemas.d.ts +0 -980
- package/dist/src/schemas.d.ts.map +0 -1
- package/dist/src/schemas.js +0 -196
- package/dist/src/schemas.js.map +0 -1
- package/dist/src/session-store.d.ts +0 -58
- package/dist/src/session-store.d.ts.map +0 -1
- package/dist/src/session-store.js +0 -206
- package/dist/src/session-store.js.map +0 -1
- package/dist/src/task-manager.d.ts +0 -25
- package/dist/src/task-manager.d.ts.map +0 -1
- package/dist/src/task-manager.js +0 -123
- package/dist/src/task-manager.js.map +0 -1
- package/dist/src/template-manager.d.ts +0 -30
- package/dist/src/template-manager.d.ts.map +0 -1
- package/dist/src/template-manager.js +0 -152
- package/dist/src/template-manager.js.map +0 -1
- package/dist/src/todo-manager.d.ts +0 -29
- package/dist/src/todo-manager.d.ts.map +0 -1
- package/dist/src/todo-manager.js +0 -135
- package/dist/src/todo-manager.js.map +0 -1
- package/dist/src/tools/registry.d.ts +0 -25
- package/dist/src/tools/registry.d.ts.map +0 -1
- package/dist/src/tools/registry.js +0 -120
- package/dist/src/tools/registry.js.map +0 -1
- package/dist/src/tools/types.d.ts +0 -80
- package/dist/src/tools/types.d.ts.map +0 -1
- package/dist/src/types.d.ts +0 -193
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -11
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils/logger.d.ts +0 -37
- package/dist/src/utils/logger.d.ts.map +0 -1
- package/dist/src/utils/logger.js +0 -83
- package/dist/src/utils/logger.js.map +0 -1
- package/dist/src/utils/tapped-stream.d.ts +0 -17
- package/dist/src/utils/tapped-stream.d.ts.map +0 -1
- package/dist/src/utils/tapped-stream.js +0 -45
- package/dist/src/utils/tapped-stream.js.map +0 -1
- package/dist/src/workflow/config.d.ts +0 -3
- package/dist/src/workflow/config.d.ts.map +0 -1
- package/dist/src/workflow/config.js +0 -54
- package/dist/src/workflow/config.js.map +0 -1
- package/dist/src/workflow/steps/build.d.ts +0 -3
- package/dist/src/workflow/steps/build.d.ts.map +0 -1
- package/dist/src/workflow/steps/build.js +0 -108
- package/dist/src/workflow/steps/build.js.map +0 -1
- package/dist/src/workflow/steps/finalize.d.ts +0 -3
- package/dist/src/workflow/steps/finalize.d.ts.map +0 -1
- package/dist/src/workflow/steps/finalize.js +0 -188
- package/dist/src/workflow/steps/finalize.js.map +0 -1
- package/dist/src/workflow/steps/plan.d.ts +0 -3
- package/dist/src/workflow/steps/plan.d.ts.map +0 -1
- package/dist/src/workflow/steps/plan.js +0 -136
- package/dist/src/workflow/steps/plan.js.map +0 -1
- package/dist/src/workflow/steps/research.d.ts +0 -3
- package/dist/src/workflow/steps/research.d.ts.map +0 -1
- package/dist/src/workflow/steps/research.js +0 -189
- package/dist/src/workflow/steps/research.js.map +0 -1
- package/dist/src/workflow/types.d.ts +0 -51
- package/dist/src/workflow/types.d.ts.map +0 -1
- package/dist/src/workflow/utils.d.ts +0 -12
- package/dist/src/workflow/utils.d.ts.map +0 -1
- package/dist/src/workflow/utils.js +0 -41
- package/dist/src/workflow/utils.js.map +0 -1
- package/dist/src/worktree-manager.d.ts +0 -39
- package/dist/src/worktree-manager.d.ts.map +0 -1
- package/dist/src/worktree-manager.js +0 -808
- package/dist/src/worktree-manager.js.map +0 -1
|
@@ -1,717 +0,0 @@
|
|
|
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
|