GitHub user dosubot[bot] added a comment to the discussion: Agent using MCP cannot properly compute metrics
<!-- Answer --> Yes, these are known limitations of the MCP server's metric handling that have been actively worked on. A few things to be aware of: **The `saved_metric: true` omission** was addressed in [PR #38981](https://github.com/apache/superset/pull/38981) (merged March 31, 2026), which clarified the MCP schema and instructions so that LLMs properly use `{"name": "metric_name", "saved_metric": true}` when referencing existing dataset metrics [[1]](https://github.com/apache/superset/pull/38981). **The non-existent column references** (e.g., referencing a "count" column that doesn't exist) happen because the MCP's metric schema previously only supported fixed aggregate functions (`SUM`, `COUNT`, etc.) applied to actual dataset columns. When an AI agent tries to compute something like "count of rows," it may hallucinate a column name rather than correctly specifying a `COUNT(*)` metric. **Custom SQL metric support was added** in [PR #40448](https://github.com/apache/superset/pull/40448) (merged May 28, 2026), which introduced a `sql_expression` field allowing agents to express complex SQL adhoc metrics directly [[2]](https://github.com/apache/superset/pull/40448). There's also a related [feature request (#40917)](https://github.com/apache/superset/issues/40917) that documents the broader gap around Custom SQL metrics and virtual dataset limitations [[3]](https://github.com/apache/superset/issues/40917). **Suggestions:** - Make sure you're on the latest Superset version to get the `saved_metric` and `sql_expression` fixes - When prompting your agent, you may need to explicitly instruct it about the correct metric schema (e.g., use `saved_metric: true` for existing metrics, or use the `sql_expression` field for ad-hoc aggregations) - If the agent is still referencing non-existent columns, it's likely an LLM prompting issue — the agent needs to be told to use dataset columns that actually exist (you can use the MCP's dataset inspection tools to list available columns/metrics first) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).* --- Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=1b10c381-52cf-4989-a84c-3c9e6f207c80) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset) GitHub link: https://github.com/apache/superset/discussions/40920#discussioncomment-17245094 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
