gsc_sites
Retrieve a list of all verified sites in your Google Search Console account to identify which properties are accessible for auditing.
Instructions
List all verified sites in Google Search Console.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The gsc_sites function is a tool handler decorated with @mcp.tool(). It calls the Google Search Console API's /sites endpoint, iterates over siteEntry to extract siteUrl and permissionLevel for each verified site, and returns the results as a JSON string.
@mcp.tool() def gsc_sites() -> str: """List all verified sites in Google Search Console.""" data = _api_get(f"{BASE}/sites") results = [] for site in data.get("siteEntry", []): results.append({"url": site["siteUrl"], "permission": site["permissionLevel"]}) return json.dumps(results, indent=2, ensure_ascii=False) - src/google_search_console_mcp/server.py:92-93 (registration)The tool is registered via the @mcp.tool() decorator on the gsc_sites function. The mcp object is an instance of FastMCP (from mcp.server.fastmcp), and the decorator exposes the function as an MCP tool.
@mcp.tool() def gsc_sites() -> str: - The _api_get helper is used by gsc_sites to make authenticated GET requests to the Google Search Console API. It adds an Authorization header with a Bearer token obtained via _get_token().
def _api_get(url: str) -> dict: req = urllib.request.Request(url, headers={"Authorization": f"Bearer {_get_token()}"}) with urllib.request.urlopen(req) as resp: return json.loads(resp.read()) - The schema for gsc_sites: no input parameters (returns str). The function has no arguments, so the tool takes no user input. The return type annotation is str (a JSON string).
@mcp.tool() def gsc_sites() -> str: """List all verified sites in Google Search Console.""" data = _api_get(f"{BASE}/sites") results = [] for site in data.get("siteEntry", []): results.append({"url": site["siteUrl"], "permission": site["permissionLevel"]}) return json.dumps(results, indent=2, ensure_ascii=False)