Skip to main content
Glama
maevelynz

G2 Product Analytics MCP

by maevelynz

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_rate was 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: databricks-mcp

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 --> U

Mental 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

list_metrics

Discover approved business metrics.

get_metric_definition

Retrieve the governed definition before interpretation.

get_metric

Calculate one approved metric for an inclusive date range.

compare_review_completion_by_dimension

Slice review completion by an approved dimension.

compare_periods

Quantify absolute and relative change across two periods.

diagnose_review_completion_change

Compare device segments across two periods and explicitly warn that association is not causation.

The server also exposes:

  • an MCP resource: metrics://catalog

  • an 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.yml

See 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+

  • uv

  • 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 dev

3. Run tests

uv run pytest -q

4. Inspect the MCP server manually

uv run mcp dev src/g2_product_analytics_mcp/server.py

MCP 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.py

Check health:

claude mcp list

Then launch Claude:

claude

A 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.py

The 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:

  1. review_completion_rate is a valid ratio with a non-zero denominator.

  2. 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 agent

A 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 tools
compare_periodsC

Compare a governed metric between two periods and calculate absolute/relative change.

ParametersJSON Schema
NameRequiredDescriptionDefault
metric_nameYes
period_1_endYes
period_2_endYes
period_1_startYes
period_2_startYes

TDQS

C2.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure. It states the basic operation (comparing two periods) and the kind of output (absolute/relative change), but it does not disclose details such as the meaning of 'governed metric', date format expectations, behavior with overlapping periods, or error handling. The core behavior is conveyed, but significant context is missing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence with no filler or redundancy. It is front-loaded with the main verb and resource, achieving maximum clarity in minimal words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of five required parameters, no annotations, and no output schema, the description is severely under-specified. It fails to explain the return format, parameter conventions, or how this tool relates to its siblings. A comprehensive description would be necessary for reliable invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description does not compensate. It mentions 'two periods' but does not explain the date format, the five required parameters, or the valid values for metric_name. An agent cannot infer what inputs to provide or how they should be structured.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'compare' with a clear resource ('a governed metric between two periods') and states the intended output ('absolute/relative change'). It is clear enough to understand the core function, though it does not explicitly distinguish from the sibling 'compare_review_completion_by_dimension' tool, which also performs a comparison but on a dimension-specific metric.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this tool versus the alternatives. The description does not mention any prerequisites, exclusions, or scenarios where comparing periods is appropriate. The sibling tools include similar comparison and diagnostic tools, but no differentiation is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

compare_review_completion_by_dimensionC

Compare review completion rate across an approved dimension.

ParametersJSON Schema
NameRequiredDescriptionDefault
end_dateYes
dimensionYes
start_dateYes

TDQS

C2.4/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

There are no annotations to disclose safety or side effects, and the description does not mention read-only behavior, data freshness, pagination, or any output details. It only restates the function without revealing behavioral characteristics, so the description fails to carry the transparency burden.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no wasted words, and it front-loads the action. However, it is terse to the point of under-specification, missing qualifiers that would make the sentence more informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given three required parameters, no annotations, and no output schema, the description is far too sparse. It does not explain the notion of 'completion rate', what 'approved' means, how date ranges are formatted, or what the comparison output looks like. This is inadequate for an agent to invoke the tool reliably.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It mentions 'dimension' but does not explain date formats, the meaning of 'approved', or how parameters interact. The parameter names are partially self-explanatory, but the description adds little beyond the schema's basic types and enum.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb 'Compare' with a clear object 'review completion rate' and scope 'across an approved dimension.' The schema's enum clarifies the dimension options. It is implicitly distinguished from the sibling 'compare_periods' by focusing on dimension rather than time, though this is not explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as compare_periods or diagnose_review_completion_change. The description does not state when it is appropriate or inappropriate to invoke, leaving the agent without decision support.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

diagnose_review_completion_changeA

Diagnose a review-completion change by comparing device segments across two periods.

ParametersJSON Schema
NameRequiredDescriptionDefault
period_1_endYes
period_2_endYes
period_1_startYes
period_2_startYes

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description bears the full burden of behavioral disclosure. It says 'diagnose' and 'comparing,' suggesting analysis, but does not explicitly state whether this is read-only, what actions are taken, any prerequisites (e.g., date format validation), or what the output represents. This lack of transparency is a notable gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, focused sentence that immediately communicates the tool's purpose. No unnecessary words or repetition. It is front-loaded and concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, no annotations, and zero parameter descriptions, the description must provide a complete picture. It explains the high-level purpose but omits behavioral details, return values, error scenarios, and parameter specifics. For a 4-parameter diagnostic tool, more information is needed to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%—parameters have no descriptions. The description only mentions 'two periods,' which maps to the four date parameters but does not explain date formats, constraints, or how 'device segments' are selected or passed. The parameter names are self-explanatory, but the description fails to add meaningful detail beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: diagnose a review-completion change, with a specific method (comparing device segments across two periods). This distinguishes it from siblings like compare_periods (generic period comparison) and compare_review_completion_by_dimension (likely for any dimension).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage via the context: use when a review-completion change needs diagnosis through device segment comparison across two periods. It provides clear context but does not explicitly state when not to use it or mention alternatives (e.g., if dimension is not device-specific).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_metricA

Calculate one governed metric for an inclusive date range (YYYY-MM-DD).

ParametersJSON Schema
NameRequiredDescriptionDefault
end_dateYes
start_dateYes
metric_nameYes

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description adds the behavioral detail that the date range is inclusive and expects YYYY-MM-DD format. However, it does not disclose the return value shape, error behavior for invalid metrics, or any side effects, leaving significant gaps for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The entire description is a single, front-loaded sentence with no filler. Every word adds meaning, making it highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the core calculation and date constraints, but with no output schema and no annotations, it lacks information about return values, acceptable values for metric_name, and error handling. It is adequate for a simple tool but leaves room for ambiguity in edge cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema offers no descriptions (0% coverage), so the description compensates by clarifying the date format and inclusive nature of start_date and end_date. It does not explicitly describe metric_name, but the term 'governed metric' and the tool name make its role reasonably clear.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'calculate' and names the resource as 'one governed metric', clearly distinguishing this from list_metrics, get_metric_definition, and comparison tools. It also specifies the date range scope, making the tool's function unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool is for computing a single metric over a date range, providing clear context for when to use it. However, it does not explicitly mention alternatives or exclusions, but the sibling tools are distinct enough that the purpose is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_metric_definitionC

Return the governed definition and metadata for one metric.

ParametersJSON Schema
NameRequiredDescriptionDefault
metric_nameYes

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden, and 'Return' implies a read operation but adds no detail about governance, error behavior, or what metadata is included. It is minimally transparent about the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words. However, it is concise to the point of underspecification, which slightly diminishes its structural value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of annotations and an output schema, the description is too sparse. It does not explain what 'governed definition' entails, what metadata is returned, or what happens if the metric does not exist, leaving an agent with insufficient context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description only says 'for one metric', which does not clarify the format, constraints, or meaning of metric_name beyond its name. The description fails to compensate for the missing schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The verb 'Return' and resource 'governed definition and metadata for one metric' clearly state what the tool does. It distinguishes itself from list_metrics by focusing on a single metric, though it does not explicitly contrast with get_metric.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit guidance on when to use this tool versus alternatives like get_metric or list_metrics. The usage context is only implied by the phrase 'for one metric', which is insufficient for an agent to choose between sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_metricsA

List governed metrics available to the analytics agent.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description is the only source of behavioral transparency. It conveys that the tool lists governed metrics and implies permission-based filtering by 'available to the analytics agent,' but does not disclose return format or pagination.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single clear sentence with no wasted words, front-loading the verb and resource.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter listing tool, the description is minimally sufficient, but it leaves the return structure unspecified. Given no output schema or annotations, a bit more context about what is returned would improve completeness, yet the simplicity keeps it near the top.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the description has no obligation to explain parameter semantics. The schema is empty, and the baseline for zero-parameter tools is 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'List' and specifies the resource as 'governed metrics available to the analytics agent,' clearly indicating a read-only listing operation. It does not explicitly contrast with sibling tools like get_metric_definition, but the listing scope is evident.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given about when to use this tool versus the sibling tools. The description only states the operation without mentioning alternatives or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 6 tool updatesv0.1.0
    • First observedcompare_periods
    • First observedcompare_review_completion_by_dimension
    • First observeddiagnose_review_completion_change
    • First observedget_metric
    • First observedget_metric_definition
    • First observedlist_metrics

TDQS

B3.4/5.0
Disambiguation4/5

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.

Naming Consistency5/5

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.

Tool Count5/5

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.

Completeness4/5

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

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/maevelynz/g2-product-analytics-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server