tool.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var tool_exports = {};
  20. __export(tool_exports, {
  21. defineToolSchema: () => defineToolSchema,
  22. toMcpTool: () => toMcpTool
  23. });
  24. module.exports = __toCommonJS(tool_exports);
  25. var import_bundle = require("../sdk/bundle");
  26. function toMcpTool(tool) {
  27. const readOnly = tool.type === "readOnly" || tool.type === "assertion";
  28. return {
  29. name: tool.name,
  30. description: tool.description,
  31. inputSchema: (0, import_bundle.zodToJsonSchema)(tool.inputSchema, { strictUnions: true }),
  32. annotations: {
  33. title: tool.title,
  34. readOnlyHint: readOnly,
  35. destructiveHint: !readOnly,
  36. openWorldHint: true
  37. }
  38. };
  39. }
  40. function defineToolSchema(tool) {
  41. return tool;
  42. }
  43. // Annotate the CommonJS export names for ESM import in node:
  44. 0 && (module.exports = {
  45. defineToolSchema,
  46. toMcpTool
  47. });