G2 Product Analytics MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@G2 Product Analytics MCP Investigate the July drop in review completion by device type."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
G2 Product Analytics MCP
A portfolio project exploring a practical question:
How do you let an AI agent answer product-analytics questions autonomously without giving it unrestricted SQL access or letting it invent business definitions?
This project builds a small governed analytics layer, exposes it through Model Context Protocol (MCP), and lets an MCP-capable LLM investigate product questions in natural language.
The synthetic dataset intentionally contains a hidden July 2026 deterioration in mobile review completion. The agent is not told the answer. It has to discover the metric, compare periods, segment the change, and stop where the evidence stops.
What the demo proved
In a cold-start test, the agent was asked:
“One of our product metrics changed materially in July 2026. Using only the G2 Product Analytics MCP tools, investigate what happened.”
The agent independently found:
review_completion_ratewas the material outlier.Overall completion fell from 66.7% in June to 60.5% in July.
The decline was concentrated in mobile: 62.7% → 47.9% (-14.8pp).
Desktop was nearly flat, which made device type a much cleaner signal than country or product category.
Daily volume was too thin to claim an exact “cliff day.”
The evidence established association, not causation.
That distinction is the core design goal: LLM reasoning on top of governed evidence, not free-form guessing against raw tables.
Related MCP server: mcp-analytics
Architecture
flowchart TD
U["User<br/>Natural-language business question"]
A["LLM / Agent<br/>Reasoning + tool selection"]
MCP["MCP Server<br/>Tools + Resource + Prompt"]
SEM["Governed metric layer<br/>definitions + dimensions + ownership + freshness"]
EXE["Analytics execution<br/>Python + DuckDB"]
DATA["Synthetic product data<br/>CSV tables"]
U --> A
A --> MCP
MCP --> SEM
MCP --> EXE
EXE --> DATA
SEM --> EXE
EXE --> MCP
MCP --> A
A --> UMental model
LLM decides. MCP connects. Tools execute. Semantic definitions govern. Data provides evidence.
MCP is not the model, semantic layer, or database. It is the standardized interface through which the agent discovers and invokes capabilities.
Why I built it this way
A naive analytics agent might expose:
run_sql(sql: str)That is convenient, but it also lets the model:
silently redefine metrics,
choose the wrong denominator,
double-count joins,
query deprecated or sensitive fields,
create inconsistent answers across users,
and sound confident even when the underlying question is ambiguous.
This project takes the opposite approach.
The agent receives a deliberately small set of governed analytical primitives:
Tool | Purpose |
| Discover approved business metrics. |
| Retrieve the governed definition before interpretation. |
| Calculate one approved metric for an inclusive date range. |
| Slice review completion by an approved dimension. |
| Quantify absolute and relative change across two periods. |
| Compare device segments across two periods and explicitly warn that association is not causation. |
The server also exposes:
an MCP resource:
metrics://catalogan MCP prompt:
product_analytics_investigation
Repository map
g2-product-analytics-mcp/
├── README.md
├── LICENSE
├── pyproject.toml
├── .gitignore
│
├── data/
│ ├── users.csv
│ ├── software_products.csv
│ ├── buyer_sessions.csv
│ ├── search_events.csv
│ ├── comparison_events.csv
│ ├── reviews.csv
│ ├── review_events.csv
│ └── metric_catalog.csv
│
├── scripts/
│ └── generate_dummy_data.py
│
├── src/
│ └── g2_product_analytics_mcp/
│ ├── __init__.py
│ └── server.py
│
├── tests/
│ └── test_server.py
│
├── docs/
│ ├── ARCHITECTURE.md
│ ├── DATA_MODEL.md
│ ├── CODE_WALKTHROUGH.md
│ ├── AGENT_EVALUATION.md
│ └── INTERVIEW_WALKTHROUGH.md
│
└── .github/
└── workflows/
└── test.ymlSee docs/CODE_WALKTHROUGH.md for a detailed explanation of the Python code and docs/DATA_MODEL.md for every synthetic table.
Quick start
1. Install prerequisites
Python 3.10+
Node/npm only if you want MCP Inspector
An MCP-capable client such as Claude Code if you want the agent demo
2. Clone and install
git clone <YOUR-REPO-URL>
cd g2-product-analytics-mcp
uv sync --extra dev3. Run tests
uv run pytest -q4. Inspect the MCP server manually
uv run mcp dev src/g2_product_analytics_mcp/server.pyMCP Inspector should discover the tools, prompt, and metric-catalog resource.
5. Connect Claude Code
From this repository:
claude mcp add g2-product-analytics -- \
uv run --with mcp==2.0.0 mcp run src/g2_product_analytics_mcp/server.pyCheck health:
claude mcp listThen launch Claude:
claudeA useful cold-start evaluation prompt is:
One of our product metrics changed materially in July 2026.
Using only the G2 Product Analytics MCP tools, investigate what happened.
Identify the metric, quantify the change, determine when the change emerged,
find where it is most concentrated, and explain what the evidence does and
does not support. Do not inspect source code or CSV files.Reproduce the synthetic data
The committed CSVs make the demo immediately runnable.
They can also be regenerated deterministically:
uv run python scripts/generate_dummy_data.pyThe generator uses a fixed random seed and intentionally plants one anomaly: mobile review completion deteriorates in July 2026.
This is synthetic portfolio data. It contains no G2 proprietary information.
Tests and guardrails
The current unit tests validate two foundational properties:
review_completion_rateis a valid ratio with a non-zero denominator.mobile completion in July is lower than mobile completion in June.
The more important evaluation layer is behavioral. See docs/AGENT_EVALUATION.md for prompts covering:
definition governance,
unsupported metrics,
unsupported dimensions,
ambiguous questions,
causality traps,
leading questions,
cold-start anomaly investigation.
What I would productionize next
The portfolio version is intentionally compact:
CSV → DuckDB → governed Python metrics → MCP → LLM agentA production version would likely add:
warehouse/dbt models instead of CSVs,
a formal semantic/metrics layer,
identity propagation and SSO/OAuth,
row- and column-level authorization,
audit logs and tool-call observability,
metric lineage/versioning,
freshness/schema monitoring,
query budgets and timeouts,
PII policies,
golden-question eval suites,
and a self-service UI/Slack surface.
Design tradeoff I learned
The project intentionally contains both atomic tools (get_metric) and a more opinionated workflow tool (diagnose_review_completion_change).
During testing, the agent showed it could compose atomic tools into new workflows, including weekly trend analysis, without a dedicated weekly_trend() function.
That suggests the scalable direction is not to hard-code every analyst question as a new MCP tool. It is to expose a small number of trusted primitives with strong semantics and let the agent compose them.
Documentation
License
MIT. Synthetic data only.
Available Tools
6 toolscompare_periodsC
Compare a governed metric between two periods and calculate absolute/relative change.
Inputs: metric_name (required), period_1_end (required), period_2_end (required), period_1_start (required), +1 more.
compare_review_completion_by_dimensionC
Compare review completion rate across an approved dimension.
Inputs: end_date (required), dimension (required), start_date (required).
diagnose_review_completion_changeA
Diagnose a review-completion change by comparing device segments across two periods.
Inputs: period_1_end (required), period_2_end (required), period_1_start (required), period_2_start (required).
get_metricA
Calculate one governed metric for an inclusive date range (YYYY-MM-DD).
Inputs: end_date (required), start_date (required), metric_name (required).
get_metric_definitionC
Return the governed definition and metadata for one metric.
Inputs: metric_name (required).
list_metricsA
List governed metrics available to the analytics agent.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Tools are mostly distinct: list_metrics, get_metric_definition, and get_metric cover metric discovery, definition, and calculation, while the three comparison/diagnosis tools have clear scopes. Some potential confusion exists between compare_review_completion_by_dimension and diagnose_review_completion_change, but their descriptions differentiate by dimension vs. device segment.
All tool names follow a consistent verb_noun snake_case pattern (list, get, compare, diagnose). No mixed conventions or vague verbs are present, making the naming predictable and clear.
With 6 tools, the server is well-scoped for product analytics. Each tool serves a distinct purpose without redundancy, and the count falls comfortably within the ideal range.
The tool surface covers the core workflow: discover metrics, understand definitions, calculate values, compare across periods/dimensions, and diagnose changes. Minor gaps exist, such as lacking a general dimension breakdown for arbitrary metrics (only review completion has one), but the set is largely complete for its stated purpose.
Maintenance
Related MCP Connectors
Governed data discovery, exact queries, decisions, simulations, and runtime utilities over MCP.
Read-only analytics for Convex apps, queryable via MCP from Claude, Cursor, and other clients.
Read-only Google Analytics 4 MCP server for AI assistants.
Your whole business as one MCP server: analytics, CRM, SEO, ads, revenue. Scoped per data class.
Related MCP Servers
- AlicenseBqualityDmaintenanceRead-only MCP server for querying Shopify analytics data, including orders, customers, products, sales, retention, and attribution.19MIT
- FlicenseNot gradedqualityDmaintenanceExposes product analytics metrics from an internal data warehouse via MCP, enabling agents to query metrics, product summaries, and event breakdowns.-
- AlicenseNot gradedqualityBmaintenanceEnables MCP-compatible agents to run governed, read-only analytics queries against Postgres using predefined metrics and dimensions, with safety checks and provenance on every result.12 npmApache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables asking product analytics questions in English and receiving answers as real SQL along with the resulting numbers, through read-only MCP tools for funnels, retention, trends, paths, and event counts.657 npmMIT