@disruptorganic/mcp-google-search-console 1.0.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.
- package/.env.example +141 -0
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/oauth2.d.ts +31 -0
- package/dist/auth/oauth2.d.ts.map +1 -0
- package/dist/auth/oauth2.js +380 -0
- package/dist/auth/oauth2.js.map +1 -0
- package/dist/config/index.d.ts +36 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +87 -0
- package/dist/config/index.js.map +1 -0
- package/dist/gsc/client.d.ts +72 -0
- package/dist/gsc/client.d.ts.map +1 -0
- package/dist/gsc/client.js +243 -0
- package/dist/gsc/client.js.map +1 -0
- package/dist/gsc/index.d.ts +3 -0
- package/dist/gsc/index.d.ts.map +1 -0
- package/dist/gsc/index.js +3 -0
- package/dist/gsc/index.js.map +1 -0
- package/dist/gsc/properties.d.ts +42 -0
- package/dist/gsc/properties.d.ts.map +1 -0
- package/dist/gsc/properties.js +393 -0
- package/dist/gsc/properties.js.map +1 -0
- package/dist/gsc/queries.d.ts +73 -0
- package/dist/gsc/queries.d.ts.map +1 -0
- package/dist/gsc/queries.js +390 -0
- package/dist/gsc/queries.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +186 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/compare-date-ranges.d.ts +83 -0
- package/dist/tools/compare-date-ranges.d.ts.map +1 -0
- package/dist/tools/compare-date-ranges.js +462 -0
- package/dist/tools/compare-date-ranges.js.map +1 -0
- package/dist/tools/get-property-info.d.ts +30 -0
- package/dist/tools/get-property-info.d.ts.map +1 -0
- package/dist/tools/get-property-info.js +174 -0
- package/dist/tools/get-property-info.js.map +1 -0
- package/dist/tools/get-top-pages.d.ts +103 -0
- package/dist/tools/get-top-pages.d.ts.map +1 -0
- package/dist/tools/get-top-pages.js +254 -0
- package/dist/tools/get-top-pages.js.map +1 -0
- package/dist/tools/get-top-queries.d.ts +103 -0
- package/dist/tools/get-top-queries.d.ts.map +1 -0
- package/dist/tools/get-top-queries.js +254 -0
- package/dist/tools/get-top-queries.js.map +1 -0
- package/dist/tools/health-check.d.ts +12 -0
- package/dist/tools/health-check.d.ts.map +1 -0
- package/dist/tools/health-check.js +107 -0
- package/dist/tools/health-check.js.map +1 -0
- package/dist/tools/index.d.ts +1124 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +70 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-properties.d.ts +50 -0
- package/dist/tools/list-properties.d.ts.map +1 -0
- package/dist/tools/list-properties.js +234 -0
- package/dist/tools/list-properties.js.map +1 -0
- package/dist/tools/query-advanced.d.ts +109 -0
- package/dist/tools/query-advanced.d.ts.map +1 -0
- package/dist/tools/query-advanced.js +378 -0
- package/dist/tools/query-advanced.js.map +1 -0
- package/dist/tools/query-by-keyword.d.ts +115 -0
- package/dist/tools/query-by-keyword.d.ts.map +1 -0
- package/dist/tools/query-by-keyword.js +339 -0
- package/dist/tools/query-by-keyword.js.map +1 -0
- package/dist/tools/query-by-url.d.ts +116 -0
- package/dist/tools/query-by-url.d.ts.map +1 -0
- package/dist/tools/query-by-url.js +366 -0
- package/dist/tools/query-by-url.js.map +1 -0
- package/dist/utils/cache.d.ts +22 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +75 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +15 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/metrics.d.ts +9 -0
- package/dist/utils/metrics.d.ts.map +1 -0
- package/dist/utils/metrics.js +54 -0
- package/dist/utils/metrics.js.map +1 -0
- package/dist/utils/rate-limiter.d.ts +24 -0
- package/dist/utils/rate-limiter.d.ts.map +1 -0
- package/dist/utils/rate-limiter.js +175 -0
- package/dist/utils/rate-limiter.js.map +1 -0
- package/dist/utils/token-estimator.d.ts +33 -0
- package/dist/utils/token-estimator.d.ts.map +1 -0
- package/dist/utils/token-estimator.js +226 -0
- package/dist/utils/token-estimator.js.map +1 -0
- package/dist/utils/types.d.ts +68 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +13 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/validators.d.ts +579 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +358 -0
- package/dist/utils/validators.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { listProperties, matchProperty, generatePropertyMatchError } from '../gsc/properties.js';
|
|
2
|
+
import { queryAdvancedParamsSchema } from '../utils/validators.js';
|
|
3
|
+
import { chunkResults } from '../utils/token-estimator.js';
|
|
4
|
+
import { logger } from '../utils/logger.js';
|
|
5
|
+
export const queryAdvancedTool = {
|
|
6
|
+
name: 'query_advanced',
|
|
7
|
+
description: 'Performs multi-dimensional custom queries with up to 3 dimensions (e.g., query + device + country) and flexible filtering. Use for complex analysis not covered by specialized tools. Supports all GSC dimensions and metrics with sorting and aggregation options. Automatically chunks results to stay under token limits. IMPORTANT: Use list_properties first to get the correct property identifier.',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
property: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'Property identifier from list_properties (e.g., "sc-domain:example.com")',
|
|
14
|
+
},
|
|
15
|
+
startDate: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'Start date in ISO 8601 format (YYYY-MM-DD)',
|
|
18
|
+
pattern: '^\\d{4}-\\d{2}-\\d{2}$',
|
|
19
|
+
},
|
|
20
|
+
endDate: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
description: 'End date in ISO 8601 format (YYYY-MM-DD)',
|
|
23
|
+
pattern: '^\\d{4}-\\d{2}-\\d{2}$',
|
|
24
|
+
},
|
|
25
|
+
dimensions: {
|
|
26
|
+
type: 'array',
|
|
27
|
+
items: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
enum: ['query', 'page', 'country', 'device', 'searchAppearance', 'date'],
|
|
30
|
+
},
|
|
31
|
+
description: 'Array of 1-3 dimensions to group results by',
|
|
32
|
+
minItems: 1,
|
|
33
|
+
maxItems: 3,
|
|
34
|
+
},
|
|
35
|
+
filters: {
|
|
36
|
+
type: 'array',
|
|
37
|
+
items: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
dimension: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
enum: ['query', 'page', 'country', 'device', 'searchAppearance', 'date'],
|
|
43
|
+
},
|
|
44
|
+
operator: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
enum: ['equals', 'notEquals', 'contains', 'notContains', 'includingRegex', 'excludingRegex'],
|
|
47
|
+
},
|
|
48
|
+
expression: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ['dimension', 'operator', 'expression'],
|
|
53
|
+
},
|
|
54
|
+
description: 'Optional array of filters to apply',
|
|
55
|
+
},
|
|
56
|
+
searchType: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
enum: ['web', 'image', 'video', 'news', 'discover', 'googleNews'],
|
|
59
|
+
description: 'Search type filter (default: web)',
|
|
60
|
+
default: 'web',
|
|
61
|
+
},
|
|
62
|
+
rowLimit: {
|
|
63
|
+
type: 'number',
|
|
64
|
+
description: 'Maximum rows to retrieve (1-25000, default: 25000)',
|
|
65
|
+
minimum: 1,
|
|
66
|
+
maximum: 25000,
|
|
67
|
+
default: 25000,
|
|
68
|
+
},
|
|
69
|
+
sortBy: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
enum: ['clicks', 'impressions', 'ctr', 'position'],
|
|
72
|
+
description: 'Metric to sort by (default: clicks)',
|
|
73
|
+
default: 'clicks',
|
|
74
|
+
},
|
|
75
|
+
sortOrder: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
enum: ['asc', 'desc'],
|
|
78
|
+
description: 'Sort order (default: desc)',
|
|
79
|
+
default: 'desc',
|
|
80
|
+
},
|
|
81
|
+
offset: {
|
|
82
|
+
type: 'number',
|
|
83
|
+
description: 'Pagination offset (default: 0)',
|
|
84
|
+
default: 0,
|
|
85
|
+
minimum: 0,
|
|
86
|
+
},
|
|
87
|
+
limit: {
|
|
88
|
+
type: 'number',
|
|
89
|
+
description: 'Results per chunk - auto-calculated if not provided',
|
|
90
|
+
minimum: 1,
|
|
91
|
+
maximum: 25000,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
required: ['property', 'startDate', 'endDate', 'dimensions'],
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
function transformOperator(mcpOperator) {
|
|
98
|
+
const operatorMap = {
|
|
99
|
+
'equals': 'EQUALS',
|
|
100
|
+
'notEquals': 'NOT_EQUALS',
|
|
101
|
+
'contains': 'CONTAINS',
|
|
102
|
+
'notContains': 'NOT_CONTAINS',
|
|
103
|
+
'includingRegex': 'INCLUDING_REGEX',
|
|
104
|
+
'excludingRegex': 'EXCLUDING_REGEX',
|
|
105
|
+
};
|
|
106
|
+
const result = operatorMap[mcpOperator];
|
|
107
|
+
if (!result) {
|
|
108
|
+
logger.warn('Unknown filter operator, using as-is', { mcpOperator });
|
|
109
|
+
return mcpOperator.toUpperCase();
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
function transformFiltersToGSCFormat(filters) {
|
|
114
|
+
if (!filters || filters.length === 0) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
filters: filters.map(filter => ({
|
|
119
|
+
dimension: filter.dimension,
|
|
120
|
+
operator: transformOperator(filter.operator),
|
|
121
|
+
expression: filter.expression,
|
|
122
|
+
})),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function transformRowToMCPFormat(row, dimensions) {
|
|
126
|
+
const result = {
|
|
127
|
+
clicks: 0,
|
|
128
|
+
impressions: 0,
|
|
129
|
+
ctr: 0,
|
|
130
|
+
position: 0,
|
|
131
|
+
};
|
|
132
|
+
if (row.keys && Array.isArray(row.keys)) {
|
|
133
|
+
row.keys.forEach((key, index) => {
|
|
134
|
+
const dimension = dimensions[index];
|
|
135
|
+
if (dimension) {
|
|
136
|
+
result[dimension] = key;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
result.clicks = row.clicks || 0;
|
|
141
|
+
result.impressions = row.impressions || 0;
|
|
142
|
+
result.ctr = row.ctr || 0;
|
|
143
|
+
result.position = row.position || 0;
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
function sortResults(results, sortBy, sortOrder) {
|
|
147
|
+
results.sort((a, b) => {
|
|
148
|
+
const aVal = a[sortBy];
|
|
149
|
+
const bVal = b[sortBy];
|
|
150
|
+
if (aVal === undefined || aVal === null)
|
|
151
|
+
return 1;
|
|
152
|
+
if (bVal === undefined || bVal === null)
|
|
153
|
+
return -1;
|
|
154
|
+
const direction = sortOrder === 'asc' ? 1 : -1;
|
|
155
|
+
return direction * (aVal - bVal);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
export async function handleQueryAdvanced(params, client) {
|
|
159
|
+
try {
|
|
160
|
+
logger.info('Handling query_advanced request', {
|
|
161
|
+
propertyInput: params.property,
|
|
162
|
+
dimensions: params.dimensions,
|
|
163
|
+
filterCount: params.filters?.length || 0,
|
|
164
|
+
dateRange: params.startDate && params.endDate ? `${params.startDate} to ${params.endDate}` : 'not provided',
|
|
165
|
+
});
|
|
166
|
+
const validationResult = queryAdvancedParamsSchema.safeParse(params);
|
|
167
|
+
if (!validationResult.success) {
|
|
168
|
+
const errorMessages = validationResult.error.issues.map(issue => {
|
|
169
|
+
const path = issue.path.length > 0 ? `${issue.path.join('.')}: ` : '';
|
|
170
|
+
return `${path}${issue.message}`;
|
|
171
|
+
}).join('; ');
|
|
172
|
+
logger.error('Input validation failed', {
|
|
173
|
+
errors: errorMessages,
|
|
174
|
+
params,
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
content: [{
|
|
178
|
+
type: 'text',
|
|
179
|
+
text: JSON.stringify({
|
|
180
|
+
error: 'Input validation failed',
|
|
181
|
+
details: errorMessages,
|
|
182
|
+
}, null, 2),
|
|
183
|
+
}],
|
|
184
|
+
isError: true,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const validated = validationResult.data;
|
|
188
|
+
const { property, startDate, endDate, dimensions, filters, searchType = 'web', rowLimit = 25000, sortBy = 'clicks', sortOrder = 'desc', offset = 0, limit, } = validated;
|
|
189
|
+
logger.debug('Fetching available properties');
|
|
190
|
+
const availableProperties = await listProperties(client);
|
|
191
|
+
if (availableProperties.length === 0) {
|
|
192
|
+
logger.warn('No properties found for this account');
|
|
193
|
+
return {
|
|
194
|
+
content: [{
|
|
195
|
+
type: 'text',
|
|
196
|
+
text: JSON.stringify({
|
|
197
|
+
error: 'No properties found',
|
|
198
|
+
details: 'No Google Search Console properties are accessible with this account. Please verify your account has access to at least one property.',
|
|
199
|
+
}, null, 2),
|
|
200
|
+
}],
|
|
201
|
+
isError: true,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const matchResult = matchProperty(property, availableProperties);
|
|
205
|
+
if (!matchResult.matched) {
|
|
206
|
+
const errorMessage = generatePropertyMatchError(matchResult, availableProperties);
|
|
207
|
+
logger.error('Property matching failed', {
|
|
208
|
+
searchInput: property,
|
|
209
|
+
matchType: matchResult.matchType,
|
|
210
|
+
alternativeCount: matchResult.alternatives?.length || 0,
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
content: [{
|
|
214
|
+
type: 'text',
|
|
215
|
+
text: JSON.stringify({
|
|
216
|
+
error: 'Property not found or ambiguous',
|
|
217
|
+
details: errorMessage,
|
|
218
|
+
}, null, 2),
|
|
219
|
+
}],
|
|
220
|
+
isError: true,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const matchedProperty = matchResult.matched;
|
|
224
|
+
logger.info('Property matched successfully', {
|
|
225
|
+
searchInput: property,
|
|
226
|
+
matched: matchedProperty.propertyUrl,
|
|
227
|
+
matchType: matchResult.matchType,
|
|
228
|
+
});
|
|
229
|
+
const request = {
|
|
230
|
+
startDate,
|
|
231
|
+
endDate,
|
|
232
|
+
dimensions,
|
|
233
|
+
type: searchType,
|
|
234
|
+
dataState: 'final',
|
|
235
|
+
rowLimit: Math.min(rowLimit, 25000),
|
|
236
|
+
startRow: 0,
|
|
237
|
+
};
|
|
238
|
+
if (filters && filters.length > 0) {
|
|
239
|
+
const transformedFilters = transformFiltersToGSCFormat(filters);
|
|
240
|
+
if (transformedFilters) {
|
|
241
|
+
request.dimensionFilterGroups = [transformedFilters];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
logger.debug('GSC API request prepared', {
|
|
245
|
+
dimensions: request.dimensions,
|
|
246
|
+
filters: request.dimensionFilterGroups?.length || 0,
|
|
247
|
+
searchType: request.type,
|
|
248
|
+
rowLimit: request.rowLimit,
|
|
249
|
+
});
|
|
250
|
+
logger.info('Executing advanced query', {
|
|
251
|
+
property: matchedProperty.propertyUrl,
|
|
252
|
+
dimensions,
|
|
253
|
+
dateRange: `${startDate} to ${endDate}`,
|
|
254
|
+
});
|
|
255
|
+
const response = await client.query({
|
|
256
|
+
propertyUrl: matchedProperty.propertyUrl,
|
|
257
|
+
startDate,
|
|
258
|
+
endDate,
|
|
259
|
+
dimensions,
|
|
260
|
+
filters: request.dimensionFilterGroups ? [transformFiltersToGSCFormat(filters)].filter(Boolean) : undefined,
|
|
261
|
+
searchType,
|
|
262
|
+
rowLimit: request.rowLimit,
|
|
263
|
+
startRow: request.startRow,
|
|
264
|
+
dataState: 'final',
|
|
265
|
+
});
|
|
266
|
+
if (!response || !response.rows || response.rows.length === 0) {
|
|
267
|
+
logger.info('Query returned no results', {
|
|
268
|
+
property: matchedProperty.propertyUrl,
|
|
269
|
+
dimensions,
|
|
270
|
+
});
|
|
271
|
+
return {
|
|
272
|
+
content: [{
|
|
273
|
+
type: 'text',
|
|
274
|
+
text: JSON.stringify({
|
|
275
|
+
property: matchedProperty.propertyUrl,
|
|
276
|
+
dateRange: { start: startDate, end: endDate },
|
|
277
|
+
dimensions,
|
|
278
|
+
filters: filters || [],
|
|
279
|
+
searchType,
|
|
280
|
+
sortBy,
|
|
281
|
+
sortOrder,
|
|
282
|
+
results: [],
|
|
283
|
+
pagination: {
|
|
284
|
+
offset: 0,
|
|
285
|
+
limit: 0,
|
|
286
|
+
total_rows: 0,
|
|
287
|
+
current_chunk: 1,
|
|
288
|
+
total_chunks: 1,
|
|
289
|
+
has_more: false,
|
|
290
|
+
},
|
|
291
|
+
}, null, 2),
|
|
292
|
+
}],
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
logger.debug('Transforming GSC response', {
|
|
296
|
+
rowCount: response.rows.length,
|
|
297
|
+
});
|
|
298
|
+
const results = response.rows.map((row) => transformRowToMCPFormat(row, dimensions));
|
|
299
|
+
logger.debug('Sorting results', { sortBy, sortOrder });
|
|
300
|
+
sortResults(results, sortBy, sortOrder);
|
|
301
|
+
logger.debug('Applying chunking', {
|
|
302
|
+
totalRows: results.length,
|
|
303
|
+
offset,
|
|
304
|
+
limit: limit || 'auto',
|
|
305
|
+
});
|
|
306
|
+
const chunked = chunkResults(results, offset, limit);
|
|
307
|
+
logger.info('Results chunked', {
|
|
308
|
+
totalRows: results.length,
|
|
309
|
+
offset,
|
|
310
|
+
limit: chunked.pagination.limit,
|
|
311
|
+
currentChunk: chunked.pagination.current_chunk,
|
|
312
|
+
totalChunks: chunked.pagination.total_chunks,
|
|
313
|
+
hasMore: chunked.pagination.has_more,
|
|
314
|
+
});
|
|
315
|
+
const responseObject = {
|
|
316
|
+
property: matchedProperty.propertyUrl,
|
|
317
|
+
dateRange: {
|
|
318
|
+
start: startDate,
|
|
319
|
+
end: endDate,
|
|
320
|
+
},
|
|
321
|
+
dimensions,
|
|
322
|
+
filters: filters || [],
|
|
323
|
+
searchType,
|
|
324
|
+
sortBy,
|
|
325
|
+
sortOrder,
|
|
326
|
+
results: chunked.results,
|
|
327
|
+
pagination: chunked.pagination,
|
|
328
|
+
};
|
|
329
|
+
logger.info('Query advanced completed successfully', {
|
|
330
|
+
property: matchedProperty.propertyUrl,
|
|
331
|
+
dimensions,
|
|
332
|
+
resultsReturned: chunked.results.length,
|
|
333
|
+
hasMore: chunked.pagination.has_more,
|
|
334
|
+
});
|
|
335
|
+
return {
|
|
336
|
+
content: [{
|
|
337
|
+
type: 'text',
|
|
338
|
+
text: JSON.stringify(responseObject, null, 2),
|
|
339
|
+
}],
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
344
|
+
const errorStack = error instanceof Error ? error.stack : undefined;
|
|
345
|
+
logger.error('Query advanced handler failed', {
|
|
346
|
+
error: errorMessage,
|
|
347
|
+
stack: errorStack,
|
|
348
|
+
params,
|
|
349
|
+
});
|
|
350
|
+
let userFriendlyMessage = errorMessage;
|
|
351
|
+
if (errorMessage.includes('permission') || errorMessage.includes('Permission')) {
|
|
352
|
+
userFriendlyMessage = `Permission denied for property ${params.property}. Use list_properties to see accessible properties.`;
|
|
353
|
+
}
|
|
354
|
+
else if (errorMessage.includes('not found') || errorMessage.includes('Not Found')) {
|
|
355
|
+
userFriendlyMessage = `Property ${params.property} not found. Use list_properties to get valid property identifiers.`;
|
|
356
|
+
}
|
|
357
|
+
else if (errorMessage.includes('dimension') || errorMessage.includes('Dimension')) {
|
|
358
|
+
userFriendlyMessage = 'Invalid dimension configuration. Valid dimensions: query, page, country, device, searchAppearance, date. Maximum 3 dimensions allowed per query.';
|
|
359
|
+
}
|
|
360
|
+
else if (errorMessage.includes('date') || errorMessage.includes('Date')) {
|
|
361
|
+
userFriendlyMessage = `Invalid date range. ${errorMessage}`;
|
|
362
|
+
}
|
|
363
|
+
else if (errorMessage.includes('rate limit') || errorMessage.includes('Rate limit')) {
|
|
364
|
+
userFriendlyMessage = 'Rate limit exceeded. Please wait a moment and try again.';
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
content: [{
|
|
368
|
+
type: 'text',
|
|
369
|
+
text: JSON.stringify({
|
|
370
|
+
error: 'Query execution failed',
|
|
371
|
+
details: userFriendlyMessage,
|
|
372
|
+
}, null, 2),
|
|
373
|
+
}],
|
|
374
|
+
isError: true,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
//# sourceMappingURL=query-advanced.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-advanced.js","sourceRoot":"","sources":["../../src/tools/query-advanced.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAsB,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AA8D5C,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,2YAA2Y;IACxZ,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0EAA0E;aACxF;YACD,SAAS,EAAE;gB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AE,wBAAwB;wBAC/B,OAAO,EAAE,mBAAmB;qBAC7B,EAAE,IAAI,EAAE,CAAC,CAAC;iBACZ,CAAC;YACF,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { GSCClient } from '../gsc/client.js';
|
|
3
|
+
export interface ToolResponse {
|
|
4
|
+
content: Array<{
|
|
5
|
+
type: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
}>;
|
|
8
|
+
isError?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const QueryByKeywordSchema: z.ZodObject<{
|
|
11
|
+
property: z.ZodString;
|
|
12
|
+
keywords: z.ZodArray<z.ZodString, "many">;
|
|
13
|
+
startDate: z.ZodString;
|
|
14
|
+
endDate: z.ZodString;
|
|
15
|
+
searchType: z.ZodDefault<z.ZodOptional<z.ZodEnum<["web", "image", "video", "news", "discover", "googleNews"]>>>;
|
|
16
|
+
dimensions: z.ZodOptional<z.ZodArray<z.ZodEnum<["page", "device", "country", "searchAppearance", "date"]>, "many">>;
|
|
17
|
+
deviceType: z.ZodOptional<z.ZodEnum<["desktop", "mobile", "tablet"]>>;
|
|
18
|
+
country: z.ZodOptional<z.ZodString>;
|
|
19
|
+
offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
20
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
startDate: string;
|
|
23
|
+
endDate: string;
|
|
24
|
+
searchType: "web" | "image" | "video" | "news" | "discover" | "googleNews";
|
|
25
|
+
property: string;
|
|
26
|
+
offset: number;
|
|
27
|
+
keywords: string[];
|
|
28
|
+
dimensions?: ("page" | "country" | "device" | "searchAppearance" | "date")[] | undefined;
|
|
29
|
+
limit?: number | undefined;
|
|
30
|
+
deviceType?: "desktop" | "mobile" | "tablet" | undefined;
|
|
31
|
+
country?: string | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
startDate: string;
|
|
34
|
+
endDate: string;
|
|
35
|
+
property: string;
|
|
36
|
+
keywords: string[];
|
|
37
|
+
dimensions?: ("page" | "country" | "device" | "searchAppearance" | "date")[] | undefined;
|
|
38
|
+
searchType?: "web" | "image" | "video" | "news" | "discover" | "googleNews" | undefined;
|
|
39
|
+
limit?: number | undefined;
|
|
40
|
+
deviceType?: "desktop" | "mobile" | "tablet" | undefined;
|
|
41
|
+
country?: string | undefined;
|
|
42
|
+
offset?: number | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
export type QueryByKeywordParams = z.infer<typeof QueryByKeywordSchema>;
|
|
45
|
+
export declare const queryByKeywordTool: {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: string;
|
|
50
|
+
properties: {
|
|
51
|
+
property: {
|
|
52
|
+
type: string;
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
keywords: {
|
|
56
|
+
type: string;
|
|
57
|
+
items: {
|
|
58
|
+
type: string;
|
|
59
|
+
};
|
|
60
|
+
description: string;
|
|
61
|
+
minItems: number;
|
|
62
|
+
maxItems: number;
|
|
63
|
+
};
|
|
64
|
+
startDate: {
|
|
65
|
+
type: string;
|
|
66
|
+
description: string;
|
|
67
|
+
pattern: string;
|
|
68
|
+
};
|
|
69
|
+
endDate: {
|
|
70
|
+
type: string;
|
|
71
|
+
description: string;
|
|
72
|
+
pattern: string;
|
|
73
|
+
};
|
|
74
|
+
searchType: {
|
|
75
|
+
type: string;
|
|
76
|
+
enum: string[];
|
|
77
|
+
description: string;
|
|
78
|
+
default: string;
|
|
79
|
+
};
|
|
80
|
+
dimensions: {
|
|
81
|
+
type: string;
|
|
82
|
+
items: {
|
|
83
|
+
type: string;
|
|
84
|
+
enum: string[];
|
|
85
|
+
};
|
|
86
|
+
description: string;
|
|
87
|
+
};
|
|
88
|
+
deviceType: {
|
|
89
|
+
type: string;
|
|
90
|
+
enum: string[];
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
country: {
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
pattern: string;
|
|
97
|
+
};
|
|
98
|
+
offset: {
|
|
99
|
+
type: string;
|
|
100
|
+
description: string;
|
|
101
|
+
default: number;
|
|
102
|
+
minimum: number;
|
|
103
|
+
};
|
|
104
|
+
limit: {
|
|
105
|
+
type: string;
|
|
106
|
+
description: string;
|
|
107
|
+
minimum: number;
|
|
108
|
+
maximum: number;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
required: string[];
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
export declare function handleQueryByKeyword(params: any, client: GSCClient): Promise<ToolResponse>;
|
|
115
|
+
//# sourceMappingURL=query-by-keyword.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-by-keyword.d.ts","sourceRoot":"","sources":["../../src/tools/query-by-keyword.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAc7C,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAYD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkD/B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAcxE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkE9B,CAAC;AA0FF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,YAAY,CAAC,CAiSvB"}
|