@wix/mcp 1.0.6 → 1.0.8
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/build/api-call/index.d.ts +3 -0
- package/build/api-call/index.js +149 -0
- package/build/auth/index.d.ts +5 -0
- package/build/auth/index.js +1 -0
- package/build/bin-standalone.js +16370 -0
- package/build/bin-standalone.js.map +7 -0
- package/build/bin.d.ts +3 -3
- package/build/bin.js +82 -657
- package/build/cli-tools/cli.d.ts +4 -0
- package/build/cli-tools/cli.js +339 -0
- package/build/cli-tools/utils.d.ts +2 -0
- package/build/cli-tools/utils.js +25 -0
- package/build/docs/docs.d.ts +4 -0
- package/build/docs/docs.js +447 -0
- package/build/docs/long-content.d.ts +1 -0
- package/build/docs/long-content.js +1 -0
- package/build/docs/semanticSearch.d.ts +10 -0
- package/build/docs/semanticSearch.js +108 -0
- package/build/docs/semanticSearch.test.d.ts +1 -0
- package/build/docs/semanticSearch.test.js +459 -0
- package/build/index-standalone.js +18849 -0
- package/build/index-standalone.js.map +7 -0
- package/build/index.d.ts +7 -30
- package/build/index.js +6 -193
- package/build/infra/bi-logger.d.ts +2 -0
- package/build/infra/bi-logger.js +10 -0
- package/build/infra/environment.d.ts +9 -0
- package/build/infra/environment.js +27 -0
- package/build/infra/logger.d.ts +10 -0
- package/build/infra/logger.js +61 -0
- package/build/infra/panorama.d.ts +7 -0
- package/build/infra/panorama.js +35 -0
- package/build/infra/sentry.d.ts +1 -0
- package/build/infra/sentry.js +10 -0
- package/build/interactive-command-tools/eventually.d.ts +6 -0
- package/build/interactive-command-tools/eventually.js +15 -0
- package/build/interactive-command-tools/handleStdout.d.ts +13 -0
- package/build/interactive-command-tools/handleStdout.js +75 -0
- package/build/interactive-command-tools/interactive-command-utils.d.ts +7 -0
- package/build/interactive-command-tools/interactive-command-utils.js +75 -0
- package/build/resources/docs.d.ts +2 -0
- package/build/resources/docs.js +45 -0
- package/build/support/index.d.ts +2 -0
- package/build/support/index.js +32 -0
- package/build/tool-utils.d.ts +2 -0
- package/build/tool-utils.js +30 -0
- package/build/tool-utils.spec.d.ts +1 -0
- package/build/tool-utils.spec.js +99 -0
- package/build/wix-mcp-server.d.ts +27 -0
- package/build/wix-mcp-server.js +114 -0
- package/package.json +16 -11
- package/bin.js +0 -2
- package/build/chunk-YRLMZUQM.js +0 -1834
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { logger } from '../infra/logger.js';
|
|
3
|
+
import { handleWixAPIResponse } from '../tool-utils.js';
|
|
4
|
+
export function addApiCallTool(server, strategy) {
|
|
5
|
+
server.tool('CallWixSiteAPI', [
|
|
6
|
+
'Call Wix apis on a business or site. Use this to create, read, update, and delete data and other Wix entities in your Wix site,',
|
|
7
|
+
`You should ALWAYS check the rest docs - "SearchWixRESTDocumentation" for the specific API you want to call, don't just call it without knowing what it does, CHECK THE DOCS`,
|
|
8
|
+
'Error Handling:',
|
|
9
|
+
'If the error is related to missing installed app or "WDE0110: Wix Code not enabled", you should install the missing app by using ReadFullDocsArticle tool to fetch the article - https://dev.wix.com/docs/kb-only/MCP_REST_RECIPES_KB_ID/TRAIN_wix.devcenter.apps.installer.v1.AppsInstallerService.InstallApp',
|
|
10
|
+
'**Note:** there is no need to check if an app is installed/ Wix Code enabled in advance, just call the API and handle the error if it occurs, the API error message will state it clearly.',
|
|
11
|
+
'For any other error, use your default error handling mechanism'
|
|
12
|
+
].join('\n'), {
|
|
13
|
+
siteId: z
|
|
14
|
+
.string()
|
|
15
|
+
.describe('The id of the site selected using site selection tool'),
|
|
16
|
+
url: z
|
|
17
|
+
.string()
|
|
18
|
+
.describe('The url of the api to call - ALWAYS get the information from the Wix REST docs or from the conversation context, the URL MUST BE ABSOLUTE URL'),
|
|
19
|
+
method: z
|
|
20
|
+
.string()
|
|
21
|
+
.describe('The HTTP method to use for the API call (e.g. GET, POST, PUT, DELETE)'),
|
|
22
|
+
body: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('A string representing of a valid JSON object to describe the body of the request')
|
|
26
|
+
}, async ({ url, body, method, siteId }, { httpClient }) => {
|
|
27
|
+
logger.log(`Calling Wix Site API: ${siteId} ${url}, body: ${JSON.stringify(body)}`);
|
|
28
|
+
try {
|
|
29
|
+
const response = await httpClient.request({
|
|
30
|
+
url,
|
|
31
|
+
method: method,
|
|
32
|
+
headers: {
|
|
33
|
+
...(await strategy.getSiteAuthHeaders(siteId)),
|
|
34
|
+
...(body ? { 'Content-Type': 'application/json' } : {})
|
|
35
|
+
},
|
|
36
|
+
data: method === 'GET' ? undefined : body
|
|
37
|
+
});
|
|
38
|
+
const responseData = await handleWixAPIResponse(response);
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: 'text',
|
|
43
|
+
text: `Wix Site API call successful: ${JSON.stringify(responseData)}`
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
logger.error(`Failed to call Wix Site API: ${error}`);
|
|
50
|
+
const response = error.response;
|
|
51
|
+
if (!response) {
|
|
52
|
+
throw new Error(`Failed to call Wix Site API: ${error}`);
|
|
53
|
+
}
|
|
54
|
+
return handleWixAPIResponse(response);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
server.tool('ListWixSites', 'List Wix sites for the current user, by default it will return all sites, but you can filter by name', {
|
|
58
|
+
nameSearch: z
|
|
59
|
+
.string()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe('optional filer by name, if not provided all sites will be returned'),
|
|
62
|
+
// Hack for Cursor ignoring tools with no params (when nameSearch is optional)
|
|
63
|
+
alwaysTrue: z.boolean().describe('Always pass true to this parameter')
|
|
64
|
+
}, async ({ nameSearch }, { httpClient }) => {
|
|
65
|
+
const sitesRes = await httpClient.post('https://www.wixapis.com/site-list/v2/sites/query', {
|
|
66
|
+
query: {
|
|
67
|
+
cursorPaging: { limit: 21 },
|
|
68
|
+
filter: {
|
|
69
|
+
...(nameSearch
|
|
70
|
+
? {
|
|
71
|
+
name: nameSearch
|
|
72
|
+
}
|
|
73
|
+
: {}),
|
|
74
|
+
namespace: {
|
|
75
|
+
$in: ['WIX', 'DASHBOARD_FIRST', 'ANYWHERE', 'HEADLESS']
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
headers: {
|
|
81
|
+
...(await strategy.getAccountAuthHeaders()),
|
|
82
|
+
'Content-Type': 'application/json',
|
|
83
|
+
Accept: 'application/json, text/plain, */*'
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const result = sitesRes.data.sites?.map(({ id, displayName }) => ({
|
|
87
|
+
id,
|
|
88
|
+
name: displayName
|
|
89
|
+
})) ?? [];
|
|
90
|
+
return {
|
|
91
|
+
content: [
|
|
92
|
+
{
|
|
93
|
+
type: 'text',
|
|
94
|
+
text: JSON.stringify(result)
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: 'text',
|
|
98
|
+
text: 'if there is more than one site returned, the user should pick one from a list, list the sites (only name) for the user and ask them to pick one,' +
|
|
99
|
+
'If more than 20 are found you should list all 20 and suggest to search by the name of the site they are looking for'
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
server.tool('ManageWixSite', `Use account level API in order to create a site, update a site and publish site.
|
|
105
|
+
ALWAYS use "SearchWixRESTDocumentation" to search for the API you should invoke, NEVER GUESS THE SITE API URL
|
|
106
|
+
You should ALWAYS check the rest docs - "SearchWixRESTDocumentation" for the specific API you want to call, don't just call it without knowing what it does, CHECK THE DOCS`, {
|
|
107
|
+
url: z
|
|
108
|
+
.string()
|
|
109
|
+
.describe('The url of the api to call - ALWAYS get the information from the Wix REST docs DONT GUESS IT, the URL MUST BE ABSOLUTE URL'),
|
|
110
|
+
method: z
|
|
111
|
+
.string()
|
|
112
|
+
.describe('The HTTP method to use for the API call (e.g. GET, POST, PUT, DELETE)'),
|
|
113
|
+
body: z
|
|
114
|
+
.string()
|
|
115
|
+
.optional()
|
|
116
|
+
.describe('A string representing of a valid JSON object to describe the body of the request')
|
|
117
|
+
}, async ({ url, body, method }, { httpClient }) => {
|
|
118
|
+
logger.log(`Calling Wix Account level API: ${url}, body: ${JSON.stringify(body)}`);
|
|
119
|
+
try {
|
|
120
|
+
// if we would like to allow the user to manage multiple accounts, we should add accountId to the params
|
|
121
|
+
const response = await httpClient.request({
|
|
122
|
+
url,
|
|
123
|
+
method: method,
|
|
124
|
+
headers: {
|
|
125
|
+
...(await strategy.getAccountAuthHeaders()),
|
|
126
|
+
...(body ? { 'Content-Type': 'application/json' } : {})
|
|
127
|
+
},
|
|
128
|
+
data: method === 'GET' ? undefined : body
|
|
129
|
+
});
|
|
130
|
+
const responseData = await handleWixAPIResponse(response);
|
|
131
|
+
return {
|
|
132
|
+
content: [
|
|
133
|
+
{
|
|
134
|
+
type: 'text',
|
|
135
|
+
text: `Wix Account API call successful: ${JSON.stringify(responseData)}`
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
logger.error(`Failed to call Wix Account API: ${error}`);
|
|
142
|
+
const response = error.response;
|
|
143
|
+
if (!response) {
|
|
144
|
+
throw new Error(`Failed to call Wix Account API: ${error}`);
|
|
145
|
+
}
|
|
146
|
+
return handleWixAPIResponse(response);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|