@withpica/mcp-server-directory 1.5.0 → 1.6.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -1
  3. package/dist/client.d.ts +16 -1
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js.map +1 -1
  6. package/dist/config.d.ts +6 -0
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +8 -1
  9. package/dist/config.js.map +1 -1
  10. package/dist/lib/changelog.generated.d.ts +2 -2
  11. package/dist/lib/changelog.generated.d.ts.map +1 -1
  12. package/dist/lib/changelog.generated.js +2 -2
  13. package/dist/lib/changelog.generated.js.map +1 -1
  14. package/dist/prompts/public-question-atlas.d.ts.map +1 -1
  15. package/dist/prompts/public-question-atlas.js +3 -0
  16. package/dist/prompts/public-question-atlas.js.map +1 -1
  17. package/dist/server.d.ts +9 -1
  18. package/dist/server.d.ts.map +1 -1
  19. package/dist/server.js +15 -5
  20. package/dist/server.js.map +1 -1
  21. package/dist/tools/chain.d.ts +2 -2
  22. package/dist/tools/chain.d.ts.map +1 -1
  23. package/dist/tools/chain.js +15 -0
  24. package/dist/tools/chain.js.map +1 -1
  25. package/dist/tools/enquiries.d.ts +2 -2
  26. package/dist/tools/enquiries.d.ts.map +1 -1
  27. package/dist/tools/enquiries.js.map +1 -1
  28. package/dist/tools/index.d.ts +2 -2
  29. package/dist/tools/index.d.ts.map +1 -1
  30. package/dist/tools/index.js.map +1 -1
  31. package/dist/tools/people.d.ts +2 -2
  32. package/dist/tools/people.d.ts.map +1 -1
  33. package/dist/tools/people.js.map +1 -1
  34. package/dist/tools/recordings.d.ts +2 -2
  35. package/dist/tools/recordings.d.ts.map +1 -1
  36. package/dist/tools/recordings.js.map +1 -1
  37. package/dist/tools/release-notes.d.ts +2 -2
  38. package/dist/tools/release-notes.d.ts.map +1 -1
  39. package/dist/tools/release-notes.js.map +1 -1
  40. package/dist/tools/search.d.ts +2 -2
  41. package/dist/tools/search.d.ts.map +1 -1
  42. package/dist/tools/search.js.map +1 -1
  43. package/dist/tools/works.d.ts +2 -2
  44. package/dist/tools/works.d.ts.map +1 -1
  45. package/dist/tools/works.js.map +1 -1
  46. package/dist/utils/errors.d.ts +10 -0
  47. package/dist/utils/errors.d.ts.map +1 -1
  48. package/dist/utils/errors.js +33 -0
  49. package/dist/utils/errors.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/__tests__/tools/chain.test.ts +34 -0
  52. package/src/__tests__/utils/errors.test.ts +13 -0
  53. package/src/client.ts +16 -1
  54. package/src/config.ts +12 -1
  55. package/src/prompts/public-question-atlas.ts +3 -0
  56. package/src/server.ts +19 -7
  57. package/src/tools/chain.ts +18 -3
  58. package/src/tools/enquiries.ts +3 -3
  59. package/src/tools/index.ts +2 -2
  60. package/src/tools/people.ts +3 -3
  61. package/src/tools/recordings.ts +3 -3
  62. package/src/tools/release-notes.ts +2 -2
  63. package/src/tools/search.ts +3 -3
  64. package/src/tools/works.ts +3 -3
  65. package/src/utils/errors.ts +40 -0
@@ -19,6 +19,24 @@ export class ToolExecutionError extends McpServerError {
19
19
  }
20
20
  }
21
21
 
22
+ /**
23
+ * Status → code for a route refusal that carried no code of its own.
24
+ *
25
+ * ⚠️ A port of `STATUS_REFUSAL_CODES` in
26
+ * `mcp-server-shared/mcp-utils/src/errors.ts`. This package does not depend on
27
+ * `@withpica/mcp-utils` (it publishes on its own), so it cannot import the
28
+ * shared formatter; `scripts/__tests__/format-error-status-parity.test.ts`
29
+ * fails if the two tables disagree.
30
+ */
31
+ export const STATUS_REFUSAL_CODES: Record<number, string> = {
32
+ 400: "VALIDATION_ERROR",
33
+ 404: "NOT_FOUND",
34
+ 409: "CONFLICT",
35
+ 413: "PAYLOAD_TOO_LARGE",
36
+ 415: "UNSUPPORTED_MEDIA_TYPE",
37
+ 422: "VALIDATION_ERROR",
38
+ };
39
+
22
40
  export function formatError(error: any): { type: string; text: string } {
23
41
  if (error instanceof McpServerError) {
24
42
  return {
@@ -78,6 +96,28 @@ export function formatError(error: any): { type: string; text: string } {
78
96
  };
79
97
  }
80
98
 
99
+ // A code-less 4xx is still a refusal; its status names the kind. Without
100
+ // this it read as UNKNOWN_ERROR, the bucket for an unclassified crash (ops
101
+ // issue 55510879 — the same defect in the shared formatter).
102
+ const status = (error as { status?: unknown })?.status;
103
+ const statusCode =
104
+ typeof status === "number" ? STATUS_REFUSAL_CODES[status] : undefined;
105
+ if (statusCode) {
106
+ return {
107
+ type: "text",
108
+ text: JSON.stringify(
109
+ {
110
+ error: statusCode,
111
+ message: bodyMessage || rawMessage,
112
+ status,
113
+ ...(bodyDetails !== undefined ? { details: bodyDetails } : {}),
114
+ },
115
+ null,
116
+ 2,
117
+ ),
118
+ };
119
+ }
120
+
81
121
  return {
82
122
  type: "text",
83
123
  text: JSON.stringify(