search-console-mcp 1.9.0 → 1.9.2

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/README.md CHANGED
@@ -1,295 +1,175 @@
1
1
  # Google Search Console MCP Server
2
2
 
3
- A Model Context Protocol (MCP) server that provides AI agents with access to Google Search Console data.
3
+ A Model Context Protocol (MCP) server that transforms how you interact with Google Search Console. Stop exporting CSVs and start asking questions.
4
4
 
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [📚 View Documentation](https://searchconsolemcp.mintlify.app/)
6
6
 
7
- ## Quick Start
7
+ ---
8
8
 
9
- For users with an MCP-compatible client (like Claude Desktop):
10
-
11
- ```bash
12
- npx search-console-mcp
13
- ```
9
+ ### [🏠 Overview](#) | [🎯 Prompts](#-magic-prompts) | [🚀 Quick Start](#-quick-start) | [🛠️ Tools](#-tools-reference)
14
10
 
15
11
  ---
16
12
 
17
- ## Table of Contents
18
-
19
- - [Features](#features)
20
- - [Installation](#installation)
21
- - [Google Cloud Setup](#google-cloud-setup)
22
- - [MCP Client Configuration](#mcp-client-configuration)
23
- - [Local Development](#local-development)
24
- - [Tools Reference](#tools-reference)
25
- - [Resources](#resources)
26
- - [Prompts](#prompts)
13
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
14
+ [![Tests](https://github.com/saurabhsharma2u/search-console-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/saurabhsharma2u/search-console-mcp/actions/workflows/ci.yml)
27
15
 
28
- ---
16
+ ## Why use this?
29
17
 
30
- ## Features
18
+ ### ❌ The Old Way
19
+ 1. Open Search Console -> Performance Tab
20
+ 2. Filter by "Last 28 days"
21
+ 3. Export to CSV
22
+ 4. Open in Excel/Sheets
23
+ 5. Create a filter for "Position > 10" AND "Impressions > 1000"
24
+ 6. Analyze manually to find opportunities
31
25
 
32
- - **Sites Management**: List, add, and delete sites
33
- - **Sitemaps**: List, submit, get, and delete sitemaps
34
- - **Search Analytics**: Query performance data with advanced filtering and pagination
35
- - **Period Comparison**: Compare metrics between two date ranges
36
- - **Top Queries/Pages**: Get top performing queries and pages
37
- - **URL Inspection**: Check indexing status of specific URLs
38
- - **AI Documentation**: Built-in docs for AI agents to understand GSC concepts
26
+ ### The New Way
27
+ **Just ask:**
28
+ > "Find low-hanging fruit keywords (positions 11-20) with high impressions that I should optimize."
39
29
 
40
30
  ---
41
31
 
42
- ## Installation
32
+ ## 🎯 Magic Prompts
43
33
 
44
- ### Option 1: Use with npx (Recommended)
34
+ Copy and paste these into your MCP client (Claude Desktop, etc.) to see the intelligence engine in action:
45
35
 
46
- No installation needed. Configure your MCP client to run:
36
+ #### �️ The Traffic Detective
37
+ > "My traffic dropped this week compared to last. Use the anomaly detection and time-series tools to find exactly when the drop started and which pages are responsible."
47
38
 
48
- ```bash
49
- npx search-console-mcp
50
- ```
39
+ #### 🎯 The "Striking Distance" Hunter
40
+ > "Find keywords for https://example.com where I'm ranking in positions 8-15 but have at least 1,000 impressions. These are my best opportunities for a quick traffic boost."
51
41
 
52
- ### Option 2: Global Install
42
+ #### ⚔️ The Cannibalization Cleaner
43
+ > "Check for keyword cannibalization. Are there any queries where two or more of my pages are competing and splitting the traffic? Suggest which one should be the primary authority."
53
44
 
54
- ```bash
55
- npm install -g search-console-mcp
56
- search-console-mcp
57
- ```
45
+ #### 📈 The SEO Opportunity Scoreboard
46
+ > "Analyze my top 50 keywords for the last 90 days. Rank them by a custom 'Opportunity Score' (Impressions / Position). Give me the top 5 specific pages to focus on."
58
47
 
59
- ### Option 3: Clone for Development
48
+ #### 📊 The Executive Health Check
49
+ > "Run a full SEO health check for my site. Segment the results by Brand vs. Non-Brand and give me 3 high-impact actions for the upcoming week."
60
50
 
61
- ```bash
62
- git clone https://github.com/saurabhsharma2u/search-console-mcp.git
63
- cd search-console-mcp
64
- npm install
65
- npm run build
66
- node dist/index.js
67
- ```
51
+ #### ⚡ The Speed vs. Ranking Correlator
52
+ > "Fetch the top 5 pages by impressions. For these pages, run a PageSpeed audit. Is there any correlation between low performance scores and recently declining positions?"
68
53
 
69
54
  ---
70
55
 
71
- ## Google Cloud Setup
72
-
73
- ### Step 1: Create a Google Cloud Project
74
-
75
- 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
76
- 2. Create a new project or select an existing one
77
- 3. Enable the **Google Search Console API**:
78
- - Go to **APIs & Services** > **Library**
79
- - Search for "Google Search Console API"
80
- - Click **Enable**
56
+ ## 🔒 Security & Privacy
81
57
 
82
- ### Step 2: Create a Service Account
58
+ We take your data security seriously. This tool is designed to be **local-first** and **secure by default**.
83
59
 
84
- 1. Go to **APIs & Services** > **Credentials**
85
- 2. Click **Create Credentials** > **Service Account**
86
- 3. Fill in the details and click **Create**
87
- 4. Skip the optional steps and click **Done**
88
- 5. Click on the service account email to open it
89
- 6. Go to the **Keys** tab > **Add Key** > **Create new key**
90
- 7. Select **JSON** and download the key file
60
+ * **Credentials Never Logged**: Your Google Service Account keys are used *only* in memory to authenticate with Google APIs. They are never written to disk, logs, or sent to any third-party server.
61
+ * **Local Execution**: The code runs entirely on your local machine (or wherever you host your MCP server).
62
+ * **Path Traversal Protection**: The setup wizard implements strict validation for file paths, including null-byte removal, extension enforcement (.json), and size limits (1MB) to prevent unauthorized file access.
63
+ * **Direct Communication**: All API calls go directly from your machine to Google's servers (`googleapis.com`). There is no middleman or proxy server.
64
+ * **Open Source**: The code is fully open source. You can audit exactly how your credentials are used in `src/google-client.ts`.
91
65
 
92
- ### Step 3: Grant Access in Search Console
66
+ ---
93
67
 
94
- 1. Go to [Google Search Console](https://search.google.com/search-console/)
95
- 2. Select your property
96
- 3. Go to **Settings** > **Users and permissions**
97
- 4. Click **Add user**
98
- 5. Enter the service account email (e.g., `my-service@project.iam.gserviceaccount.com`)
99
- 6. Set permission to **Full** (for write operations) or **Restricted** (read-only)
68
+ ## Features
100
69
 
101
- ### Step 4: Configure Credentials
70
+ - **Advanced Analytics**: Query performance data with powerful filters (Regex supported).
71
+ - *New*: Support for 'News', 'Discover', 'Image' search types.
72
+ - *New*: 'Fresh' data support for real-time monitoring.
73
+ - *New*: **Drop Attribution** to identify device-level traffic losses.
74
+ - *New*: **Time Series Insights** with rolling averages and trend forecasting.
75
+ - **Trend Detection**: Automatically identify rising or falling trends in your traffic.
76
+ - **Anomaly Detection**: Spot unusual spikes or drops that need attention.
77
+ - **Sitemaps Management**: List, submit, and validte sitemaps.
78
+ - **URL Inspection**: Check real-time indexing status and mobile usability.
79
+ - **PageSpeed Insights**: Integrated performance and Core Web Vitals analysis.
80
+ - **Schema Validation**: Validate JSON-LD structured data.
102
81
 
103
- **Option A: File-based (Local Development)**
82
+ ---
104
83
 
105
- ```bash
106
- export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-key.json"
107
- ```
84
+ ## Quick Start
108
85
 
109
- **Option B: Environment Variables (Serverless/Cloudflare)**
86
+ ### 1. Run the Setup Wizard
87
+ First, use the interactive wizard to validate your credentials and get your configuration:
110
88
 
111
89
  ```bash
112
- export GOOGLE_CLIENT_EMAIL="your-service-account@project.iam.gserviceaccount.com"
113
- export GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"
90
+ npx search-console-mcp-setup
114
91
  ```
115
92
 
116
- ---
93
+ The wizard will guide you through:
94
+ - Creating a Google Service Account.
95
+ - Adding the account to Search Console.
96
+ - Validating your JSON key file.
97
+ - Generating the configuration for your MCP client.
117
98
 
118
- ## MCP Client Configuration
99
+ ### 2. Connect to an MCP Client
119
100
 
120
- ### Claude Desktop
101
+ **Note:** The server uses `stdio` to communicate. Do not run `npx search-console-mcp` directly in your terminal; it is meant to be run by an MCP client like Claude Desktop or Cursor.
121
102
 
122
- Add to your `claude_desktop_config.json`:
103
+ #### Claude Desktop Configuration
104
+ Add this to your `claude_desktop_config.json`:
123
105
 
124
106
  ```json
125
107
  {
126
108
  "mcpServers": {
127
109
  "google-search-console": {
128
110
  "command": "npx",
129
- "args": ["search-console-mcp"],
111
+ "args": ["-y", "search-console-mcp"],
130
112
  "env": {
131
- "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json"
113
+ "GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/your/service-account-key.json"
132
114
  }
133
115
  }
134
116
  }
135
117
  }
136
118
  ```
137
119
 
138
- ### Generic MCP Client
139
-
140
- ```json
141
- {
142
- "name": "google-search-console",
143
- "command": "npx",
144
- "args": ["search-console-mcp"],
145
- "env": {
146
- "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json"
147
- }
148
- }
149
- ```
150
-
151
- ---
152
-
153
- ## Local Development
154
-
155
- ### Setup
156
-
157
- ```bash
158
- # Clone the repository
159
- git clone https://github.com/saurabhsharma2u/search-console-mcp.git
160
- cd search-console-mcp
161
-
162
- # Install dependencies
163
- npm install
164
-
165
- # Create .env file
166
- cp .env.example .env
167
- # Edit .env with your credentials
168
-
169
- # Build
170
- npm run build
171
-
172
- # Run tests
173
- npm test
174
-
175
- # Run the server
176
- node dist/index.js
177
- ```
178
-
179
- ### Project Structure
180
-
181
- ```
182
- src/
183
- ├── index.ts # MCP server entry point
184
- ├── google-client.ts # Google API authentication
185
- ├── errors.ts # Error handling utilities
186
- ├── docs/ # Embedded documentation for AI
187
- │ ├── dimensions.ts
188
- │ ├── filters.ts
189
- │ ├── search-types.ts
190
- │ └── patterns.ts
191
- └── tools/ # Tool implementations
192
- ├── sites.ts
193
- ├── sitemaps.ts
194
- ├── analytics.ts
195
- └── inspection.ts
196
- ```
197
-
198
120
  ---
199
121
 
200
122
  ## Tools Reference
201
123
 
202
- ### Sites
203
-
204
- | Tool | Description | Arguments |
205
- |------|-------------|-----------|
206
- | `sites_list` | List all sites | none |
207
- | `sites_add` | Add a site | `siteUrl` |
208
- | `sites_delete` | Delete a site | `siteUrl` |
209
- | `sites_get` | Get site details | `siteUrl` |
210
-
211
- ### Sitemaps
212
-
213
- | Tool | Description | Arguments |
214
- |------|-------------|-----------|
215
- | `sitemaps_list` | List sitemaps | `siteUrl` |
216
- | `sitemaps_get` | Get sitemap details | `siteUrl`, `feedpath` |
217
- | `sitemaps_submit` | Submit sitemap | `siteUrl`, `feedpath` |
218
- | `sitemaps_delete` | Delete sitemap | `siteUrl`, `feedpath` |
219
-
220
124
  ### Analytics
221
-
222
- | Tool | Description | Arguments |
223
- |------|-------------|-----------|
224
- | `analytics_query` | Query search analytics with filters | `siteUrl`, `startDate`, `endDate`, `dimensions?`, `type?`, `limit?`, `startRow?`, `filters?` |
225
- | `analytics_performance_summary` | Get aggregate metrics for N days | `siteUrl`, `days?` |
226
- | `analytics_compare_periods` | Compare two date ranges | `siteUrl`, `period1Start`, `period1End`, `period2Start`, `period2End` |
227
- | `analytics_top_queries` | Get top queries | `siteUrl`, `days?`, `limit?`, `sortBy?` |
228
- | `analytics_top_pages` | Get top pages | `siteUrl`, `days?`, `limit?`, `sortBy?` |
229
-
230
- ### Inspection
231
-
232
- | Tool | Description | Arguments |
233
- |------|-------------|-----------|
234
- | `inspection_inspect` | Inspect URL index status | `siteUrl`, `inspectionUrl`, `languageCode?` |
235
-
236
- ### PageSpeed Insights
237
-
238
- | Tool | Description | Arguments |
239
- |------|-------------|-----------|
240
- | `pagespeed_analyze` | PageSpeed Insights scores (performance, accessibility, SEO) | `url`, `strategy?` (mobile/desktop) |
241
- | `pagespeed_core_web_vitals` | Core Web Vitals for mobile & desktop (LCP, FID, CLS, etc.) | `url` |
242
-
243
- ### SEO Insights
244
-
245
- | Tool | Description | Arguments |
246
- |------|-------------|-----------|
247
- | `seo_recommendations` | Generate actionable SEO recommendations | `siteUrl`, `days?` |
248
- | `seo_low_hanging_fruit` | Find keywords at positions 5-20 with high impressions | `siteUrl`, `days?`, `minImpressions?`, `limit?` |
249
- | `seo_cannibalization` | Detect pages competing for the same keywords | `siteUrl`, `days?`, `minImpressions?`, `limit?` |
250
- | `seo_quick_wins` | Find pages close to page 1 (positions 11-20) | `siteUrl`, `days?`, `minImpressions?`, `limit?` |
251
-
252
- ---
253
-
254
- ## Resources
255
-
256
- AI agents can read these built-in documentation and data resources:
257
-
258
- | URI | Description |
259
- |-----|-------------|
260
- | `sites://list` | List of all sites (JSON) |
261
- | `sitemaps://list/{siteUrl}` | Sitemaps for a specific site (JSON) |
262
- | `analytics://summary/{siteUrl}` | Performance summary for a site (JSON) |
263
- | `docs://dimensions` | Available dimensions reference |
264
- | `docs://filters` | Filter operators and examples |
265
- | `docs://search-types` | Search types (web, image, video, etc.) |
266
- | `docs://patterns` | Common usage patterns and recipes |
267
-
268
- ---
269
-
270
- ## Prompts
271
-
272
- Pre-configured analysis workflows for AI agents:
273
-
274
- | Prompt | Description | Arguments |
275
- |--------|-------------|-----------|
276
- | `analyze-site-performance` | Analyze site's 28-day performance | `siteUrl` |
277
- | `compare-performance` | Compare this week vs last week | `siteUrl` |
278
- | `find-declining-pages` | Find pages losing traffic | `siteUrl` |
279
- | `keyword-opportunities` | Find low-CTR high-impression queries | `siteUrl` |
280
- | `new-content-impact` | Analyze new content performance | `siteUrl`, `pageUrl` |
281
- | `mobile-vs-desktop` | Compare device performance | `siteUrl` |
125
+ | Tool | Description |
126
+ |------|-------------|
127
+ | `analytics_query` | Master tool for raw data. Supports `dimensions`, `filters`, `aggregationType` (byPage/byProperty), `dataState` (final/all), and `type` (web/image/news/discover). |
128
+ | `analytics_trends` | Detect trends (rising/falling) for specific queries or pages. |
129
+ | `analytics_anomalies` | Detect statistical anomalies in daily traffic. |
130
+ | `analytics_drop_attribution` | **[NEW]** Attribute traffic drops to mobile/desktop or correlate with known Google Algorithm Updates. |
131
+ | `analytics_time_series` | **[NEW]** Advanced time series with rolling averages, seasonality detection, and forecasting. |
132
+ | `analytics_compare_periods` | Compare two date ranges (e.g., WoW, MoM). |
133
+ | `seo_brand_vs_nonbrand` | **[NEW]** Analyze performance split between Brand vs Non-Brand traffic. |
134
+
135
+ ### SEO Opportunities (Opinionated)
136
+ | Tool | Description |
137
+ |------|-------------|
138
+ | `seo_low_hanging_fruit` | Find keywords ranking in pos 5-20 with high impressions. |
139
+ | `seo_striking_distance` | **[NEW]** Find keywords ranking 8-15 (Quickest ROI wins). |
140
+ | `seo_low_ctr_opportunities` | **[NEW]** Find top ranking queries (pos 1-10) with poor CTR. |
141
+ | `seo_cannibalization` | **[Enhanced]** Detect pages competing for the same query with traffic conflict. |
142
+ | `seo_lost_queries` | **[NEW]** Identify queries that lost all traffic in the last 28 days. |
143
+
144
+ ### SEO Primitives (Atoms for Agents)
145
+ These are low-level tools designed to be used by other AI agents to build complex logic.
146
+ | Tool | Description |
147
+ |------|-------------|
148
+ | `seo_primitive_ranking_bucket` | Categorize a position (e.g. "Top 3", "Page 1", "Unranked"). |
149
+ | `seo_primitive_traffic_delta` | Calculate absolute and % change between two numbers. |
150
+ | `seo_primitive_is_brand` | Check if a query matches a brand regex. |
151
+ | `seo_primitive_is_cannibalized` | Check if two pages are competing for the same query. |
152
+
153
+ ### Sites & Sitemaps
154
+ | Tool | Description |
155
+ |------|-------------|
156
+ | `sites_list` | List all verified sites. |
157
+ | `sites_add` / `sites_delete` | Manage properties. |
158
+ | `sitemaps_list` / `sitemaps_submit` | Manage sitemaps. |
159
+
160
+ ### Inspection & Validation
161
+ | Tool | Description |
162
+ |------|-------------|
163
+ | `inspection_inspect` | Google URL Inspection API (Index status, mobile usability). |
164
+ | `pagespeed_analyze` | Lighthouse scores & Core Web Vitals. |
165
+ | `schema_validate` | Validate Structured Data (JSON-LD). |
282
166
 
283
167
  ---
284
168
 
285
169
  ## Contributing
286
170
 
287
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for contribution guidelines.
288
-
289
- ## Roadmap
290
-
291
- See [ROADMAP.md](./ROADMAP.md) for planned features.
171
+ We love contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
292
172
 
293
173
  ## License
294
174
 
295
- MIT - see [LICENSE](./LICENSE)
175
+ MIT
@@ -0,0 +1,20 @@
1
+ export const algorithmUpdatesDocs = `
2
+ # Google Algorithm Updates Reference
3
+
4
+ The \`analytics_drop_attribution\` tool correlates traffic drops with major known Google Algorithm Updates. The following updates are currently supported:
5
+
6
+ | Date | Update Name | Impact Area |
7
+ |------|-------------|-------------|
8
+ | 2025-01-15 | January 2025 Core Update | General Ranking |
9
+ | 2024-11-11 | November 2024 Core Update | General Ranking |
10
+ | 2024-08-15 | August 2024 Core Update | General Ranking |
11
+ | 2024-06-20 | June 2024 Spam Update | Content Quality / Spam |
12
+ | 2024-03-05 | March 2024 Core Update | General Ranking / Quality |
13
+ | 2023-11-02 | November 2023 Core Update | General Ranking |
14
+ | 2023-10-05 | October 2023 Core Update | General Ranking |
15
+ | 2023-09-14 | September 2023 Helpful Content Update | Quality / Value |
16
+
17
+ ## How Attribution Works
18
+ When a traffic drop is detected, the system checks if it occurred within **+/- 2 days** of any of these dates. If it matches, the update is flagged as a potential primary cause of the drop.
19
+ `;
20
+ export default algorithmUpdatesDocs;
@@ -5,3 +5,4 @@ export { dimensionsDocs } from './dimensions.js';
5
5
  export { filtersDocs } from './filters.js';
6
6
  export { searchTypesDocs } from './search-types.js';
7
7
  export { patternsDocs } from './patterns.js';
8
+ export { algorithmUpdatesDocs } from './algorithm-updates.js';
@@ -26,6 +26,35 @@ Args: {
26
26
  }
27
27
  \`\`\`
28
28
 
29
+ | Tool | Description |
30
+ |------|-------------|
31
+ | \`analytics_drop_attribution\` | Identify if a traffic drop was device-specific or algorithm-linked. |
32
+ | \`analytics_time_series\` | Get rolling averages, seasonality strength, and trend forecasts. |
33
+
34
+ ---
35
+
36
+ ## Advanced Analytics Patterns
37
+
38
+ ### Attribute a Traffic Drop
39
+ Identify if a recent drop was caused by mobile/desktop devices or correlates with a Google Algorithm Update:
40
+ \`\`\`json
41
+ {
42
+ "siteUrl": "https://example.com",
43
+ "days": 30
44
+ }
45
+ \`\`\`
46
+
47
+ ### Time Series Forecasting
48
+ Get a 14-day rolling average and forecast the next 14 days of traffic:
49
+ \`\`\`json
50
+ {
51
+ "siteUrl": "https://example.com",
52
+ "days": 60,
53
+ "window": 14,
54
+ "forecastDays": 14
55
+ }
56
+ \`\`\`
57
+
29
58
  ---
30
59
 
31
60
  ## Analytics Patterns
@@ -1,11 +1,15 @@
1
1
  import { google } from 'googleapis';
2
2
  const SCOPES = ['https://www.googleapis.com/auth/webmasters'];
3
+ let cachedClient = null;
3
4
  /**
4
5
  * Get an authenticated Google Search Console API client.
5
6
  * Supports both file-based credentials (GOOGLE_APPLICATION_CREDENTIALS)
6
7
  * and environment variable credentials (GOOGLE_CLIENT_EMAIL + GOOGLE_PRIVATE_KEY).
7
8
  */
8
9
  export async function getSearchConsoleClient() {
10
+ if (cachedClient) {
11
+ return cachedClient;
12
+ }
9
13
  // Option 1: Environment variables (for serverless/Cloudflare)
10
14
  if (!process.env.GOOGLE_APPLICATION_CREDENTIALS && process.env.GOOGLE_CLIENT_EMAIL && process.env.GOOGLE_PRIVATE_KEY) {
11
15
  const jwtClient = new google.auth.JWT({
@@ -14,12 +18,14 @@ export async function getSearchConsoleClient() {
14
18
  scopes: SCOPES
15
19
  });
16
20
  await jwtClient.authorize();
17
- return google.searchconsole({ version: 'v1', auth: jwtClient });
21
+ cachedClient = google.searchconsole({ version: 'v1', auth: jwtClient });
22
+ return cachedClient;
18
23
  }
19
24
  // Option 2: File-based credentials (default)
20
25
  const auth = new google.auth.GoogleAuth({
21
26
  scopes: SCOPES,
22
27
  });
23
28
  const client = await auth.getClient();
24
- return google.searchconsole({ version: 'v1', auth: client });
29
+ cachedClient = google.searchconsole({ version: 'v1', auth: client });
30
+ return cachedClient;
25
31
  }