Repository avatar
Other Tools
v1.0.0
active

mcp

eu.transparenta/mcp

Read-only MCP for Romanian public budgets, procurement, and official records.

Documentation

Transparenta.eu Server

Backend service for analyzing and visualizing Romanian public budget data (working on more public data).

Overview

Transparenta.eu Server provides a GraphQL API for querying public budget execution data across Romanian institutions. It enables real-time budget tracking, multi-dimensional analytics, and data normalization (inflation-adjusted, per-capita, currency conversion).

Key Capabilities:

  • Budget execution tracking across 13,000+ public institutions
  • Multi-dimensional filtering (by classification, geography, funding source)
  • County and UAT-level heatmap analytics
  • Normalization modes: total, per-capita, % of GDP, EUR conversion
  • File-based macroeconomic datasets (GDP, inflation, population)

Tech Stack

ComponentTechnology
RuntimeNode.js 20+, TypeScript (ESM)
HTTP FrameworkFastify 5.x
APIGraphQL (Mercurius)
DatabasePostgreSQL 16+ (Kysely)
CachingRedis / In-Memory (pluggable)
Mathdecimal.js (no floats allowed)
ValidationTypeBox
Error Handlingneverthrow (Result types)

Quick Start

Prerequisites

  • Node.js >= 20.0.0
  • pnpm >= 10.24.0
  • PostgreSQL 16+
  • Redis (optional, for caching)

Installation

# Clone the repository
git clone https://github.com/your-org/transparenta-eu-server.git
cd transparenta-eu-server

# Install dependencies
pnpm install

# Configure environment
cp .env.example .env
# Edit .env with your database credentials

Environment Variables

# Server
NODE_ENV=development
PORT=3000
HOST=0.0.0.0
LOG_LEVEL=debug

# Database (required)
DATABASE_URL=postgresql://user:pass@localhost:5432/budget_db
USER_DATABASE_URL=postgresql://user:pass@localhost:5432/user_db

# Caching (optional)
REDIS_URL=redis://localhost:6379
CACHE_BACKEND=memory  # memory | redis | multi | disabled

# BullMQ / jobs
BULLMQ_REDIS_URL=redis://localhost:6380
BULLMQ_REDIS_PASSWORD=
BULLMQ_PREFIX=transparenta:jobs

Run the Server

# Development (with hot reload)
pnpm dev

# Production build
pnpm build
pnpm start

The GraphQL endpoint is available at http://localhost:3000/api/v1/graphql (MCP at /api/v1/mcp, health at /api/v1/health).

MCP and the ChatGPT plugin

Connect a Streamable HTTP client to https://api.transparenta.eu/api/v1/mcp. The server advertises the tools available on that deployment during discovery. Start with the identifier returned by a search or domain resolver, then use a detail or aggregate tool for the requested period. Results include structured data and a text fallback. Supported hosts can also display the five entity and budget widgets.

The plugin runbook covers packaging and publication. The agent evaluation gives example calls and recovery steps. The data cross-checks compare sampled answers with GraphQL and published records.

API

GraphQL Endpoint

URL: http://localhost:3000/api/v1/graphql (the legacy /graphql endpoint was retired on 2026-09-09)

The API is GraphQL-first. Use the GraphQL Playground or introspection to explore the schema:

query {
  __schema {
    types {
      name
    }
  }
}

Main Query Categories (one GraphQL slice per source module, merged by the kernel):

  • entity / searchEntities - Public institutions (kernel identity hub)
  • budget* roots and the carried executionAnalytics / entityAnalytics / aggregatedLineItems - Budget execution (docs/server-redesign/02-budget.md, 13-legacy-roots-on-kernel.md)
  • budgetCountyHeatmap / budgetUatHeatmap and the REST map routes - Geographic analytics
  • ins* - INS statistics (ins-native)
  • budgetSectors / fundingSources / functionalClassifications / economicClassifications - Reference data
  • companies, parliament, legal, judicial, PNRR, procurement, primării transparency - the other source modules

Health Endpoints

GET /health/live   # Liveness probe (always 200)
GET /health/ready  # Readiness probe (checks DB/cache)

Development

Commands

# Quality checks
pnpm typecheck        # TypeScript type checking
pnpm lint             # ESLint (zero warnings tolerance)
pnpm lint:fix         # Auto-fix linting issues
pnpm format           # Format with Prettier

# Testing
pnpm test             # Run all tests
pnpm test:unit        # Unit tests only
pnpm test:integration # Integration tests
pnpm test:e2e         # E2E tests (requires Docker)
pnpm test:coverage    # Coverage report (80% threshold)

# Data validation
pnpm validate-datasets  # Validate YAML dataset files

# CI pipeline
pnpm ci               # typecheck → lint → test → build

Git Workflow

Commits follow Conventional Commits:

feat(datasets): add validation for annual budgets
fix(health): return correct status codes
chore(deps): update fastify to 5.6.2

Pre-commit hooks run ESLint, Prettier, and TypeScript checks automatically.

User Data Deletion Coverage

Any new table or JSON document that stores user-generated data, user-owned state, copied account/contact data, or user-linked operational records must add a Clerk user.deleted delete/anonymize handler path. Document the field treatment in docs/USER-DATA-ANONYMIZATION.md.

The deleted-user anonymizer is intentionally restricted by ESLint imports and should only be reached through the verified Clerk user.deleted webhook handler.

Architecture

This codebase follows Functional Core / Imperative Shell (Hexagonal Architecture):

┌─────────────────────────────────────────────────────────────┐
│               IMPERATIVE SHELL (I/O Layer)                  │
│   GraphQL Resolvers │ REST Handlers │ Database Repositories │
└──────────────────────────┬──────────────────────────────────┘
                           │ Calls
                           ▼
┌─────────────────────────────────────────────────────────────┐
│                  FUNCTIONAL CORE (Pure)                     │
│        Use-cases │ Domain Types │ Business Rules            │
│           No I/O │ No side effects │ 100% testable          │
└─────────────────────────────────────────────────────────────┘

Project Structure

src/
├── api.ts                    # Server entry point
├── app/
│   └── build-app.ts          # Composition root (wires dependencies)
├── common/                   # Shared types and utilities
├── infra/                    # Infrastructure (DB, config, logger)
└── modules/
    └── {feature}/            # Feature modules
        ├── core/             # Pure business logic
        │   ├── types.ts
        │   ├── ports.ts      # Dependency interfaces
        │   └── usecases/
        └── shell/            # I/O adapters
            ├── repo/         # Database queries
            └── graphql/      # Resolvers + schema

Critical Rules

  1. No Floats - All financial calculations use decimal.js
  2. Result Pattern - Core returns Result<T, E>, no throwing
  3. Strict Booleans - Must check amount !== 0, not if (amount)
  4. Layer Boundaries - Core cannot import Shell or Infra

For detailed architecture documentation, see:

Documentation

DocumentDescription
AGENTS.mdAgent instructions — canonical (GEMINI.md symlinks to it)
docs/server-redesign/00-foundation-shared-kernel.mdBinding module/kernel contract
docs/ARCHITECTURE.mdArchitectural principles and patterns
docs/CACHE.mdCaching layer specification
docs/DATASETS.mdDataset format and validation
docs/NORMALIZATION-FACTORS.mdData normalization logic
docs/USER-DATA-ANONYMIZATION.mdClerk user.deleted anonymization strategy

Testing

The project uses a testing pyramid approach:

TypeCoverageDescription
Unit70-80%Pure functions with in-memory fakes
Integration15-25%HTTP/GraphQL routes with fakes
E2E5-10%Full stack with Testcontainers
# Run tests
pnpm test              # Unit + Integration
pnpm test:e2e          # E2E (requires Docker)
pnpm test:watch        # Watch mode for TDD

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feat/amazing-feature)
  3. Make your changes following the architecture guidelines
  4. Run the CI pipeline (pnpm ci)
  5. Commit with conventional commit format
  6. Open a Pull Request

License

MIT

No installation packages available.

Remote