agentleFS
AppsYogi-comAppsYogi-com/gsc-mcp-server/.github/copilot-instructions.md

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
  1. Very specific:

    Create tool definition in src/server/tools/<domain>.ts following the pattern:

    line 40
  2. Very specific:

    Always use GSCClient.create() factory (handles auth automatically)

    line 59
  3. Very specific:

    Test MCP tools via HTTP: gsc-mcp run --http 3333, then curl /tools or POST to /mcp

    line 78

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

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 results

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

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 endpoints

Code Conventions

Adding New MCP Tools

  1. Create tool definition in src/server/tools/<domain>.ts following the pattern:
    • Export <domain>Tools array with name, description, inputSchema
    • Export handle<Domain>Tool(name, args) handler function
  2. Register in src/server/tools/index.ts by adding to getAllTools() and routing in handleToolCall()
  3. Tool names use dot notation: searchanalytics.query, opportunities.lowCtrHighPos

Type Definitions

  • Define Zod schemas in src/types.ts, derive TypeScript types with z.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 list
  • full: Additionally allows sitemap submission, URL inspection
  • Scope set at init time: gsc-mcp init --scope full

External Dependencies

  • @modelcontextprotocol/sdk - MCP protocol implementation
  • googleapis - Google Search Console API
  • keytar - OS keychain (optional, file fallback)
  • better-sqlite3 - Query result caching
  • zod - Runtime validation

Testing Changes

  1. Run npm run build
  2. Test CLI: ./dist/cli/index.js doctor --verbose
  3. Test MCP tools via HTTP: gsc-mcp run --http 3333, then curl /tools or POST to /mcp

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.