mcpengine/servers/google-console/src/auth/service-account.ts
Jake Shore f3c4cd817b Add all MCP servers + factory infra to MCPEngine — 2026-02-06
=== NEW SERVERS ADDED (7) ===
- servers/closebot — 119 tools, 14 modules, 4,656 lines TS (Stage 7)
- servers/google-console — Google Search Console MCP (Stage 7)
- servers/meta-ads — Meta/Facebook Ads MCP (Stage 8)
- servers/twilio — Twilio communications MCP (Stage 8)
- servers/competitor-research — Competitive intel MCP (Stage 6)
- servers/n8n-apps — n8n workflow MCP apps (Stage 6)
- servers/reonomy — Commercial real estate MCP (Stage 1)

=== FACTORY INFRASTRUCTURE ADDED ===
- infra/factory-tools — mcp-jest, mcp-validator, mcp-add, MCP Inspector
  - 60 test configs, 702 auto-generated test cases
  - All 30 servers score 100/100 protocol compliance
- infra/command-center — Pipeline state, operator playbook, dashboard config
- infra/factory-reviews — Automated eval reports

=== DOCS ADDED ===
- docs/MCP-FACTORY.md — Factory overview
- docs/reports/ — 5 pipeline evaluation reports
- docs/research/ — Browser MCP research

=== RULES ESTABLISHED ===
- CONTRIBUTING.md — All MCP work MUST go in this repo
- README.md — Full inventory of 37 servers + infra docs
- .gitignore — Updated for Python venvs

TOTAL: 37 MCP servers + full factory pipeline in one repo.
This is now the single source of truth for all MCP work.
2026-02-06 06:32:29 -05:00

79 lines
2.0 KiB
TypeScript

/**
* Service Account authentication for Google Search Console
* Used for automated/CI environments
*/
import { JWT } from 'google-auth-library';
import { readFileSync } from 'fs';
const SCOPES = [
'https://www.googleapis.com/auth/webmasters',
'https://www.googleapis.com/auth/webmasters.readonly',
'https://www.googleapis.com/auth/indexing'
];
export interface ServiceAccountConfig {
type: string;
project_id: string;
private_key_id: string;
private_key: string;
client_email: string;
client_id: string;
auth_uri: string;
token_uri: string;
auth_provider_x509_cert_url: string;
client_x509_cert_url: string;
}
/**
* Load service account credentials from environment or file
*/
export function loadServiceAccountConfig(): ServiceAccountConfig | null {
// Try GOOGLE_APPLICATION_CREDENTIALS (standard Google Cloud env var)
if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
try {
const content = readFileSync(process.env.GOOGLE_APPLICATION_CREDENTIALS, 'utf-8');
return JSON.parse(content);
} catch (error: any) {
throw new Error(
`Failed to load service account from GOOGLE_APPLICATION_CREDENTIALS: ${error.message}`
);
}
}
// Try GSC_SERVICE_ACCOUNT_KEY (base64 encoded JSON)
if (process.env.GSC_SERVICE_ACCOUNT_KEY) {
try {
const decoded = Buffer.from(process.env.GSC_SERVICE_ACCOUNT_KEY, 'base64').toString('utf-8');
return JSON.parse(decoded);
} catch (error: any) {
throw new Error(
`Failed to decode GSC_SERVICE_ACCOUNT_KEY: ${error.message}`
);
}
}
return null;
}
/**
* Create authenticated JWT client from service account
*/
export function getServiceAccountClient(): JWT {
const config = loadServiceAccountConfig();
if (!config) {
throw new Error(
'Service account credentials not found. Set GOOGLE_APPLICATION_CREDENTIALS or GSC_SERVICE_ACCOUNT_KEY'
);
}
const client = new JWT({
email: config.client_email,
key: config.private_key,
scopes: SCOPES
});
return client;
}