@wisewandtools/mcp-server 2.1.2 → 2.2.1

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.js CHANGED
@@ -134,11 +134,12 @@ var parseConfig = /* @__PURE__ */ __name(() => {
134
134
  strategy: process.env.CACHE_STRATEGY
135
135
  },
136
136
  monitoring: {
137
- enableMetrics: process.env.ENABLE_METRICS !== "false",
137
+ // Default metrics and health check to false in MCP stdio mode (no port binding needed)
138
+ enableMetrics: process.env.ENABLE_METRICS === "true" ? true : process.env.ENABLE_METRICS === "false" ? false : process.env.MCP_MODE !== "stdio",
138
139
  metricsPort: process.env.METRICS_PORT ? parseInt(process.env.METRICS_PORT) : void 0,
139
140
  enableTracing: process.env.ENABLE_TRACING === "true",
140
141
  tracingEndpoint: process.env.TRACING_ENDPOINT,
141
- enableHealthCheck: process.env.ENABLE_HEALTH_CHECK !== "false",
142
+ enableHealthCheck: process.env.ENABLE_HEALTH_CHECK === "true" ? true : process.env.ENABLE_HEALTH_CHECK === "false" ? false : process.env.MCP_MODE !== "stdio",
142
143
  healthCheckInterval: process.env.HEALTH_CHECK_INTERVAL ? parseInt(process.env.HEALTH_CHECK_INTERVAL) : void 0
143
144
  },
144
145
  features: {
@@ -264,13 +265,11 @@ var WisewandAPIClient = class {
264
265
  "User-Agent": "Wisewand-MCP/1.0.0",
265
266
  "Accept": "application/json"
266
267
  };
267
- this.abortController = new AbortController();
268
268
  }
269
269
  static {
270
270
  __name(this, "WisewandAPIClient");
271
271
  }
272
272
  headers;
273
- abortController;
274
273
  /**
275
274
  * Make HTTP request with retry logic
276
275
  */
@@ -278,25 +277,18 @@ var WisewandAPIClient = class {
278
277
  const url = `${this.config.apiUrl}${endpoint}`;
279
278
  return pRetry(
280
279
  async () => {
280
+ const abortController = new AbortController();
281
281
  const timeoutId = setTimeout(() => {
282
- this.abortController.abort();
282
+ abortController.abort();
283
283
  }, this.config.timeout);
284
284
  try {
285
285
  const bodyJSON = body ? JSON.stringify(body) : void 0;
286
- logger.info("API HTTP REQUEST - EXACT JSON", {
287
- method,
288
- endpoint,
289
- url,
290
- bodyJSON,
291
- // The EXACT string being sent over HTTP
292
- body_includes_apply_project_brief_config: bodyJSON?.includes("apply_project_brief_config"),
293
- body_apply_project_brief_config_value: bodyJSON?.match(/"apply_project_brief_config":(true|false)/)?.[1]
294
- });
286
+ logger.debug("API request", { method, endpoint, url });
295
287
  const response = await fetch(url, {
296
288
  method,
297
289
  headers: this.headers,
298
290
  body: bodyJSON,
299
- signal: this.abortController.signal,
291
+ signal: abortController.signal,
300
292
  ...options
301
293
  });
302
294
  clearTimeout(timeoutId);
@@ -310,7 +302,6 @@ var WisewandAPIClient = class {
310
302
  } catch (error) {
311
303
  clearTimeout(timeoutId);
312
304
  if (error instanceof Error && error.name === "AbortError") {
313
- this.abortController = new AbortController();
314
305
  throw new Error(`Request timeout after ${this.config.timeout}ms`);
315
306
  }
316
307
  throw error;
@@ -617,7 +608,6 @@ var APIError = class extends Error {
617
608
 
618
609
  // src/services/CacheManager.ts
619
610
  import NodeCache from "node-cache";
620
- import Redis from "ioredis";
621
611
  var CacheManager = class {
622
612
  constructor(config2, redisConfig) {
623
613
  this.config = config2;
@@ -644,6 +634,20 @@ var CacheManager = class {
644
634
  });
645
635
  }
646
636
  if ((this.strategy === "redis" || this.strategy === "hybrid") && this.redisConfig) {
637
+ this.initRedis();
638
+ }
639
+ }
640
+ static {
641
+ __name(this, "CacheManager");
642
+ }
643
+ memoryCache;
644
+ redisClient;
645
+ enabled;
646
+ strategy;
647
+ defaultTTL;
648
+ async initRedis() {
649
+ try {
650
+ const { default: Redis } = await import("ioredis");
647
651
  this.redisClient = new Redis({
648
652
  host: this.redisConfig.host,
649
653
  port: this.redisConfig.port,
@@ -664,16 +668,20 @@ var CacheManager = class {
664
668
  this.redisClient.on("error", (error) => {
665
669
  logger.error("Redis cache error", error);
666
670
  });
671
+ } catch (error) {
672
+ logger.warn("Failed to load ioredis, falling back to memory-only cache", { error });
673
+ this.strategy = "memory";
674
+ if (!this.memoryCache) {
675
+ this.memoryCache = new NodeCache({
676
+ stdTTL: this.defaultTTL,
677
+ checkperiod: 120,
678
+ useClones: false,
679
+ deleteOnExpire: true,
680
+ maxKeys: Math.floor(this.config.maxSizeMB * 1e3)
681
+ });
682
+ }
667
683
  }
668
684
  }
669
- static {
670
- __name(this, "CacheManager");
671
- }
672
- memoryCache;
673
- redisClient;
674
- enabled;
675
- strategy;
676
- defaultTTL;
677
685
  async get(key) {
678
686
  if (!this.enabled) return null;
679
687
  try {
@@ -869,8 +877,6 @@ var RateLimiter = class {
869
877
  };
870
878
 
871
879
  // src/monitoring/MetricsCollector.ts
872
- import { Counter, Histogram, Gauge, Registry, collectDefaultMetrics } from "prom-client";
873
- import express from "express";
874
880
  var MetricsCollector = class {
875
881
  static {
876
882
  __name(this, "MetricsCollector");
@@ -878,7 +884,8 @@ var MetricsCollector = class {
878
884
  registry;
879
885
  app;
880
886
  server;
881
- // Metrics
887
+ enabled;
888
+ // Metrics (only initialized when enabled)
882
889
  toolCallCounter;
883
890
  toolCallDuration;
884
891
  apiCallCounter;
@@ -887,116 +894,156 @@ var MetricsCollector = class {
887
894
  cacheMissCounter;
888
895
  activeConnections;
889
896
  errorCounter;
890
- constructor() {
891
- this.registry = new Registry();
892
- collectDefaultMetrics({ register: this.registry });
893
- this.toolCallCounter = new Counter({
894
- name: "mcp_tool_calls_total",
895
- help: "Total number of tool calls",
896
- labelNames: ["tool", "status"],
897
- registers: [this.registry]
898
- });
899
- this.toolCallDuration = new Histogram({
900
- name: "mcp_tool_call_duration_ms",
901
- help: "Tool call duration in milliseconds",
902
- labelNames: ["tool"],
903
- buckets: [10, 50, 100, 500, 1e3, 5e3, 1e4],
904
- registers: [this.registry]
905
- });
906
- this.apiCallCounter = new Counter({
907
- name: "wisewand_api_calls_total",
908
- help: "Total number of Wisewand API calls",
909
- labelNames: ["endpoint", "status"],
910
- registers: [this.registry]
911
- });
912
- this.apiCallDuration = new Histogram({
913
- name: "wisewand_api_call_duration_ms",
914
- help: "Wisewand API call duration in milliseconds",
915
- labelNames: ["endpoint"],
916
- buckets: [100, 500, 1e3, 2e3, 5e3, 1e4, 3e4],
917
- registers: [this.registry]
918
- });
919
- this.cacheHitCounter = new Counter({
920
- name: "cache_hits_total",
921
- help: "Total number of cache hits",
922
- labelNames: ["cache_type"],
923
- registers: [this.registry]
924
- });
925
- this.cacheMissCounter = new Counter({
926
- name: "cache_misses_total",
927
- help: "Total number of cache misses",
928
- labelNames: ["cache_type"],
929
- registers: [this.registry]
930
- });
931
- this.activeConnections = new Gauge({
932
- name: "mcp_active_connections",
933
- help: "Number of active MCP connections",
934
- registers: [this.registry]
935
- });
936
- this.errorCounter = new Counter({
937
- name: "mcp_errors_total",
938
- help: "Total number of errors",
939
- labelNames: ["type", "source"],
940
- registers: [this.registry]
941
- });
942
- logger.info("Metrics collector initialized");
897
+ constructor(enabled = true) {
898
+ this.enabled = enabled;
899
+ if (!this.enabled) {
900
+ logger.info("Metrics collector disabled");
901
+ return;
902
+ }
903
+ }
904
+ async init() {
905
+ if (!this.enabled) return;
906
+ try {
907
+ const { Counter, Histogram, Gauge, Registry, collectDefaultMetrics } = await import("prom-client");
908
+ this.registry = new Registry();
909
+ collectDefaultMetrics({ register: this.registry });
910
+ this.toolCallCounter = new Counter({
911
+ name: "mcp_tool_calls_total",
912
+ help: "Total number of tool calls",
913
+ labelNames: ["tool", "status"],
914
+ registers: [this.registry]
915
+ });
916
+ this.toolCallDuration = new Histogram({
917
+ name: "mcp_tool_call_duration_ms",
918
+ help: "Tool call duration in milliseconds",
919
+ labelNames: ["tool"],
920
+ buckets: [10, 50, 100, 500, 1e3, 5e3, 1e4],
921
+ registers: [this.registry]
922
+ });
923
+ this.apiCallCounter = new Counter({
924
+ name: "wisewand_api_calls_total",
925
+ help: "Total number of Wisewand API calls",
926
+ labelNames: ["endpoint", "status"],
927
+ registers: [this.registry]
928
+ });
929
+ this.apiCallDuration = new Histogram({
930
+ name: "wisewand_api_call_duration_ms",
931
+ help: "Wisewand API call duration in milliseconds",
932
+ labelNames: ["endpoint"],
933
+ buckets: [100, 500, 1e3, 2e3, 5e3, 1e4, 3e4],
934
+ registers: [this.registry]
935
+ });
936
+ this.cacheHitCounter = new Counter({
937
+ name: "cache_hits_total",
938
+ help: "Total number of cache hits",
939
+ labelNames: ["cache_type"],
940
+ registers: [this.registry]
941
+ });
942
+ this.cacheMissCounter = new Counter({
943
+ name: "cache_misses_total",
944
+ help: "Total number of cache misses",
945
+ labelNames: ["cache_type"],
946
+ registers: [this.registry]
947
+ });
948
+ this.activeConnections = new Gauge({
949
+ name: "mcp_active_connections",
950
+ help: "Number of active MCP connections",
951
+ registers: [this.registry]
952
+ });
953
+ this.errorCounter = new Counter({
954
+ name: "mcp_errors_total",
955
+ help: "Total number of errors",
956
+ labelNames: ["type", "source"],
957
+ registers: [this.registry]
958
+ });
959
+ logger.info("Metrics collector initialized");
960
+ } catch (error) {
961
+ logger.warn("Failed to initialize metrics collector, disabling", { error });
962
+ this.enabled = false;
963
+ }
943
964
  }
944
965
  recordToolCall(tool, status, durationMs) {
945
- this.toolCallCounter.inc({ tool, status });
946
- this.toolCallDuration.observe({ tool }, durationMs);
966
+ if (!this.enabled) return;
967
+ this.toolCallCounter?.inc({ tool, status });
968
+ this.toolCallDuration?.observe({ tool }, durationMs);
947
969
  }
948
970
  recordAPICall(endpoint, status, durationMs) {
949
- this.apiCallCounter.inc({ endpoint, status });
971
+ if (!this.enabled) return;
972
+ this.apiCallCounter?.inc({ endpoint, status });
950
973
  if (durationMs) {
951
- this.apiCallDuration.observe({ endpoint }, durationMs);
974
+ this.apiCallDuration?.observe({ endpoint }, durationMs);
952
975
  }
953
976
  }
954
977
  recordCacheHit(cacheType = "memory") {
955
- this.cacheHitCounter.inc({ cache_type: cacheType });
978
+ if (!this.enabled) return;
979
+ this.cacheHitCounter?.inc({ cache_type: cacheType });
956
980
  }
957
981
  recordCacheMiss(cacheType = "memory") {
958
- this.cacheMissCounter.inc({ cache_type: cacheType });
982
+ if (!this.enabled) return;
983
+ this.cacheMissCounter?.inc({ cache_type: cacheType });
959
984
  }
960
985
  setActiveConnections(count) {
961
- this.activeConnections.set(count);
986
+ if (!this.enabled) return;
987
+ this.activeConnections?.set(count);
962
988
  }
963
989
  incrementActiveConnections() {
964
- this.activeConnections.inc();
990
+ if (!this.enabled) return;
991
+ this.activeConnections?.inc();
965
992
  }
966
993
  decrementActiveConnections() {
967
- this.activeConnections.dec();
994
+ if (!this.enabled) return;
995
+ this.activeConnections?.dec();
968
996
  }
969
997
  recordError(type, source) {
970
- this.errorCounter.inc({ type, source });
998
+ if (!this.enabled) return;
999
+ this.errorCounter?.inc({ type, source });
971
1000
  }
972
1001
  async getMetrics() {
1002
+ if (!this.enabled || !this.registry) return "";
973
1003
  return await this.registry.metrics();
974
1004
  }
975
1005
  getMetricsContentType() {
1006
+ if (!this.enabled || !this.registry) return "text/plain";
976
1007
  return this.registry.contentType;
977
1008
  }
978
- startServer(port) {
1009
+ async startServer(port) {
1010
+ if (!this.enabled) return;
979
1011
  if (this.server) {
980
1012
  logger.warn("Metrics server already running");
981
1013
  return;
982
1014
  }
983
- this.app = express();
984
- this.app.get("/health", (_req, res) => {
985
- res.status(200).json({ status: "healthy" });
986
- });
987
- this.app.get("/metrics", async (_req, res) => {
988
- try {
989
- res.set("Content-Type", this.getMetricsContentType());
990
- const metrics = await this.getMetrics();
991
- res.end(metrics);
992
- } catch (error) {
993
- logger.error("Error collecting metrics", error);
994
- res.status(500).end();
1015
+ try {
1016
+ if (!this.registry) {
1017
+ await this.init();
995
1018
  }
996
- });
997
- this.server = this.app.listen(port, () => {
998
- logger.info(`Metrics server started on port ${port}`);
999
- });
1019
+ if (!this.enabled) return;
1020
+ const express = (await import("express")).default;
1021
+ this.app = express();
1022
+ this.app.get("/health", (_req, res) => {
1023
+ res.status(200).json({ status: "healthy" });
1024
+ });
1025
+ this.app.get("/metrics", async (_req, res) => {
1026
+ try {
1027
+ res.set("Content-Type", this.getMetricsContentType());
1028
+ const metrics = await this.getMetrics();
1029
+ res.end(metrics);
1030
+ } catch (error) {
1031
+ logger.error("Error collecting metrics", error);
1032
+ res.status(500).end();
1033
+ }
1034
+ });
1035
+ this.server = this.app.listen(port, () => {
1036
+ logger.info(`Metrics server started on port ${port}`);
1037
+ });
1038
+ this.server.on("error", (error) => {
1039
+ logger.error(`Metrics server failed to bind port ${port}`, { error: error.message, code: error.code });
1040
+ this.server = void 0;
1041
+ this.enabled = false;
1042
+ });
1043
+ } catch (error) {
1044
+ logger.error("Failed to start metrics server", { error });
1045
+ this.enabled = false;
1046
+ }
1000
1047
  }
1001
1048
  async stopServer() {
1002
1049
  if (this.server) {
@@ -1009,6 +1056,7 @@ var MetricsCollector = class {
1009
1056
  }
1010
1057
  }
1011
1058
  reset() {
1059
+ if (!this.enabled || !this.registry) return;
1012
1060
  this.registry.clear();
1013
1061
  }
1014
1062
  };
@@ -1121,6 +1169,42 @@ var HealthChecker = class {
1121
1169
 
1122
1170
  // src/handlers/tools/ArticleToolHandler.ts
1123
1171
  import { z as z2 } from "zod";
1172
+
1173
+ // src/utils/tool-helpers.ts
1174
+ var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1175
+ var ToolInputError = class extends Error {
1176
+ static {
1177
+ __name(this, "ToolInputError");
1178
+ }
1179
+ constructor(message) {
1180
+ super(message);
1181
+ this.name = "ToolInputError";
1182
+ }
1183
+ };
1184
+ function resolveId(args, ...fallbackKeys) {
1185
+ const value = args.id ?? args.Id ?? args.ID;
1186
+ if (value !== void 0 && value !== null) {
1187
+ return validateUuid(value);
1188
+ }
1189
+ for (const key of fallbackKeys) {
1190
+ if (args[key] !== void 0 && args[key] !== null) {
1191
+ return validateUuid(args[key]);
1192
+ }
1193
+ }
1194
+ const tried = ["id", ...fallbackKeys].join(", ");
1195
+ throw new ToolInputError(`Missing required ID. Provide one of: ${tried}`);
1196
+ }
1197
+ __name(resolveId, "resolveId");
1198
+ function validateUuid(value) {
1199
+ const str = String(value);
1200
+ if (!UUID_REGEX.test(str)) {
1201
+ throw new ToolInputError(`Invalid ID format: "${str}" is not a valid UUID`);
1202
+ }
1203
+ return str;
1204
+ }
1205
+ __name(validateUuid, "validateUuid");
1206
+
1207
+ // src/handlers/tools/ArticleToolHandler.ts
1124
1208
  var boolField = z2.union([z2.boolean(), z2.string()]).transform(
1125
1209
  (val) => typeof val === "string" ? val === "true" : val
1126
1210
  ).optional().default(false);
@@ -1500,8 +1584,8 @@ var ArticleToolHandler = class {
1500
1584
  title: article.title || "Article created",
1501
1585
  message: `Article "${article.title || validated.subject}" created successfully.`,
1502
1586
  next_steps: [
1503
- `Use 'generate_article' with article_id: ${article.id} to start content generation`,
1504
- `Use 'get_article' with article_id: ${article.id} to check status`
1587
+ `Use 'generate_article' with id: ${article.id} to start content generation`,
1588
+ `Use 'get_article' with id: ${article.id} to check status`
1505
1589
  ]
1506
1590
  }, null, 2)
1507
1591
  }]
@@ -1524,15 +1608,16 @@ var ArticleToolHandler = class {
1524
1608
  inputSchema: {
1525
1609
  type: "object",
1526
1610
  properties: {
1527
- article_id: { type: "string", format: "uuid", description: "ID of the article to generate" },
1611
+ id: { type: "string", format: "uuid", description: "ID of the article to generate" },
1528
1612
  wait_for_completion: { type: "boolean", description: "Wait for generation to complete (may take several minutes)", default: true },
1529
1613
  max_wait_time: { type: "number", description: "Maximum time to wait in seconds", default: 300, maximum: 600 }
1530
1614
  },
1531
- required: ["article_id"]
1615
+ required: ["id"]
1532
1616
  },
1533
1617
  handler: /* @__PURE__ */ __name(async (args) => {
1534
1618
  try {
1535
- const { article_id, wait_for_completion = true, max_wait_time = 300 } = args;
1619
+ const article_id = resolveId(args, "article_id");
1620
+ const { wait_for_completion = true, max_wait_time = 300 } = args;
1536
1621
  await this.apiClient.runArticleGeneration(article_id);
1537
1622
  if (!wait_for_completion) {
1538
1623
  return { content: [{ type: "text", text: JSON.stringify({ success: true, message: "Article generation started", article_id, next_step: `Use 'get_article' or 'get_article_output' to check status` }, null, 2) }] };
@@ -1583,12 +1668,12 @@ var ArticleToolHandler = class {
1583
1668
  description: "Get article details and status",
1584
1669
  inputSchema: {
1585
1670
  type: "object",
1586
- properties: { article_id: { type: "string", format: "uuid", description: "ID of the article to retrieve" } },
1587
- required: ["article_id"]
1671
+ properties: { id: { type: "string", format: "uuid", description: "ID of the article to retrieve" } },
1672
+ required: ["id"]
1588
1673
  },
1589
1674
  handler: /* @__PURE__ */ __name(async (args) => {
1590
1675
  try {
1591
- const { article_id } = args;
1676
+ const article_id = resolveId(args, "article_id");
1592
1677
  const cached = await this.cache.get(`article:${article_id}`);
1593
1678
  if (cached) {
1594
1679
  return { content: [{ type: "text", text: JSON.stringify({ success: true, article: cached, from_cache: true }, null, 2) }] };
@@ -1614,8 +1699,7 @@ var ArticleToolHandler = class {
1614
1699
  properties: {
1615
1700
  search: { type: "string", description: "Search term to filter articles" },
1616
1701
  status: { type: "string", description: "Filter by status" },
1617
- projectId: { type: "string", format: "uuid", description: "Filter by project (camelCase as per API)" },
1618
- project_id: { type: "string", format: "uuid", description: "Filter by project (alias)" },
1702
+ project_id: { type: "string", format: "uuid", description: "Filter by project" },
1619
1703
  maker: { type: "string", description: "Filter by maker" },
1620
1704
  persona: { type: "string", description: "Filter by persona" },
1621
1705
  author: { type: "string", description: "Filter by author" },
@@ -1629,7 +1713,12 @@ var ArticleToolHandler = class {
1629
1713
  },
1630
1714
  handler: /* @__PURE__ */ __name(async (args) => {
1631
1715
  try {
1632
- const result2 = await this.apiClient.listArticles(args);
1716
+ const apiParams = { ...args };
1717
+ if (apiParams.project_id) {
1718
+ apiParams.projectId = apiParams.project_id;
1719
+ delete apiParams.project_id;
1720
+ }
1721
+ const result2 = await this.apiClient.listArticles(apiParams);
1633
1722
  this.metrics.recordAPICall("list_articles", "success");
1634
1723
  return {
1635
1724
  content: [{
@@ -1638,7 +1727,17 @@ var ArticleToolHandler = class {
1638
1727
  success: true,
1639
1728
  total: result2.total,
1640
1729
  count: result2.items.length,
1641
- articles: result2.items.map((a) => ({ id: a.id, title: a.title, status: a.status, created_at: a.created_at, type: a.data?.input?.type })),
1730
+ articles: result2.items.map((a) => ({
1731
+ id: a.id,
1732
+ title: a.title,
1733
+ status: a.status,
1734
+ created_at: a.created_at,
1735
+ type: a.data?.input?.type,
1736
+ project_id: a.data?.input?.project_id,
1737
+ target_keyword: a.data?.input?.target_keyword,
1738
+ lang: a.data?.input?.lang,
1739
+ subject: a.data?.input?.subject
1740
+ })),
1642
1741
  pagination: { skip: result2.skip, take: result2.take, has_more: result2.skip + result2.take < result2.total }
1643
1742
  }, null, 2)
1644
1743
  }]
@@ -1658,18 +1757,19 @@ var ArticleToolHandler = class {
1658
1757
  inputSchema: {
1659
1758
  type: "object",
1660
1759
  properties: {
1661
- article_id: { type: "string", format: "uuid", description: "ID of the article to update" },
1760
+ id: { type: "string", format: "uuid", description: "ID of the article to update" },
1662
1761
  updates: {
1663
1762
  type: "object",
1664
1763
  description: "Fields to update (supports all create_article parameters)",
1665
1764
  properties: this.buildArticleInputSchema()
1666
1765
  }
1667
1766
  },
1668
- required: ["article_id", "updates"]
1767
+ required: ["id", "updates"]
1669
1768
  },
1670
1769
  handler: /* @__PURE__ */ __name(async (args) => {
1671
1770
  try {
1672
- const { article_id, updates } = args;
1771
+ const article_id = resolveId(args, "article_id");
1772
+ const { updates } = args;
1673
1773
  await this.apiClient.updateArticle(article_id, updates);
1674
1774
  await this.cache.delete(`article:${article_id}`);
1675
1775
  this.metrics.recordAPICall("update_article", "success");
@@ -1691,14 +1791,15 @@ var ArticleToolHandler = class {
1691
1791
  inputSchema: {
1692
1792
  type: "object",
1693
1793
  properties: {
1694
- article_id: { type: "string", format: "uuid", description: "ID of the article" },
1794
+ id: { type: "string", format: "uuid", description: "ID of the article" },
1695
1795
  format: { type: "string", enum: ["full", "html", "markdown", "summary"], description: "Output format", default: "full" }
1696
1796
  },
1697
- required: ["article_id"]
1797
+ required: ["id"]
1698
1798
  },
1699
1799
  handler: /* @__PURE__ */ __name(async (args) => {
1700
1800
  try {
1701
- const { article_id, format = "full" } = args;
1801
+ const article_id = resolveId(args, "article_id");
1802
+ const { format = "full" } = args;
1702
1803
  const cacheKey = `article:output:${article_id}`;
1703
1804
  const cached = await this.cache.get(cacheKey);
1704
1805
  const output = cached || await this.apiClient.getArticleOutput(article_id);
@@ -1736,15 +1837,16 @@ var ArticleToolHandler = class {
1736
1837
  inputSchema: {
1737
1838
  type: "object",
1738
1839
  properties: {
1739
- article_id: { type: "string", format: "uuid", description: "ID of the article" },
1840
+ id: { type: "string", format: "uuid", description: "ID of the article" },
1740
1841
  output_id: { type: "string", format: "uuid", description: "ID of the output to update" },
1741
1842
  updates: { type: "object", description: "Fields to update in the output" }
1742
1843
  },
1743
- required: ["article_id", "output_id", "updates"]
1844
+ required: ["id", "output_id", "updates"]
1744
1845
  },
1745
1846
  handler: /* @__PURE__ */ __name(async (args) => {
1746
1847
  try {
1747
- const { article_id, output_id, updates } = args;
1848
+ const article_id = resolveId(args, "article_id");
1849
+ const { output_id, updates } = args;
1748
1850
  const result2 = await this.apiClient.updateArticleOutput(article_id, output_id, updates);
1749
1851
  await this.cache.delete(`article:output:${article_id}`);
1750
1852
  this.metrics.recordAPICall("update_article_output", "success");
@@ -1899,18 +2001,18 @@ var ProjectToolHandler = class {
1899
2001
  inputSchema: {
1900
2002
  type: "object",
1901
2003
  properties: {
1902
- project_id: {
2004
+ id: {
1903
2005
  type: "string",
1904
2006
  format: "uuid",
1905
2007
  description: "Project ID"
1906
2008
  }
1907
2009
  },
1908
- required: ["project_id"]
2010
+ required: ["id"]
1909
2011
  },
1910
2012
  handler: /* @__PURE__ */ __name(async (args) => {
1911
2013
  try {
1912
- const { project_id } = args;
1913
- const cached = await this.cache.get(`project:${project_id}`);
2014
+ const id = resolveId(args, "project_id");
2015
+ const cached = await this.cache.get(`project:${id}`);
1914
2016
  if (cached) {
1915
2017
  return {
1916
2018
  content: [
@@ -1925,8 +2027,8 @@ var ProjectToolHandler = class {
1925
2027
  ]
1926
2028
  };
1927
2029
  }
1928
- const project = await this.apiClient.getProject(project_id);
1929
- await this.cache.set(`project:${project_id}`, project, 600);
2030
+ const project = await this.apiClient.getProject(id);
2031
+ await this.cache.set(`project:${id}`, project, 600);
1930
2032
  this.metrics.recordAPICall("get_project", "success");
1931
2033
  return {
1932
2034
  content: [
@@ -1994,12 +2096,7 @@ var ProjectToolHandler = class {
1994
2096
  success: true,
1995
2097
  total: result2.total,
1996
2098
  count: result2.items.length,
1997
- projects: result2.items.map((p) => ({
1998
- id: p.id,
1999
- name: p.name,
2000
- website_url: p.website_url,
2001
- created_at: p.created_at
2002
- }))
2099
+ projects: result2.items
2003
2100
  }, null, 2)
2004
2101
  }
2005
2102
  ]
@@ -2030,7 +2127,7 @@ var ProjectToolHandler = class {
2030
2127
  inputSchema: {
2031
2128
  type: "object",
2032
2129
  properties: {
2033
- project_id: {
2130
+ id: {
2034
2131
  type: "string",
2035
2132
  format: "uuid",
2036
2133
  description: "Project ID"
@@ -2047,13 +2144,14 @@ var ProjectToolHandler = class {
2047
2144
  }
2048
2145
  }
2049
2146
  },
2050
- required: ["project_id", "updates"]
2147
+ required: ["id", "updates"]
2051
2148
  },
2052
2149
  handler: /* @__PURE__ */ __name(async (args) => {
2053
2150
  try {
2054
- const { project_id, updates } = args;
2055
- await this.apiClient.updateProject(project_id, updates);
2056
- await this.cache.delete(`project:${project_id}`);
2151
+ const id = resolveId(args, "project_id");
2152
+ const { updates } = args;
2153
+ await this.apiClient.updateProject(id, updates);
2154
+ await this.cache.delete(`project:${id}`);
2057
2155
  this.metrics.recordAPICall("update_project", "success");
2058
2156
  return {
2059
2157
  content: [
@@ -2062,7 +2160,7 @@ var ProjectToolHandler = class {
2062
2160
  text: JSON.stringify({
2063
2161
  success: true,
2064
2162
  message: "Project updated successfully",
2065
- project_id,
2163
+ project_id: id,
2066
2164
  updated_fields: Object.keys(updates)
2067
2165
  }, null, 2)
2068
2166
  }
@@ -2094,7 +2192,7 @@ var ProjectToolHandler = class {
2094
2192
  inputSchema: {
2095
2193
  type: "object",
2096
2194
  properties: {
2097
- project_id: {
2195
+ id: {
2098
2196
  type: "string",
2099
2197
  format: "uuid",
2100
2198
  description: "Project ID to delete"
@@ -2105,11 +2203,12 @@ var ProjectToolHandler = class {
2105
2203
  const: true
2106
2204
  }
2107
2205
  },
2108
- required: ["project_id", "confirm"]
2206
+ required: ["id", "confirm"]
2109
2207
  },
2110
2208
  handler: /* @__PURE__ */ __name(async (args) => {
2111
2209
  try {
2112
- const { project_id, confirm } = args;
2210
+ const id = resolveId(args, "project_id");
2211
+ const { confirm } = args;
2113
2212
  if (!confirm) {
2114
2213
  return {
2115
2214
  content: [
@@ -2124,8 +2223,8 @@ var ProjectToolHandler = class {
2124
2223
  isError: true
2125
2224
  };
2126
2225
  }
2127
- await this.apiClient.deleteProject(project_id);
2128
- await this.cache.delete(`project:${project_id}`);
2226
+ await this.apiClient.deleteProject(id);
2227
+ await this.cache.delete(`project:${id}`);
2129
2228
  this.metrics.recordAPICall("delete_project", "success");
2130
2229
  return {
2131
2230
  content: [
@@ -2134,7 +2233,7 @@ var ProjectToolHandler = class {
2134
2233
  text: JSON.stringify({
2135
2234
  success: true,
2136
2235
  message: "Project deleted successfully",
2137
- project_id
2236
+ project_id: id
2138
2237
  }, null, 2)
2139
2238
  }
2140
2239
  ]
@@ -2448,18 +2547,18 @@ var PersonaToolHandler = class {
2448
2547
  inputSchema: {
2449
2548
  type: "object",
2450
2549
  properties: {
2451
- persona_id: {
2550
+ id: {
2452
2551
  type: "string",
2453
2552
  format: "uuid",
2454
2553
  description: "Persona ID"
2455
2554
  }
2456
2555
  },
2457
- required: ["persona_id"]
2556
+ required: ["id"]
2458
2557
  },
2459
2558
  handler: /* @__PURE__ */ __name(async (args) => {
2460
2559
  try {
2461
- const { persona_id } = args;
2462
- const cached = await this.cache.get(`persona:${persona_id}`);
2560
+ const id = resolveId(args, "persona_id");
2561
+ const cached = await this.cache.get(`persona:${id}`);
2463
2562
  if (cached) {
2464
2563
  return {
2465
2564
  content: [
@@ -2474,8 +2573,8 @@ var PersonaToolHandler = class {
2474
2573
  ]
2475
2574
  };
2476
2575
  }
2477
- const persona = await this.apiClient.getPersona(persona_id);
2478
- await this.cache.set(`persona:${persona_id}`, persona, 600);
2576
+ const persona = await this.apiClient.getPersona(id);
2577
+ await this.cache.set(`persona:${id}`, persona, 600);
2479
2578
  this.metrics.recordAPICall("get_persona", "success");
2480
2579
  return {
2481
2580
  content: [
@@ -2580,7 +2679,7 @@ var PersonaToolHandler = class {
2580
2679
  inputSchema: {
2581
2680
  type: "object",
2582
2681
  properties: {
2583
- persona_id: {
2682
+ id: {
2584
2683
  type: "string",
2585
2684
  format: "uuid",
2586
2685
  description: "Persona ID"
@@ -2601,13 +2700,14 @@ var PersonaToolHandler = class {
2601
2700
  }
2602
2701
  }
2603
2702
  },
2604
- required: ["persona_id", "updates"]
2703
+ required: ["id", "updates"]
2605
2704
  },
2606
2705
  handler: /* @__PURE__ */ __name(async (args) => {
2607
2706
  try {
2608
- const { persona_id, updates } = args;
2609
- await this.apiClient.updatePersona(persona_id, updates);
2610
- await this.cache.delete(`persona:${persona_id}`);
2707
+ const id = resolveId(args, "persona_id");
2708
+ const { updates } = args;
2709
+ await this.apiClient.updatePersona(id, updates);
2710
+ await this.cache.delete(`persona:${id}`);
2611
2711
  this.metrics.recordAPICall("update_persona", "success");
2612
2712
  return {
2613
2713
  content: [
@@ -2616,7 +2716,7 @@ var PersonaToolHandler = class {
2616
2716
  text: JSON.stringify({
2617
2717
  success: true,
2618
2718
  message: "Persona updated successfully",
2619
- persona_id,
2719
+ persona_id: id,
2620
2720
  updated_fields: Object.keys(updates)
2621
2721
  }, null, 2)
2622
2722
  }
@@ -2648,7 +2748,7 @@ var PersonaToolHandler = class {
2648
2748
  inputSchema: {
2649
2749
  type: "object",
2650
2750
  properties: {
2651
- persona_id: {
2751
+ id: {
2652
2752
  type: "string",
2653
2753
  format: "uuid",
2654
2754
  description: "Persona ID to delete"
@@ -2659,11 +2759,12 @@ var PersonaToolHandler = class {
2659
2759
  const: true
2660
2760
  }
2661
2761
  },
2662
- required: ["persona_id", "confirm"]
2762
+ required: ["id", "confirm"]
2663
2763
  },
2664
2764
  handler: /* @__PURE__ */ __name(async (args) => {
2665
2765
  try {
2666
- const { persona_id, confirm } = args;
2766
+ const id = resolveId(args, "persona_id");
2767
+ const { confirm } = args;
2667
2768
  if (!confirm) {
2668
2769
  return {
2669
2770
  content: [
@@ -2678,8 +2779,8 @@ var PersonaToolHandler = class {
2678
2779
  isError: true
2679
2780
  };
2680
2781
  }
2681
- await this.apiClient.deletePersona(persona_id);
2682
- await this.cache.delete(`persona:${persona_id}`);
2782
+ await this.apiClient.deletePersona(id);
2783
+ await this.cache.delete(`persona:${id}`);
2683
2784
  this.metrics.recordAPICall("delete_persona", "success");
2684
2785
  return {
2685
2786
  content: [
@@ -2688,7 +2789,7 @@ var PersonaToolHandler = class {
2688
2789
  text: JSON.stringify({
2689
2790
  success: true,
2690
2791
  message: "Persona deleted successfully",
2691
- persona_id
2792
+ persona_id: id
2692
2793
  }, null, 2)
2693
2794
  }
2694
2795
  ]
@@ -3045,18 +3146,18 @@ var ConnectionsToolHandler = class {
3045
3146
  inputSchema: {
3046
3147
  type: "object",
3047
3148
  properties: {
3048
- connection_id: {
3149
+ id: {
3049
3150
  type: "string",
3050
3151
  format: "uuid",
3051
3152
  description: "Connection ID"
3052
3153
  }
3053
3154
  },
3054
- required: ["connection_id"]
3155
+ required: ["id"]
3055
3156
  },
3056
3157
  handler: /* @__PURE__ */ __name(async (args) => {
3057
3158
  try {
3058
- const { connection_id } = args;
3059
- const cached = await this.cache.get(`connection:${connection_id}`);
3159
+ const id = resolveId(args, "connection_id");
3160
+ const cached = await this.cache.get(`connection:${id}`);
3060
3161
  if (cached) {
3061
3162
  return {
3062
3163
  content: [
@@ -3071,8 +3172,8 @@ var ConnectionsToolHandler = class {
3071
3172
  ]
3072
3173
  };
3073
3174
  }
3074
- const connection = await this.apiClient.getConnection(connection_id);
3075
- await this.cache.set(`connection:${connection_id}`, connection, 600);
3175
+ const connection = await this.apiClient.getConnection(id);
3176
+ await this.cache.set(`connection:${id}`, connection, 600);
3076
3177
  this.metrics.recordAPICall("get_connection", "success");
3077
3178
  return {
3078
3179
  content: [
@@ -3175,7 +3276,7 @@ var ConnectionsToolHandler = class {
3175
3276
  inputSchema: {
3176
3277
  type: "object",
3177
3278
  properties: {
3178
- connection_id: {
3279
+ id: {
3179
3280
  type: "string",
3180
3281
  format: "uuid",
3181
3282
  description: "Connection ID"
@@ -3188,13 +3289,14 @@ var ConnectionsToolHandler = class {
3188
3289
  }
3189
3290
  }
3190
3291
  },
3191
- required: ["connection_id", "updates"]
3292
+ required: ["id", "updates"]
3192
3293
  },
3193
3294
  handler: /* @__PURE__ */ __name(async (args) => {
3194
3295
  try {
3195
- const { connection_id, updates } = args;
3196
- await this.apiClient.updateConnection(connection_id, updates);
3197
- await this.cache.delete(`connection:${connection_id}`);
3296
+ const id = resolveId(args, "connection_id");
3297
+ const { updates } = args;
3298
+ await this.apiClient.updateConnection(id, updates);
3299
+ await this.cache.delete(`connection:${id}`);
3198
3300
  this.metrics.recordAPICall("update_connection", "success");
3199
3301
  return {
3200
3302
  content: [
@@ -3203,7 +3305,7 @@ var ConnectionsToolHandler = class {
3203
3305
  text: JSON.stringify({
3204
3306
  success: true,
3205
3307
  message: "Connection updated successfully",
3206
- connection_id
3308
+ connection_id: id
3207
3309
  }, null, 2)
3208
3310
  }
3209
3311
  ]
@@ -3234,7 +3336,7 @@ var ConnectionsToolHandler = class {
3234
3336
  inputSchema: {
3235
3337
  type: "object",
3236
3338
  properties: {
3237
- connection_id: {
3339
+ id: {
3238
3340
  type: "string",
3239
3341
  format: "uuid",
3240
3342
  description: "Connection ID to delete"
@@ -3245,11 +3347,12 @@ var ConnectionsToolHandler = class {
3245
3347
  const: true
3246
3348
  }
3247
3349
  },
3248
- required: ["connection_id", "confirm"]
3350
+ required: ["id", "confirm"]
3249
3351
  },
3250
3352
  handler: /* @__PURE__ */ __name(async (args) => {
3251
3353
  try {
3252
- const { connection_id, confirm } = args;
3354
+ const id = resolveId(args, "connection_id");
3355
+ const { confirm } = args;
3253
3356
  if (!confirm) {
3254
3357
  return {
3255
3358
  content: [
@@ -3264,8 +3367,8 @@ var ConnectionsToolHandler = class {
3264
3367
  isError: true
3265
3368
  };
3266
3369
  }
3267
- await this.apiClient.deleteConnection(connection_id);
3268
- await this.cache.delete(`connection:${connection_id}`);
3370
+ await this.apiClient.deleteConnection(id);
3371
+ await this.cache.delete(`connection:${id}`);
3269
3372
  this.metrics.recordAPICall("delete_connection", "success");
3270
3373
  return {
3271
3374
  content: [
@@ -3274,7 +3377,7 @@ var ConnectionsToolHandler = class {
3274
3377
  text: JSON.stringify({
3275
3378
  success: true,
3276
3379
  message: "Connection deleted successfully",
3277
- connection_id
3380
+ connection_id: id
3278
3381
  }, null, 2)
3279
3382
  }
3280
3383
  ]
@@ -3588,7 +3691,7 @@ var CategoryPagesToolHandler = class {
3588
3691
  inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid", description: "ID of the category page" } }, required: ["id"] },
3589
3692
  handler: /* @__PURE__ */ __name(async (args) => {
3590
3693
  try {
3591
- const { id } = args;
3694
+ const id = resolveId(args);
3592
3695
  const cached = await this.cache.get(`category_page:${id}`);
3593
3696
  if (cached) {
3594
3697
  return { content: [{ type: "text", text: JSON.stringify({ success: true, category_page: cached, from_cache: true }, null, 2) }] };
@@ -3648,7 +3751,8 @@ var CategoryPagesToolHandler = class {
3648
3751
  },
3649
3752
  handler: /* @__PURE__ */ __name(async (args) => {
3650
3753
  try {
3651
- const { id, updates } = args;
3754
+ const id = resolveId(args);
3755
+ const { updates } = args;
3652
3756
  await this.apiClient.updateCategoryPage(id, updates);
3653
3757
  await this.cache.delete(`category_page:${id}`);
3654
3758
  this.metrics.recordAPICall("update_category_page", "success");
@@ -3676,7 +3780,8 @@ var CategoryPagesToolHandler = class {
3676
3780
  },
3677
3781
  handler: /* @__PURE__ */ __name(async (args) => {
3678
3782
  try {
3679
- const { id, wait_for_completion = true, max_wait_time = 300 } = args;
3783
+ const id = resolveId(args);
3784
+ const { wait_for_completion = true, max_wait_time = 300 } = args;
3680
3785
  await this.apiClient.runCategoryPageGeneration(id);
3681
3786
  if (!wait_for_completion) {
3682
3787
  return { content: [{ type: "text", text: JSON.stringify({ success: true, message: "Category page generation started", category_page_id: id }, null, 2) }] };
@@ -3712,7 +3817,7 @@ var CategoryPagesToolHandler = class {
3712
3817
  inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid", description: "ID of the category page" } }, required: ["id"] },
3713
3818
  handler: /* @__PURE__ */ __name(async (args) => {
3714
3819
  try {
3715
- const { id } = args;
3820
+ const id = resolveId(args);
3716
3821
  const cacheKey = `category_page:output:${id}`;
3717
3822
  const cached = await this.cache.get(cacheKey);
3718
3823
  const output = cached || await this.apiClient.getCategoryPageOutput(id);
@@ -3900,7 +4005,7 @@ var ProductPagesToolHandler = class {
3900
4005
  inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid", description: "ID of the product page" } }, required: ["id"] },
3901
4006
  handler: /* @__PURE__ */ __name(async (args) => {
3902
4007
  try {
3903
- const { id } = args;
4008
+ const id = resolveId(args);
3904
4009
  const cached = await this.cache.get(`product_page:${id}`);
3905
4010
  if (cached) {
3906
4011
  return { content: [{ type: "text", text: JSON.stringify({ success: true, product_page: cached, from_cache: true }, null, 2) }] };
@@ -3951,7 +4056,8 @@ var ProductPagesToolHandler = class {
3951
4056
  inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid", description: "ID of the product page to update" }, updates: { type: "object", description: "Fields to update" } }, required: ["id", "updates"] },
3952
4057
  handler: /* @__PURE__ */ __name(async (args) => {
3953
4058
  try {
3954
- const { id, updates } = args;
4059
+ const id = resolveId(args);
4060
+ const { updates } = args;
3955
4061
  await this.apiClient.updateProductPage(id, updates);
3956
4062
  await this.cache.delete(`product_page:${id}`);
3957
4063
  this.metrics.recordAPICall("update_product_page", "success");
@@ -3971,7 +4077,8 @@ var ProductPagesToolHandler = class {
3971
4077
  inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid" }, wait_for_completion: { type: "boolean", default: true }, max_wait_time: { type: "number", default: 300, maximum: 600 } }, required: ["id"] },
3972
4078
  handler: /* @__PURE__ */ __name(async (args) => {
3973
4079
  try {
3974
- const { id, wait_for_completion = true, max_wait_time = 300 } = args;
4080
+ const id = resolveId(args);
4081
+ const { wait_for_completion = true, max_wait_time = 300 } = args;
3975
4082
  await this.apiClient.runProductPageGeneration(id);
3976
4083
  if (!wait_for_completion) {
3977
4084
  return { content: [{ type: "text", text: JSON.stringify({ success: true, message: "Product page generation started", product_page_id: id }, null, 2) }] };
@@ -4007,7 +4114,7 @@ var ProductPagesToolHandler = class {
4007
4114
  inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid" } }, required: ["id"] },
4008
4115
  handler: /* @__PURE__ */ __name(async (args) => {
4009
4116
  try {
4010
- const { id } = args;
4117
+ const id = resolveId(args);
4011
4118
  const cacheKey = `product_page:output:${id}`;
4012
4119
  const cached = await this.cache.get(cacheKey);
4013
4120
  const output = cached || await this.apiClient.getProductPageOutput(id);
@@ -4287,7 +4394,7 @@ var DiscoverToolHandler = class {
4287
4394
  inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid" } }, required: ["id"] },
4288
4395
  handler: /* @__PURE__ */ __name(async (args) => {
4289
4396
  try {
4290
- const { id } = args;
4397
+ const id = resolveId(args);
4291
4398
  const cached = await this.cache.get(`discover:${id}`);
4292
4399
  if (cached) {
4293
4400
  return { content: [{ type: "text", text: JSON.stringify({ success: true, discovery: cached, from_cache: true }, null, 2) }] };
@@ -4338,7 +4445,8 @@ var DiscoverToolHandler = class {
4338
4445
  inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid" }, updates: { type: "object", description: "Fields to update" } }, required: ["id", "updates"] },
4339
4446
  handler: /* @__PURE__ */ __name(async (args) => {
4340
4447
  try {
4341
- const { id, updates } = args;
4448
+ const id = resolveId(args);
4449
+ const { updates } = args;
4342
4450
  await this.apiClient.updateDiscoverArticle(id, updates);
4343
4451
  await this.cache.delete(`discover:${id}`);
4344
4452
  this.metrics.recordAPICall("update_discover_article", "success");
@@ -4358,7 +4466,7 @@ var DiscoverToolHandler = class {
4358
4466
  inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid" } }, required: ["id"] },
4359
4467
  handler: /* @__PURE__ */ __name(async (args) => {
4360
4468
  try {
4361
- const { id } = args;
4469
+ const id = resolveId(args);
4362
4470
  await this.apiClient.runDiscovery(id);
4363
4471
  await this.cache.delete(`discover:${id}`);
4364
4472
  this.metrics.recordAPICall("run_discovery", "success");
@@ -4378,7 +4486,7 @@ var DiscoverToolHandler = class {
4378
4486
  inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid" } }, required: ["id"] },
4379
4487
  handler: /* @__PURE__ */ __name(async (args) => {
4380
4488
  try {
4381
- const { id } = args;
4489
+ const id = resolveId(args);
4382
4490
  const cacheKey = `discover:output:${id}`;
4383
4491
  const cached = await this.cache.get(cacheKey);
4384
4492
  const output = cached || await this.apiClient.getDiscoverArticleOutput(id);
@@ -4534,7 +4642,7 @@ var RSSToolHandler = class {
4534
4642
  },
4535
4643
  handler: /* @__PURE__ */ __name(async (args) => {
4536
4644
  try {
4537
- const { id } = args;
4645
+ const id = resolveId(args);
4538
4646
  const cached = await this.cache.get(`feed:${id}`);
4539
4647
  if (cached) {
4540
4648
  return { content: [{ type: "text", text: JSON.stringify({ success: true, feed: cached, from_cache: true }, null, 2) }] };
@@ -4624,7 +4732,8 @@ var RSSToolHandler = class {
4624
4732
  },
4625
4733
  handler: /* @__PURE__ */ __name(async (args) => {
4626
4734
  try {
4627
- const { id, updates } = args;
4735
+ const id = resolveId(args);
4736
+ const { updates } = args;
4628
4737
  await this.apiClient.updateFeed(id, updates);
4629
4738
  await this.cache.delete(`feed:${id}`);
4630
4739
  this.metrics.recordAPICall("update_feed", "success");
@@ -4650,7 +4759,7 @@ var RSSToolHandler = class {
4650
4759
  },
4651
4760
  handler: /* @__PURE__ */ __name(async (args) => {
4652
4761
  try {
4653
- const { id } = args;
4762
+ const id = resolveId(args);
4654
4763
  await this.apiClient.deleteFeed(id);
4655
4764
  await this.cache.delete(`feed:${id}`);
4656
4765
  this.metrics.recordAPICall("delete_feed", "success");
@@ -4772,7 +4881,7 @@ var JobsToolHandler = class {
4772
4881
  },
4773
4882
  handler: /* @__PURE__ */ __name(async (args) => {
4774
4883
  try {
4775
- const { id } = args;
4884
+ const id = resolveId(args);
4776
4885
  const job = await this.apiClient.getJob(id);
4777
4886
  this.metrics.recordAPICall("get_job", "success");
4778
4887
  return {
@@ -6097,7 +6206,7 @@ var WisewandMCPServer = class {
6097
6206
  this.apiClient = new WisewandAPIClient(config2.wisewand);
6098
6207
  this.cacheManager = new CacheManager(config2.cache);
6099
6208
  this.rateLimiter = new RateLimiter(config2.security);
6100
- this.metrics = new MetricsCollector();
6209
+ this.metrics = new MetricsCollector(config2.monitoring.enableMetrics);
6101
6210
  this.healthChecker = new HealthChecker(this.apiClient, this.cacheManager);
6102
6211
  this.articleHandler = new ArticleToolHandler(this.apiClient, this.cacheManager, this.metrics);
6103
6212
  this.projectHandler = new ProjectToolHandler(this.apiClient, this.cacheManager, this.metrics);
@@ -6289,32 +6398,9 @@ var WisewandMCPServer = class {
6289
6398
  getMetrics() {
6290
6399
  return this.metrics.getMetrics();
6291
6400
  }
6292
- /**
6293
- * Test API connection during startup
6294
- * Returns {ok: boolean, error?: string}
6295
- */
6296
- async testAPIConnection() {
6297
- try {
6298
- const health = await this.healthChecker.checkHealth();
6299
- if (health.checks.api) {
6300
- return { ok: true };
6301
- } else {
6302
- return {
6303
- ok: false,
6304
- error: "API health check failed - check API key and network connection"
6305
- };
6306
- }
6307
- } catch (error) {
6308
- return {
6309
- ok: false,
6310
- error: error.message || "Unknown error"
6311
- };
6312
- }
6313
- }
6314
6401
  };
6315
6402
 
6316
6403
  // src/utils/shutdown.ts
6317
- import * as readline from "readline";
6318
6404
  function gracefulShutdown(server) {
6319
6405
  let isShuttingDown = false;
6320
6406
  const shutdown = /* @__PURE__ */ __name(async (signal) => {
@@ -6342,13 +6428,15 @@ function gracefulShutdown(server) {
6342
6428
  process.on("SIGTERM", () => shutdown("SIGTERM"));
6343
6429
  process.on("SIGINT", () => shutdown("SIGINT"));
6344
6430
  process.on("SIGHUP", () => shutdown("SIGHUP"));
6345
- if (process.platform === "win32") {
6346
- const rl = readline.createInterface({
6347
- input: process.stdin,
6348
- output: process.stdout
6349
- });
6350
- rl.on("SIGINT", () => {
6351
- process.emit("SIGINT");
6431
+ if (process.platform === "win32" && process.env.MCP_MODE !== "stdio") {
6432
+ import("readline").then((readline) => {
6433
+ const rl = readline.createInterface({
6434
+ input: process.stdin,
6435
+ output: process.stderr
6436
+ });
6437
+ rl.on("SIGINT", () => {
6438
+ process.emit("SIGINT");
6439
+ });
6352
6440
  });
6353
6441
  }
6354
6442
  }
@@ -6363,23 +6451,6 @@ async function main() {
6363
6451
  nodeVersion: process.version
6364
6452
  });
6365
6453
  const server = new WisewandMCPServer(config);
6366
- logger.info("Testing API connectivity...");
6367
- try {
6368
- const apiHealth = await server.testAPIConnection();
6369
- if (!apiHealth.ok) {
6370
- console.error("\u274C FATAL: Cannot connect to Wisewand API");
6371
- console.error(` Reason: ${apiHealth.error}`);
6372
- console.error(" Check your WISEWAND_API_KEY and network connection");
6373
- console.error(" Get your API key from: https://app.wisewand.ai/api");
6374
- process.exit(1);
6375
- }
6376
- logger.info("\u2713 API connectivity verified");
6377
- } catch (error) {
6378
- console.error("\u274C FATAL: Failed to validate API connection");
6379
- console.error(` Error: ${error.message}`);
6380
- console.error(" Check your WISEWAND_API_KEY and network connection");
6381
- process.exit(1);
6382
- }
6383
6454
  const transport = new StdioServerTransport();
6384
6455
  await server.connect(transport);
6385
6456
  logger.info("Wisewand MCP Server started successfully", {
@@ -6396,11 +6467,9 @@ async function main() {
6396
6467
  __name(main, "main");
6397
6468
  process.on("uncaughtException", (error) => {
6398
6469
  logCriticalError("Uncaught Exception", error);
6399
- process.exit(1);
6400
6470
  });
6401
6471
  process.on("unhandledRejection", (reason) => {
6402
6472
  logCriticalError("Unhandled Rejection", reason);
6403
- process.exit(1);
6404
6473
  });
6405
6474
  main();
6406
6475
  export {