Skip to main content
Glama
USA Web Analytics MCP

USA Web Analytics MCP

USA Web Analytics MCP

An MCP server developed by the National Library of Medicine (NLM) for the GSA 2026 MCP Server Hackathon. It provides read-only access to United States government website analytics through tools backed by the GSA Digital Analytics Program (DAP).

The server uses FastMCP and uv. It can run locally over stdio or remotely over streamable HTTP.

Features

  • Retrieve analytics reports across all participating US government agencies.

  • Filter analytics reports by agency or US government web domain.

  • Retrieve the most recent 30 minutes of top pages for a selected agency.

  • Use inclusive YYYY-MM-DD date filters and paginated report requests.

  • Read agency, report, and parameter information through MCP resources.

  • Start report analysis through a reusable MCP prompt.

Related MCP server: AgentKit

Available tools

Tool

Description

get_analytic_reports

Retrieve an analytics report across all agencies.

get_agency_analytic_reports

Retrieve a report filtered by agency.

get_domain_analytic_reports

Retrieve a report filtered by a US government web domain.

get_top_pages_realtime

Retrieve the latest 30 minutes of top pages for an agency.

All tools are read-only and return structured data.

Prerequisites

  • Python 3.11 or newer

  • uv

Install and run locally

cp .env.example .env
uv sync
uv run analytics-server

The default transport is stdio, so the server communicates through standard input and output as a local MCP client subprocess.

To run the HTTP transport locally:

$env:MCP_TRANSPORT = "streamable-http"
uv run analytics-server

The HTTP server listens on 0.0.0.0:8000 by default. Its MCP endpoint is /mcp, and it provides /health and /version status routes.

Example client configuration:

{
  "mcpServers": {
    "analytics-mcp": {
      "command": "uv",
      "args": ["run", "analytics-server"],
      "cwd": "/absolute/path/to/mcp-hackathon-template"
    }
  }
}

Configuration

Configuration is loaded from environment variables or a local .env file.

Variable

Default

Purpose

MCP_TRANSPORT

stdio

Use stdio locally or streamable-http remotely.

MCP_HOST

0.0.0.0

HTTP bind address.

MCP_PORT

8000

HTTP port.

ANALYTICS_API_KEY

DEMO_KEY

API key sent to the GSA Analytics API.

ANALYTICS_API_BASE_URL

GSA DAP API v2 URL

Override the upstream API origin.

Do not commit .env or API credentials. Use an environment secret store for deployed instances.

Project structure

src/analytics_server/
├── app.py           # FastMCP setup and transport selection
├── config.py        # Environment-based settings
├── models.py        # Pydantic inputs and shared types
├── utils.py         # Outbound HTTP, validation, and pagination
├── routes.py        # /health and /version routes
├── tools/           # One MCP tool per module
├── prompts/         # Reusable report-analysis prompt
└── resources/       # Analytics and parameter resources
tests/               # Import, registration, and security tests
deploy/              # Platform deployment examples
eval/                # Evaluation guidance

Verification

uv sync --group dev
uv run pytest tests/ -v
uv run ruff check .

The test suite includes MCP registration checks and outbound HTTP security coverage, including validation of relative paths and sanitization of upstream failures.

Security

The MCP endpoint is unauthenticated by default. This is appropriate for the public-data hackathon posture but is not sufficient for a production deployment. Databricks Apps and other platforms may add authentication at the platform layer, but per-tool authorization and agency-specific ATO controls should be reviewed before production use.

The outbound HTTP helper:

  • Uses an operator-controlled GSA API origin.

  • Rejects absolute URLs, traversal paths, queries, fragments, and encoded escapes.

  • Disables redirects and environment proxy inheritance.

  • Applies a 30-second timeout and a five-megabyte response limit.

  • Sanitizes upstream errors so response bodies and sensitive values are not returned or logged.

Treat tool arguments, upstream content, and MCP messages as untrusted. Keep credentials out of source control and structured logs. See SECURITY.md for vulnerability reporting and additional guidance.

Deployment status

Deployment examples are included for cloud.gov, IBM watsonx Orchestrate/Code Engine, and Databricks Apps:

IBM and Databricks deployments have not been tested for this project. Use the supplied kits as deployment templates and validate authentication, networking, secrets, health checks, and tool behavior in your target environment before use.

Evaluation

This repository does not yet include a complete evaluation harness. See eval/README.md for the evaluation approach and setup guidance.

License

MIT. The project is subject to the GSA vulnerability disclosure policy described in SECURITY.md.

Available Tools

1 tool
example_search_datasetsSearch Datasets (example)B
Read-onlyIdempotent

Search federal datasets matching a query string. (STUB — replace me.)

This stub shows the shape of a real tool without calling a live API. Swap the body for an actual request using fetch_json(...); a worked pattern is included below in a comment.

Inputs: query (required), pagination, response_format. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 1 tool

    Disambiguation4/5

    With only a single tool there is nothing to confuse it with, and its stated purpose (searching federal datasets by query string) is clear. The 'example_' prefix and stub labelling make it slightly unclear whether this is the real tool or a placeholder, keeping it below a 5.

    Naming Consistency4/5

    The lone name example_search_datasets follows a readable snake_case verb_noun pattern with no competing conventions to clash with. The 'example_' prefix signals scaffolding rather than a production-facing name, which is a minor deviation.

    Tool Count2/5

    A single stub tool cannot represent a whole web analytics surface; the server is drastically under-scoped. One tool is the strongest signal of a thin or unfinished surface.

    Completeness1/5

    The tool is explicitly marked as a STUB to be replaced, and there are no analytics operations at all (no metrics, reports, sites, or time-series queries). The stated purpose is essentially unserved, so agents would hit dead ends immediately.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      The most comprehensive keyless federal-data MCP server. 36 tools for SAM.gov + USAspending + Federal Register + eCFR + Grants.gov. No API key, no registration, no signup. Works in Claude Desktop, Claude Code, Codex CLI, Cursor, Continue, Gemini CLI, and any MCP-aware host.
      153
      238 npm
      19
      MIT
    • A
      license
      A
      quality
      A
      maintenance
      Production Model Context Protocol (MCP) server for business — replaces stale generic descriptions with concrete 2026 technical intelligence and data agents. Exposes dynamic KPI analytics, forecasting, anomaly detection, and schema resources across 10 enterprise domains via FastMCP over stdio and SSE transports.
      9
      AGPL 3.0
    • A
      license
      A
      quality
      D
      maintenance
      First-party web analytics MCP server for AI agents, providing 42 tools to query traffic, events, funnels, conversions, sources, and performance data.
      40
      283 npm
      MIT