Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ to provide several
- `run_realtime_report`: Runs a Google Analytics realtime report using the
Data API.

## Prompts 💬

The server exposes [MCP Prompts](https://modelcontextprotocol.io/docs/concepts/prompts)
for common Google Analytics workflows. In Gemini CLI, prompts are available as
[slash commands](https://google-gemini.github.io/gemini-cli/docs/tools/mcp-server.html#mcp-prompts-as-slash-commands).

| Prompt | Description |
|--------|-------------|
| `traffic-summary` | Summarize overall traffic (sessions, users, bounce rate, engagement time) for a date range. |
| `top-pages` | Show the top pages by sessions with engagement metrics. |
| `acquisition-overview` | Break down traffic by source / medium and highlight top channels. |
| `compare-periods` | Compare key metrics between two time periods with percentage changes. |
| `campaign-performance` | Analyze UTM-tagged campaign performance ranked by conversions. |
| `realtime-overview` | Show active users right now broken down by page, country, and device. |

All prompts require a `property_id` argument. Most accept an optional
`date_range` argument (e.g. `"last 30 days"`, `"last 7 days"`,
`"2024-01-01 to 2024-01-31"`).

## Setup instructions 🔧

✨ Watch the [Google Analytics MCP Setup
Expand Down
18 changes: 17 additions & 1 deletion analytics_mcp/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@

# MCP Server Imports
import json
from json import tool
from mcp import types as mcp_types # Use alias to avoid conflict
from mcp.server.lowlevel import Server

import analytics_mcp.prompts as prompts_module

# ADK Tool Imports
from google.adk.tools.function_tool import FunctionTool
from google.adk.tools.mcp_tool.conversion_utils import adk_to_mcp_tool_type
Expand Down Expand Up @@ -156,3 +157,18 @@ async def call_mcp_tool(name: str, arguments: dict) -> list[mcp_types.Content]:
{"error": f"Tool '{name}' not implemented by this server."}
)
return [mcp_types.TextContent(type="text", text=error_text)]


@app.list_prompts()
async def list_prompts() -> list[mcp_types.Prompt]:
return prompts_module.list_prompts()


@app.get_prompt()
async def get_prompt(
name: str, arguments: dict | None
) -> mcp_types.GetPromptResult:
try:
return prompts_module.get_prompt(name, arguments)
except ValueError as e:
raise ValueError(str(e))
Loading