@wootsup/mcp 0.1.0 → 0.4.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 (208) hide show
  1. package/CHANGELOG.md +157 -83
  2. package/README.md +31 -27
  3. package/SECURITY.md +15 -6
  4. package/dist/auth/keychain.d.ts +27 -1
  5. package/dist/auth/keychain.js +48 -2
  6. package/dist/auth/keychain.js.map +1 -1
  7. package/dist/catalog/build-catalog.d.ts +31 -0
  8. package/dist/catalog/build-catalog.js +68 -0
  9. package/dist/catalog/build-catalog.js.map +1 -0
  10. package/dist/cli-hint.d.ts +22 -0
  11. package/dist/cli-hint.js +55 -0
  12. package/dist/cli-hint.js.map +1 -0
  13. package/dist/index.js +129 -22
  14. package/dist/index.js.map +1 -1
  15. package/dist/install-skill.js +1 -1
  16. package/dist/modules/apimapper/auto-layout.d.ts +21 -0
  17. package/dist/modules/apimapper/auto-layout.js +54 -0
  18. package/dist/modules/apimapper/auto-layout.js.map +1 -0
  19. package/dist/modules/apimapper/cache.js +25 -17
  20. package/dist/modules/apimapper/cache.js.map +1 -1
  21. package/dist/modules/apimapper/client.d.ts +115 -4
  22. package/dist/modules/apimapper/client.js +699 -304
  23. package/dist/modules/apimapper/client.js.map +1 -1
  24. package/dist/modules/apimapper/connections-format.d.ts +31 -1
  25. package/dist/modules/apimapper/connections-format.js +97 -5
  26. package/dist/modules/apimapper/connections-format.js.map +1 -1
  27. package/dist/modules/apimapper/connections.d.ts +9 -7
  28. package/dist/modules/apimapper/connections.js +449 -127
  29. package/dist/modules/apimapper/connections.js.map +1 -1
  30. package/dist/modules/apimapper/credential-sanitizer.d.ts +5 -0
  31. package/dist/modules/apimapper/credential-sanitizer.js +60 -1
  32. package/dist/modules/apimapper/credential-sanitizer.js.map +1 -1
  33. package/dist/modules/apimapper/credentials.js +105 -61
  34. package/dist/modules/apimapper/credentials.js.map +1 -1
  35. package/dist/modules/apimapper/diagnose.js +21 -2
  36. package/dist/modules/apimapper/diagnose.js.map +1 -1
  37. package/dist/modules/apimapper/elicitation.d.ts +29 -0
  38. package/dist/modules/apimapper/elicitation.js +62 -0
  39. package/dist/modules/apimapper/elicitation.js.map +1 -1
  40. package/dist/modules/apimapper/example-extract.d.ts +13 -0
  41. package/dist/modules/apimapper/example-extract.js +111 -0
  42. package/dist/modules/apimapper/example-extract.js.map +1 -0
  43. package/dist/modules/apimapper/filter-operators.d.ts +24 -0
  44. package/dist/modules/apimapper/filter-operators.js +103 -0
  45. package/dist/modules/apimapper/filter-operators.js.map +1 -0
  46. package/dist/modules/apimapper/flows-format.js +92 -22
  47. package/dist/modules/apimapper/flows-format.js.map +1 -1
  48. package/dist/modules/apimapper/flows.d.ts +8 -7
  49. package/dist/modules/apimapper/flows.js +275 -120
  50. package/dist/modules/apimapper/flows.js.map +1 -1
  51. package/dist/modules/apimapper/gateway/advanced-read-tool.d.ts +9 -0
  52. package/dist/modules/apimapper/gateway/advanced-read-tool.js +172 -0
  53. package/dist/modules/apimapper/gateway/advanced-read-tool.js.map +1 -0
  54. package/dist/modules/apimapper/gateway/advanced-tool.js +66 -106
  55. package/dist/modules/apimapper/gateway/advanced-tool.js.map +1 -1
  56. package/dist/modules/apimapper/gateway/collect-module-tools.d.ts +17 -0
  57. package/dist/modules/apimapper/gateway/collect-module-tools.js +44 -0
  58. package/dist/modules/apimapper/gateway/collect-module-tools.js.map +1 -0
  59. package/dist/modules/apimapper/gateway/essentials.d.ts +1 -1
  60. package/dist/modules/apimapper/gateway/essentials.js +21 -2
  61. package/dist/modules/apimapper/gateway/essentials.js.map +1 -1
  62. package/dist/modules/apimapper/gateway/gateway-shared.d.ts +21 -0
  63. package/dist/modules/apimapper/gateway/gateway-shared.js +124 -0
  64. package/dist/modules/apimapper/gateway/gateway-shared.js.map +1 -0
  65. package/dist/modules/apimapper/gateway/test-support.d.ts +1 -17
  66. package/dist/modules/apimapper/gateway/test-support.js +4 -33
  67. package/dist/modules/apimapper/gateway/test-support.js.map +1 -1
  68. package/dist/modules/apimapper/get-skill-cores.d.ts +4 -0
  69. package/dist/modules/apimapper/get-skill-cores.js +220 -0
  70. package/dist/modules/apimapper/get-skill-cores.js.map +1 -0
  71. package/dist/modules/apimapper/get-skill.d.ts +1 -1
  72. package/dist/modules/apimapper/get-skill.js +74 -9
  73. package/dist/modules/apimapper/get-skill.js.map +1 -1
  74. package/dist/modules/apimapper/graph-builder.d.ts +85 -2
  75. package/dist/modules/apimapper/graph-builder.js +151 -15
  76. package/dist/modules/apimapper/graph-builder.js.map +1 -1
  77. package/dist/modules/apimapper/graph.js +152 -48
  78. package/dist/modules/apimapper/graph.js.map +1 -1
  79. package/dist/modules/apimapper/index.js +27 -13
  80. package/dist/modules/apimapper/index.js.map +1 -1
  81. package/dist/modules/apimapper/jmespath-test.d.ts +4 -0
  82. package/dist/modules/apimapper/jmespath-test.js +152 -0
  83. package/dist/modules/apimapper/jmespath-test.js.map +1 -0
  84. package/dist/modules/apimapper/library.js +553 -88
  85. package/dist/modules/apimapper/library.js.map +1 -1
  86. package/dist/modules/apimapper/license.js +12 -36
  87. package/dist/modules/apimapper/license.js.map +1 -1
  88. package/dist/modules/apimapper/list-footer.d.ts +27 -0
  89. package/dist/modules/apimapper/list-footer.js +57 -0
  90. package/dist/modules/apimapper/list-footer.js.map +1 -0
  91. package/dist/modules/apimapper/local-sources.js +100 -57
  92. package/dist/modules/apimapper/local-sources.js.map +1 -1
  93. package/dist/modules/apimapper/mcp-client-identity.d.ts +32 -0
  94. package/dist/modules/apimapper/mcp-client-identity.js +70 -0
  95. package/dist/modules/apimapper/mcp-client-identity.js.map +1 -0
  96. package/dist/modules/apimapper/merge-constants.d.ts +6 -0
  97. package/dist/modules/apimapper/merge-constants.js +26 -0
  98. package/dist/modules/apimapper/merge-constants.js.map +1 -0
  99. package/dist/modules/apimapper/misc.js +13 -27
  100. package/dist/modules/apimapper/misc.js.map +1 -1
  101. package/dist/modules/apimapper/node-schema.d.ts +52 -2
  102. package/dist/modules/apimapper/node-schema.js +95 -4
  103. package/dist/modules/apimapper/node-schema.js.map +1 -1
  104. package/dist/modules/apimapper/onboarding.d.ts +59 -1
  105. package/dist/modules/apimapper/onboarding.js +231 -28
  106. package/dist/modules/apimapper/onboarding.js.map +1 -1
  107. package/dist/modules/apimapper/read-cache.d.ts +16 -3
  108. package/dist/modules/apimapper/read-cache.js +59 -4
  109. package/dist/modules/apimapper/read-cache.js.map +1 -1
  110. package/dist/modules/apimapper/render/index.js +26 -5
  111. package/dist/modules/apimapper/render/index.js.map +1 -1
  112. package/dist/modules/apimapper/resource-id.d.ts +13 -0
  113. package/dist/modules/apimapper/resource-id.js +69 -0
  114. package/dist/modules/apimapper/resource-id.js.map +1 -0
  115. package/dist/modules/apimapper/schema.js +9 -18
  116. package/dist/modules/apimapper/schema.js.map +1 -1
  117. package/dist/modules/apimapper/settings.js +49 -52
  118. package/dist/modules/apimapper/settings.js.map +1 -1
  119. package/dist/modules/apimapper/sites-tools.d.ts +29 -0
  120. package/dist/modules/apimapper/sites-tools.js +165 -0
  121. package/dist/modules/apimapper/sites-tools.js.map +1 -0
  122. package/dist/modules/apimapper/tool-result.d.ts +66 -0
  123. package/dist/modules/apimapper/tool-result.js +125 -0
  124. package/dist/modules/apimapper/tool-result.js.map +1 -0
  125. package/dist/modules/apimapper/toolslist-size.d.ts +12 -11
  126. package/dist/modules/apimapper/toolslist-size.js +34 -21
  127. package/dist/modules/apimapper/toolslist-size.js.map +1 -1
  128. package/dist/modules/apimapper/types.d.ts +34 -0
  129. package/dist/modules/apimapper/types.js +1 -1
  130. package/dist/modules/apimapper/types.js.map +1 -1
  131. package/dist/modules/apimapper/whitelist-drift.d.ts +85 -0
  132. package/dist/modules/apimapper/whitelist-drift.js +375 -0
  133. package/dist/modules/apimapper/whitelist-drift.js.map +1 -0
  134. package/dist/modules/apimapper/workflows.js +302 -58
  135. package/dist/modules/apimapper/workflows.js.map +1 -1
  136. package/dist/modules/apimapper/yootheme-binding.d.ts +35 -0
  137. package/dist/modules/apimapper/yootheme-binding.js +267 -0
  138. package/dist/modules/apimapper/yootheme-binding.js.map +1 -0
  139. package/dist/platform/index.d.ts +56 -0
  140. package/dist/platform/index.js +158 -2
  141. package/dist/platform/index.js.map +1 -1
  142. package/dist/proxy/bridge.d.ts +35 -0
  143. package/dist/proxy/bridge.js +129 -0
  144. package/dist/proxy/bridge.js.map +1 -0
  145. package/dist/proxy/mode.d.ts +9 -0
  146. package/dist/proxy/mode.js +20 -0
  147. package/dist/proxy/mode.js.map +1 -0
  148. package/dist/setup/detect-clients.d.ts +40 -1
  149. package/dist/setup/detect-clients.js +148 -1
  150. package/dist/setup/detect-clients.js.map +1 -1
  151. package/dist/setup/probe-auth.d.ts +51 -0
  152. package/dist/setup/probe-auth.js +141 -0
  153. package/dist/setup/probe-auth.js.map +1 -0
  154. package/dist/setup/probe-handshake.js +40 -7
  155. package/dist/setup/probe-handshake.js.map +1 -1
  156. package/dist/setup/remove-config.d.ts +8 -0
  157. package/dist/setup/remove-config.js +145 -0
  158. package/dist/setup/remove-config.js.map +1 -0
  159. package/dist/setup/uninstall.d.ts +34 -0
  160. package/dist/setup/uninstall.js +147 -0
  161. package/dist/setup/uninstall.js.map +1 -0
  162. package/dist/setup-cli.d.ts +16 -0
  163. package/dist/setup-cli.js +63 -1
  164. package/dist/setup-cli.js.map +1 -1
  165. package/dist/sites/loader.d.ts +48 -0
  166. package/dist/sites/loader.js +134 -0
  167. package/dist/sites/loader.js.map +1 -0
  168. package/dist/sites/schema.d.ts +69 -0
  169. package/dist/sites/schema.js +71 -0
  170. package/dist/sites/schema.js.map +1 -0
  171. package/dist/sites/secret-resolver.d.ts +47 -0
  172. package/dist/sites/secret-resolver.js +150 -0
  173. package/dist/sites/secret-resolver.js.map +1 -0
  174. package/dist/skill-instructions.d.ts +14 -1
  175. package/dist/skill-instructions.js +35 -6
  176. package/dist/skill-instructions.js.map +1 -1
  177. package/dist/transports/stdio.js +4 -4
  178. package/dist/transports/stdio.js.map +1 -1
  179. package/dist/uninstall-skill.d.ts +27 -0
  180. package/dist/uninstall-skill.js +89 -0
  181. package/dist/uninstall-skill.js.map +1 -0
  182. package/docs/architecture.md +21 -21
  183. package/docs/customgraph-internal-migration.md +4 -4
  184. package/docs/security.md +2 -21
  185. package/docs/tools.md +40 -12
  186. package/manifest.json +77 -79
  187. package/package.json +69 -65
  188. package/skills/apimapper/SKILL.md +128 -7
  189. package/skills/apimapper/reference/conditional-style-multi-items.md +114 -0
  190. package/skills/apimapper/reference/dynamize-existing-layout.md +158 -0
  191. package/skills/apimapper/reference/jmespath-cookbook.md +241 -0
  192. package/skills/apimapper/reference/jmespath-pitfalls.md +189 -0
  193. package/skills/apimapper/reference/joomla.md +1 -1
  194. package/skills/apimapper/reference/library-template-discovery.md +65 -0
  195. package/skills/apimapper/reference/merge-two-sources-on-key.md +204 -0
  196. package/skills/apimapper/reference/oauth.md +143 -52
  197. package/skills/apimapper/reference/troubleshooting.md +22 -2
  198. package/skills/apimapper/reference/yootheme-source-to-builder-handoff.md +348 -0
  199. package/skills/apimapper/reference/yootheme.md +75 -44
  200. package/dist/auth/oauth-provider.d.ts +0 -68
  201. package/dist/auth/oauth-provider.js +0 -232
  202. package/dist/auth/oauth-provider.js.map +0 -1
  203. package/dist/server-http.d.ts +0 -22
  204. package/dist/server-http.js +0 -159
  205. package/dist/server-http.js.map +0 -1
  206. package/dist/transports/http.d.ts +0 -29
  207. package/dist/transports/http.js +0 -267
  208. package/dist/transports/http.js.map +0 -1
@@ -1,5 +1,6 @@
1
1
  import { type ApiResponse } from "@getimo/mcp-toolkit";
2
2
  import { type Platform } from "../../platform/index.js";
3
+ import { type SitesRegistry } from "../../sites/loader.js";
3
4
  /**
4
5
  * WordPress / Joomla site base URL.
5
6
  *
@@ -45,7 +46,7 @@ export declare function sanitizeErrorString(s: string): string;
45
46
  * The underlying toolkit `ApiResponse` only carries `{success, data?, error?}`.
46
47
  * We wrap each call so we capture the HTTP code via `fetch` and merge.
47
48
  */
48
- export type ApiErrorCode = "auth" | "not_found" | "rate_limit" | "server" | "network" | "unknown";
49
+ export type ApiErrorCode = "auth" | "not_found" | "conflict" | "rate_limit" | "server" | "network" | "credential_expired" | "tier_limit_reached" | "unknown";
49
50
  export interface ExtApiResponse<T = unknown> extends ApiResponse<T> {
50
51
  status?: number;
51
52
  errorCode?: ApiErrorCode;
@@ -105,6 +106,66 @@ export interface PlatformClient {
105
106
  */
106
107
  export declare function createPlatformClient(platform: Platform): PlatformClient;
107
108
  export declare const PLATFORM_KIND: "wordpress" | "joomla";
109
+ /**
110
+ * Network platform auto-detect. Concurrently probes the WordPress REST identity
111
+ * endpoint and the Joomla com_ajax getIdentity task with the same auth header,
112
+ * and decides which CMS is actually running at WP_BASE:
113
+ *
114
+ * - Joomla wins if its probe is HTTP 200 AND the body parses to
115
+ * `{success:true, data:[{success:true, …}]}` (or `data[0].platform` set).
116
+ * - WordPress wins if its probe is HTTP 200 AND the body is a JSON object
117
+ * that is NOT a `{success:false}` error envelope.
118
+ * - If both look OK (shouldn't happen on a single CMS), prefer the one whose
119
+ * reported identity `.platform` matches its own kind; else WordPress.
120
+ * - If neither answers → return "wordpress" (graceful fallback — no worse
121
+ * than the pre-Phase-1 silent default).
122
+ *
123
+ * All fetch errors are swallowed → fallback. The token is sent on the wire but
124
+ * never logged. Short timeout so a blocked probe host can't stall startup.
125
+ *
126
+ * Phase 3 (2026-06-03): accepts optional `(baseUrl, token)` overrides so a
127
+ * per-site probe (sites-file path) can target the entry's own URL + token. The
128
+ * no-arg call preserves the env-path behaviour exactly (module WP_BASE +
129
+ * probeAuthHeader()).
130
+ */
131
+ export declare function probePlatform(baseUrl?: string, token?: string): Promise<"wordpress" | "joomla">;
132
+ /**
133
+ * Lazily load + memoize the sites-file registry from APIMAPPER_SITES_FILE.
134
+ * Returns `null` when the env var is unset/empty, the file is absent, or it has
135
+ * zero sites — in all those cases the caller falls through to the env path.
136
+ * A malformed / schema-invalid file throws `SitesFileError` (loud-fail at first
137
+ * use rather than silently degrading multi-site to single-site).
138
+ */
139
+ export declare function getSitesRegistry(): SitesRegistry | null;
140
+ /**
141
+ * The currently-active site_id, or `null` when none has been explicitly set
142
+ * (the file's default entry is then used) or when no sites-file is loaded.
143
+ */
144
+ export declare function getActiveSiteId(): string | null;
145
+ /**
146
+ * Switch the active site. Validates that `id` exists in the loaded sites-file
147
+ * registry, updates the in-memory pointer, and resets the resolution memo so
148
+ * the next `request()` re-resolves (URL + token + platform) against the new
149
+ * site. Throws when no sites-file is loaded or the id is unknown — the pointer
150
+ * is NOT changed on error.
151
+ */
152
+ export declare function setActiveSite(id: string): void;
153
+ /**
154
+ * Drop the memoized platform resolution (and the cached sites-file registry +
155
+ * active-site pointer) so the next `request()` re-resolves from scratch —
156
+ * re-reading APIMAPPER_SITES_FILE, re-running the env-check / network probe.
157
+ *
158
+ * Production callers: invoke after deliberately changing the active selection
159
+ * outside `setActiveSite()` (the tool wiring uses `setActiveSite`, which already
160
+ * resets the memo). Safe to call any time.
161
+ */
162
+ export declare function resetPlatformResolution(): void;
163
+ /**
164
+ * Test-only alias of {@link resetPlatformResolution}, kept for the existing
165
+ * Phase-1 client tests that reference it by this name. New code should call
166
+ * `resetPlatformResolution()`.
167
+ */
168
+ export declare function __resetPlatformResolutionForTests(): void;
108
169
  /**
109
170
  * Issue a request through the toolkit HTTP client + capture HTTP status.
110
171
  *
@@ -120,11 +181,61 @@ export declare const PLATFORM_KIND: "wordpress" | "joomla";
120
181
  */
121
182
  export declare function request<T = unknown>(path: string, init?: RequestInit, opts?: RequestOpts): Promise<ExtApiResponse<T>>;
122
183
  /**
123
- * Map an `errorCode` to a focused hint string for the caller.
124
- * Falls back to the generic health-tool hint.
184
+ * Optional second argument to {@link hintFor}, used to route a hint more
185
+ * precisely than the coarse `ApiErrorCode` alone allows. Both fields are
186
+ * optional and every legacy `hintFor(code)` call keeps its exact prior
187
+ * output (back-compat), so the ~12 call sites need not change.
188
+ *
189
+ * Welle 2 (F112 + F113, 2026-06-11):
190
+ * - `message`: the upstream error string. Lets the `unknown` branch route
191
+ * a config/validation/argument error to a "fix the field / fix the flow
192
+ * shape / detect schema" hint instead of the catch-all HEALTH_HINT
193
+ * (which sends the agent on a connectivity probe that always passes).
194
+ * It is also the channel for the F83 JMESPath depth-limit detection
195
+ * (see {@link DEPTH_SPLIT_HINT}).
196
+ * - `origin`: WHERE a 401/403 came from. `classify()` maps every 401/403
197
+ * to `'auth'`, but a 401/403 raised by a *connection* / *credential*
198
+ * fetch is an EXPIRED UPSTREAM token, not a broken MCP key. With
199
+ * `origin: 'connection' | 'credential'` the auth branch steers to
200
+ * re-authorising the upstream credential (`oauth_authorize_begin`)
201
+ * rather than rotating the still-valid MCP bearer key.
125
202
  */
126
- export declare function hintFor(code?: ApiErrorCode): string;
203
+ export interface HintContext {
204
+ /** The upstream error message, used for message-pattern routing of `unknown`. */
205
+ message?: string;
206
+ /**
207
+ * The origin of an auth (401/403) failure. `connection` / `credential`
208
+ * mean an expired upstream token; `mcp_transport` (or omitted) means the
209
+ * MCP bearer key itself.
210
+ */
211
+ origin?: "connection" | "credential" | "mcp_transport";
212
+ }
213
+ export declare const DEPTH_SPLIT_HINT: string;
214
+ /**
215
+ * Map an `errorCode` (and optional {@link HintContext}) to a focused hint
216
+ * string for the caller. Falls back to the generic health-tool hint only for
217
+ * genuinely connectivity-shaped failures.
218
+ *
219
+ * The second argument is a UNION: a bare `string` is treated as
220
+ * `{ message }` so the ~12 legacy call sites that pass the upstream error
221
+ * string verbatim (`hintFor(code, r.error)`) keep working unchanged, while
222
+ * the richer `{ message, origin }` form drives F112/F113 routing. Omit it to
223
+ * keep the legacy code-only behaviour byte-for-byte.
224
+ */
225
+ export declare function hintFor(code?: ApiErrorCode, context?: string | HintContext): string;
127
226
  export declare const HEALTH_HINT = "Use apimapper_health to check connectivity and auth.";
227
+ /**
228
+ * Recovery hint for an auth failure on the MCP transport itself (the bearer
229
+ * key is wrong/revoked/expired). Kept verbatim for the legacy `hintFor('auth')`
230
+ * contract.
231
+ */
232
+ export declare const MCP_KEY_AUTH_HINT: string;
233
+ /**
234
+ * F113 — recovery hint for an EXPIRED UPSTREAM credential surfaced as a
235
+ * connection/credential 401/403. The fix is to re-authorise the credential in
236
+ * place (preserving the refresh_token), NOT to rotate the MCP key.
237
+ */
238
+ export declare const CREDENTIAL_EXPIRED_HINT: string;
128
239
  export declare function authConfigured(): boolean;
129
240
  export declare const api: {
130
241
  request: <T>(path: string, init?: RequestInit, _retryCount?: number, responseSchema?: import("zod").ZodType<T>) => Promise<ApiResponse<T>>;