mcpServer:
  name: datadriven
  version: 1.0.0
  url: https://api.datadriven.ro/mcp
  transport: streamable-http
  description: |
    Programmatic access to Romanian public-procurement data from DataDriven.ro.
    These tools mirror the app's own menus 1-to-1: Monitorizare Licitații
    (monitored), Salvate (saved), Toate Licitațiile (all + full search),
    Atribuiri (awards full search), Detalii (tender by id / by notice no /
    history). All require an Ocp-Apim-Subscription-Key from a Premium-plan
    account.
  tools:
    - name: get_me
      description: |
        Return the caller's project identity: { projectId, projectName }. Useful
        for confirming that the key is valid before doing real work.
      arguments:
        type: object
    - name: get_usage
      description: |
        Return the current billing cycle's full-retrieval counter, credit-pack
        balance, and operations-cap status: { fullRetrievalsThisPeriod,
        fullRetrievalsCap (100 for Premium), overflowCredits, callsThisCycle,
        callsCap, callsCapFloor, creditsUsedThisCycle, callsPerCredit,
        periodStart, periodEnd }. callsCap = max(callsCapFloor,
        creditsUsedThisCycle × callsPerCredit) — every credit used (full
        retrieval) raises the per-cycle operations limit by 500 calls.
        periodStart/periodEnd are anchored to the Stripe subscription's monthly
        anniversary day — not the calendar 1st.
      arguments:
        type: object
    - name: list_monitored_tenders
      description: |
        List tenders matching the project's monitoring criteria (CPVs, keywords,
        authorities — same as the app's "Monitorizare Licitații" menu). Returns
        a summary projection plus the per-project overlay (tags, color, comment).
        Optional `query` further refines by full-text search.
      arguments:
        type: object
        properties:
          query:
            type: string
            description: Optional refinement text. Defaults to '*'.
          skip:
            type: integer
            minimum: 0
            default: 0
          top:
            type: integer
            minimum: 1
            maximum: 1000
            default: 25
    - name: list_saved_tenders
      description: |
        List the tenders the user has bookmarked in this project (same as the
        "Salvate" view). Summary + tags/color/comment overlay.
      arguments:
        type: object
        properties:
          query:
            type: string
          skip:
            type: integer
            minimum: 0
            default: 0
          top:
            type: integer
            minimum: 1
            maximum: 1000
            default: 25
    - name: list_all_tenders
      description: |
        List any tenders in the corpus (same as the "Toate Licitațiile" view —
        no monitoring filter). Summary only — no overlay. Empty query = most
        recent tenders sorted by published date descending.
      arguments:
        type: object
        properties:
          query:
            type: string
          skip:
            type: integer
            minimum: 0
            default: 0
          top:
            type: integer
            minimum: 1
            maximum: 1000
            default: 25
    - name: get_tender_by_id
      description: |
        Fetch the full tender object by internal id (e.g. 'cnotice_101341473').
        Includes lots, awards, attachments (1h SAS download URLs), procedure
        metadata, AI fields, plus the per-project tags/color/comment overlay.
        Optional `includePages=true` embeds per-attachment extracted text inline.
        Charges 1 full-retrieval per (tender, billing cycle).
      arguments:
        type: object
        required:
          - id
        properties:
          id:
            type: string
            description: Internal tender id.
          includePages:
            type: boolean
            default: false
    - name: get_tender_by_notice
      description: |
        Same as `get_tender_by_id` but resolves by the public SEAP/SICAP notice
        number (e.g. SCN1174909, CN1234567). Charges 1 full-retrieval per
        (tender, billing cycle).
      arguments:
        type: object
        required:
          - noticeNo
        properties:
          noticeNo:
            type: string
    - name: get_tender_history
      description: |
        The "Istoric" data for a tender: similar past tenders from the same
        authority filtered by CPV/category, plus aggregated supplier statistics
        (top winners by value and by count). No full-retrieval charge.
      arguments:
        type: object
        required:
          - id
        properties:
          id:
            type: string
          cpvs:
            type: array
            items:
              type: string
            description: Optional — narrow by these CPVs (defaults to the tender's own CPVs).
          categories:
            type: array
            items:
              type: string
    - name: search_awards_full
      description: |
        Search awarded contracts and ongoing acquisitions (same as the
        "Atribuiri" menu). Full AwardSearchRequest envelope plus two flags:
        applyMonitoringCriteria and onlyOngoingAcquisitions. No full-retrieval
        charge.
      arguments:
        type: object
        description: Full AwardSearchRequest envelope plus optional applyMonitoringCriteria / onlyOngoingAcquisitions booleans.
    - name: get_company
      description: |
        Look up a company's full statistical profile by CUI. Returns identity
        (name, code, address, city, county, country) plus precomputed stats
        from the companyStats Azure Table (won values across acquisition /
        notice / framework contracts, lot counts, participation count,
        bid-to-award ratios, top authorities, top competitors). No on-the-fly
        aggregation.
      arguments:
        type: object
        required:
          - cui
        properties:
          cui:
            type: string
            description: Romanian tax ID (with or without RO prefix).
    - name: get_tender_pages
      description: |
        Per-attachment page-by-page OCR text from the cached pages.json.
        Response shape: each attachment has `totalPages` + a `pages` array
        of `{ pageNumber, text, length }`. Cuts off at a ~60 000-char total
        budget and sets `truncated:true` + `nextPage`/`nextAttachment` to
        paginate. First call without `attachmentId` to see all attachments
        and their totalPages; for long PDFs call again with `attachmentId`
        + `pageStart`/`pageEnd`. For finding a specific phrase, prefer
        find_in_tender. Shares the byId dedup pool.
      arguments:
        type: object
        required:
          - id
        properties:
          id:
            type: string
          attachmentId:
            type: string
            description: Optional — return only this attachment's pages.
          pageStart:
            type: integer
            minimum: 1
            description: 1-based first page (default 1).
          pageEnd:
            type: integer
            minimum: 1
            description: '1-based last page (default: budget-limited).'
    - name: download_tender_pages
      description: |
        15-minute SAS URL to the tender's pages.json blob + per-attachment
        preview (totalPages + first 200 chars). For filesystem-capable agents
        (Claude Code, Cursor, Codex), download once and grep locally — far
        faster than paginating through MCP. Older tenders without pages.json
        return `pagesJsonAvailable=false`; fall back to get_tender_pages /
        find_in_tender. Shares the byId dedup pool.
      arguments:
        type: object
        required:
          - id
        properties:
          id:
            type: string
    - name: find_in_tender
      description: |
        Case-insensitive substring search across attached document text.
        Returns per-attachment `{ pageNumber, snippet }` matches with
        `contextChars` of surrounding context. Token-efficient way to find
        warranty period, quantities, technical thresholds, etc. without
        loading the full PDF text into context. Romanian diacritics are
        NOT normalised — try both `garanție` and `garantie`. Shares the
        byId dedup pool.
      arguments:
        type: object
        required:
          - id
          - query
        properties:
          id:
            type: string
          query:
            type: string
          attachmentId:
            type: string
          contextChars:
            type: integer
            minimum: 50
            maximum: 1000
            default: 200
          maxHits:
            type: integer
            minimum: 1
            maximum: 100
            default: 30
    - name: get_tender_attachments
      description: |
        Return the list of attachments for a tender plus archive + extracted-text
        download links. Each attachment has an `originalUrl` (the raw file) and
        `searchableUrl` (OCR'd PDF, text-selectable, present when available).
        `archives.originalsArchiveUrl` and `archives.searchableArchiveUrl` give the
        whole bundle as a single zip. `extractedText.pagesJsonUrl` is the
        LLM-friendly shortcut — a SAS-protected JSON of per-page text keyed by
        attachment id; fetch it directly when you need to read content without
        parsing PDFs. Use this when the user asks for files, PDFs, attachments,
        downloads, or "the text of the tender". Shares the byId dedup pool.
      arguments:
        type: object
        required:
          - id
        properties:
          id:
            type: string
            description: Internal tender id.
