gsc-mcp-server
Copilot instructions4 starsChanged 10 months agoMITView on GitHub
Key data flows: 1. CLI commands → createServer() → MCP transport (stdio for clients, HTTP for debugging) 2. Tool calls → handleToolCall() routes to domain handlers → GSCClient → Google API 3. Tokens stored via keytar (OS keychain) with file fallback; config in env-paths directories
The file
We split this copilot-instructions.md into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 40
Create tool definition in src/server/tools/<domain>.ts following the pattern:
- Very specific: line 59
Always use GSCClient.create() factory (handles auth automatically)
- Very specific: line 78
Test MCP tools via HTTP: gsc-mcp run --http 3333, then curl /tools or POST to /mcp
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GSC-MCP Copilot Instructions
Project Overview
This is a Model Context Protocol (MCP) server that provides Google Search Console (GSC) API access to AI clients (Claude, Cursor, VS Code Copilot). It's distributed as a CLI tool via npm (gsc-mcp) with OAuth/service account authentication.
Architecture
src/
├── index.ts # Public exports for programmatic use
├── types.ts # Zod schemas & TypeScript types (single source of truth)
├── cli/ # Commander-based CLI (`gsc-mcp init|doctor|run`)
├── server/ # MCP server implementation
│ ├── index.ts # Server factory with stdio/HTTP transports
│ ├── tools/ # MCP tools organized by domain (searchAnalytics, sitemaps, etc.)
│ └── resources/ # MCP resources
├── gsc/client.ts # GSC API wrapper with retry logic & pagination
├── auth/ # OAuth2 + service account auth, token storage (keytar/file)
└── cache/sqlite.ts # SQLite cache with TTL for query resultsKey data flows:
- CLI commands →
createServer()→ MCP transport (stdio for clients, HTTP for debugging) - Tool calls →
handleToolCall()routes to domain handlers →GSCClient→ Google API - Tokens stored via
keytar(OS keychain) with file fallback; config inenv-pathsdirectories
Development Commands
npm run build # tsup build (ESM, Node 18+)
npm run dev # Watch mode
npm run typecheck # tsc --noEmit
npm run lint # eslint src/
gsc-mcp run --http 3333 # Debug server with HTTP endpointsCode Conventions
Adding New MCP Tools
- Create tool definition in
src/server/tools/<domain>.tsfollowing the pattern:- Export
<domain>Toolsarray withname,description,inputSchema - Export
handle<Domain>Tool(name, args)handler function
- Export
- Register in
src/server/tools/index.tsby adding togetAllTools()and routing inhandleToolCall() - Tool names use dot notation:
searchanalytics.query,opportunities.lowCtrHighPos
Type Definitions
- Define Zod schemas in
src/types.ts, derive TypeScript types withz.infer<> - Tool input schemas in tool files mirror Zod schemas but use plain JSON Schema format for MCP
Error Handling Pattern
return {
content: [{ type: 'text', text: `Error: ${error.message}` }],
isError: true,
};GSCClient Usage
- Always use
GSCClient.create()factory (handles auth automatically) - Built-in retry with exponential backoff (
withRetry()) - Pagination handled internally for large result sets (>25000 rows)
Auth Scopes
readonly(default): Read analytics, sitemaps listfull: Additionally allows sitemap submission, URL inspection- Scope set at init time:
gsc-mcp init --scope full
External Dependencies
@modelcontextprotocol/sdk- MCP protocol implementationgoogleapis- Google Search Console APIkeytar- OS keychain (optional, file fallback)better-sqlite3- Query result cachingzod- Runtime validation
Testing Changes
- Run
npm run build - Test CLI:
./dist/cli/index.js doctor --verbose - Test MCP tools via HTTP:
gsc-mcp run --http 3333, then curl/toolsor POST to/mcp
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

