@wootsup/mcp 0.1.0-rc.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/CHANGELOG.md +91 -0
- package/LICENSE +21 -0
- package/README.md +179 -0
- package/SECURITY.md +163 -0
- package/dist/auth/keychain.d.ts +47 -0
- package/dist/auth/keychain.js +262 -0
- package/dist/auth/keychain.js.map +1 -0
- package/dist/auth/oauth-provider.d.ts +68 -0
- package/dist/auth/oauth-provider.js +232 -0
- package/dist/auth/oauth-provider.js.map +1 -0
- package/dist/auth/profiles.d.ts +52 -0
- package/dist/auth/profiles.js +200 -0
- package/dist/auth/profiles.js.map +1 -0
- package/dist/auth/token.d.ts +27 -0
- package/dist/auth/token.js +88 -0
- package/dist/auth/token.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +137 -0
- package/dist/index.js.map +1 -0
- package/dist/install-skill.d.ts +23 -0
- package/dist/install-skill.js +73 -0
- package/dist/install-skill.js.map +1 -0
- package/dist/modules/apimapper/cache.d.ts +2 -0
- package/dist/modules/apimapper/cache.js +71 -0
- package/dist/modules/apimapper/cache.js.map +1 -0
- package/dist/modules/apimapper/client.d.ts +85 -0
- package/dist/modules/apimapper/client.js +523 -0
- package/dist/modules/apimapper/client.js.map +1 -0
- package/dist/modules/apimapper/connections.d.ts +2 -0
- package/dist/modules/apimapper/connections.js +406 -0
- package/dist/modules/apimapper/connections.js.map +1 -0
- package/dist/modules/apimapper/credential-sanitizer.d.ts +7 -0
- package/dist/modules/apimapper/credential-sanitizer.js +70 -0
- package/dist/modules/apimapper/credential-sanitizer.js.map +1 -0
- package/dist/modules/apimapper/credentials.d.ts +2 -0
- package/dist/modules/apimapper/credentials.js +258 -0
- package/dist/modules/apimapper/credentials.js.map +1 -0
- package/dist/modules/apimapper/diagnose.d.ts +18 -0
- package/dist/modules/apimapper/diagnose.js +305 -0
- package/dist/modules/apimapper/diagnose.js.map +1 -0
- package/dist/modules/apimapper/flows.d.ts +2 -0
- package/dist/modules/apimapper/flows.js +372 -0
- package/dist/modules/apimapper/flows.js.map +1 -0
- package/dist/modules/apimapper/get-skill.d.ts +4 -0
- package/dist/modules/apimapper/get-skill.js +88 -0
- package/dist/modules/apimapper/get-skill.js.map +1 -0
- package/dist/modules/apimapper/graph-builder.d.ts +47 -0
- package/dist/modules/apimapper/graph-builder.js +117 -0
- package/dist/modules/apimapper/graph-builder.js.map +1 -0
- package/dist/modules/apimapper/graph.d.ts +2 -0
- package/dist/modules/apimapper/graph.js +117 -0
- package/dist/modules/apimapper/graph.js.map +1 -0
- package/dist/modules/apimapper/index.d.ts +2 -0
- package/dist/modules/apimapper/index.js +43 -0
- package/dist/modules/apimapper/index.js.map +1 -0
- package/dist/modules/apimapper/inspect.d.ts +20 -0
- package/dist/modules/apimapper/inspect.js +86 -0
- package/dist/modules/apimapper/inspect.js.map +1 -0
- package/dist/modules/apimapper/library.d.ts +2 -0
- package/dist/modules/apimapper/library.js +237 -0
- package/dist/modules/apimapper/library.js.map +1 -0
- package/dist/modules/apimapper/license.d.ts +2 -0
- package/dist/modules/apimapper/license.js +142 -0
- package/dist/modules/apimapper/license.js.map +1 -0
- package/dist/modules/apimapper/local-sources.d.ts +2 -0
- package/dist/modules/apimapper/local-sources.js +123 -0
- package/dist/modules/apimapper/local-sources.js.map +1 -0
- package/dist/modules/apimapper/misc.d.ts +2 -0
- package/dist/modules/apimapper/misc.js +149 -0
- package/dist/modules/apimapper/misc.js.map +1 -0
- package/dist/modules/apimapper/node-schema.d.ts +217 -0
- package/dist/modules/apimapper/node-schema.js +218 -0
- package/dist/modules/apimapper/node-schema.js.map +1 -0
- package/dist/modules/apimapper/normalizers.d.ts +13 -0
- package/dist/modules/apimapper/normalizers.js +37 -0
- package/dist/modules/apimapper/normalizers.js.map +1 -0
- package/dist/modules/apimapper/onboarding.d.ts +51 -0
- package/dist/modules/apimapper/onboarding.js +201 -0
- package/dist/modules/apimapper/onboarding.js.map +1 -0
- package/dist/modules/apimapper/schema.d.ts +2 -0
- package/dist/modules/apimapper/schema.js +84 -0
- package/dist/modules/apimapper/schema.js.map +1 -0
- package/dist/modules/apimapper/settings.d.ts +2 -0
- package/dist/modules/apimapper/settings.js +157 -0
- package/dist/modules/apimapper/settings.js.map +1 -0
- package/dist/modules/apimapper/skill-resources.d.ts +4 -0
- package/dist/modules/apimapper/skill-resources.js +85 -0
- package/dist/modules/apimapper/skill-resources.js.map +1 -0
- package/dist/modules/apimapper/types.d.ts +111 -0
- package/dist/modules/apimapper/types.js +14 -0
- package/dist/modules/apimapper/types.js.map +1 -0
- package/dist/modules/apimapper/use-profile.d.ts +34 -0
- package/dist/modules/apimapper/use-profile.js +176 -0
- package/dist/modules/apimapper/use-profile.js.map +1 -0
- package/dist/modules/apimapper/workflows.d.ts +2 -0
- package/dist/modules/apimapper/workflows.js +301 -0
- package/dist/modules/apimapper/workflows.js.map +1 -0
- package/dist/platform/index.d.ts +71 -0
- package/dist/platform/index.js +377 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/server-http.d.ts +22 -0
- package/dist/server-http.js +159 -0
- package/dist/server-http.js.map +1 -0
- package/dist/setup/detect-clients.d.ts +39 -0
- package/dist/setup/detect-clients.js +152 -0
- package/dist/setup/detect-clients.js.map +1 -0
- package/dist/setup/probe-handshake.d.ts +26 -0
- package/dist/setup/probe-handshake.js +159 -0
- package/dist/setup/probe-handshake.js.map +1 -0
- package/dist/setup/write-config.d.ts +25 -0
- package/dist/setup/write-config.js +247 -0
- package/dist/setup/write-config.js.map +1 -0
- package/dist/setup-cli.d.ts +49 -0
- package/dist/setup-cli.js +292 -0
- package/dist/setup-cli.js.map +1 -0
- package/dist/skill-instructions.d.ts +10 -0
- package/dist/skill-instructions.js +68 -0
- package/dist/skill-instructions.js.map +1 -0
- package/dist/transports/http.d.ts +29 -0
- package/dist/transports/http.js +267 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/transports/stdio.d.ts +9 -0
- package/dist/transports/stdio.js +19 -0
- package/dist/transports/stdio.js.map +1 -0
- package/docs/architecture.md +140 -0
- package/docs/customgraph-internal-migration.md +210 -0
- package/docs/security.md +126 -0
- package/docs/tools.md +230 -0
- package/manifest.json +76 -0
- package/package.json +61 -0
- package/skills/apimapper/SKILL.md +57 -0
- package/skills/apimapper/reference/joomla.md +85 -0
- package/skills/apimapper/reference/oauth.md +94 -0
- package/skills/apimapper/reference/troubleshooting.md +123 -0
- package/skills/apimapper/reference/yootheme.md +96 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { Connection, Flow, LibraryItem, LicenseStatus } from "./types.js";
|
|
3
|
+
export type SuggestionType = "activate-template" | "publish-flow" | "reconnect-oauth";
|
|
4
|
+
export interface OnboardingSuggestion {
|
|
5
|
+
type: SuggestionType;
|
|
6
|
+
label: string;
|
|
7
|
+
action: string;
|
|
8
|
+
}
|
|
9
|
+
export interface OnboardingSubError {
|
|
10
|
+
tool: string;
|
|
11
|
+
error: string;
|
|
12
|
+
}
|
|
13
|
+
export interface OnboardingReport {
|
|
14
|
+
site: {
|
|
15
|
+
wp_base: string;
|
|
16
|
+
};
|
|
17
|
+
license: Partial<LicenseStatus> & {
|
|
18
|
+
available: boolean;
|
|
19
|
+
};
|
|
20
|
+
connections: {
|
|
21
|
+
count: number;
|
|
22
|
+
items: Array<Pick<Connection, "id" | "name" | "source" | "auth_type" | "credential_id">>;
|
|
23
|
+
};
|
|
24
|
+
flows: {
|
|
25
|
+
count: number;
|
|
26
|
+
published: number;
|
|
27
|
+
draft: number;
|
|
28
|
+
items: Array<Pick<Flow, "id" | "name" | "source" | "is_compiled" | "node_count">>;
|
|
29
|
+
};
|
|
30
|
+
library: {
|
|
31
|
+
popular: Array<Pick<LibraryItem, "id" | "name" | "category">>;
|
|
32
|
+
};
|
|
33
|
+
suggestions: OnboardingSuggestion[];
|
|
34
|
+
errors: OnboardingSubError[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Pure function — given aggregated state, derive a small list of
|
|
38
|
+
* suggested next actions. Empty list if nothing useful to suggest.
|
|
39
|
+
*/
|
|
40
|
+
export declare function deriveSuggestions(args: {
|
|
41
|
+
connections: Connection[];
|
|
42
|
+
flows: Flow[];
|
|
43
|
+
expiredOauthCredentialIds: Set<string>;
|
|
44
|
+
popular: LibraryItem[];
|
|
45
|
+
}): OnboardingSuggestion[];
|
|
46
|
+
/**
|
|
47
|
+
* Run the five sub-calls in parallel + assemble an OnboardingReport.
|
|
48
|
+
* Never throws. Sub-call failures land in `errors[]`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildOnboardingReport(): Promise<OnboardingReport>;
|
|
51
|
+
export declare function registerOnboardingTool(server: McpServer): void;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// src/modules/apimapper/onboarding.ts — Phase 8.1 composite tool.
|
|
2
|
+
//
|
|
3
|
+
// `apimapper_onboarding` runs five read-only sub-calls in parallel via
|
|
4
|
+
// `Promise.allSettled` (vs sequential try/catch). Rationale: each sub-call
|
|
5
|
+
// is independent, so parallel cuts latency by ~5×, and `allSettled` gives
|
|
6
|
+
// us per-call success/failure without ever throwing.
|
|
7
|
+
//
|
|
8
|
+
// Partial-failure tolerance: any sub-call that fails (rejected promise OR
|
|
9
|
+
// `success:false` response) is recorded into `errors[]`. The remaining
|
|
10
|
+
// data is still returned. The tool NEVER throws.
|
|
11
|
+
//
|
|
12
|
+
// Suggestion engine: pure function that derives recommended next actions
|
|
13
|
+
// from the aggregated payload. Rules are simple and intentionally narrow —
|
|
14
|
+
// the goal is "show the user a sensible first step", not "complete agent
|
|
15
|
+
// reasoning". When in doubt, suggest nothing.
|
|
16
|
+
import { formatResult, readOnly } from "@getimo/mcp-toolkit";
|
|
17
|
+
import { request, WP_BASE } from "./client.js";
|
|
18
|
+
async function safeRequest(tool, path) {
|
|
19
|
+
try {
|
|
20
|
+
const r = await request(path);
|
|
21
|
+
if (!r.success) {
|
|
22
|
+
return { tool, data: null, error: r.error || "request failed" };
|
|
23
|
+
}
|
|
24
|
+
return { tool, data: (r.data ?? null), error: null };
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
return {
|
|
28
|
+
tool,
|
|
29
|
+
data: null,
|
|
30
|
+
error: e instanceof Error ? e.message : String(e),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// ── Suggestion rules ───────────────────────────────────────────────────
|
|
35
|
+
/**
|
|
36
|
+
* Pure function — given aggregated state, derive a small list of
|
|
37
|
+
* suggested next actions. Empty list if nothing useful to suggest.
|
|
38
|
+
*/
|
|
39
|
+
export function deriveSuggestions(args) {
|
|
40
|
+
const out = [];
|
|
41
|
+
// Rule 1: 0 connections AND library has popular items → activate-template.
|
|
42
|
+
if (args.connections.length === 0 && args.popular.length > 0) {
|
|
43
|
+
const first = args.popular[0];
|
|
44
|
+
out.push({
|
|
45
|
+
type: "activate-template",
|
|
46
|
+
label: `Activate "${first.name}" from the Library to get started`,
|
|
47
|
+
action: `apimapper_library_activate id=${first.id}`,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// Rule 2: 1+ flows created but 0 published → publish-flow.
|
|
51
|
+
const draftFlow = args.flows.find((f) => !f.is_compiled);
|
|
52
|
+
const anyPublished = args.flows.some((f) => f.is_compiled);
|
|
53
|
+
if (draftFlow && !anyPublished) {
|
|
54
|
+
out.push({
|
|
55
|
+
type: "publish-flow",
|
|
56
|
+
label: `Publish flow "${draftFlow.name}" so YOOtheme can see it`,
|
|
57
|
+
action: `apimapper_flow_full_recompile_publish id=${draftFlow.id}`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Rule 3: any connection whose oauth credential has expired → reconnect-oauth.
|
|
61
|
+
for (const c of args.connections) {
|
|
62
|
+
if (c.credential_id && args.expiredOauthCredentialIds.has(c.credential_id)) {
|
|
63
|
+
out.push({
|
|
64
|
+
type: "reconnect-oauth",
|
|
65
|
+
label: `Reconnect "${c.name}" — OAuth credential expired`,
|
|
66
|
+
action: `apimapper_credential_link credential_id=${c.credential_id}`,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Run the five sub-calls in parallel + assemble an OnboardingReport.
|
|
74
|
+
* Never throws. Sub-call failures land in `errors[]`.
|
|
75
|
+
*/
|
|
76
|
+
export async function buildOnboardingReport() {
|
|
77
|
+
const [health, license, connections, flows, popular] = await Promise.allSettled([
|
|
78
|
+
safeRequest("apimapper_health", "/connections"),
|
|
79
|
+
safeRequest("apimapper_license_status", "/license"),
|
|
80
|
+
safeRequest("apimapper_connection_list", "/connections"),
|
|
81
|
+
safeRequest("apimapper_flow_list", "/flows"),
|
|
82
|
+
safeRequest("apimapper_library_popular", "/library/popular?limit=5"),
|
|
83
|
+
]);
|
|
84
|
+
const errors = [];
|
|
85
|
+
// Helper that pulls .value from a settled promise + records any error.
|
|
86
|
+
const take = (s) => {
|
|
87
|
+
if (s.status === "rejected") {
|
|
88
|
+
// Should not happen — safeRequest swallows. Defensive.
|
|
89
|
+
errors.push({ tool: "unknown", error: String(s.reason) });
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
if (s.value.error) {
|
|
93
|
+
errors.push({ tool: s.value.tool, error: s.value.error });
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return s.value.data;
|
|
97
|
+
};
|
|
98
|
+
void take(health); // health call is just used to populate errors[]; data unused
|
|
99
|
+
const licenseData = take(license);
|
|
100
|
+
const connData = take(connections);
|
|
101
|
+
const flowData = take(flows);
|
|
102
|
+
const popularData = take(popular);
|
|
103
|
+
const allConns = Array.isArray(connData?.connections) ? connData.connections : [];
|
|
104
|
+
const allFlows = Array.isArray(flowData?.flows) ? flowData.flows : [];
|
|
105
|
+
const popItems = Array.isArray(popularData?.items) ? popularData.items : [];
|
|
106
|
+
// ── Conditional second-stage call: credentials, only if any conn has an oauth creds.
|
|
107
|
+
const oauthCredIds = allConns
|
|
108
|
+
.filter((c) => (c.auth_type || "").startsWith("oauth2") && c.credential_id)
|
|
109
|
+
.map((c) => c.credential_id);
|
|
110
|
+
let expiredOauthCredentialIds = new Set();
|
|
111
|
+
if (oauthCredIds.length > 0) {
|
|
112
|
+
const credRes = await safeRequest("apimapper_credential_list", "/credentials");
|
|
113
|
+
if (credRes.error) {
|
|
114
|
+
errors.push({ tool: credRes.tool, error: credRes.error });
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const creds = Array.isArray(credRes.data?.credentials) ? credRes.data.credentials : [];
|
|
118
|
+
const now = Date.now();
|
|
119
|
+
expiredOauthCredentialIds = new Set(creds
|
|
120
|
+
.filter((c) => {
|
|
121
|
+
if (!c.oauth_token_expires_at)
|
|
122
|
+
return false;
|
|
123
|
+
const t = Date.parse(c.oauth_token_expires_at);
|
|
124
|
+
return Number.isFinite(t) && t < now;
|
|
125
|
+
})
|
|
126
|
+
.map((c) => c.id));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const published = allFlows.filter((f) => f.is_compiled).length;
|
|
130
|
+
const draft = allFlows.filter((f) => !f.is_compiled).length;
|
|
131
|
+
const suggestions = deriveSuggestions({
|
|
132
|
+
connections: allConns,
|
|
133
|
+
flows: allFlows,
|
|
134
|
+
expiredOauthCredentialIds,
|
|
135
|
+
popular: popItems,
|
|
136
|
+
});
|
|
137
|
+
// License: licenseData is the raw /license response; surface known fields.
|
|
138
|
+
const licMap = (() => {
|
|
139
|
+
if (!licenseData || typeof licenseData !== "object")
|
|
140
|
+
return { available: false };
|
|
141
|
+
const o = licenseData;
|
|
142
|
+
return {
|
|
143
|
+
available: true,
|
|
144
|
+
status: typeof o.status === "string" ? o.status : undefined,
|
|
145
|
+
tier: typeof o.tier === "string" ? o.tier : undefined,
|
|
146
|
+
expires_at: typeof o.expires_at === "string" ? o.expires_at : null,
|
|
147
|
+
beta_channel: typeof o.beta_channel === "boolean" ? o.beta_channel : undefined,
|
|
148
|
+
};
|
|
149
|
+
})();
|
|
150
|
+
return {
|
|
151
|
+
site: { wp_base: WP_BASE },
|
|
152
|
+
license: licMap,
|
|
153
|
+
connections: {
|
|
154
|
+
count: allConns.length,
|
|
155
|
+
items: allConns.slice(0, 10).map((c) => ({
|
|
156
|
+
id: c.id,
|
|
157
|
+
name: c.name,
|
|
158
|
+
source: c.source,
|
|
159
|
+
auth_type: c.auth_type,
|
|
160
|
+
credential_id: c.credential_id ?? null,
|
|
161
|
+
})),
|
|
162
|
+
},
|
|
163
|
+
flows: {
|
|
164
|
+
count: allFlows.length,
|
|
165
|
+
published,
|
|
166
|
+
draft,
|
|
167
|
+
items: allFlows.slice(0, 10).map((f) => ({
|
|
168
|
+
id: f.id,
|
|
169
|
+
name: f.name,
|
|
170
|
+
source: f.source,
|
|
171
|
+
is_compiled: f.is_compiled,
|
|
172
|
+
node_count: f.node_count,
|
|
173
|
+
})),
|
|
174
|
+
},
|
|
175
|
+
library: {
|
|
176
|
+
popular: popItems.slice(0, 5).map((p) => ({
|
|
177
|
+
id: p.id,
|
|
178
|
+
name: p.name,
|
|
179
|
+
category: p.category,
|
|
180
|
+
})),
|
|
181
|
+
},
|
|
182
|
+
suggestions,
|
|
183
|
+
errors,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// ── MCP tool registration ──────────────────────────────────────────────
|
|
187
|
+
export function registerOnboardingTool(server) {
|
|
188
|
+
server.registerTool("apimapper_onboarding", {
|
|
189
|
+
title: "Onboarding Report (Composite)",
|
|
190
|
+
description: "Aggregate health, license, connections, flows, and popular library items into a single " +
|
|
191
|
+
"onboarding report with suggested next actions. Run this first when meeting a new install — " +
|
|
192
|
+
"tolerates partial failures and never throws." +
|
|
193
|
+
"\n\nExample:\n apimapper_onboarding({})",
|
|
194
|
+
inputSchema: {},
|
|
195
|
+
annotations: readOnly(),
|
|
196
|
+
}, async () => {
|
|
197
|
+
const report = await buildOnboardingReport();
|
|
198
|
+
return formatResult(report, false, { maxChars: 6000 });
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=onboarding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.js","sourceRoot":"","sources":["../../../src/modules/apimapper/onboarding.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,uEAAuE;AACvE,2EAA2E;AAC3E,0EAA0E;AAC1E,qDAAqD;AACrD,EAAE;AACF,0EAA0E;AAC1E,uEAAuE;AACvE,iDAAiD;AACjD,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,8CAA8C;AAG9C,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAmD/C,KAAK,UAAU,WAAW,CACxB,IAAY,EACZ,IAAY;IAEZ,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,OAAO,CAAI,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACf,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,gBAAgB,EAAE,CAAC;QAClE,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAa,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACnE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO;YACL,IAAI;YACJ,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;SAClD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,0E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QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACvC,EAAE,EAAE,CAAC,CAAC,EAAE;gBACR,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,UAAU,EAAE,CAAC,CAAC,UAAU;aACzB,CAAC,CAAC;SACJ;QACD,OAAO,EAAE;YACP,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACxC,EAAE,EAAE,CAAC,CAAC,EAAE;gBACR,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,QAAQ,EAAE,CAAC,CAAC,QAAQ;aACrB,CAAC,CAAC;SACJ;QACD,WAAW;QACX,MAAM;KACP,CAAC;AACJ,CAAC;AAED,0EAA0E;AAE1E,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,YAAY,CACjB,sBAAsB,EACtB;QACE,KAAK,EAAE,+BAA+B;QACtC,WAAW,EACT,yFAAyF;YACzF,6FAA6F;YAC7F,8CAA8C;YAC9C,0CAA0C;QAC5C,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,QAAQ,EAAE;KACxB,EACD,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,MAAM,qBAAqB,EAAE,CAAC;QAC7C,OAAO,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatResult, autoFormatTable, readOnly } from "@getimo/mcp-toolkit";
|
|
3
|
+
import { request, hintFor } from "./client.js";
|
|
4
|
+
export function registerSchemaTools(server) {
|
|
5
|
+
// ── apimapper_schema_profile ───────────────────────────────────────
|
|
6
|
+
server.registerTool("apimapper_schema_profile", {
|
|
7
|
+
title: "Profile Schema from Payload",
|
|
8
|
+
description: "Analyse a JSON payload and detect field names, types, nullability, sample values, and " +
|
|
9
|
+
"candidate items_path. Used by the Library Quick-Add to auto-configure new connections." +
|
|
10
|
+
"\n\nExample:\n apimapper_schema_profile({ payload: { photos: [{ id: 1, src: { medium: 'https://...' } }] } })",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
payload: z.unknown().describe('Any JSON value — typically a sample API response (e.g., {data:[{id:1,title:"..."}]})'),
|
|
13
|
+
items_path_hint: z
|
|
14
|
+
.string()
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('Optional hint for items_path (e.g., "data", "collection")'),
|
|
17
|
+
},
|
|
18
|
+
annotations: readOnly(),
|
|
19
|
+
}, async ({ payload, items_path_hint }) => {
|
|
20
|
+
const r = await request("/schema-profile", { method: "POST", body: JSON.stringify({ payload, items_path_hint }) });
|
|
21
|
+
if (!r.success) {
|
|
22
|
+
return formatResult({
|
|
23
|
+
error: r.error,
|
|
24
|
+
status: r.status,
|
|
25
|
+
errorCode: r.errorCode,
|
|
26
|
+
context: { items_path_hint },
|
|
27
|
+
hint: hintFor(r.errorCode),
|
|
28
|
+
}, true);
|
|
29
|
+
}
|
|
30
|
+
const fields = Array.isArray(r.data?.fields) ? r.data.fields : [];
|
|
31
|
+
return formatResult({
|
|
32
|
+
items_path: r.data?.items_path,
|
|
33
|
+
field_count: fields.length,
|
|
34
|
+
fields: fields.slice(0, 100),
|
|
35
|
+
profile: r.data?.profile,
|
|
36
|
+
}, false, { maxChars: 6000 });
|
|
37
|
+
});
|
|
38
|
+
// ── apimapper_node_snapshot_list ───────────────────────────────────
|
|
39
|
+
server.registerTool("apimapper_node_snapshot_list", {
|
|
40
|
+
title: "List Node Snapshots",
|
|
41
|
+
description: "List node-level data snapshots (per-flow/per-node cached payloads used by preview hydrate path)." +
|
|
42
|
+
"\n\nExample:\n apimapper_node_snapshot_list({ flow_id: 'flow_Z2fLg70M84' })",
|
|
43
|
+
inputSchema: {
|
|
44
|
+
flow_id: z.string().optional().describe("Filter by flow id"),
|
|
45
|
+
limit: z.number().min(1).max(500).default(50).describe("Max items (1-500)"),
|
|
46
|
+
},
|
|
47
|
+
annotations: readOnly(),
|
|
48
|
+
}, async ({ flow_id, limit }) => {
|
|
49
|
+
const params = new URLSearchParams();
|
|
50
|
+
if (flow_id)
|
|
51
|
+
params.set("flow_id", flow_id);
|
|
52
|
+
params.set("limit", String(limit));
|
|
53
|
+
const r = await request(`/node-snapshots?${params.toString()}`);
|
|
54
|
+
if (!r.success) {
|
|
55
|
+
return formatResult({
|
|
56
|
+
error: r.error,
|
|
57
|
+
status: r.status,
|
|
58
|
+
errorCode: r.errorCode,
|
|
59
|
+
context: { flow_id, limit },
|
|
60
|
+
hint: hintFor(r.errorCode),
|
|
61
|
+
}, true);
|
|
62
|
+
}
|
|
63
|
+
const items = Array.isArray(r.data?.snapshots) ? r.data.snapshots : [];
|
|
64
|
+
return autoFormatTable(items.map((s) => ({
|
|
65
|
+
id: s.id,
|
|
66
|
+
flow_id: s.flow_id || "—",
|
|
67
|
+
node_id: s.node_id || "—",
|
|
68
|
+
type: s.type || "—",
|
|
69
|
+
items: s.item_count ?? "?",
|
|
70
|
+
created_at: s.created_at || "—",
|
|
71
|
+
})), {
|
|
72
|
+
columns: [
|
|
73
|
+
{ key: "id", label: "ID", width: 24 },
|
|
74
|
+
{ key: "flow_id", label: "FLOW", width: 28 },
|
|
75
|
+
{ key: "node_id", label: "NODE", width: 24 },
|
|
76
|
+
{ key: "type", label: "TYPE", width: 10 },
|
|
77
|
+
{ key: "items", label: "N", width: 5 },
|
|
78
|
+
{ key: "created_at", label: "CREATED", width: 22 },
|
|
79
|
+
],
|
|
80
|
+
header: (n) => `${n} snapshots`,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/apimapper/schema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,sEAAsE;IACtE,MAAM,CAAC,YAAY,CACjB,0BAA0B,EAC1B;QACE,KAAK,EAAE,6BAA6B;QACpC,WAAW,EACT,wFAAwF;YACxF,wFAAwF;YACxF,gHAAgH;QAClH,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,sFAAsF,CAAC;YACrH,eAAe,EAAE,CAAC;iBACf,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,2DAA2D,CAAC;SACzE;QACD,WAAW,EAAE,QAAQ,EAAE;KACxB,EACD,KAAK,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE;QACrC,MAAM,CAAC,GAAG,MAAM,OAAO,CACrB,iBAAiB,EACjB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,CACvE,CAAC;QACF,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACf,OAAO,YAAY,CACjB;gBACE,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,SAAS,EAAE,CAAC,CAAC,SAAS;gBACtB,OAAO,EAAE,EAAE,eAAe,EAAE;gBAC5B,IAAI,EAAE,OAAO,CAAC,CA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AE,KAAK,EAAE,EAAE,EAAE;gBAC5C,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;gBACzC,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE;gBACtC,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE;aACnD;YACD,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY;SAChC,CACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatResult, autoFormatTable, readOnly, mutating, destructive, } from "@getimo/mcp-toolkit";
|
|
3
|
+
import { request, hintFor } from "./client.js";
|
|
4
|
+
export function registerSettingsTools(server) {
|
|
5
|
+
// ── apimapper_settings_get ─────────────────────────────────────────
|
|
6
|
+
server.registerTool("apimapper_settings_get", {
|
|
7
|
+
title: "Get Settings",
|
|
8
|
+
description: "Fetch all API Mapper plugin settings (telemetry, beta_channel, debug flags, etc.)." +
|
|
9
|
+
"\n\nExample:\n apimapper_settings_get({})",
|
|
10
|
+
inputSchema: {},
|
|
11
|
+
annotations: readOnly(),
|
|
12
|
+
}, async () => {
|
|
13
|
+
const r = await request("/settings");
|
|
14
|
+
if (!r.success) {
|
|
15
|
+
return formatResult({ error: r.error, status: r.status, errorCode: r.errorCode, context: {}, hint: hintFor(r.errorCode) }, true);
|
|
16
|
+
}
|
|
17
|
+
return formatResult(r.data ?? {}, false, { maxChars: 4000 });
|
|
18
|
+
});
|
|
19
|
+
// ── apimapper_settings_update ──────────────────────────────────────
|
|
20
|
+
server.registerTool("apimapper_settings_update", {
|
|
21
|
+
title: "Update Settings",
|
|
22
|
+
description: "Update plugin settings. Only provided keys are changed. " +
|
|
23
|
+
'Common keys: beta_channel (bool), debug_mode (bool), telemetry_enabled (bool). ' +
|
|
24
|
+
'Use apimapper_settings_get to inspect the current full set.' +
|
|
25
|
+
"\n\nExample:\n apimapper_settings_update({ settings: { telemetry: false, beta_channel: true } })",
|
|
26
|
+
inputSchema: {
|
|
27
|
+
patch: z.record(z.string(), z.unknown()).describe('Settings keys to update'),
|
|
28
|
+
},
|
|
29
|
+
annotations: mutating(),
|
|
30
|
+
}, async ({ patch }) => {
|
|
31
|
+
const r = await request("/settings", {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: JSON.stringify(patch),
|
|
34
|
+
});
|
|
35
|
+
if (!r.success) {
|
|
36
|
+
return formatResult({
|
|
37
|
+
error: r.error,
|
|
38
|
+
status: r.status,
|
|
39
|
+
errorCode: r.errorCode,
|
|
40
|
+
context: { keys: Object.keys(patch) },
|
|
41
|
+
hint: hintFor(r.errorCode),
|
|
42
|
+
}, true);
|
|
43
|
+
}
|
|
44
|
+
return formatResult({ updated: true, applied_keys: Object.keys(patch) }, false, { maxChars: 2000 });
|
|
45
|
+
});
|
|
46
|
+
// ── apimapper_settings_reset_demo ──────────────────────────────────
|
|
47
|
+
server.registerTool("apimapper_settings_reset_demo", {
|
|
48
|
+
title: "Reset Demo Data",
|
|
49
|
+
description: "Reset demo connections + demo flows back to factory state. Removes user-modifications " +
|
|
50
|
+
"to demo entries. Does NOT touch user-created connections/flows." +
|
|
51
|
+
"\n\nExample:\n apimapper_settings_reset_demo({ confirm: false })",
|
|
52
|
+
inputSchema: {
|
|
53
|
+
confirm: z
|
|
54
|
+
.boolean()
|
|
55
|
+
.default(false)
|
|
56
|
+
.describe("Must be true to execute. Ask user for confirmation first."),
|
|
57
|
+
},
|
|
58
|
+
annotations: destructive(),
|
|
59
|
+
}, async ({ confirm }) => {
|
|
60
|
+
if (!confirm) {
|
|
61
|
+
return formatResult({
|
|
62
|
+
preview: true,
|
|
63
|
+
warning: "DESTRUCTIVE — All demo data resets. User customisations to demo entries are lost.",
|
|
64
|
+
target: { operation: "reset-demo" },
|
|
65
|
+
instruction: "Ask user to confirm, then call again with confirm: true.",
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const r = await request("/settings/reset-demo", { method: "POST" });
|
|
69
|
+
if (!r.success) {
|
|
70
|
+
return formatResult({ error: r.error, status: r.status, errorCode: r.errorCode, context: {}, hint: hintFor(r.errorCode) }, true);
|
|
71
|
+
}
|
|
72
|
+
return formatResult({ reset: true, counts: r.data?.counts }, false, { maxChars: 2000 });
|
|
73
|
+
});
|
|
74
|
+
// ── apimapper_features_get ─────────────────────────────────────────
|
|
75
|
+
server.registerTool("apimapper_features_get", {
|
|
76
|
+
title: "Get License-Gated Features",
|
|
77
|
+
description: "Fetch the feature-flag matrix for the current license tier (Free/Pro/Developer)." +
|
|
78
|
+
"\n\nExample:\n apimapper_features_get({})",
|
|
79
|
+
inputSchema: {},
|
|
80
|
+
annotations: readOnly(),
|
|
81
|
+
}, async () => {
|
|
82
|
+
const r = await request("/features");
|
|
83
|
+
if (!r.success) {
|
|
84
|
+
return formatResult({ error: r.error, status: r.status, errorCode: r.errorCode, context: {}, hint: hintFor(r.errorCode) }, true);
|
|
85
|
+
}
|
|
86
|
+
const features = r.data?.features ?? {};
|
|
87
|
+
const featureCount = Object.keys(features).length;
|
|
88
|
+
return formatResult({ tier: r.data?.tier, feature_count: featureCount, features }, false, { maxChars: 4000 });
|
|
89
|
+
});
|
|
90
|
+
// ── apimapper_platform_parity ──────────────────────────────────────
|
|
91
|
+
server.registerTool("apimapper_platform_parity", {
|
|
92
|
+
title: "Get Platform Parity Status",
|
|
93
|
+
description: "Compare feature parity between WordPress and Joomla versions of API Mapper." +
|
|
94
|
+
"\n\nExample:\n apimapper_platform_parity({})",
|
|
95
|
+
inputSchema: {},
|
|
96
|
+
annotations: readOnly(),
|
|
97
|
+
}, async () => {
|
|
98
|
+
const r = await request("/platform-parity");
|
|
99
|
+
if (!r.success) {
|
|
100
|
+
return formatResult({ error: r.error, status: r.status, errorCode: r.errorCode, context: {}, hint: hintFor(r.errorCode) }, true);
|
|
101
|
+
}
|
|
102
|
+
const gaps = Array.isArray(r.data?.gaps) ? r.data.gaps : [];
|
|
103
|
+
return formatResult({
|
|
104
|
+
gap_count: gaps.length,
|
|
105
|
+
wordpress: r.data?.wordpress,
|
|
106
|
+
joomla: r.data?.joomla,
|
|
107
|
+
gaps,
|
|
108
|
+
}, false, { maxChars: 4000 });
|
|
109
|
+
});
|
|
110
|
+
// ── apimapper_health_warnings_list ─────────────────────────────────
|
|
111
|
+
server.registerTool("apimapper_health_warnings_list", {
|
|
112
|
+
title: "List Health Warnings",
|
|
113
|
+
description: "List active admin health-warnings (banners shown in the Admin UI)." +
|
|
114
|
+
"\n\nExample:\n apimapper_health_warnings_list({})",
|
|
115
|
+
inputSchema: {},
|
|
116
|
+
annotations: readOnly(),
|
|
117
|
+
}, async () => {
|
|
118
|
+
const r = await request("/admin/health-warnings");
|
|
119
|
+
if (!r.success) {
|
|
120
|
+
return formatResult({ error: r.error, status: r.status, errorCode: r.errorCode, context: {}, hint: hintFor(r.errorCode) }, true);
|
|
121
|
+
}
|
|
122
|
+
const warnings = Array.isArray(r.data?.warnings) ? r.data.warnings : [];
|
|
123
|
+
return autoFormatTable(warnings.map((w) => ({
|
|
124
|
+
id: w.id,
|
|
125
|
+
severity: w.severity,
|
|
126
|
+
message: w.message,
|
|
127
|
+
})), {
|
|
128
|
+
columns: [
|
|
129
|
+
{ key: "id", label: "ID", width: 24 },
|
|
130
|
+
{ key: "severity", label: "SEVERITY", width: 12 },
|
|
131
|
+
{ key: "message", label: "MESSAGE", width: 60 },
|
|
132
|
+
],
|
|
133
|
+
header: (n) => `${n} active warnings`,
|
|
134
|
+
footer: "Use apimapper_health_warnings_dismiss <id> to dismiss.",
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
// ── apimapper_health_warnings_dismiss ──────────────────────────────
|
|
138
|
+
server.registerTool("apimapper_health_warnings_dismiss", {
|
|
139
|
+
title: "Dismiss Health Warning",
|
|
140
|
+
description: "Dismiss a specific health-warning banner by ID." +
|
|
141
|
+
"\n\nExample:\n apimapper_health_warnings_dismiss({ id: 'oauth_refresh_drift' })",
|
|
142
|
+
inputSchema: {
|
|
143
|
+
id: z.string().describe("Warning ID. Use apimapper_health_warnings_list to find."),
|
|
144
|
+
},
|
|
145
|
+
annotations: mutating(),
|
|
146
|
+
}, async ({ id }) => {
|
|
147
|
+
const r = await request("/admin/health-warnings/dismiss", {
|
|
148
|
+
method: "POST",
|
|
149
|
+
body: JSON.stringify({ id }),
|
|
150
|
+
});
|
|
151
|
+
if (!r.success) {
|
|
152
|
+
return formatResult({ error: r.error, status: r.status, errorCode: r.errorCode, context: { id }, hint: hintFor(r.errorCode) }, true);
|
|
153
|
+
}
|
|
154
|
+
return formatResult({ dismissed: true, id }, false, { maxChars: 1500 });
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../src/modules/apimapper/settings.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACrD,sEAAsE;IACtE,MAAM,CAAC,YAAY,CACjB,wBAAwB,EACxB;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,oFAAoF;YACjG,4CAA4C;QAC5C,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,QAAQ,EAAE;KACxB,EACD,KAAK,IAAI,EAAE;QACT,MAAM,CAAC,GAAG,MAAM,OAAO,CAA0B,WAAW,CAAC,CAAC;QAC9D,IAAI,CAAC,CA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;SACnF;QACD,WAAW,EAAE,QAAQ,EAAE;KACxB,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;QACf,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,gCAAgC,EAAE;YACxD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;SAC7B,CAAC,CAAC;QACH,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACf,OAAO,YAAY,CACjB,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EACzG,IAAI,CACL,CAAC;QACJ,CAAC;QACD,OAAO,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1E,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
export declare const SKILL_RESOURCE_URIS: readonly ["skill://apimapper/getting-started", "skill://apimapper/oauth", "skill://apimapper/yootheme", "skill://apimapper/joomla", "skill://apimapper/troubleshooting"];
|
|
3
|
+
export type SkillResourceUri = (typeof SKILL_RESOURCE_URIS)[number];
|
|
4
|
+
export declare function registerSkillResources(server: McpServer, rootDir?: string): void;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// src/modules/apimapper/skill-resources.ts — Phase 7.3.
|
|
2
|
+
//
|
|
3
|
+
// Exposes the bundled apimapper skill docs as MCP resources at stable
|
|
4
|
+
// skill://apimapper/<topic> URIs. Each resource serves a markdown file from
|
|
5
|
+
// packages/apimapper-mcp/skills/apimapper/ as text/markdown.
|
|
6
|
+
//
|
|
7
|
+
// MCP clients that support resource discovery (Claude Code, ChatGPT, Cursor)
|
|
8
|
+
// can list + read these without invoking a tool, so the skill docs are
|
|
9
|
+
// accessible both via tool (apimapper_get_skill, Phase 7.4) and resource.
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
import { dirname, join, resolve } from "node:path";
|
|
13
|
+
export const SKILL_RESOURCE_URIS = [
|
|
14
|
+
"skill://apimapper/getting-started",
|
|
15
|
+
"skill://apimapper/oauth",
|
|
16
|
+
"skill://apimapper/yootheme",
|
|
17
|
+
"skill://apimapper/joomla",
|
|
18
|
+
"skill://apimapper/troubleshooting",
|
|
19
|
+
];
|
|
20
|
+
const RESOURCES = [
|
|
21
|
+
{
|
|
22
|
+
uri: "skill://apimapper/getting-started",
|
|
23
|
+
name: "apimapper-getting-started",
|
|
24
|
+
title: "API Mapper — Getting Started",
|
|
25
|
+
description: "Quickstart, common tools, common pitfalls.",
|
|
26
|
+
fileName: "SKILL.md",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
uri: "skill://apimapper/oauth",
|
|
30
|
+
name: "apimapper-oauth",
|
|
31
|
+
title: "API Mapper — OAuth Sources",
|
|
32
|
+
description: "Wiring OAuth-protected sources (Pexels, Google, Instagram, Notion, ...).",
|
|
33
|
+
fileName: "reference/oauth.md",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
uri: "skill://apimapper/yootheme",
|
|
37
|
+
name: "apimapper-yootheme",
|
|
38
|
+
title: "API Mapper — YOOtheme Dynamic Content",
|
|
39
|
+
description: "Publish flows as YOOtheme sources; Save-vs-Publish; render-time responsibilities.",
|
|
40
|
+
fileName: "reference/yootheme.md",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
uri: "skill://apimapper/joomla",
|
|
44
|
+
name: "apimapper-joomla",
|
|
45
|
+
title: "API Mapper — Joomla Notes",
|
|
46
|
+
description: "Joomla 3-tier auth, com_ajax envelope, system plugin layout.",
|
|
47
|
+
fileName: "reference/joomla.md",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
uri: "skill://apimapper/troubleshooting",
|
|
51
|
+
name: "apimapper-troubleshooting",
|
|
52
|
+
title: "API Mapper — Troubleshooting",
|
|
53
|
+
description: "HTTP status triage, flow issues, credential states, log locations.",
|
|
54
|
+
fileName: "reference/troubleshooting.md",
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
function defaultSkillsRoot() {
|
|
58
|
+
// This module is at <pkg-root>/src/modules/apimapper/skill-resources.ts in
|
|
59
|
+
// dev (or its compiled twin in dist/). Package root is three dirs up.
|
|
60
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
61
|
+
return resolve(here, "..", "..", "..");
|
|
62
|
+
}
|
|
63
|
+
export function registerSkillResources(server, rootDir) {
|
|
64
|
+
const baseDir = rootDir ?? defaultSkillsRoot();
|
|
65
|
+
for (const meta of RESOURCES) {
|
|
66
|
+
const filePath = join(baseDir, "skills", "apimapper", meta.fileName);
|
|
67
|
+
server.registerResource(meta.name, meta.uri, {
|
|
68
|
+
title: meta.title,
|
|
69
|
+
description: meta.description,
|
|
70
|
+
mimeType: "text/markdown",
|
|
71
|
+
}, async (uri) => {
|
|
72
|
+
const text = readFileSync(filePath, "utf8");
|
|
73
|
+
return {
|
|
74
|
+
contents: [
|
|
75
|
+
{
|
|
76
|
+
uri: uri.toString(),
|
|
77
|
+
mimeType: "text/markdown",
|
|
78
|
+
text,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=skill-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-resources.js","sourceRoot":"","sources":["../../../src/modules/apimapper/skill-resources.ts"],"names":[],"mappings":"AAAA,wDAAwD;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