{
  "openapi": "3.1.0",
  "info": {
    "title": "Google Analytics MCP Server",
    "description": "Google Analytics 4 Admin and Data API for property configuration and reporting",
    "version": "1.0.0",
    "contact": {
      "name": "Hopkin",
      "url": "https://hopkin.ai"
    }
  },
  "servers": [
    {
      "url": "https://ga4.mcp.hopkin.ai",
      "description": "Production MCP endpoint"
    }
  ],
  "paths": {
    "/tools": {
      "get": {
        "operationId": "listTools",
        "summary": "List available tools",
        "description": "Returns all tools registered on this server with their names, descriptions, and input schemas.",
        "tags": [
          "discovery"
        ],
        "responses": {
          "200": {
            "description": "Tool list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ToolList"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_list_account_summaries": {
      "post": {
        "operationId": "ga4_list_account_summaries",
        "summary": "List GA4 Accounts & Properties",
        "description": "List every GA4 account and property visible to the connected Google account (Admin API accountSummaries).\n\nUse this tool first to discover which properties are available before calling other GA4 tools.\nResults are cached; pass refresh=true only when you need the latest list.\n\nArgs:\n  limit (number, optional): Max accounts per page (default 20, max 200).\n  cursor (string, optional): Opaque pagination cursor from a previous response's pagination.nextCursor.\n  refresh (bool, optional): Force a fresh fetch from the API, bypassing cache. Default: false.\n\nReturns:\n  data: accounts (each with account resource name, display_name, and properties[] of { property_id, display_name, property_type, parent }).\n  count (total accounts), property_count (total properties), cached, synced_at, and pagination { hasMore, nextCursor }.",
        "tags": [
          "-account-summaries"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": true,
          "destructiveHint": false,
          "idempotentHint": false,
          "openWorldHint": true
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200,
                    "description": "Max accounts per page (default 20)."
                  },
                  "cursor": {
                    "type": "string",
                    "description": "Opaque pagination cursor from a previous response's pagination.nextCursor. Do not construct by hand."
                  },
                  "refresh": {
                    "type": "boolean",
                    "description": "Force a fresh fetch from the Admin API, bypassing the cache. Default: false."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "list-accounts-properties": {
                  "summary": "List accounts & properties",
                  "value": {
                    "reason": "Discover which GA4 properties are available"
                  }
                },
                "next-page": {
                  "summary": "Next page",
                  "value": {
                    "limit": 20,
                    "cursor": "eyJvZmZzZXQiOjIwfQ==",
                    "reason": "Fetch the next page of accounts"
                  }
                },
                "force-refresh": {
                  "summary": "Force refresh",
                  "value": {
                    "refresh": true,
                    "reason": "Need the latest account/property list"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_check_auth_status": {
      "post": {
        "operationId": "ga4_check_auth_status",
        "summary": "Check GA4 Auth Status",
        "description": "Troubleshoot authentication issues. Only use this when another tool fails with a permission or auth error — do NOT call proactively.\n\nReturns: authenticated status, user_id, email, and a human-readable message.",
        "tags": [
          "k-auth-status"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": true,
          "destructiveHint": false,
          "idempotentHint": true,
          "openWorldHint": false
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "check-auth": {
                  "summary": "Check auth",
                  "value": {
                    "reason": "Another tool returned an auth error, checking connection status"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_list_connections": {
      "post": {
        "operationId": "ga4_list_connections",
        "summary": "List Google Analytics Connections",
        "description": "List the Google Analytics connections available to you — both ones you own and ones shared with you via an organization. Only Google connections with Google Analytics (analytics.readonly) scope are returned. Use this to discover connection IDs for set_default / share / rename / revoke.",
        "tags": [
          "-connections"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": true,
          "destructiveHint": false,
          "idempotentHint": true,
          "openWorldHint": false
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "list-connections": {
                  "summary": "List connections",
                  "value": {
                    "reason": "User asked which Google Analytics accounts they have connected"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_set_default_connection": {
      "post": {
        "operationId": "ga4_set_default_connection",
        "summary": "Set Default Google Analytics Connection",
        "description": "Set the Google Analytics connection that should be used by default for subsequent GA4 tool calls. The default is scoped to the calling actor (your user account, or the API key being used).",
        "tags": [
          "default-connection"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": true,
          "destructiveHint": false,
          "idempotentHint": true,
          "openWorldHint": false
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "UUID of the connection to mark as the actor's default Google Analytics connection."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "connection_id",
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "set-default": {
                  "summary": "Set default",
                  "value": {
                    "connection_id": "00000000-0000-0000-0000-000000000001",
                    "reason": "User picked their primary Google Analytics workspace"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_share_connection": {
      "post": {
        "operationId": "ga4_share_connection",
        "summary": "Share Google Analytics Connection With Organization",
        "description": "Share an owned Google Analytics connection with all members of your organization, so teammates can use it without having to reconnect Google themselves. You must be the owner of the connection.",
        "tags": [
          "e-connection"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": false,
          "destructiveHint": false,
          "idempotentHint": true,
          "openWorldHint": false
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "UUID of the connection to mark as the actor's default Google Analytics connection."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "connection_id",
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "share-with-org": {
                  "summary": "Share with org",
                  "value": {
                    "connection_id": "00000000-0000-0000-0000-000000000001",
                    "reason": "User asked to share this Google Analytics connection with their teammates"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_unshare_connection": {
      "post": {
        "operationId": "ga4_unshare_connection",
        "summary": "Unshare Google Analytics Connection From Organization",
        "description": "Stop sharing an owned Google Analytics connection with your organization. Teammates lose access immediately. You must be the owner.",
        "tags": [
          "are-connection"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": false,
          "destructiveHint": true,
          "idempotentHint": true,
          "openWorldHint": false
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "UUID of the connection to mark as the actor's default Google Analytics connection."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "connection_id",
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "stop-sharing": {
                  "summary": "Stop sharing",
                  "value": {
                    "connection_id": "00000000-0000-0000-0000-000000000001",
                    "reason": "User no longer wants the team to access this Google Analytics connection"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_rename_connection": {
      "post": {
        "operationId": "ga4_rename_connection",
        "summary": "Rename Google Analytics Connection",
        "description": "Rename the display name of an owned Google Analytics connection. The OAuth grant and underlying account are unaffected — this only changes the human-readable label. You must be the owner.",
        "tags": [
          "me-connection"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": false,
          "destructiveHint": false,
          "idempotentHint": true,
          "openWorldHint": false
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "UUID of the connection to mark as the actor's default Google Analytics connection."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "connection_id",
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "rename": {
                  "summary": "Rename",
                  "value": {
                    "connection_id": "00000000-0000-0000-0000-000000000001",
                    "display_name": "Acme — Production",
                    "reason": "User wanted a clearer label for this Google Analytics connection"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_revoke_connection": {
      "post": {
        "operationId": "ga4_revoke_connection",
        "summary": "Revoke Google Analytics Connection",
        "description": "Revoke (soft-delete) an owned Google Analytics connection. Any defaults pointing to it are invalidated and shared org members lose access. The OAuth grant at Google is NOT revoked by this tool — the user must disconnect via the dashboard if they want to fully revoke at Google. You must be the owner.",
        "tags": [
          "ke-connection"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": false,
          "destructiveHint": true,
          "idempotentHint": true,
          "openWorldHint": false
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "UUID of the connection to mark as the actor's default Google Analytics connection."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "connection_id",
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "revoke": {
                  "summary": "Revoke",
                  "value": {
                    "connection_id": "00000000-0000-0000-0000-000000000001",
                    "reason": "User asked to disconnect this Google Analytics account"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_developer_feedback": {
      "post": {
        "operationId": "ga4_developer_feedback",
        "summary": "Submit Developer Feedback",
        "description": "Submit feedback about missing tools, improvements, bugs, or workflow gaps in the GA4 MCP toolset. Not for user-facing issues (auth errors, API errors).\n\nArgs:\n  feedback_type: new_tool, improvement, bug, workflow_gap\n  title: Short description (5-200 chars)\n  description: What is needed and why (20-2000 chars)\n  current_workaround (optional): How you're working around the gap\n  priority (optional): low, medium (default), high\n\nReturns: confirmation that feedback was recorded.",
        "tags": [
          "loper-feedback"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": false,
          "destructiveHint": false,
          "idempotentHint": true,
          "openWorldHint": true
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "feedback_type": {
                    "type": "string",
                    "enum": [
                      "new_tool",
                      "improvement",
                      "bug",
                      "workflow_gap"
                    ],
                    "description": "Feedback category: new_tool (request new capability), improvement (enhance existing tool), bug (report issue), workflow_gap (missing workflow)"
                  },
                  "title": {
                    "type": "string",
                    "minLength": 5,
                    "maxLength": 200,
                    "description": "Concise title summarizing the feedback"
                  },
                  "description": {
                    "type": "string",
                    "minLength": 20,
                    "maxLength": 2000,
                    "description": "What is needed and why"
                  },
                  "current_workaround": {
                    "type": "string",
                    "maxLength": 1000,
                    "description": "Current workaround, if any"
                  },
                  "priority": {
                    "type": "string",
                    "enum": [
                      "low",
                      "medium",
                      "high"
                    ],
                    "default": "medium",
                    "description": "Impact level: low (nice-to-have), medium (improves workflow), high (blocking issue)"
                  },
                  "interface": {
                    "type": "string",
                    "enum": [
                      "MCP",
                      "CLI"
                    ],
                    "default": "MCP",
                    "description": "Interface the feedback originated from: MCP (default) or CLI"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "feedback_type",
                  "title",
                  "description",
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "missing-tool": {
                  "summary": "Missing tool",
                  "value": {
                    "feedback_type": "new_tool",
                    "title": "Audience export",
                    "description": "Need ability to list GA4 audiences and their definitions",
                    "priority": "medium",
                    "reason": "User asked to audit audience setup"
                  }
                },
                "workflow-gap": {
                  "summary": "Workflow gap",
                  "value": {
                    "feedback_type": "workflow_gap",
                    "title": "Multi-property reports",
                    "description": "Cannot run one report across several GA4 properties at once",
                    "current_workaround": "Call ga4_run_report per property and merge results",
                    "reason": "User manages 12 properties"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_get_metadata": {
      "post": {
        "operationId": "ga4_get_metadata",
        "summary": "Get GA4 Dimensions & Metrics",
        "description": "List the dimensions and metrics available on a GA4 property (including custom definitions), so ga4_run_report calls use valid API names instead of guessing.\n\nArgs:\n  property_id (string, required): GA4 property ID (numeric) or full resource name.\n  search (string, optional): Case-insensitive substring filter on API name / UI name (e.g. 'channel', 'revenue'). Omit to list everything.\n\nReturns:\n  dimension_count, metric_count, and matching dimensions/metrics with api_name, ui_name, category, type (metrics), and custom flag.",
        "tags": [
          "metadata"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": true,
          "destructiveHint": false,
          "idempotentHint": false,
          "openWorldHint": true
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "property_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "GA4 property ID (numeric) or full resource name."
                  },
                  "search": {
                    "type": "string",
                    "description": "Case-insensitive substring filter on API name / UI name (e.g. 'channel', 'revenue'). Omit to list everything."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "property_id",
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "search-revenue-metrics": {
                  "summary": "Search revenue metrics",
                  "value": {
                    "property_id": "123456789",
                    "search": "revenue",
                    "reason": "Find valid revenue metric API names"
                  }
                },
                "list-everything": {
                  "summary": "List everything",
                  "value": {
                    "property_id": "123456789",
                    "reason": "Full dimension/metric inventory including custom definitions"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_ping": {
      "post": {
        "operationId": "ga4_ping",
        "summary": "Ping GA4 MCP Server",
        "description": "Health check. Returns server status, version, and timestamp.",
        "tags": [
          ""
        ],
        "x-mcp-annotations": {
          "readOnlyHint": true,
          "destructiveHint": false,
          "idempotentHint": true,
          "openWorldHint": false
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Optional message to echo back"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "health-check": {
                  "summary": "Health check",
                  "value": {
                    "reason": "Verify server is running"
                  }
                },
                "with-message": {
                  "summary": "With message",
                  "value": {
                    "message": "hello",
                    "reason": "Test connectivity"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_get_property_details": {
      "post": {
        "operationId": "ga4_get_property_details",
        "summary": "Get GA4 Property Details",
        "description": "Setup-health snapshot for one GA4 property: property info, data streams (with enhanced measurement settings for web streams), key events, Google Ads links, attribution settings, and data retention settings.\n\nSections that fail to load are returned with an error string instead of failing the whole call.\n\nArgs:\n  property_id (string, required): GA4 property ID (numeric, e.g. '123456789') or full resource name ('properties/123456789').\n\nReturns:\n  property, data_streams, key_events, google_ads_links, attribution_settings, data_retention_settings — each either the API payload or { error }.",
        "tags": [
          "property-details"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": true,
          "destructiveHint": false,
          "idempotentHint": false,
          "openWorldHint": true
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "property_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "GA4 property ID (numeric, e.g. '123456789') or full resource name ('properties/123456789')."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "property_id",
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "audit-property-setup": {
                  "summary": "Audit property setup",
                  "value": {
                    "property_id": "123456789",
                    "reason": "Check tracking and attribution configuration"
                  }
                },
                "full-resource-name": {
                  "summary": "Full resource name",
                  "value": {
                    "property_id": "properties/123456789",
                    "reason": "Verify key events on the property"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_run_report": {
      "post": {
        "operationId": "ga4_run_report",
        "summary": "Run GA4 Report",
        "description": "Run a GA4 report (Data API runReport): arbitrary dimensions × metrics over one or more date ranges, with an optional simple dimension filter and ordering.\n\nUse ga4_get_metadata first to look up valid dimension/metric API names.\n\nArgs:\n  property_id (string, required): GA4 property ID (numeric) or full resource name.\n  dimensions (string[], optional): Up to 9 dimension API names (e.g. sessionDefaultChannelGroup, date).\n  metrics (string[], required): 1-10 metric API names (e.g. sessions, totalUsers, keyEvents, purchaseRevenue).\n  date_ranges (array, required): 1-4 ranges of { start_date, end_date, name? }. Dates are YYYY-MM-DD or relative (30daysAgo, yesterday, today).\n  dimension_filter (object, optional): Single-field filter { field, values[], match_type?, case_sensitive?, negate? }.\n  order_by (object, optional): { type: 'metric'|'dimension', name, desc? }.\n  limit (number, optional): Max rows, default 100, max 10000.\n  offset (number, optional): Row offset for pagination.\n\nReturns:\n  row_count (total rows before pagination), returned_rows, and rows flattened as { dimension: value, metric: value } objects.\n  For a single date range: metric_totals ({ metric: total }). For multiple date ranges: metric_totals_by_range ({ \"date_range_0\": { metric: total }, ... }) keyed by the dateRange dimension value (or the range's name).",
        "tags": [
          "report"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": true,
          "destructiveHint": false,
          "idempotentHint": false,
          "openWorldHint": true
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "property_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "GA4 property ID (numeric) or full resource name."
                  },
                  "dimensions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 9,
                    "description": "GA4 dimension API names, e.g. sessionDefaultChannelGroup, landingPagePlusQueryString, date. Use ga4_get_metadata for valid names."
                  },
                  "metrics": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 10,
                    "description": "GA4 metric API names, e.g. sessions, totalUsers, keyEvents, purchaseRevenue."
                  },
                  "date_ranges": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "start_date": {
                          "type": "string",
                          "minLength": 1,
                          "description": "YYYY-MM-DD or relative (e.g. 30daysAgo, yesterday)."
                        },
                        "end_date": {
                          "type": "string",
                          "minLength": 1,
                          "description": "YYYY-MM-DD or relative (e.g. today, yesterday)."
                        },
                        "name": {
                          "type": "string",
                          "description": "Optional label; appears as dateRange dimension when multiple ranges are used."
                        }
                      },
                      "required": [
                        "start_date",
                        "end_date"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 4,
                    "description": "One to 4 date ranges."
                  },
                  "dimension_filter": {
                    "type": "object",
                    "properties": {
                      "field": {
                        "type": "string",
                        "minLength": 1,
                        "description": "Dimension API name to filter on."
                      },
                      "values": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "minItems": 1,
                        "description": "Values to match; multiple values become an in-list filter."
                      },
                      "match_type": {
                        "type": "string",
                        "enum": [
                          "EXACT",
                          "CONTAINS",
                          "BEGINS_WITH",
                          "ENDS_WITH",
                          "FULL_REGEXP"
                        ],
                        "description": "String match type for single-value filters (default EXACT); ignored for multi-value in-list filters."
                      },
                      "case_sensitive": {
                        "type": "boolean",
                        "description": "Case-sensitive matching (GA4 default is case-insensitive)."
                      },
                      "negate": {
                        "type": "boolean",
                        "description": "Invert the filter."
                      }
                    },
                    "required": [
                      "field",
                      "values"
                    ],
                    "additionalProperties": false,
                    "description": "Simple single-field dimension filter."
                  },
                  "order_by": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "metric",
                          "dimension"
                        ]
                      },
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "description": "Metric or dimension API name to order by."
                      },
                      "desc": {
                        "type": "boolean",
                        "description": "Descending (default true for metrics, false for dimensions)."
                      }
                    },
                    "required": [
                      "type",
                      "name"
                    ],
                    "additionalProperties": false
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000,
                    "description": "Max rows (default 100). Range: 1-10000."
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Row offset for pagination."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "property_id",
                  "metrics",
                  "date_ranges",
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "sessions-by-channel-30-days": {
                  "summary": "Sessions by channel (30 days)",
                  "value": {
                    "property_id": "123456789",
                    "dimensions": [
                      "sessionDefaultChannelGroup"
                    ],
                    "metrics": [
                      "sessions",
                      "totalUsers",
                      "keyEvents"
                    ],
                    "date_ranges": [
                      {
                        "start_date": "30daysAgo",
                        "end_date": "yesterday"
                      }
                    ],
                    "reason": "Channel mix overview for the last 30 days"
                  }
                },
                "landing-page-revenue-filtered": {
                  "summary": "Landing page revenue, filtered",
                  "value": {
                    "property_id": "123456789",
                    "dimensions": [
                      "landingPagePlusQueryString"
                    ],
                    "metrics": [
                      "sessions",
                      "purchaseRevenue"
                    ],
                    "date_ranges": [
                      {
                        "start_date": "2024-01-01",
                        "end_date": "2024-01-31"
                      }
                    ],
                    "dimension_filter": {
                      "field": "sessionDefaultChannelGroup",
                      "values": [
                        "Paid Search"
                      ]
                    },
                    "order_by": {
                      "type": "metric",
                      "name": "purchaseRevenue"
                    },
                    "limit": 25,
                    "reason": "Top paid-search landing pages by revenue"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/ga4_run_realtime_report": {
      "post": {
        "operationId": "ga4_run_realtime_report",
        "summary": "Run GA4 Realtime Report",
        "description": "Run a GA4 realtime report (last 30 minutes of events). Primary use: verifying tags and key events fire after a tracking change, without waiting for standard processing lag.\n\nArgs:\n  property_id (string, required): GA4 property ID (numeric) or full resource name.\n  dimensions (string[], optional): Up to 9 realtime dimension API names (e.g. eventName, unifiedScreenName, country, deviceCategory).\n  metrics (string[], required): 1-10 realtime metric API names (e.g. activeUsers, eventCount, keyEvents).\n  limit (number, optional): Max rows, default 50.\n\nReturns:\n  row_count and rows flattened as { dimension: value, metric: value } objects.",
        "tags": [
          "realtime-report"
        ],
        "x-mcp-annotations": {
          "readOnlyHint": true,
          "destructiveHint": false,
          "idempotentHint": false,
          "openWorldHint": true
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "property_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "GA4 property ID (numeric) or full resource name."
                  },
                  "dimensions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 9,
                    "description": "Realtime dimension API names, e.g. eventName, unifiedScreenName, country, deviceCategory."
                  },
                  "metrics": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 10,
                    "description": "Realtime metric API names, e.g. activeUsers, eventCount, keyEvents."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000,
                    "description": "Max rows (default 50)."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Why this tool call is needed"
                  }
                },
                "required": [
                  "property_id",
                  "metrics",
                  "reason"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "examples": {
                "verify-events-firing": {
                  "summary": "Verify events firing",
                  "value": {
                    "property_id": "123456789",
                    "dimensions": [
                      "eventName"
                    ],
                    "metrics": [
                      "eventCount"
                    ],
                    "reason": "Confirm tags fire after a tracking change"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown-formatted result with structured content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolResult"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpError"
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid parameters — request body failed schema validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Supabase JWT or hpk_live_... API key"
      }
    },
    "schemas": {
      "McpToolResult": {
        "type": "object",
        "properties": {
          "content": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "text",
                    "resource_link"
                  ]
                },
                "text": {
                  "type": "string"
                }
              }
            }
          },
          "structuredContent": {
            "type": "object",
            "additionalProperties": true
          },
          "isError": {
            "type": "boolean"
          }
        }
      },
      "McpError": {
        "type": "object",
        "properties": {
          "isError": {
            "type": "boolean",
            "const": true
          },
          "content": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "text"
                },
                "text": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "RestError": {
        "type": "object",
        "description": "Error response from REST tool endpoints (mapped from JSON-RPC error codes)",
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable error message"
          },
          "code": {
            "type": "integer",
            "description": "JSON-RPC error code"
          },
          "data": {
            "description": "Additional error context"
          }
        },
        "required": [
          "error",
          "code"
        ]
      },
      "ToolList": {
        "type": "object",
        "properties": {
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "inputSchema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "discovery",
      "description": "Tool discovery and introspection"
    },
    {
      "name": "",
      "description": " tools"
    },
    {
      "name": "-account-summaries",
      "description": "-account-summaries tools"
    },
    {
      "name": "-connections",
      "description": "-connections tools"
    },
    {
      "name": "are-connection",
      "description": "Are-connection tools"
    },
    {
      "name": "default-connection",
      "description": "Default-connection tools"
    },
    {
      "name": "e-connection",
      "description": "E-connection tools"
    },
    {
      "name": "k-auth-status",
      "description": "K-auth-status tools"
    },
    {
      "name": "ke-connection",
      "description": "Ke-connection tools"
    },
    {
      "name": "loper-feedback",
      "description": "Loper-feedback tools"
    },
    {
      "name": "me-connection",
      "description": "Me-connection tools"
    },
    {
      "name": "metadata",
      "description": "Metadata tools"
    },
    {
      "name": "property-details",
      "description": "Property-details tools"
    },
    {
      "name": "realtime-report",
      "description": "Realtime-report tools"
    },
    {
      "name": "report",
      "description": "Report tools"
    }
  ]
}