field-analytics
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Field analytics assistant
A small, working example of how I build AI analytics: governed metrics, an MCP server that puts them in front of Claude, skills that tell Claude how to answer, a screen people can use, and an evaluation set that has to pass before any change ships.

The data is synthetic. My production work lives in private company repositories, so I wrote this sample to show the same way of working on numbers I can publish. It covers two subjects I know well: harvesting machines running two shifts across three sites, and machine sales through a dealer channel in three regions.
The problem it solves
People stop using an assistant the first time it gives a number that disagrees with the report they already trust. I've watched two departments bring two different production totals for the same day to the same meeting. The cause was small. The night shift crosses midnight, and one side counted those hours on the next calendar day.
So this project starts with the definition and works outward:
semantic/metrics.yamlholds one written definition per metric, with an owner.src/field_analytics/metrics.pyimplements each definition once, in SQL.The MCP server serves both the number and the definition, so the model reads the rule before it reports.
evals/expected.pyrecomputes every expected value from the raw file with separate code. If the two disagree, the build fails.
Related MCP server: factory-floor-mcp
What is in here
Path | What it does |
| Metric definitions and written rules for two subjects: production (by site) and dealer sales (by region) |
| Which sites and regions each role may read, and who may request actions |
| The metric SQL (DuckDB), with every model supplied argument validated |
| Access by role, applied to every query |
| The MCP server: four tools over stdio |
| Actions create a pending request. A person approves it |
| The tool loop that asks Claude, shared by the app and the evaluation set |
| The usage log: what people ask for and what gets refused |
| The Streamlit screen, ready to deploy as a Databricks App |
| Two Agent Skills: how Claude should answer on production and on dealer sales, and what it must never do |
| The evaluation set, the independent expected values, and the grader |
| The same rules in PySpark, writing a Delta table on Databricks |
| Unit tests, access tests, and a parity test between PySpark and the metric layer |
| The project instructions Claude Code reads when I work here |
Run it
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest # 40 tests (the Spark parity test is skipped without PySpark)
python evals/run_evals.py # 12 evaluation cases, graded against the toolsThe screen
pip install -e ".[dev,app]"
streamlit run app/app.pyPick a role in the sidebar. Without an API key the screen runs with no model: a few selectors call the same tools Claude would, and every result shows what the number covers and how the metric is defined. Set ANTHROPIC_API_KEY and the selectors give way to a question box.
To run it as a Databricks App, create an app in your workspace from this repository. app.yaml starts the screen and requirements.txt lists what Databricks needs to install. To turn on the question box there, add the API key as a secret resource on the app and uncomment the two lines in app.yaml.
What people ask
Every query is logged with the role, the metric, the grouping, and whether it was refused. The person and the rows are never logged.
python scripts/top_questions.pyThe same summary is the second tab of the screen. I read it as a backlog: the view people request most is the next dashboard worth building, and a refusal that keeps repeating is either missing access or a question nobody has defined yet.
Claude through MCP
To ask questions in plain language, connect the server to Claude Desktop or Claude Code:
{
"mcpServers": {
"field-analytics": {
"command": "field-analytics-mcp",
"env": { "FIELD_ANALYTICS_ROLE": "north_supervisor" }
}
}
}Then try "What was output per hour by shift in September?" As north_supervisor you get the north site only, and the answer says so. Ask about the river site and the tool refuses.
To grade Claude's own answers instead of the tools:
pip install -e ".[app]"
export ANTHROPIC_API_KEY=...
python evals/run_evals.py --mode claudeTo build the gold table with PySpark locally (needs Java):
pip install -e ".[spark]"
python databricks/build_gold_production.pyOn Databricks, import the same file as a notebook. It writes main.field.gold_production as a Delta table.
Decisions I would defend in a review
The model never picks its own role. The role is set by whoever starts the server or the session for a person. Every tool call is checked against it, and a request for another site or region is refused out loud, not returned empty. An empty answer looks like "no production", which is worse than a refusal.
A new subject is a definition, a query, and an access scope. Dealer sales went in as a block in metrics.yaml, one base query, and a regions list on the roles. The server, the skills, the screen, and the grader did not need a second code path.
Model input is untrusted input. Metric and dimension names are checked against a fixed list before any SQL exists. Dates and sites are bound as parameters. There is a test that sends site; drop table x as a dimension.
Expected values are computed, not typed. A typed expected value goes stale the day the data changes. Here the grader recomputes each one from the raw file with code that shares nothing with the metric layer.
Actions wait for a person. The assistant can ask for a maintenance window. That writes a pending request and stops. scripts/approve.py is the human step.
Refusals and bad arguments come back as answers. The model gets {"ok": false, "error": "..."} and can tell the person what happened, instead of the server crashing mid conversation.
What I would add for production
This is a sample, so a few things are simpler than what I run at work:
The role would come from the signed in user, which Databricks Apps passes to the app, not from a selector or an environment variable.
The metric layer would read the Delta gold table through a SQL warehouse, not a CSV through DuckDB.
The usage log would be a Delta table, and the evaluation set would grow from the questions in it.
How this was built
I built it with Claude Code, the way I work every day: I write the definitions and the review rules, Claude Code writes much of the code and tests with me, and I read every line before it is committed. CLAUDE.md is the instruction file from that process.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Connect your ads, shop, analytics, social, CRM and finance platforms once, then let Claude, ChatGPT, Cursor or any MCP client read, join and explain your numbers. Public statistics from the World Bank, IMF, Eurostat, OECD, WHO and SEC filings come as context, searchable and chartable from the same tools. Read-only by design, every number carries its source.
Read-only analytics for Convex apps, queryable via MCP from Claude, Cursor, and other clients.
GA4, Google Ads and Search Console in Claude. Read-only OAuth, multi-account for agencies.
Read-only access to a company's ERP for Claude, ChatGPT and Gemini, with OAuth and an audit trail.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceEnables agents and Claude Desktop to query a single canonical source for multifamily marketing metrics, with 22 tools for retrieving metric definitions and values from a synthetic portfolio database.MIT
- AlicenseAqualityCmaintenanceProvides read-only access to manufacturing plant data from Excel or SAP S/4HANA, enabling natural-language queries for OEE, downtime Pareto, late work orders, scrap, and inventory alerts. It enforces data classification, masking, row limits, and audit logging for safe Claude/MCP client access.10MIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude to answer plain-English metric questions by selecting validated metrics, dimensions, filters, and dates from a MetricForge semantic layer, ensuring answers use only controlled definitions and never model-written SQL.MIT
- AlicenseNot gradedqualityCmaintenanceGives Claude governed access to a curated registry of go-to-market KPIs, with definitions, sources, and formulas, so it can draft a leadership business review from approved numbers rather than pasted-in data. It also validates every figure in the draft against its source KPI and flags anything unsupported before the review or 5-slide deck reaches leadership.MIT