@disruptorganic/mcp-google-search-console 1.0.5 → 2.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 +70 -112
- package/README.md +0 -0
- package/dist/auth/account-lock.d.ts +26 -0
- package/dist/auth/account-lock.d.ts.map +1 -0
- package/dist/auth/account-lock.js +72 -0
- package/dist/auth/account-lock.js.map +1 -0
- package/dist/auth/oauth2.d.ts.map +1 -1
- package/dist/auth/oauth2.js +17 -33
- package/dist/auth/oauth2.js.map +1 -1
- package/dist/auth/token-validator.d.ts +18 -0
- package/dist/auth/token-validator.d.ts.map +1 -0
- package/dist/auth/token-validator.js +175 -0
- package/dist/auth/token-validator.js.map +1 -0
- package/dist/config/index.d.ts +15 -22
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +89 -79
- package/dist/config/index.js.map +1 -1
- package/dist/index.js +118 -70
- package/dist/index.js.map +1 -1
- package/dist/server/http.d.ts +36 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +394 -0
- package/dist/server/http.js.map +1 -0
- package/dist/tools/compare-date-ranges.d.ts +1 -1
- package/dist/tools/compare-date-ranges.d.ts.map +1 -1
- package/dist/tools/compare-date-ranges.js +13 -12
- package/dist/tools/compare-date-ranges.js.map +1 -1
- package/dist/tools/get-property-info.d.ts +1 -1
- package/dist/tools/get-property-info.d.ts.map +1 -1
- package/dist/tools/get-property-info.js +13 -12
- package/dist/tools/get-property-info.js.map +1 -1
- package/dist/tools/get-top-pages.d.ts +1 -1
- package/dist/tools/get-top-pages.d.ts.map +1 -1
- package/dist/tools/get-top-pages.js +13 -12
- package/dist/tools/get-top-pages.js.map +1 -1
- package/dist/tools/get-top-queries.d.ts +1 -1
- package/dist/tools/get-top-queries.d.ts.map +1 -1
- package/dist/tools/get-top-queries.js +13 -12
- package/dist/tools/get-top-queries.js.map +1 -1
- package/dist/tools/health-check.d.ts +1 -1
- package/dist/tools/health-check.d.ts.map +1 -1
- package/dist/tools/health-check.js +24 -32
- package/dist/tools/health-check.js.map +1 -1
- package/dist/tools/index.d.ts +3 -19
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +0 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/list-properties.d.ts +1 -1
- package/dist/tools/list-properties.d.ts.map +1 -1
- package/dist/tools/list-properties.js +13 -12
- package/dist/tools/list-properties.js.map +1 -1
- package/dist/tools/query-advanced.d.ts +1 -1
- package/dist/tools/query-advanced.d.ts.map +1 -1
- package/dist/tools/query-advanced.js +13 -12
- package/dist/tools/query-advanced.js.map +1 -1
- package/dist/tools/query-by-keyword.d.ts +1 -1
- package/dist/tools/query-by-keyword.d.ts.map +1 -1
- package/dist/tools/query-by-keyword.js +13 -12
- package/dist/tools/query-by-keyword.js.map +1 -1
- package/dist/tools/query-by-url.d.ts +1 -1
- package/dist/tools/query-by-url.d.ts.map +1 -1
- package/dist/tools/query-by-url.js +13 -12
- package/dist/tools/query-by-url.js.map +1 -1
- package/package.json +20 -9
- package/dist/tools/auth.d.ts +0 -51
- package/dist/tools/auth.d.ts.map +0 -1
- package/dist/tools/auth.js +0 -83
- package/dist/tools/auth.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
3
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
-
import {
|
|
4
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
6
5
|
import { GSCClient } from './gsc/client.js';
|
|
7
6
|
import { allTools, toolHandlers, getToolStats } from './tools/index.js';
|
|
8
7
|
import { logger } from './utils/logger.js';
|
|
9
|
-
import { getEnvironment } from './config/index.js';
|
|
10
|
-
|
|
8
|
+
import { config, logConfiguration, getEnvironment } from './config/index.js';
|
|
9
|
+
import { createHttpServer } from './server/http.js';
|
|
10
|
+
const SERVER_VERSION = '2.0.0';
|
|
11
11
|
const SERVER_NAME = 'google-search-console-mcp';
|
|
12
|
-
let
|
|
13
|
-
let clientInitializationPromise = null;
|
|
12
|
+
let httpServer = null;
|
|
14
13
|
const server = new Server({
|
|
15
14
|
name: SERVER_NAME,
|
|
16
15
|
version: SERVER_VERSION,
|
|
@@ -19,44 +18,17 @@ const server = new Server({
|
|
|
19
18
|
tools: {},
|
|
20
19
|
},
|
|
21
20
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
logger.
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
const authManager = new GSCAuth();
|
|
35
|
-
const oauth2Client = await authManager.getAuthenticatedClient();
|
|
36
|
-
logger.info('Using cached OAuth2 tokens (auto-refresh enabled)');
|
|
37
|
-
gscClient = new GSCClient(oauth2Client);
|
|
38
|
-
const isValid = await gscClient.validateConnection();
|
|
39
|
-
if (!isValid) {
|
|
40
|
-
throw new Error('Failed to validate GSC API connection');
|
|
41
|
-
}
|
|
42
|
-
logger.info('GSC client initialized and validated successfully');
|
|
43
|
-
return gscClient;
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
clientInitializationPromise = null;
|
|
47
|
-
logger.error('Failed to initialize GSC client', {
|
|
48
|
-
error: error instanceof Error ? error.message : String(error),
|
|
49
|
-
});
|
|
50
|
-
if (error instanceof Error && error.message.includes('Configuration Error')) {
|
|
51
|
-
throw new Error(`Configuration Error: The server configuration is invalid.\n\n${error.message}\n\nPlease check your environment variables or .env file.`);
|
|
52
|
-
}
|
|
53
|
-
if (error instanceof Error && error.message.includes('not authenticated')) {
|
|
54
|
-
throw new Error('Authentication required. Please run authentication setup first. See docs/AUTHENTICATION_SETUP.md');
|
|
55
|
-
}
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
})();
|
|
59
|
-
return clientInitializationPromise;
|
|
21
|
+
function createGSCClientFromToken(accessToken) {
|
|
22
|
+
logger.debug('Creating ephemeral GSC client from access token', {
|
|
23
|
+
tokenPrefix: accessToken.substring(0, 8),
|
|
24
|
+
});
|
|
25
|
+
const oauth2Client = new OAuth2Client();
|
|
26
|
+
oauth2Client.setCredentials({
|
|
27
|
+
access_token: accessToken,
|
|
28
|
+
});
|
|
29
|
+
const client = new GSCClient(oauth2Client);
|
|
30
|
+
logger.debug('Ephemeral GSC client created successfully');
|
|
31
|
+
return client;
|
|
60
32
|
}
|
|
61
33
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
62
34
|
logger.debug('Listing available tools', { count: allTools.length });
|
|
@@ -86,22 +58,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
86
58
|
isError: true,
|
|
87
59
|
};
|
|
88
60
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
logger.info('Tool executed successfully', {
|
|
101
|
-
tool: name,
|
|
102
|
-
hasError: result.isError || false,
|
|
103
|
-
});
|
|
104
|
-
return result;
|
|
61
|
+
logger.warn('Tool called without HTTP authentication context', { tool: name });
|
|
62
|
+
return {
|
|
63
|
+
content: [
|
|
64
|
+
{
|
|
65
|
+
type: 'text',
|
|
66
|
+
text: 'Authentication required. Please use the HTTP endpoint with proper OAuth 2.1 authentication.',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
isError: true,
|
|
70
|
+
};
|
|
105
71
|
}
|
|
106
72
|
catch (error) {
|
|
107
73
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -125,11 +91,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
125
91
|
async function shutdown(signal) {
|
|
126
92
|
logger.info(`Received ${signal}, shutting down gracefully...`);
|
|
127
93
|
try {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
logger.info('Tool statistics', toolStats);
|
|
94
|
+
const toolStats = getToolStats();
|
|
95
|
+
logger.info('Tool statistics', toolStats);
|
|
96
|
+
if (httpServer) {
|
|
97
|
+
await httpServer.stop();
|
|
133
98
|
}
|
|
134
99
|
await server.close();
|
|
135
100
|
logger.info('Server shut down successfully');
|
|
@@ -151,10 +116,12 @@ async function main() {
|
|
|
151
116
|
platform: process.platform,
|
|
152
117
|
environment: getEnvironment(),
|
|
153
118
|
});
|
|
119
|
+
logConfiguration();
|
|
154
120
|
const toolStats = getToolStats();
|
|
155
121
|
logger.info('Server configuration', {
|
|
156
122
|
totalTools: toolStats.total,
|
|
157
123
|
tools: toolStats.names,
|
|
124
|
+
authMode: 'OAuth 2.1 (Google token passthrough with account locking)',
|
|
158
125
|
});
|
|
159
126
|
logger.debug('Tool details', {
|
|
160
127
|
tools: toolStats.tools.map((t) => ({
|
|
@@ -179,12 +146,93 @@ async function main() {
|
|
|
179
146
|
});
|
|
180
147
|
shutdown('unhandledRejection');
|
|
181
148
|
});
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
149
|
+
httpServer = createHttpServer(server, { port: config.port });
|
|
150
|
+
httpServer.setToolCallHandler(async (name, args, userEmail, accessToken) => {
|
|
151
|
+
logger.info('Tool called via HTTP', {
|
|
152
|
+
tool: name,
|
|
153
|
+
hasParams: !!args,
|
|
154
|
+
paramKeys: args ? Object.keys(args) : [],
|
|
155
|
+
user: userEmail,
|
|
156
|
+
hasAccessToken: !!accessToken,
|
|
157
|
+
});
|
|
158
|
+
try {
|
|
159
|
+
const handler = toolHandlers[name];
|
|
160
|
+
if (!handler) {
|
|
161
|
+
const availableTools = Object.keys(toolHandlers).join(', ');
|
|
162
|
+
logger.error('Tool not found', { tool: name, availableTools });
|
|
163
|
+
return {
|
|
164
|
+
content: [
|
|
165
|
+
{
|
|
166
|
+
type: 'text',
|
|
167
|
+
text: `Unknown tool: ${name}\n\nAvailable tools: ${availableTools}`,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
isError: true,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
let client = null;
|
|
174
|
+
if (name !== 'health_check') {
|
|
175
|
+
if (!accessToken) {
|
|
176
|
+
logger.error('Access token missing for data tool', { tool: name });
|
|
177
|
+
return {
|
|
178
|
+
content: [
|
|
179
|
+
{
|
|
180
|
+
type: 'text',
|
|
181
|
+
text: 'Authentication required. Access token not provided.',
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
isError: true,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
client = createGSCClientFromToken(accessToken);
|
|
188
|
+
logger.debug('Ephemeral GSC client created for tool execution', {
|
|
189
|
+
tool: name,
|
|
190
|
+
user: userEmail,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
logger.debug('Executing tool handler', { tool: name, user: userEmail });
|
|
194
|
+
const result = await handler(args || {}, client);
|
|
195
|
+
logger.info('Tool executed successfully', {
|
|
196
|
+
tool: name,
|
|
197
|
+
hasError: result.isError || false,
|
|
198
|
+
user: userEmail,
|
|
199
|
+
});
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
204
|
+
const errorStack = error instanceof Error ? error.stack : undefined;
|
|
205
|
+
logger.error('Tool execution failed', {
|
|
206
|
+
tool: name,
|
|
207
|
+
error: errorMessage,
|
|
208
|
+
stack: errorStack,
|
|
209
|
+
user: userEmail,
|
|
210
|
+
});
|
|
211
|
+
return {
|
|
212
|
+
content: [
|
|
213
|
+
{
|
|
214
|
+
type: 'text',
|
|
215
|
+
text: `Error executing ${name}: ${errorMessage}`,
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
isError: true,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
await httpServer.start();
|
|
223
|
+
logger.info('MCP Server started successfully', {
|
|
224
|
+
transport: 'HTTP',
|
|
225
|
+
url: `http://localhost:${config.port}`,
|
|
226
|
+
endpoints: [
|
|
227
|
+
'/.well-known/oauth-protected-resource',
|
|
228
|
+
'/health',
|
|
229
|
+
'/auth/status',
|
|
230
|
+
'/mcp',
|
|
231
|
+
],
|
|
232
|
+
authMode: 'OAuth 2.1 (Google token passthrough)',
|
|
233
|
+
});
|
|
185
234
|
logger.info(`Available tools: ${toolStats.names.join(', ')}`);
|
|
186
|
-
logger.info('
|
|
187
|
-
logger.info('Configuration will be validated when tools are called');
|
|
235
|
+
logger.info('Authentication: Google OAuth 2.1 via Claude Code (single-user account locking)');
|
|
188
236
|
}
|
|
189
237
|
catch (error) {
|
|
190
238
|
logger.error('Failed to start server', {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAwBA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAc,MAAM,kBAAkB,CAAC;AA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I,EAAE,mBAAmB,IAAI,KAAK,YAAY,EAAE;yBACjD;qBACF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QAGH,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;QAEzB,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE;YAC7C,SAAS,EAAE,MAAM;YACjB,GAAG,EAAE,oBAAoB,MAAM,CAAC,IAAI,EAAE;YACtC,SAAS,EAAE;gBACT,uCAAuC;gBACvC,SAAS;gBACT,cAAc;gBACd,MAAM;aACP;YACD,QAAQ,EAAE,sCAAsC;SACjD,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,oBAAoB,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9D,MAAM,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;IAChG,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE;YACrC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC7D,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACxD,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAGD,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace Express {
|
|
5
|
+
interface Request {
|
|
6
|
+
user?: {
|
|
7
|
+
email: string;
|
|
8
|
+
userId: string;
|
|
9
|
+
accessToken: string;
|
|
10
|
+
scope?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export interface HttpServerConfig {
|
|
16
|
+
port: number;
|
|
17
|
+
host?: string;
|
|
18
|
+
}
|
|
19
|
+
export type ToolCallHandler = (name: string, args: any, userEmail?: string, accessToken?: string) => Promise<any>;
|
|
20
|
+
export declare class HttpServer {
|
|
21
|
+
private app;
|
|
22
|
+
private server;
|
|
23
|
+
private config;
|
|
24
|
+
private toolCallHandler;
|
|
25
|
+
constructor(_mcpServer: Server, config: HttpServerConfig);
|
|
26
|
+
setToolCallHandler(handler: ToolCallHandler): void;
|
|
27
|
+
private setupRoutes;
|
|
28
|
+
private handleToolsList;
|
|
29
|
+
private handleToolsCall;
|
|
30
|
+
private handleInitialize;
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
stop(): Promise<void>;
|
|
33
|
+
getApp(): express.Application;
|
|
34
|
+
}
|
|
35
|
+
export declare function createHttpServer(mcpServer: Server, config: HttpServerConfig): HttpServer;
|
|
36
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/server/http.ts"],"names":[],"mappings":"AAqDA,OAAO,OAA4C,MAAM,SAAS,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAQnE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,IAAI,CAAC,EAAE;gBACL,KAAK,EAAE,MAAM,CAAC;gBACd,MAAM,EAAE,MAAM,CAAC;gBACf,WAAW,EAAE,MAAM,CAAC;gBACpB,KAAK,CAAC,EAAE,MAAM,CAAC;aAChB,CAAC;SACH;KACF;CACF;AAwCD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAqQD,MAAM,MAAM,eAAe,GAAG,CAAC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