@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,174 @@
|
|
|
1
|
+
import { listProperties, matchProperty, generatePropertyMatchError } from '../gsc/properties.js';
|
|
2
|
+
import { getPropertyInfoParamsSchema } from '../utils/validators.js';
|
|
3
|
+
import { logger } from '../utils/logger.js';
|
|
4
|
+
function getPropertyType(propertyUrl) {
|
|
5
|
+
if (propertyUrl.startsWith('sc-domain:')) {
|
|
6
|
+
return 'domain';
|
|
7
|
+
}
|
|
8
|
+
return 'url_prefix';
|
|
9
|
+
}
|
|
10
|
+
function normalizePermissionLevel(apiLevel) {
|
|
11
|
+
const mapping = {
|
|
12
|
+
'siteOwner': 'owner',
|
|
13
|
+
'siteFullUser': 'full',
|
|
14
|
+
'siteRestrictedUser': 'restricted',
|
|
15
|
+
'siteUnverifiedUser': 'unverified'
|
|
16
|
+
};
|
|
17
|
+
return mapping[apiLevel] || apiLevel;
|
|
18
|
+
}
|
|
19
|
+
export const getPropertyInfoTool = {
|
|
20
|
+
name: 'get_property_info',
|
|
21
|
+
description: 'Gets metadata and verification status for a specific Google Search Console property. Returns permission level (owner/full/restricted), property type (domain/url-prefix), and property URL. Use this to confirm property access before running queries or to check which properties you have permissions for. IMPORTANT: Use list_properties first to get available property identifiers.',
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
propertyUrl: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'Property identifier from list_properties (e.g., "sc-domain:example.com" or "https://example.com/")',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
required: ['propertyUrl'],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export async function handleGetPropertyInfo(params, client) {
|
|
34
|
+
try {
|
|
35
|
+
logger.info('Handling get_property_info request', {
|
|
36
|
+
propertyUrlInput: params.propertyUrl,
|
|
37
|
+
});
|
|
38
|
+
const validationResult = getPropertyInfoParamsSchema.safeParse(params);
|
|
39
|
+
if (!validationResult.success) {
|
|
40
|
+
const errorMessages = validationResult.error.issues.map(issue => {
|
|
41
|
+
const path = issue.path.length > 0 ? `${issue.path.join('.')}: ` : '';
|
|
42
|
+
return `${path}${issue.message}`;
|
|
43
|
+
}).join('; ');
|
|
44
|
+
logger.error('Input validation failed', {
|
|
45
|
+
errors: errorMessages,
|
|
46
|
+
params,
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
content: [{
|
|
50
|
+
type: 'text',
|
|
51
|
+
text: JSON.stringify({
|
|
52
|
+
error: 'Input validation failed',
|
|
53
|
+
details: errorMessages,
|
|
54
|
+
}, null, 2),
|
|
55
|
+
}],
|
|
56
|
+
isError: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const validated = validationResult.data;
|
|
60
|
+
const { propertyUrl } = validated;
|
|
61
|
+
logger.debug('Fetching available properties for validation');
|
|
62
|
+
const availableProperties = await listProperties(client);
|
|
63
|
+
if (availableProperties.length === 0) {
|
|
64
|
+
logger.warn('No properties found for this account');
|
|
65
|
+
return {
|
|
66
|
+
content: [{
|
|
67
|
+
type: 'text',
|
|
68
|
+
text: JSON.stringify({
|
|
69
|
+
error: 'No properties found',
|
|
70
|
+
details: 'No Google Search Console properties are accessible with this account. Please verify your account has access to at least one property.',
|
|
71
|
+
}, null, 2),
|
|
72
|
+
}],
|
|
73
|
+
isError: true,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const matchResult = matchProperty(propertyUrl, availableProperties);
|
|
77
|
+
if (!matchResult.matched) {
|
|
78
|
+
const errorMessage = generatePropertyMatchError(matchResult, availableProperties);
|
|
79
|
+
logger.error('Property matching failed', {
|
|
80
|
+
searchInput: propertyUrl,
|
|
81
|
+
matchType: matchResult.matchType,
|
|
82
|
+
alternativeCount: matchResult.alternatives?.length || 0,
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
content: [{
|
|
86
|
+
type: 'text',
|
|
87
|
+
text: JSON.stringify({
|
|
88
|
+
error: 'Property not found or ambiguous',
|
|
89
|
+
details: errorMessage,
|
|
90
|
+
}, null, 2),
|
|
91
|
+
}],
|
|
92
|
+
isError: true,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const matchedProperty = matchResult.matched;
|
|
96
|
+
logger.info('Property matched successfully', {
|
|
97
|
+
searchInput: propertyUrl,
|
|
98
|
+
matched: matchedProperty.propertyUrl,
|
|
99
|
+
matchType: matchResult.matchType,
|
|
100
|
+
});
|
|
101
|
+
logger.info('Fetching property details from GSC API', {
|
|
102
|
+
property: matchedProperty.propertyUrl,
|
|
103
|
+
});
|
|
104
|
+
const propertyDetails = await client.getPropertyInfo(matchedProperty.propertyUrl);
|
|
105
|
+
if (!propertyDetails) {
|
|
106
|
+
logger.error('Failed to retrieve property details', {
|
|
107
|
+
property: matchedProperty.propertyUrl,
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
content: [{
|
|
111
|
+
type: 'text',
|
|
112
|
+
text: JSON.stringify({
|
|
113
|
+
error: 'Unable to retrieve property details',
|
|
114
|
+
details: `Unable to retrieve details for property "${matchedProperty.propertyUrl}". The property may exist but details are unavailable.`,
|
|
115
|
+
}, null, 2),
|
|
116
|
+
}],
|
|
117
|
+
isError: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const permissionLevel = normalizePermissionLevel(propertyDetails.permissionLevel || 'unknown');
|
|
121
|
+
const propertyType = getPropertyType(matchedProperty.propertyUrl);
|
|
122
|
+
logger.info('Property details retrieved successfully', {
|
|
123
|
+
property: matchedProperty.propertyUrl,
|
|
124
|
+
permissionLevel,
|
|
125
|
+
propertyType,
|
|
126
|
+
});
|
|
127
|
+
const responseObject = {
|
|
128
|
+
propertyUrl: matchedProperty.propertyUrl,
|
|
129
|
+
permissionLevel,
|
|
130
|
+
propertyType,
|
|
131
|
+
};
|
|
132
|
+
logger.info('Get property info completed successfully', {
|
|
133
|
+
property: matchedProperty.propertyUrl,
|
|
134
|
+
permissionLevel,
|
|
135
|
+
propertyType,
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
content: [{
|
|
139
|
+
type: 'text',
|
|
140
|
+
text: JSON.stringify(responseObject, null, 2),
|
|
141
|
+
}],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
146
|
+
const errorStack = error instanceof Error ? error.stack : undefined;
|
|
147
|
+
logger.error('Get property info handler failed', {
|
|
148
|
+
error: errorMessage,
|
|
149
|
+
stack: errorStack,
|
|
150
|
+
params,
|
|
151
|
+
});
|
|
152
|
+
let userFriendlyMessage = errorMessage;
|
|
153
|
+
if (errorMessage.includes('permission') || errorMessage.includes('Permission')) {
|
|
154
|
+
userFriendlyMessage = `Permission denied for property ${params.propertyUrl}. You may not have access to this property.`;
|
|
155
|
+
}
|
|
156
|
+
else if (errorMessage.includes('not found') || errorMessage.includes('Not Found')) {
|
|
157
|
+
userFriendlyMessage = `Property ${params.propertyUrl} not found. Use list_properties to get valid property identifiers.`;
|
|
158
|
+
}
|
|
159
|
+
else if (errorMessage.includes('rate limit') || errorMessage.includes('Rate limit')) {
|
|
160
|
+
userFriendlyMessage = 'Rate limit exceeded. Please wait a moment and try again.';
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
content: [{
|
|
164
|
+
type: 'text',
|
|
165
|
+
text: JSON.stringify({
|
|
166
|
+
error: 'Get property info execution failed',
|
|
167
|
+
details: userFriendlyMessage,
|
|
168
|
+
}, null, 2),
|
|
169
|
+
}],
|
|
170
|
+
isError: true,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=get-property-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-property-info.js","sourceRoot":"","sources":["../../src/tools/get-property-info.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAgD5C,SAAS,eAAe,CAAC,WAAmB;IAC1C,IAAI,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAkBD,SAAS,wBAAwB,CAAC,QAAgB;IAChD,MAAM,OAAO,GAA2B;QACtC,WAAW,EAAE,OAAO;QACpB,cAAc,EAAE,MAAM;QACtB,oBAAoB,EAAE,YAAY;QAClC,oBAAoB,EAAE,YAAY;KACnC,CAAC;IACF,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;AACvC,CAAC;AAeD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,2XAA2X;IACxY,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE;gBAC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,EAAE,mBAAmB;qBAC7B,EAAE,IAAI,EAAE,CAAC,CAAC;iBACZ,CAAC;YACF,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { GSCClient } from '../gsc/client.js';
|
|
2
|
+
export interface ToolResponse {
|
|
3
|
+
content: Array<{
|
|
4
|
+
type: 'text';
|
|
5
|
+
text: string;
|
|
6
|
+
}>;
|
|
7
|
+
isError?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface TopPageRow {
|
|
10
|
+
page: string;
|
|
11
|
+
clicks: number;
|
|
12
|
+
impressions: number;
|
|
13
|
+
ctr: number;
|
|
14
|
+
position: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const getTopPagesTool: {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: string;
|
|
21
|
+
properties: {
|
|
22
|
+
property: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
startDate: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
pattern: string;
|
|
30
|
+
};
|
|
31
|
+
endDate: {
|
|
32
|
+
type: string;
|
|
33
|
+
description: string;
|
|
34
|
+
pattern: string;
|
|
35
|
+
};
|
|
36
|
+
limit: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
minimum: number;
|
|
40
|
+
maximum: number;
|
|
41
|
+
default: number;
|
|
42
|
+
};
|
|
43
|
+
sortBy: {
|
|
44
|
+
type: string;
|
|
45
|
+
enum: string[];
|
|
46
|
+
description: string;
|
|
47
|
+
default: string;
|
|
48
|
+
};
|
|
49
|
+
sortOrder: {
|
|
50
|
+
type: string;
|
|
51
|
+
enum: string[];
|
|
52
|
+
description: string;
|
|
53
|
+
default: string;
|
|
54
|
+
};
|
|
55
|
+
searchType: {
|
|
56
|
+
type: string;
|
|
57
|
+
enum: string[];
|
|
58
|
+
description: string;
|
|
59
|
+
default: string;
|
|
60
|
+
};
|
|
61
|
+
minClicks: {
|
|
62
|
+
type: string;
|
|
63
|
+
description: string;
|
|
64
|
+
minimum: number;
|
|
65
|
+
};
|
|
66
|
+
minImpressions: {
|
|
67
|
+
type: string;
|
|
68
|
+
description: string;
|
|
69
|
+
minimum: number;
|
|
70
|
+
};
|
|
71
|
+
positionRange: {
|
|
72
|
+
type: string;
|
|
73
|
+
properties: {
|
|
74
|
+
min: {
|
|
75
|
+
type: string;
|
|
76
|
+
description: string;
|
|
77
|
+
minimum: number;
|
|
78
|
+
};
|
|
79
|
+
max: {
|
|
80
|
+
type: string;
|
|
81
|
+
description: string;
|
|
82
|
+
minimum: number;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
required: string[];
|
|
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
|
+
};
|
|
99
|
+
required: string[];
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
export declare function handleGetTopPages(params: any, client: GSCClient): Promise<ToolResponse>;
|
|
103
|
+
//# sourceMappingURL=get-top-pages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-top-pages.d.ts","sourceRoot":"","sources":["../../src/tools/get-top-pages.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAa7C,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;AAKD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAsCD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqF3B,CAAC;AAiCF,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,YAAY,CAAC,CAiOvB"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { listProperties, matchProperty, generatePropertyMatchError } from '../gsc/properties.js';
|
|
2
|
+
import { executeTopNQuery } from '../gsc/queries.js';
|
|
3
|
+
import { getTopPagesParamsSchema } from '../utils/validators.js';
|
|
4
|
+
import { logger } from '../utils/logger.js';
|
|
5
|
+
export const getTopPagesTool = {
|
|
6
|
+
name: 'get_top_pages',
|
|
7
|
+
description: 'Quickly retrieves top performing URLs/pages for a property. Returns the highest traffic pages sorted by clicks, impressions, CTR, or position. Perfect for identifying which content performs best. Supports filtering by minimum thresholds, position ranges, and date ranges. No chunking needed - results fit within 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
|
+
limit: {
|
|
26
|
+
type: 'number',
|
|
27
|
+
description: 'Number of top pages to return (1-1000, default: 20)',
|
|
28
|
+
minimum: 1,
|
|
29
|
+
maximum: 1000,
|
|
30
|
+
default: 20,
|
|
31
|
+
},
|
|
32
|
+
sortBy: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
enum: ['clicks', 'impressions', 'ctr', 'position'],
|
|
35
|
+
description: 'Metric to sort by (default: clicks)',
|
|
36
|
+
default: 'clicks',
|
|
37
|
+
},
|
|
38
|
+
sortOrder: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
enum: ['asc', 'desc'],
|
|
41
|
+
description: 'Sort order (default: desc)',
|
|
42
|
+
default: 'desc',
|
|
43
|
+
},
|
|
44
|
+
searchType: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
enum: ['web', 'image', 'video', 'news', 'discover', 'googleNews'],
|
|
47
|
+
description: 'Search type filter (default: web)',
|
|
48
|
+
default: 'web',
|
|
49
|
+
},
|
|
50
|
+
minClicks: {
|
|
51
|
+
type: 'number',
|
|
52
|
+
description: 'Minimum clicks threshold (optional)',
|
|
53
|
+
minimum: 0,
|
|
54
|
+
},
|
|
55
|
+
minImpressions: {
|
|
56
|
+
type: 'number',
|
|
57
|
+
description: 'Minimum impressions threshold (optional)',
|
|
58
|
+
minimum: 0,
|
|
59
|
+
},
|
|
60
|
+
positionRange: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
min: {
|
|
64
|
+
type: 'number',
|
|
65
|
+
description: 'Minimum position (e.g., 1)',
|
|
66
|
+
minimum: 1,
|
|
67
|
+
},
|
|
68
|
+
max: {
|
|
69
|
+
type: 'number',
|
|
70
|
+
description: 'Maximum position (e.g., 10)',
|
|
71
|
+
minimum: 1,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
required: ['min', 'max'],
|
|
75
|
+
description: 'Filter by position range (optional)',
|
|
76
|
+
},
|
|
77
|
+
deviceType: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
enum: ['desktop', 'mobile', 'tablet'],
|
|
80
|
+
description: 'Filter by device type (optional)',
|
|
81
|
+
},
|
|
82
|
+
country: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: '3-letter country code (e.g., "usa", "gbr") (optional)',
|
|
85
|
+
pattern: '^[a-z]{3}$',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
required: ['property', 'startDate', 'endDate'],
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
export async function handleGetTopPages(params, client) {
|
|
92
|
+
try {
|
|
93
|
+
logger.info('Handling get_top_pages request', {
|
|
94
|
+
propertyInput: params.property,
|
|
95
|
+
limit: params.limit || 20,
|
|
96
|
+
sortBy: params.sortBy || 'clicks',
|
|
97
|
+
dateRange: params.startDate && params.endDate ? `${params.startDate} to ${params.endDate}` : 'not provided',
|
|
98
|
+
});
|
|
99
|
+
const validationResult = getTopPagesParamsSchema.safeParse(params);
|
|
100
|
+
if (!validationResult.success) {
|
|
101
|
+
const errorMessages = validationResult.error.issues.map(issue => {
|
|
102
|
+
const path = issue.path.length > 0 ? `${issue.path.join('.')}: ` : '';
|
|
103
|
+
return `${path}${issue.message}`;
|
|
104
|
+
}).join('; ');
|
|
105
|
+
logger.error('Input validation failed', {
|
|
106
|
+
errors: errorMessages,
|
|
107
|
+
params,
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
content: [{
|
|
111
|
+
type: 'text',
|
|
112
|
+
text: JSON.stringify({
|
|
113
|
+
error: 'Input validation failed',
|
|
114
|
+
details: errorMessages,
|
|
115
|
+
}, null, 2),
|
|
116
|
+
}],
|
|
117
|
+
isError: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const validated = validationResult.data;
|
|
121
|
+
const { property, startDate, endDate, limit = 20, sortBy = 'clicks', sortOrder = 'desc', searchType = 'web', minClicks, minImpressions, positionRange, deviceType, country, } = validated;
|
|
122
|
+
logger.debug('Fetching available properties');
|
|
123
|
+
const availableProperties = await listProperties(client);
|
|
124
|
+
if (availableProperties.length === 0) {
|
|
125
|
+
logger.warn('No properties found for this account');
|
|
126
|
+
return {
|
|
127
|
+
content: [{
|
|
128
|
+
type: 'text',
|
|
129
|
+
text: JSON.stringify({
|
|
130
|
+
error: 'No properties found',
|
|
131
|
+
details: 'No Google Search Console properties are accessible with this account. Please verify your account has access to at least one property.',
|
|
132
|
+
}, null, 2),
|
|
133
|
+
}],
|
|
134
|
+
isError: true,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const matchResult = matchProperty(property, availableProperties);
|
|
138
|
+
if (!matchResult.matched) {
|
|
139
|
+
const errorMessage = generatePropertyMatchError(matchResult, availableProperties);
|
|
140
|
+
logger.error('Property matching failed', {
|
|
141
|
+
searchInput: property,
|
|
142
|
+
matchType: matchResult.matchType,
|
|
143
|
+
alternativeCount: matchResult.alternatives?.length || 0,
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
content: [{
|
|
147
|
+
type: 'text',
|
|
148
|
+
text: JSON.stringify({
|
|
149
|
+
error: 'Property not found or ambiguous',
|
|
150
|
+
details: errorMessage,
|
|
151
|
+
}, null, 2),
|
|
152
|
+
}],
|
|
153
|
+
isError: true,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const matchedProperty = matchResult.matched;
|
|
157
|
+
logger.info('Property matched successfully', {
|
|
158
|
+
searchInput: property,
|
|
159
|
+
matched: matchedProperty.propertyUrl,
|
|
160
|
+
matchType: matchResult.matchType,
|
|
161
|
+
});
|
|
162
|
+
logger.info('Executing top pages query', {
|
|
163
|
+
property: matchedProperty.propertyUrl,
|
|
164
|
+
limit,
|
|
165
|
+
dateRange: `${startDate} to ${endDate}`,
|
|
166
|
+
});
|
|
167
|
+
const results = await executeTopNQuery(client, matchedProperty.propertyUrl, startDate, endDate, 'page', {
|
|
168
|
+
limit,
|
|
169
|
+
sortBy: sortBy,
|
|
170
|
+
sortOrder: sortOrder,
|
|
171
|
+
searchType,
|
|
172
|
+
minClicks,
|
|
173
|
+
minImpressions,
|
|
174
|
+
positionRange,
|
|
175
|
+
deviceType,
|
|
176
|
+
country,
|
|
177
|
+
});
|
|
178
|
+
const topPages = results.map((row) => ({
|
|
179
|
+
page: row.keys[0] || '',
|
|
180
|
+
clicks: row.clicks,
|
|
181
|
+
impressions: row.impressions,
|
|
182
|
+
ctr: row.ctr,
|
|
183
|
+
position: row.position,
|
|
184
|
+
}));
|
|
185
|
+
const filters = {};
|
|
186
|
+
if (minClicks !== undefined)
|
|
187
|
+
filters.minClicks = minClicks;
|
|
188
|
+
if (minImpressions !== undefined)
|
|
189
|
+
filters.minImpressions = minImpressions;
|
|
190
|
+
if (positionRange)
|
|
191
|
+
filters.positionRange = positionRange;
|
|
192
|
+
if (deviceType)
|
|
193
|
+
filters.deviceType = deviceType;
|
|
194
|
+
if (country)
|
|
195
|
+
filters.country = country;
|
|
196
|
+
const responseObject = {
|
|
197
|
+
property: matchedProperty.propertyUrl,
|
|
198
|
+
topPages,
|
|
199
|
+
totalPages: topPages.length,
|
|
200
|
+
...(Object.keys(filters).length > 0 && { filters }),
|
|
201
|
+
sortBy,
|
|
202
|
+
sortOrder,
|
|
203
|
+
searchType,
|
|
204
|
+
dateRange: {
|
|
205
|
+
start: startDate,
|
|
206
|
+
end: endDate,
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
logger.info('Get top pages completed successfully', {
|
|
210
|
+
property: matchedProperty.propertyUrl,
|
|
211
|
+
pagesReturned: topPages.length,
|
|
212
|
+
limit,
|
|
213
|
+
});
|
|
214
|
+
return {
|
|
215
|
+
content: [{
|
|
216
|
+
type: 'text',
|
|
217
|
+
text: JSON.stringify(responseObject, null, 2),
|
|
218
|
+
}],
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
223
|
+
const errorStack = error instanceof Error ? error.stack : undefined;
|
|
224
|
+
logger.error('Get top pages handler failed', {
|
|
225
|
+
error: errorMessage,
|
|
226
|
+
stack: errorStack,
|
|
227
|
+
params,
|
|
228
|
+
});
|
|
229
|
+
let userFriendlyMessage = errorMessage;
|
|
230
|
+
if (errorMessage.includes('permission') || errorMessage.includes('Permission')) {
|
|
231
|
+
userFriendlyMessage = `Permission denied for property ${params.property}. Use list_properties to see accessible properties.`;
|
|
232
|
+
}
|
|
233
|
+
else if (errorMessage.includes('not found') || errorMessage.includes('Not Found')) {
|
|
234
|
+
userFriendlyMessage = `Property ${params.property} not found. Use list_properties to get valid property identifiers.`;
|
|
235
|
+
}
|
|
236
|
+
else if (errorMessage.includes('date') || errorMessage.includes('Date')) {
|
|
237
|
+
userFriendlyMessage = `Invalid date range. ${errorMessage}`;
|
|
238
|
+
}
|
|
239
|
+
else if (errorMessage.includes('rate limit') || errorMessage.includes('Rate limit')) {
|
|
240
|
+
userFriendlyMessage = 'Rate limit exceeded. Please wait a moment and try again.';
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
content: [{
|
|
244
|
+
type: 'text',
|
|
245
|
+
text: JSON.stringify({
|
|
246
|
+
error: 'Get top pages execution failed',
|
|
247
|
+
details: userFriendlyMessage,
|
|
248
|
+
}, null, 2),
|
|
249
|
+
}],
|
|
250
|
+
isError: true,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=get-top-pages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-top-pages.js","sourceRoot":"","sources":["../../src/tools/get-top-pages.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,E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YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YACpF,mBAAmB,GAAG,YAAY,MAAM,CAAC,QAAQ,oEAAoE,CAAC;QACxH,CAAC;aAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1E,mBAAmB,GAAG,uBAAuB,YAAY,EAAE,CAAC;QAC9D,CAAC;aAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YACtF,mBAAmB,GAAG,0DAA0D,CAAC;QACnF,CAAC;QAED,OAAO;YACL,OAAO,EAAE,CAAC;oBACR,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,KAAK,EAAE,gCAAgC;wBACvC,OAAO,EAAE,mBAAmB;qBAC7B,EAAE,IAAI,EAAE,CAAC,CAAC;iBACZ,CAAC;YACF,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { GSCClient } from '../gsc/client.js';
|
|
2
|
+
export interface ToolResponse {
|
|
3
|
+
content: Array<{
|
|
4
|
+
type: 'text';
|
|
5
|
+
text: string;
|
|
6
|
+
}>;
|
|
7
|
+
isError?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface TopQueryRow {
|
|
10
|
+
query: string;
|
|
11
|
+
clicks: number;
|
|
12
|
+
impressions: number;
|
|
13
|
+
ctr: number;
|
|
14
|
+
position: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const getTopQueriesTool: {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: string;
|
|
21
|
+
properties: {
|
|
22
|
+
property: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
startDate: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
pattern: string;
|
|
30
|
+
};
|
|
31
|
+
endDate: {
|
|
32
|
+
type: string;
|
|
33
|
+
description: string;
|
|
34
|
+
pattern: string;
|
|
35
|
+
};
|
|
36
|
+
limit: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
minimum: number;
|
|
40
|
+
maximum: number;
|
|
41
|
+
default: number;
|
|
42
|
+
};
|
|
43
|
+
sortBy: {
|
|
44
|
+
type: string;
|
|
45
|
+
enum: string[];
|
|
46
|
+
description: string;
|
|
47
|
+
default: string;
|
|
48
|
+
};
|
|
49
|
+
sortOrder: {
|
|
50
|
+
type: string;
|
|
51
|
+
enum: string[];
|
|
52
|
+
description: string;
|
|
53
|
+
default: string;
|
|
54
|
+
};
|
|
55
|
+
searchType: {
|
|
56
|
+
type: string;
|
|
57
|
+
enum: string[];
|
|
58
|
+
description: string;
|
|
59
|
+
default: string;
|
|
60
|
+
};
|
|
61
|
+
minClicks: {
|
|
62
|
+
type: string;
|
|
63
|
+
description: string;
|
|
64
|
+
minimum: number;
|
|
65
|
+
};
|
|
66
|
+
minImpressions: {
|
|
67
|
+
type: string;
|
|
68
|
+
description: string;
|
|
69
|
+
minimum: number;
|
|
70
|
+
};
|
|
71
|
+
positionRange: {
|
|
72
|
+
type: string;
|
|
73
|
+
properties: {
|
|
74
|
+
min: {
|
|
75
|
+
type: string;
|
|
76
|
+
description: string;
|
|
77
|
+
minimum: number;
|
|
78
|
+
};
|
|
79
|
+
max: {
|
|
80
|
+
type: string;
|
|
81
|
+
description: string;
|
|
82
|
+
minimum: number;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
required: string[];
|
|
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
|
+
};
|
|
99
|
+
required: string[];
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
export declare function handleGetTopQueries(params: any, client: GSCClient): Promise<ToolResponse>;
|
|
103
|
+
//# sourceMappingURL=get-top-queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-top-queries.d.ts","sourceRoot":"","sources":["../../src/tools/get-top-queries.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAa7C,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;AAKD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAsCD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqF7B,CAAC;AAiCF,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,YAAY,CAAC,CAiOvB"}
|