@weavelogic/knowledge-graph-agent 0.2.0 → 0.3.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/README.md +686 -304
- package/dist/_virtual/_commonjsHelpers.js +7 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/additionalItems.js +5 -0
- package/dist/_virtual/additionalItems.js.map +1 -0
- package/dist/_virtual/additionalProperties.js +5 -0
- package/dist/_virtual/additionalProperties.js.map +1 -0
- package/dist/_virtual/ajv.js +6 -0
- package/dist/_virtual/ajv.js.map +1 -0
- package/dist/_virtual/ajv2.js +5 -0
- package/dist/_virtual/ajv2.js.map +1 -0
- package/dist/_virtual/allOf.js +5 -0
- package/dist/_virtual/allOf.js.map +1 -0
- package/dist/_virtual/anyOf.js +5 -0
- package/dist/_virtual/anyOf.js.map +1 -0
- package/dist/_virtual/applicability.js +5 -0
- package/dist/_virtual/applicability.js.map +1 -0
- package/dist/_virtual/boolSchema.js +5 -0
- package/dist/_virtual/boolSchema.js.map +1 -0
- package/dist/_virtual/code.js +5 -0
- package/dist/_virtual/code.js.map +1 -0
- package/dist/_virtual/code2.js +5 -0
- package/dist/_virtual/code2.js.map +1 -0
- package/dist/_virtual/const.js +5 -0
- package/dist/_virtual/const.js.map +1 -0
- package/dist/_virtual/contains.js +5 -0
- package/dist/_virtual/contains.js.map +1 -0
- package/dist/_virtual/core.js +5 -0
- package/dist/_virtual/core.js.map +1 -0
- package/dist/_virtual/dataType.js +5 -0
- package/dist/_virtual/dataType.js.map +1 -0
- package/dist/_virtual/defaults.js +5 -0
- package/dist/_virtual/defaults.js.map +1 -0
- package/dist/_virtual/dependencies.js +5 -0
- package/dist/_virtual/dependencies.js.map +1 -0
- package/dist/_virtual/draft7.js +5 -0
- package/dist/_virtual/draft7.js.map +1 -0
- package/dist/_virtual/enum.js +5 -0
- package/dist/_virtual/enum.js.map +1 -0
- package/dist/_virtual/equal.js +5 -0
- package/dist/_virtual/equal.js.map +1 -0
- package/dist/_virtual/errors.js +5 -0
- package/dist/_virtual/errors.js.map +1 -0
- package/dist/_virtual/format.js +5 -0
- package/dist/_virtual/format.js.map +1 -0
- package/dist/_virtual/formats.js +5 -0
- package/dist/_virtual/formats.js.map +1 -0
- package/dist/_virtual/id.js +5 -0
- package/dist/_virtual/id.js.map +1 -0
- package/dist/_virtual/if.js +5 -0
- package/dist/_virtual/if.js.map +1 -0
- package/dist/_virtual/index.js +8 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index10.js +5 -0
- package/dist/_virtual/index10.js.map +1 -0
- package/dist/_virtual/index11.js +5 -0
- package/dist/_virtual/index11.js.map +1 -0
- package/dist/_virtual/index12.js +5 -0
- package/dist/_virtual/index12.js.map +1 -0
- package/dist/_virtual/index2.js +5 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/index3.js +5 -0
- package/dist/_virtual/index3.js.map +1 -0
- package/dist/_virtual/index4.js +5 -0
- package/dist/_virtual/index4.js.map +1 -0
- package/dist/_virtual/index5.js +5 -0
- package/dist/_virtual/index5.js.map +1 -0
- package/dist/_virtual/index6.js +5 -0
- package/dist/_virtual/index6.js.map +1 -0
- package/dist/_virtual/index7.js +5 -0
- package/dist/_virtual/index7.js.map +1 -0
- package/dist/_virtual/index8.js +5 -0
- package/dist/_virtual/index8.js.map +1 -0
- package/dist/_virtual/index9.js +5 -0
- package/dist/_virtual/index9.js.map +1 -0
- package/dist/_virtual/items.js +5 -0
- package/dist/_virtual/items.js.map +1 -0
- package/dist/_virtual/items2020.js +5 -0
- package/dist/_virtual/items2020.js.map +1 -0
- package/dist/_virtual/keyword.js +5 -0
- package/dist/_virtual/keyword.js.map +1 -0
- package/dist/_virtual/limit.js +5 -0
- package/dist/_virtual/limit.js.map +1 -0
- package/dist/_virtual/limitItems.js +5 -0
- package/dist/_virtual/limitItems.js.map +1 -0
- package/dist/_virtual/limitLength.js +5 -0
- package/dist/_virtual/limitLength.js.map +1 -0
- package/dist/_virtual/limitNumber.js +5 -0
- package/dist/_virtual/limitNumber.js.map +1 -0
- package/dist/_virtual/limitProperties.js +5 -0
- package/dist/_virtual/limitProperties.js.map +1 -0
- package/dist/_virtual/metadata.js +5 -0
- package/dist/_virtual/metadata.js.map +1 -0
- package/dist/_virtual/multipleOf.js +5 -0
- package/dist/_virtual/multipleOf.js.map +1 -0
- package/dist/_virtual/names.js +5 -0
- package/dist/_virtual/names.js.map +1 -0
- package/dist/_virtual/not.js +5 -0
- package/dist/_virtual/not.js.map +1 -0
- package/dist/_virtual/oneOf.js +5 -0
- package/dist/_virtual/oneOf.js.map +1 -0
- package/dist/_virtual/pattern.js +5 -0
- package/dist/_virtual/pattern.js.map +1 -0
- package/dist/_virtual/patternProperties.js +5 -0
- package/dist/_virtual/patternProperties.js.map +1 -0
- package/dist/_virtual/prefixItems.js +5 -0
- package/dist/_virtual/prefixItems.js.map +1 -0
- package/dist/_virtual/properties.js +5 -0
- package/dist/_virtual/properties.js.map +1 -0
- package/dist/_virtual/propertyNames.js +5 -0
- package/dist/_virtual/propertyNames.js.map +1 -0
- package/dist/_virtual/ref.js +5 -0
- package/dist/_virtual/ref.js.map +1 -0
- package/dist/_virtual/ref_error.js +5 -0
- package/dist/_virtual/ref_error.js.map +1 -0
- package/dist/_virtual/required.js +5 -0
- package/dist/_virtual/required.js.map +1 -0
- package/dist/_virtual/resolve.js +5 -0
- package/dist/_virtual/resolve.js.map +1 -0
- package/dist/_virtual/rules.js +5 -0
- package/dist/_virtual/rules.js.map +1 -0
- package/dist/_virtual/scope.js +5 -0
- package/dist/_virtual/scope.js.map +1 -0
- package/dist/_virtual/subschema.js +5 -0
- package/dist/_virtual/subschema.js.map +1 -0
- package/dist/_virtual/thenElse.js +5 -0
- package/dist/_virtual/thenElse.js.map +1 -0
- package/dist/_virtual/types.js +5 -0
- package/dist/_virtual/types.js.map +1 -0
- package/dist/_virtual/ucs2length.js +5 -0
- package/dist/_virtual/ucs2length.js.map +1 -0
- package/dist/_virtual/uniqueItems.js +5 -0
- package/dist/_virtual/uniqueItems.js.map +1 -0
- package/dist/_virtual/uri.js +5 -0
- package/dist/_virtual/uri.js.map +1 -0
- package/dist/_virtual/util.js +5 -0
- package/dist/_virtual/util.js.map +1 -0
- package/dist/_virtual/validation_error.js +5 -0
- package/dist/_virtual/validation_error.js.map +1 -0
- package/dist/agents/analyst-agent.d.ts +230 -0
- package/dist/agents/analyst-agent.d.ts.map +1 -0
- package/dist/agents/analyst-agent.js +793 -0
- package/dist/agents/analyst-agent.js.map +1 -0
- package/dist/agents/architect-agent.d.ts +248 -0
- package/dist/agents/architect-agent.d.ts.map +1 -0
- package/dist/agents/architect-agent.js +685 -0
- package/dist/agents/architect-agent.js.map +1 -0
- package/dist/agents/base-agent.d.ts +169 -0
- package/dist/agents/base-agent.d.ts.map +1 -0
- package/dist/agents/base-agent.js +441 -0
- package/dist/agents/base-agent.js.map +1 -0
- package/dist/agents/coder-agent.d.ts +191 -0
- package/dist/agents/coder-agent.d.ts.map +1 -0
- package/dist/agents/coder-agent.js +1008 -0
- package/dist/agents/coder-agent.js.map +1 -0
- package/dist/agents/index.d.ts +18 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +40 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/registry.d.ts +213 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/registry.js +419 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/researcher-agent.d.ts +226 -0
- package/dist/agents/researcher-agent.d.ts.map +1 -0
- package/dist/agents/researcher-agent.js +572 -0
- package/dist/agents/researcher-agent.js.map +1 -0
- package/dist/agents/rules-engine.d.ts +320 -0
- package/dist/agents/rules-engine.d.ts.map +1 -0
- package/dist/agents/rules-engine.js +552 -0
- package/dist/agents/rules-engine.js.map +1 -0
- package/dist/agents/tester-agent.d.ts +219 -0
- package/dist/agents/tester-agent.d.ts.map +1 -0
- package/dist/agents/tester-agent.js +683 -0
- package/dist/agents/tester-agent.js.map +1 -0
- package/dist/agents/types.d.ts +425 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +57 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/caching/index.d.ts +55 -0
- package/dist/caching/index.d.ts.map +1 -0
- package/dist/caching/index.js +206 -0
- package/dist/caching/index.js.map +1 -0
- package/dist/caching/lru-cache.d.ts +254 -0
- package/dist/caching/lru-cache.d.ts.map +1 -0
- package/dist/caching/types.d.ts +95 -0
- package/dist/caching/types.d.ts.map +1 -0
- package/dist/chunking/chunker.d.ts +94 -0
- package/dist/chunking/chunker.d.ts.map +1 -0
- package/dist/chunking/index.d.ts +125 -0
- package/dist/chunking/index.d.ts.map +1 -0
- package/dist/chunking/index.js +283 -0
- package/dist/chunking/index.js.map +1 -0
- package/dist/chunking/types.d.ts +92 -0
- package/dist/chunking/types.d.ts.map +1 -0
- package/dist/cli/commands/commit.d.ts +11 -0
- package/dist/cli/commands/commit.d.ts.map +1 -0
- package/dist/cli/commands/commit.js +379 -0
- package/dist/cli/commands/commit.js.map +1 -0
- package/dist/cli/commands/config.d.ts +8 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +107 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/cultivate.d.ts +16 -0
- package/dist/cli/commands/cultivate.d.ts.map +1 -0
- package/dist/cli/commands/cultivate.js +254 -0
- package/dist/cli/commands/cultivate.js.map +1 -0
- package/dist/cli/commands/diagnostics.d.ts +8 -0
- package/dist/cli/commands/diagnostics.d.ts.map +1 -0
- package/dist/cli/commands/diagnostics.js +140 -0
- package/dist/cli/commands/diagnostics.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +13 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/init-primitives.d.ts +19 -0
- package/dist/cli/commands/init-primitives.d.ts.map +1 -0
- package/dist/cli/commands/init-primitives.js +208 -0
- package/dist/cli/commands/init-primitives.js.map +1 -0
- package/dist/cli/commands/sop.d.ts +14 -0
- package/dist/cli/commands/sop.d.ts.map +1 -0
- package/dist/cli/commands/sop.js +598 -0
- package/dist/cli/commands/sop.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +40 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +153 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +141 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/manager.d.ts +136 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/config/types.d.ts +127 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/core/cache.d.ts +185 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/cache.js +435 -0
- package/dist/core/cache.js.map +1 -0
- package/dist/cultivation/deep-analyzer.d.ts +129 -0
- package/dist/cultivation/deep-analyzer.d.ts.map +1 -0
- package/dist/cultivation/deep-analyzer.js +322 -0
- package/dist/cultivation/deep-analyzer.js.map +1 -0
- package/dist/cultivation/index.d.ts +13 -0
- package/dist/cultivation/index.d.ts.map +1 -0
- package/dist/cultivation/seed-generator.d.ts +92 -0
- package/dist/cultivation/seed-generator.d.ts.map +1 -0
- package/dist/cultivation/seed-generator.js +1033 -0
- package/dist/cultivation/seed-generator.js.map +1 -0
- package/dist/cultivation/types.d.ts +230 -0
- package/dist/cultivation/types.d.ts.map +1 -0
- package/dist/generators/claude-md.d.ts +7 -0
- package/dist/generators/claude-md.d.ts.map +1 -1
- package/dist/generators/claude-md.js.map +1 -1
- package/dist/generators/docs-init.d.ts +6 -0
- package/dist/generators/docs-init.d.ts.map +1 -1
- package/dist/generators/docs-init.js.map +1 -1
- package/dist/health/checks.d.ts +135 -0
- package/dist/health/checks.d.ts.map +1 -0
- package/dist/health/index.d.ts +119 -0
- package/dist/health/index.d.ts.map +1 -0
- package/dist/health/index.js +191 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/monitor.d.ts +146 -0
- package/dist/health/monitor.d.ts.map +1 -0
- package/dist/health/types.d.ts +135 -0
- package/dist/health/types.d.ts.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +173 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/auto-commit.d.ts +175 -0
- package/dist/integrations/auto-commit.d.ts.map +1 -0
- package/dist/integrations/auto-commit.js +399 -0
- package/dist/integrations/auto-commit.js.map +1 -0
- package/dist/integrations/git.d.ts +299 -0
- package/dist/integrations/git.d.ts.map +1 -0
- package/dist/integrations/git.js +465 -0
- package/dist/integrations/git.js.map +1 -0
- package/dist/mcp-server/bin.d.ts +11 -0
- package/dist/mcp-server/bin.d.ts.map +1 -0
- package/dist/mcp-server/handlers/index.d.ts +57 -0
- package/dist/mcp-server/handlers/index.d.ts.map +1 -0
- package/dist/mcp-server/handlers/index.js +235 -0
- package/dist/mcp-server/handlers/index.js.map +1 -0
- package/dist/mcp-server/index.d.ts +28 -0
- package/dist/mcp-server/index.d.ts.map +1 -0
- package/dist/mcp-server/server.d.ts +133 -0
- package/dist/mcp-server/server.d.ts.map +1 -0
- package/dist/mcp-server/server.js +280 -0
- package/dist/mcp-server/server.js.map +1 -0
- package/dist/mcp-server/tools/agents/index.d.ts +10 -0
- package/dist/mcp-server/tools/agents/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/agents/list.d.ts +19 -0
- package/dist/mcp-server/tools/agents/list.d.ts.map +1 -0
- package/dist/mcp-server/tools/agents/spawn.d.ts +19 -0
- package/dist/mcp-server/tools/agents/spawn.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/generate.d.ts +21 -0
- package/dist/mcp-server/tools/graph/generate.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/index.d.ts +11 -0
- package/dist/mcp-server/tools/graph/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/query.d.ts +22 -0
- package/dist/mcp-server/tools/graph/query.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/stats.d.ts +22 -0
- package/dist/mcp-server/tools/graph/stats.d.ts.map +1 -0
- package/dist/mcp-server/tools/health.d.ts +21 -0
- package/dist/mcp-server/tools/health.d.ts.map +1 -0
- package/dist/mcp-server/tools/index.d.ts +13 -0
- package/dist/mcp-server/tools/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/registry.d.ts +90 -0
- package/dist/mcp-server/tools/registry.d.ts.map +1 -0
- package/dist/mcp-server/tools/registry.js +663 -0
- package/dist/mcp-server/tools/registry.js.map +1 -0
- package/dist/mcp-server/tools/search/index.d.ts +10 -0
- package/dist/mcp-server/tools/search/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/search/nodes.d.ts +22 -0
- package/dist/mcp-server/tools/search/nodes.d.ts.map +1 -0
- package/dist/mcp-server/tools/search/tags.d.ts +22 -0
- package/dist/mcp-server/tools/search/tags.d.ts.map +1 -0
- package/dist/mcp-server/types/index.d.ts +286 -0
- package/dist/mcp-server/types/index.d.ts.map +1 -0
- package/dist/memory/index.d.ts +10 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/vault-sync.d.ts +212 -0
- package/dist/memory/vault-sync.d.ts.map +1 -0
- package/dist/memory/vault-sync.js +463 -0
- package/dist/memory/vault-sync.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +296 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +71 -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 +26 -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 +407 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1332 -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 +71 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
- package/dist/node_modules/ajv/dist/ajv.js +84 -0
- package/dist/node_modules/ajv/dist/ajv.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js +160 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js +728 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js +152 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/errors.js +131 -0
- package/dist/node_modules/ajv/dist/compile/errors.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/index.js +234 -0
- package/dist/node_modules/ajv/dist/compile/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/names.js +44 -0
- package/dist/node_modules/ajv/dist/compile/names.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js +22 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js +163 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/rules.js +35 -0
- package/dist/node_modules/ajv/dist/compile/rules.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/util.js +173 -0
- package/dist/node_modules/ajv/dist/compile/util.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js +27 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +58 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js +193 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js +43 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js +522 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js +126 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js +89 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
- package/dist/node_modules/ajv/dist/core.js +628 -0
- package/dist/node_modules/ajv/dist/core.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js +24 -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 +25 -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 +16 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js +30 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js +16 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js +20 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +59 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +114 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +32 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +22 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +100 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +103 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +75 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +68 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +64 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +43 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +36 -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 +81 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +22 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +66 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +49 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +23 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js +140 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js +19 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js +27 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +132 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +114 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +18 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js +31 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js +95 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js +16 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js +27 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +36 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +56 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +52 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +34 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +39 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +37 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +34 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +33 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +34 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +89 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +75 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/formats.js +209 -0
- package/dist/node_modules/ajv-formats/dist/formats.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/index.js +51 -0
- package/dist/node_modules/ajv-formats/dist/index.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/limit.js +80 -0
- package/dist/node_modules/ajv-formats/dist/limit.js.map +1 -0
- package/dist/node_modules/fast-deep-equal/index.js +39 -0
- package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
- package/dist/node_modules/fast-uri/index.js +261 -0
- package/dist/node_modules/fast-uri/index.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/schemes.js +215 -0
- package/dist/node_modules/fast-uri/lib/schemes.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/utils.js +261 -0
- package/dist/node_modules/fast-uri/lib/utils.js.map +1 -0
- package/dist/node_modules/json-schema-traverse/index.js +92 -0
- package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.js +37 -0
- package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.js +43 -0
- package/dist/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.js +13 -0
- package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.js +688 -0
- package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/api.js +492 -0
- package/dist/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.js +405 -0
- package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/zod/v4/core/core.js +58 -0
- package/dist/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.js +38 -0
- package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.js +82 -0
- package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.js +60 -0
- package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.js +87 -0
- package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.js +52 -0
- package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.js +1283 -0
- package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/util.js +341 -0
- package/dist/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.js +9 -0
- package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +2 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
- package/dist/reasoning/index.d.ts +74 -0
- package/dist/reasoning/index.d.ts.map +1 -0
- package/dist/reasoning/index.js +124 -0
- package/dist/reasoning/index.js.map +1 -0
- package/dist/reasoning/tracker.d.ts +210 -0
- package/dist/reasoning/tracker.d.ts.map +1 -0
- package/dist/reasoning/types.d.ts +146 -0
- package/dist/reasoning/types.d.ts.map +1 -0
- package/dist/recovery/backup.d.ts +110 -0
- package/dist/recovery/backup.d.ts.map +1 -0
- package/dist/recovery/index.d.ts +70 -0
- package/dist/recovery/index.d.ts.map +1 -0
- package/dist/recovery/index.js +186 -0
- package/dist/recovery/index.js.map +1 -0
- package/dist/recovery/integrity.d.ts +74 -0
- package/dist/recovery/integrity.d.ts.map +1 -0
- package/dist/recovery/types.d.ts +94 -0
- package/dist/recovery/types.d.ts.map +1 -0
- package/dist/services/index.d.ts +130 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +134 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/manager.d.ts +140 -0
- package/dist/services/manager.d.ts.map +1 -0
- package/dist/services/types.d.ts +106 -0
- package/dist/services/types.d.ts.map +1 -0
- package/dist/services/watchers.d.ts +95 -0
- package/dist/services/watchers.d.ts.map +1 -0
- package/dist/sops/compliance-checker.d.ts +83 -0
- package/dist/sops/compliance-checker.d.ts.map +1 -0
- package/dist/sops/compliance-checker.js +399 -0
- package/dist/sops/compliance-checker.js.map +1 -0
- package/dist/sops/gap-analyzer.d.ts +124 -0
- package/dist/sops/gap-analyzer.d.ts.map +1 -0
- package/dist/sops/gap-analyzer.js +313 -0
- package/dist/sops/gap-analyzer.js.map +1 -0
- package/dist/sops/index.d.ts +14 -0
- package/dist/sops/index.d.ts.map +1 -0
- package/dist/sops/overlay-manager.d.ts +115 -0
- package/dist/sops/overlay-manager.d.ts.map +1 -0
- package/dist/sops/overlay-manager.js +394 -0
- package/dist/sops/overlay-manager.js.map +1 -0
- package/dist/sops/registry.d.ts +73 -0
- package/dist/sops/registry.d.ts.map +1 -0
- package/dist/sops/registry.js +919 -0
- package/dist/sops/registry.js.map +1 -0
- package/dist/sops/types.d.ts +377 -0
- package/dist/sops/types.d.ts.map +1 -0
- package/dist/sops/types.js +46 -0
- package/dist/sops/types.js.map +1 -0
- package/dist/utils/error-recovery.d.ts +230 -0
- package/dist/utils/error-recovery.d.ts.map +1 -0
- package/dist/utils/error-recovery.js +228 -0
- package/dist/utils/error-recovery.js.map +1 -0
- package/dist/utils/error-taxonomy.d.ts +149 -0
- package/dist/utils/error-taxonomy.d.ts.map +1 -0
- package/dist/utils/error-taxonomy.js +260 -0
- package/dist/utils/error-taxonomy.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +139 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +311 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/workflows/index.d.ts +11 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/registry.d.ts +118 -0
- package/dist/workflows/registry.d.ts.map +1 -0
- package/dist/workflows/registry.js +575 -0
- package/dist/workflows/registry.js.map +1 -0
- package/dist/workflows/types.d.ts +322 -0
- package/dist/workflows/types.d.ts.map +1 -0
- package/dist/workflows/types.js +16 -0
- package/dist/workflows/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { McpError, ErrorCode } from "../../node_modules/@modelcontextprotocol/sdk/dist/esm/types.js";
|
|
2
|
+
import { createLogger } from "../../utils/logger.js";
|
|
3
|
+
import { getToolHandler } from "../tools/registry.js";
|
|
4
|
+
const logger = createLogger("mcp-handler");
|
|
5
|
+
async function handleToolCall(request) {
|
|
6
|
+
const startTime = Date.now();
|
|
7
|
+
const { name: toolName, arguments: params = {} } = request.params;
|
|
8
|
+
logger.debug("Handling tool call", { toolName, paramKeys: Object.keys(params || {}) });
|
|
9
|
+
({
|
|
10
|
+
requestId: generateRequestId()
|
|
11
|
+
});
|
|
12
|
+
try {
|
|
13
|
+
const handler = getToolHandler(toolName);
|
|
14
|
+
if (!handler) {
|
|
15
|
+
logger.warn(`Unknown tool requested: ${toolName}`);
|
|
16
|
+
throw new McpError(
|
|
17
|
+
ErrorCode.MethodNotFound,
|
|
18
|
+
`Unknown tool: ${toolName}`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
validateParams(params, toolName);
|
|
22
|
+
const result = await handler(params);
|
|
23
|
+
const executionTime = Date.now() - startTime;
|
|
24
|
+
logger.debug(`Tool ${toolName} completed in ${executionTime}ms`, {
|
|
25
|
+
success: result.success,
|
|
26
|
+
hasData: !!result.data
|
|
27
|
+
});
|
|
28
|
+
return formatResponse(result, executionTime);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
const executionTime = Date.now() - startTime;
|
|
31
|
+
logger.error(
|
|
32
|
+
`Tool ${toolName} failed after ${executionTime}ms`,
|
|
33
|
+
error instanceof Error ? error : void 0
|
|
34
|
+
);
|
|
35
|
+
if (error instanceof McpError) {
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
throw new McpError(
|
|
39
|
+
ErrorCode.InternalError,
|
|
40
|
+
`Tool execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const VALIDATION_LIMITS = {
|
|
45
|
+
MAX_OBJECT_DEPTH: 10,
|
|
46
|
+
MAX_ARRAY_LENGTH: 1e3,
|
|
47
|
+
MAX_STRING_LENGTH: 1e5
|
|
48
|
+
};
|
|
49
|
+
function validateParams(params, toolName) {
|
|
50
|
+
if (params === null || params === void 0) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (typeof params !== "object" || Array.isArray(params)) {
|
|
54
|
+
throw new McpError(
|
|
55
|
+
ErrorCode.InvalidParams,
|
|
56
|
+
`Invalid parameters for tool ${toolName}: expected object, got ${Array.isArray(params) ? "array" : typeof params}`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
validateValueRecursive(params, toolName, "", 0);
|
|
60
|
+
}
|
|
61
|
+
function validateValueRecursive(value, toolName, path, depth) {
|
|
62
|
+
if (depth > VALIDATION_LIMITS.MAX_OBJECT_DEPTH) {
|
|
63
|
+
throw new McpError(
|
|
64
|
+
ErrorCode.InvalidParams,
|
|
65
|
+
`Parameter nesting too deep at ${path || "root"} for tool ${toolName}: maximum depth is ${VALIDATION_LIMITS.MAX_OBJECT_DEPTH} levels`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
if (value === null || value === void 0) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (typeof value === "string") {
|
|
72
|
+
validateString(value, toolName, path);
|
|
73
|
+
} else if (Array.isArray(value)) {
|
|
74
|
+
validateArray(value, toolName, path, depth);
|
|
75
|
+
} else if (typeof value === "object") {
|
|
76
|
+
validateObject(value, toolName, path, depth);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function validateString(value, toolName, path) {
|
|
80
|
+
const paramName = path || "value";
|
|
81
|
+
if (value.length > VALIDATION_LIMITS.MAX_STRING_LENGTH) {
|
|
82
|
+
throw new McpError(
|
|
83
|
+
ErrorCode.InvalidParams,
|
|
84
|
+
`Parameter ${paramName} exceeds maximum length (${VALIDATION_LIMITS.MAX_STRING_LENGTH} characters) for tool ${toolName}`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (isPathLike(path) && containsPathTraversal(value)) {
|
|
88
|
+
throw new McpError(
|
|
89
|
+
ErrorCode.InvalidParams,
|
|
90
|
+
`Parameter ${paramName} contains invalid path traversal sequence for tool ${toolName}`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (value.includes("\0")) {
|
|
94
|
+
throw new McpError(
|
|
95
|
+
ErrorCode.InvalidParams,
|
|
96
|
+
`Parameter ${paramName} contains invalid null byte for tool ${toolName}`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function validateArray(value, toolName, path, depth) {
|
|
101
|
+
const paramName = path || "array";
|
|
102
|
+
if (value.length > VALIDATION_LIMITS.MAX_ARRAY_LENGTH) {
|
|
103
|
+
throw new McpError(
|
|
104
|
+
ErrorCode.InvalidParams,
|
|
105
|
+
`Parameter ${paramName} exceeds maximum array length (${VALIDATION_LIMITS.MAX_ARRAY_LENGTH} items) for tool ${toolName}`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
for (let i = 0; i < value.length; i++) {
|
|
109
|
+
validateValueRecursive(value[i], toolName, `${path}[${i}]`, depth + 1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function validateObject(value, toolName, path, depth) {
|
|
113
|
+
for (const [key, propValue] of Object.entries(value)) {
|
|
114
|
+
const propPath = path ? `${path}.${key}` : key;
|
|
115
|
+
validateValueRecursive(propValue, toolName, propPath, depth + 1);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function isPathLike(paramPath) {
|
|
119
|
+
const pathIndicators = [
|
|
120
|
+
"path",
|
|
121
|
+
"file",
|
|
122
|
+
"dir",
|
|
123
|
+
"directory",
|
|
124
|
+
"folder",
|
|
125
|
+
"location",
|
|
126
|
+
"source",
|
|
127
|
+
"dest",
|
|
128
|
+
"destination",
|
|
129
|
+
"target",
|
|
130
|
+
"uri",
|
|
131
|
+
"url"
|
|
132
|
+
];
|
|
133
|
+
const lowerPath = paramPath.toLowerCase();
|
|
134
|
+
return pathIndicators.some(
|
|
135
|
+
(indicator) => lowerPath.includes(indicator) || lowerPath.endsWith(indicator)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
function containsPathTraversal(value) {
|
|
139
|
+
if (value.includes("..")) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
const decoded = decodeURIComponent(value.toLowerCase());
|
|
144
|
+
if (decoded.includes("..")) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
} catch {
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
function formatResponse(result, executionTime) {
|
|
152
|
+
const enrichedResult = {
|
|
153
|
+
...result,
|
|
154
|
+
metadata: {
|
|
155
|
+
...result.metadata,
|
|
156
|
+
executionTime
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
content: [
|
|
161
|
+
{
|
|
162
|
+
type: "text",
|
|
163
|
+
text: JSON.stringify(enrichedResult, null, 2)
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function generateRequestId() {
|
|
169
|
+
return `req_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
170
|
+
}
|
|
171
|
+
function handleError(error, context) {
|
|
172
|
+
logger.error(
|
|
173
|
+
`Tool execution error: ${context.toolName}`,
|
|
174
|
+
error instanceof Error ? error : void 0,
|
|
175
|
+
{ requestId: context.requestId }
|
|
176
|
+
);
|
|
177
|
+
if (error instanceof McpError) {
|
|
178
|
+
return error;
|
|
179
|
+
}
|
|
180
|
+
if (error instanceof Error) {
|
|
181
|
+
if (error.message.includes("not found") || error.message.includes("does not exist")) {
|
|
182
|
+
return new McpError(
|
|
183
|
+
ErrorCode.InvalidParams,
|
|
184
|
+
`${context.toolName} failed: ${error.message}`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
if (error.message.includes("permission") || error.message.includes("unauthorized")) {
|
|
188
|
+
return new McpError(
|
|
189
|
+
ErrorCode.InvalidRequest,
|
|
190
|
+
`${context.toolName} failed: ${error.message}`
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
if (error.message.includes("timeout")) {
|
|
194
|
+
return new McpError(
|
|
195
|
+
ErrorCode.InternalError,
|
|
196
|
+
`${context.toolName} timed out: ${error.message}`
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
return new McpError(
|
|
200
|
+
ErrorCode.InternalError,
|
|
201
|
+
`${context.toolName} failed: ${error.message}`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return new McpError(
|
|
205
|
+
ErrorCode.InternalError,
|
|
206
|
+
`${context.toolName} failed: ${String(error)}`
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
function createErrorResult(error, toolName) {
|
|
210
|
+
return {
|
|
211
|
+
success: false,
|
|
212
|
+
error: error instanceof Error ? error.message : String(error),
|
|
213
|
+
metadata: {
|
|
214
|
+
toolName,
|
|
215
|
+
timestamp: Date.now()
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function createSuccessResult(data, metadata) {
|
|
220
|
+
return {
|
|
221
|
+
success: true,
|
|
222
|
+
data,
|
|
223
|
+
metadata: {
|
|
224
|
+
...metadata,
|
|
225
|
+
timestamp: Date.now()
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
export {
|
|
230
|
+
createErrorResult,
|
|
231
|
+
createSuccessResult,
|
|
232
|
+
handleError,
|
|
233
|
+
handleToolCall
|
|
234
|
+
};
|
|
235
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/mcp-server/handlers/index.ts"],"sourcesContent":["/**\n * MCP Tool Request Handler\n *\n * Handles incoming tool call requests from MCP clients.\n * Validates parameters, executes handlers, and formats responses.\n *\n * @module mcp-server/handlers\n */\n\nimport {\n ErrorCode,\n McpError,\n type CallToolResult,\n} from '@modelcontextprotocol/sdk/types.js';\nimport type { ToolContext, ToolResult } from '../types/index.js';\nimport { createLogger } from '../../utils/index.js';\nimport { getToolHandler } from '../tools/registry.js';\n\nconst logger = createLogger('mcp-handler');\n\n/**\n * MCP CallToolRequest params structure\n */\ninterface CallToolParams {\n name: string;\n arguments?: Record<string, unknown>;\n}\n\n/**\n * MCP request structure\n */\ninterface MCPRequest {\n params: CallToolParams;\n}\n\n/**\n * Handle tool call requests from MCP clients\n *\n * @param request - MCP call tool request\n * @returns MCP response with tool result\n * @throws McpError if tool not found or execution fails\n */\nexport async function handleToolCall(request: MCPRequest): Promise<CallToolResult> {\n const startTime = Date.now();\n const { name: toolName, arguments: params = {} } = request.params;\n\n // Log only parameter keys, not values, to avoid exposing sensitive data\n logger.debug('Handling tool call', { toolName, paramKeys: Object.keys(params || {}) });\n\n const context: ToolContext = {\n toolName,\n params,\n timestamp: startTime,\n requestId: generateRequestId(),\n };\n\n try {\n // Get handler from registry\n const handler = getToolHandler(toolName);\n\n if (!handler) {\n logger.warn(`Unknown tool requested: ${toolName}`);\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Unknown tool: ${toolName}`\n );\n }\n\n // Validate parameters\n validateParams(params, toolName);\n\n // Execute handler\n const result = await handler(params);\n\n const executionTime = Date.now() - startTime;\n logger.debug(`Tool ${toolName} completed in ${executionTime}ms`, {\n success: result.success,\n hasData: !!result.data,\n });\n\n // Format response\n return formatResponse(result, executionTime);\n } catch (error) {\n const executionTime = Date.now() - startTime;\n logger.error(\n `Tool ${toolName} failed after ${executionTime}ms`,\n error instanceof Error ? error : undefined\n );\n\n // Re-throw MCP errors as-is\n if (error instanceof McpError) {\n throw error;\n }\n\n // Wrap other errors\n throw new McpError(\n ErrorCode.InternalError,\n `Tool execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n\n/**\n * Security constants for input validation\n *\n * SECURITY: These limits prevent various attack vectors:\n * - MAX_OBJECT_DEPTH: Prevents stack overflow from deeply nested objects\n * - MAX_ARRAY_LENGTH: Prevents memory exhaustion from large arrays\n * - MAX_STRING_LENGTH: Prevents DoS from excessively long strings\n */\nconst VALIDATION_LIMITS = {\n MAX_OBJECT_DEPTH: 10,\n MAX_ARRAY_LENGTH: 1000,\n MAX_STRING_LENGTH: 100000,\n} as const;\n\n/**\n * Validate tool parameters with comprehensive security checks\n *\n * SECURITY: This function performs multi-layered input validation to protect against:\n * 1. Stack overflow attacks via deeply nested objects (max 10 levels)\n * 2. Memory exhaustion via large arrays (max 1000 items)\n * 3. DoS via excessively long strings (max 100000 chars)\n * 4. Path traversal attacks via '..' sequences and null bytes in paths\n *\n * @param params - Parameters to validate\n * @param toolName - Tool name for error messages\n * @throws McpError if parameters are invalid or potentially malicious\n */\nfunction validateParams(params: unknown, toolName: string): void {\n // Null/undefined is valid (empty params)\n if (params === null || params === undefined) {\n return;\n }\n\n // Must be an object\n if (typeof params !== 'object' || Array.isArray(params)) {\n throw new McpError(\n ErrorCode.InvalidParams,\n `Invalid parameters for tool ${toolName}: expected object, got ${Array.isArray(params) ? 'array' : typeof params}`\n );\n }\n\n // SECURITY: Perform recursive validation with depth tracking\n validateValueRecursive(params, toolName, '', 0);\n}\n\n/**\n * Recursively validate a value with security checks\n *\n * SECURITY: Validates nested structures to prevent:\n * - Deep nesting attacks (stack overflow)\n * - Large array attacks (memory exhaustion)\n * - Path traversal in string values\n * - Null byte injection\n *\n * @param value - Value to validate\n * @param toolName - Tool name for error context\n * @param path - Current property path for error messages\n * @param depth - Current nesting depth\n * @throws McpError if validation fails\n */\nfunction validateValueRecursive(\n value: unknown,\n toolName: string,\n path: string,\n depth: number\n): void {\n // SECURITY: Prevent stack overflow from deeply nested objects\n // Attackers may send deeply nested JSON to exhaust call stack\n if (depth > VALIDATION_LIMITS.MAX_OBJECT_DEPTH) {\n throw new McpError(\n ErrorCode.InvalidParams,\n `Parameter nesting too deep at ${path || 'root'} for tool ${toolName}: ` +\n `maximum depth is ${VALIDATION_LIMITS.MAX_OBJECT_DEPTH} levels`\n );\n }\n\n // Handle null/undefined (valid leaf values)\n if (value === null || value === undefined) {\n return;\n }\n\n // Validate based on type\n if (typeof value === 'string') {\n validateString(value, toolName, path);\n } else if (Array.isArray(value)) {\n validateArray(value, toolName, path, depth);\n } else if (typeof value === 'object') {\n validateObject(value as Record<string, unknown>, toolName, path, depth);\n }\n // Primitives (number, boolean) are always valid\n}\n\n/**\n * Validate string values for security issues\n *\n * SECURITY: Checks for:\n * - Excessive length (DoS prevention)\n * - Path traversal sequences (..)\n * - Null byte injection (\\x00)\n *\n * @param value - String value to validate\n * @param toolName - Tool name for error context\n * @param path - Property path for error messages\n * @throws McpError if string contains malicious content\n */\nfunction validateString(value: string, toolName: string, path: string): void {\n const paramName = path || 'value';\n\n // SECURITY: Check for excessively long strings (potential DoS)\n // Large strings can exhaust memory or cause slow processing\n if (value.length > VALIDATION_LIMITS.MAX_STRING_LENGTH) {\n throw new McpError(\n ErrorCode.InvalidParams,\n `Parameter ${paramName} exceeds maximum length (${VALIDATION_LIMITS.MAX_STRING_LENGTH} characters) for tool ${toolName}`\n );\n }\n\n // SECURITY: Check for path traversal attacks\n // Detects attempts to escape directory boundaries using '..' sequences\n // This prevents unauthorized file system access\n if (isPathLike(path) && containsPathTraversal(value)) {\n throw new McpError(\n ErrorCode.InvalidParams,\n `Parameter ${paramName} contains invalid path traversal sequence for tool ${toolName}`\n );\n }\n\n // SECURITY: Check for null byte injection\n // Null bytes can truncate strings in C-based systems, potentially bypassing validation\n // They have no legitimate use in parameter values\n if (value.includes('\\x00')) {\n throw new McpError(\n ErrorCode.InvalidParams,\n `Parameter ${paramName} contains invalid null byte for tool ${toolName}`\n );\n }\n}\n\n/**\n * Validate array values for security issues\n *\n * SECURITY: Prevents memory exhaustion from excessively large arrays\n *\n * @param value - Array to validate\n * @param toolName - Tool name for error context\n * @param path - Property path for error messages\n * @param depth - Current nesting depth\n * @throws McpError if array is too large or contains invalid items\n */\nfunction validateArray(\n value: unknown[],\n toolName: string,\n path: string,\n depth: number\n): void {\n const paramName = path || 'array';\n\n // SECURITY: Check for excessively large arrays (memory exhaustion prevention)\n // Large arrays can consume excessive memory during processing\n if (value.length > VALIDATION_LIMITS.MAX_ARRAY_LENGTH) {\n throw new McpError(\n ErrorCode.InvalidParams,\n `Parameter ${paramName} exceeds maximum array length (${VALIDATION_LIMITS.MAX_ARRAY_LENGTH} items) for tool ${toolName}`\n );\n }\n\n // Recursively validate each array element\n for (let i = 0; i < value.length; i++) {\n validateValueRecursive(value[i], toolName, `${path}[${i}]`, depth + 1);\n }\n}\n\n/**\n * Validate object values recursively\n *\n * @param value - Object to validate\n * @param toolName - Tool name for error context\n * @param path - Property path for error messages\n * @param depth - Current nesting depth\n * @throws McpError if object contains invalid values\n */\nfunction validateObject(\n value: Record<string, unknown>,\n toolName: string,\n path: string,\n depth: number\n): void {\n for (const [key, propValue] of Object.entries(value)) {\n const propPath = path ? `${path}.${key}` : key;\n validateValueRecursive(propValue, toolName, propPath, depth + 1);\n }\n}\n\n/**\n * Check if a parameter path suggests it contains a file/directory path\n *\n * SECURITY: Identifies path-like parameters that should be checked for traversal attacks\n *\n * @param paramPath - The parameter's property path (e.g., \"config.filePath\")\n * @returns True if the parameter name suggests it's a path\n */\nfunction isPathLike(paramPath: string): boolean {\n const pathIndicators = [\n 'path',\n 'file',\n 'dir',\n 'directory',\n 'folder',\n 'location',\n 'source',\n 'dest',\n 'destination',\n 'target',\n 'uri',\n 'url',\n ];\n\n const lowerPath = paramPath.toLowerCase();\n return pathIndicators.some(\n (indicator) => lowerPath.includes(indicator) || lowerPath.endsWith(indicator)\n );\n}\n\n/**\n * Check if a string contains path traversal sequences\n *\n * SECURITY: Detects various forms of path traversal attacks:\n * - Direct '..' sequences\n * - URL-encoded '..' (%2e%2e)\n * - Mixed encoding\n *\n * @param value - String to check for path traversal\n * @returns True if path traversal detected\n */\nfunction containsPathTraversal(value: string): boolean {\n // SECURITY: Check for literal '..' path traversal\n if (value.includes('..')) {\n return true;\n }\n\n // SECURITY: Check for URL-encoded path traversal\n // %2e is URL-encoded '.', so %2e%2e or %2e. or .%2e are all '..'\n try {\n const decoded = decodeURIComponent(value.toLowerCase());\n if (decoded.includes('..')) {\n return true;\n }\n } catch {\n // If decoding fails, the string may contain malformed encoding\n // which is suspicious but not necessarily path traversal\n }\n\n return false;\n}\n\n/**\n * Format tool result as MCP response\n *\n * @param result - Tool execution result\n * @param executionTime - Execution time in milliseconds\n * @returns Formatted MCP response\n */\nfunction formatResponse(result: ToolResult, executionTime: number): CallToolResult {\n // Add execution time to metadata\n const enrichedResult: ToolResult = {\n ...result,\n metadata: {\n ...result.metadata,\n executionTime,\n },\n };\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(enrichedResult, null, 2),\n },\n ],\n };\n}\n\n/**\n * Generate unique request ID for tracing\n */\nfunction generateRequestId(): string {\n return `req_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n}\n\n/**\n * Handle errors and convert to MCP errors\n *\n * @param error - Original error\n * @param context - Tool execution context\n * @returns MCP error\n */\nexport function handleError(error: unknown, context: ToolContext): McpError {\n logger.error(\n `Tool execution error: ${context.toolName}`,\n error instanceof Error ? error : undefined,\n { requestId: context.requestId }\n );\n\n // Return as-is if already MCP error\n if (error instanceof McpError) {\n return error;\n }\n\n // Handle specific error types\n if (error instanceof Error) {\n // Check for known error patterns\n if (error.message.includes('not found') || error.message.includes('does not exist')) {\n return new McpError(\n ErrorCode.InvalidParams,\n `${context.toolName} failed: ${error.message}`\n );\n }\n\n if (error.message.includes('permission') || error.message.includes('unauthorized')) {\n return new McpError(\n ErrorCode.InvalidRequest,\n `${context.toolName} failed: ${error.message}`\n );\n }\n\n if (error.message.includes('timeout')) {\n return new McpError(\n ErrorCode.InternalError,\n `${context.toolName} timed out: ${error.message}`\n );\n }\n\n // Generic error\n return new McpError(\n ErrorCode.InternalError,\n `${context.toolName} failed: ${error.message}`\n );\n }\n\n // Unknown error type\n return new McpError(\n ErrorCode.InternalError,\n `${context.toolName} failed: ${String(error)}`\n );\n}\n\n/**\n * Create error response for tool failures\n *\n * @param error - Error message or object\n * @param toolName - Tool that failed\n * @returns Tool result indicating failure\n */\nexport function createErrorResult(error: unknown, toolName: string): ToolResult {\n return {\n success: false,\n error: error instanceof Error ? error.message : String(error),\n metadata: {\n toolName,\n timestamp: Date.now(),\n },\n };\n}\n\n/**\n * Create success response for tool results\n *\n * @param data - Result data\n * @param metadata - Additional metadata\n * @returns Tool result indicating success\n */\nexport function createSuccessResult(\n data: unknown,\n metadata?: Record<string, unknown>\n): ToolResult {\n return {\n success: true,\n data,\n metadata: {\n ...metadata,\n timestamp: Date.now(),\n },\n };\n}\n"],"names":[],"mappings":";;;AAkBA,MAAM,SAAS,aAAa,aAAa;AAwBzC,eAAsB,eAAe,SAA8C;AACjF,QAAM,YAAY,KAAK,IAAA;AACvB,QAAM,EAAE,MAAM,UAAU,WAAW,SAAS,CAAA,EAAC,IAAM,QAAQ;AAG3D,SAAO,MAAM,sBAAsB,EAAE,UAAU,WAAW,OAAO,KAAK,UAAU,CAAA,CAAE,GAAG;AAErF,GAA6B;AAAA,IAI3B,WAAW,kBAAA;AAAA,EAAkB;AAG/B,MAAI;AAEF,UAAM,UAAU,eAAe,QAAQ;AAEvC,QAAI,CAAC,SAAS;AACZ,aAAO,KAAK,2BAA2B,QAAQ,EAAE;AACjD,YAAM,IAAI;AAAA,QACR,UAAU;AAAA,QACV,iBAAiB,QAAQ;AAAA,MAAA;AAAA,IAE7B;AAGA,mBAAe,QAAQ,QAAQ;AAG/B,UAAM,SAAS,MAAM,QAAQ,MAAM;AAEnC,UAAM,gBAAgB,KAAK,IAAA,IAAQ;AACnC,WAAO,MAAM,QAAQ,QAAQ,iBAAiB,aAAa,MAAM;AAAA,MAC/D,SAAS,OAAO;AAAA,MAChB,SAAS,CAAC,CAAC,OAAO;AAAA,IAAA,CACnB;AAGD,WAAO,eAAe,QAAQ,aAAa;AAAA,EAC7C,SAAS,OAAO;AACd,UAAM,gBAAgB,KAAK,IAAA,IAAQ;AACnC,W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;AAAA,MAAA;AAAA,IAEhD;AAEA,QAAI,MAAM,QAAQ,SAAS,YAAY,KAAK,MAAM,QAAQ,SAAS,cAAc,GAAG;AAClF,aAAO,IAAI;AAAA,QACT,UAAU;AAAA,QACV,GAAG,QAAQ,QAAQ,YAAY,MAAM,OAAO;AAAA,MAAA;AAAA,IAEhD;AAEA,QAAI,MAAM,QAAQ,SAAS,SAAS,GAAG;AACrC,aAAO,IAAI;AAAA,QACT,UAAU;AAAA,QACV,GAAG,QAAQ,QAAQ,eAAe,MAAM,OAAO;AAAA,MAAA;AAAA,IAEnD;AAGA,WAAO,IAAI;AAAA,MACT,UAAU;AAAA,MACV,GAAG,QAAQ,QAAQ,YAAY,MAAM,OAAO;AAAA,IAAA;AAAA,EAEhD;AAGA,SAAO,IAAI;AAAA,IACT,UAAU;AAAA,IACV,GAAG,QAAQ,QAAQ,YAAY,OAAO,KAAK,CAAC;AAAA,EAAA;AAEhD;AASO,SAAS,kBAAkB,OAAgB,UAA8B;AAC9E,SAAO;AAAA,IACL,SAAS;AAAA,IACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,IAC5D,UAAU;AAAA,MACR;AAAA,MACA,WAAW,KAAK,IAAA;AAAA,IAAI;AAAA,EACtB;AAEJ;AASO,SAAS,oBACd,MACA,UACY;AACZ,SAAO;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA,UAAU;AAAA,MACR,GAAG;AAAA,MACH,WAAW,KAAK,IAAA;AAAA,IAAI;AAAA,EACtB;AAEJ;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Graph MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Model Context Protocol server for knowledge graph operations.
|
|
5
|
+
* Exposes knowledge graph functionality to Claude Desktop and other MCP clients.
|
|
6
|
+
*
|
|
7
|
+
* @module mcp-server
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { createMCPServer, KnowledgeGraphMCPServer } from './mcp-server';
|
|
12
|
+
*
|
|
13
|
+
* // Create and run server
|
|
14
|
+
* const server = await createMCPServer({
|
|
15
|
+
* name: 'my-kg-server',
|
|
16
|
+
* version: '1.0.0',
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Check health
|
|
20
|
+
* const health = server.getHealth();
|
|
21
|
+
* console.log('Server status:', health.status);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export { KnowledgeGraphMCPServer, createMCPServer, runServer, } from './server.js';
|
|
25
|
+
export type { MCPServerConfig, ServerHealth, ToolCategory, ToolHandler, ToolHandlerEntry, ToolResult, ToolContext, ToolInputSchema, ToolDefinition, GraphQueryParams, GraphNodeResult, AgentInvokeParams, AgentResult, WorkflowParams, WorkflowResult, MemoryParams, MemoryResult, } from './types/index.js';
|
|
26
|
+
export { initializeTools, registerTool, getToolHandler, getToolDefinition, getToolDefinitions, getToolCategories, hasToolRegistered, getToolCount, clearRegistry, getDatabase, getCache, getProjectRoot, } from './tools/index.js';
|
|
27
|
+
export { handleToolCall, handleError, createErrorResult, createSuccessResult, } from './handlers/index.js';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp-server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,SAAS,GACV,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,cAAc,EACd,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,WAAW,EACX,QAAQ,EACR,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Graph MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Main MCP server implementation for exposing knowledge graph functionality
|
|
5
|
+
* to Claude Desktop and other MCP clients.
|
|
6
|
+
*
|
|
7
|
+
* @module mcp-server/server
|
|
8
|
+
*/
|
|
9
|
+
import type { MCPServerConfig, ServerHealth } from './types/index.js';
|
|
10
|
+
import type { KnowledgeGraphDatabase } from '../core/database.js';
|
|
11
|
+
import type { ShadowCache } from '../core/cache.js';
|
|
12
|
+
/**
|
|
13
|
+
* Knowledge Graph MCP Server
|
|
14
|
+
*
|
|
15
|
+
* Provides MCP protocol implementation for knowledge graph operations.
|
|
16
|
+
* Supports tool listing and execution over stdio transport.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const server = new KnowledgeGraphMCPServer();
|
|
21
|
+
* await server.run();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class KnowledgeGraphMCPServer {
|
|
25
|
+
private server;
|
|
26
|
+
private isRunning;
|
|
27
|
+
private startTime;
|
|
28
|
+
private requestCount;
|
|
29
|
+
private config;
|
|
30
|
+
private requestCounts;
|
|
31
|
+
private readonly MAX_REQUESTS_PER_MINUTE;
|
|
32
|
+
private database?;
|
|
33
|
+
private cache?;
|
|
34
|
+
private projectRoot?;
|
|
35
|
+
/**
|
|
36
|
+
* Create new MCP server instance
|
|
37
|
+
*
|
|
38
|
+
* @param config - Server configuration
|
|
39
|
+
* @param database - Knowledge graph database instance
|
|
40
|
+
* @param cache - Shadow cache instance
|
|
41
|
+
* @param projectRoot - Project root path
|
|
42
|
+
*/
|
|
43
|
+
constructor(config?: Partial<MCPServerConfig>, database?: KnowledgeGraphDatabase, cache?: ShadowCache, projectRoot?: string);
|
|
44
|
+
/**
|
|
45
|
+
* Check rate limit and throw if exceeded
|
|
46
|
+
*
|
|
47
|
+
* Implements a fixed-window rate limit of MAX_REQUESTS_PER_MINUTE per minute.
|
|
48
|
+
* Cleans up old entries to prevent memory leaks.
|
|
49
|
+
*
|
|
50
|
+
* @throws McpError if rate limit is exceeded
|
|
51
|
+
*/
|
|
52
|
+
private checkRateLimit;
|
|
53
|
+
/**
|
|
54
|
+
* Setup MCP request handlers
|
|
55
|
+
*/
|
|
56
|
+
private setupHandlers;
|
|
57
|
+
/**
|
|
58
|
+
* Start the MCP server
|
|
59
|
+
*
|
|
60
|
+
* @throws Error if server is already running
|
|
61
|
+
*/
|
|
62
|
+
run(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Shutdown the MCP server gracefully
|
|
65
|
+
*/
|
|
66
|
+
shutdown(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Get server health status
|
|
69
|
+
*
|
|
70
|
+
* @returns Health status object
|
|
71
|
+
*/
|
|
72
|
+
getHealth(): ServerHealth;
|
|
73
|
+
/**
|
|
74
|
+
* Check if server is currently running
|
|
75
|
+
*
|
|
76
|
+
* @returns true if server is running
|
|
77
|
+
*/
|
|
78
|
+
isServerRunning(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Get server configuration
|
|
81
|
+
*
|
|
82
|
+
* @returns Server configuration
|
|
83
|
+
*/
|
|
84
|
+
getConfig(): MCPServerConfig;
|
|
85
|
+
/**
|
|
86
|
+
* Get request count
|
|
87
|
+
*
|
|
88
|
+
* @returns Number of requests handled
|
|
89
|
+
*/
|
|
90
|
+
getRequestCount(): number;
|
|
91
|
+
/**
|
|
92
|
+
* Get server uptime in milliseconds
|
|
93
|
+
*
|
|
94
|
+
* @returns Uptime in milliseconds, 0 if not running
|
|
95
|
+
*/
|
|
96
|
+
getUptime(): number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create and start an MCP server
|
|
100
|
+
*
|
|
101
|
+
* Convenience function for creating and running an MCP server in one call.
|
|
102
|
+
*
|
|
103
|
+
* @param config - Server configuration
|
|
104
|
+
* @param database - Knowledge graph database instance
|
|
105
|
+
* @param cache - Shadow cache instance
|
|
106
|
+
* @param projectRoot - Project root path
|
|
107
|
+
* @returns Running MCP server instance
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const server = await createMCPServer(
|
|
112
|
+
* { name: 'my-kg-server' },
|
|
113
|
+
* database,
|
|
114
|
+
* cache,
|
|
115
|
+
* '/my/project'
|
|
116
|
+
* );
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function createMCPServer(config?: Partial<MCPServerConfig>, database?: KnowledgeGraphDatabase, cache?: ShadowCache, projectRoot?: string): Promise<KnowledgeGraphMCPServer>;
|
|
120
|
+
/**
|
|
121
|
+
* Run MCP server as standalone process
|
|
122
|
+
*
|
|
123
|
+
* Entry point for running the MCP server from command line.
|
|
124
|
+
*
|
|
125
|
+
* @param options - Server options
|
|
126
|
+
*/
|
|
127
|
+
export declare function runServer(options?: {
|
|
128
|
+
config?: Partial<MCPServerConfig>;
|
|
129
|
+
database?: KnowledgeGraphDatabase;
|
|
130
|
+
cache?: ShadowCache;
|
|
131
|
+
projectRoot?: string;
|
|
132
|
+
}): Promise<void>;
|
|
133
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp-server/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAaH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACtE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