Skip to main content
Glama
portco-mcp

portco-mcp

by ahines99

Portfolio Company Data Onboarding Agent

One company records invoice lines in cents and invoice headers in dollars. Another calls a CRM opportunity column rev, although it represents potential bookings, not recognized revenue. A plausible column match can quietly turn either into the wrong financial report.

This system profiles sources, proposes evidence-linked mappings to a private-equity reporting model, generates dbt and semantic definitions, and reconciles the results before a separate reviewer can certify publication.

Scope: an AI-assisted portfolio prototype with synthetic financial workflows, typed CSV and read-only PostgreSQL snapshots, and local publication; no production customers or measured savings.

CI

Project page and replay · Case study · Architecture · Evaluation and limitations · Release status

Run the demo

Requires Python 3.12 and uv. The demo needs no Docker or API keys.

uv sync --all-extras --frozen
uv run poe demo

The synthetic SaaS fixture catches both traps, denies agent self-approval, and publishes nine reconciled metrics after scripted reviewer decisions. The other paths demonstrate malformed source data, a retried timeout and an instruction planted in a table comment.

== 1. Success path: fixture A (synthetic B2B SaaS company)
   agent profiled, inferred entities/joins and proposed mappings -> paused at 'mapping_review' with 28 review items
   trap caught -> billing.invoice_lines.amount -> invoice_line.amount (suggest cents_to_major) [UNIT_MISMATCH]
   trap caught -> crm.opportunities.rev -> opportunity.amount [LOW_CONFIDENCE, SEMANTIC_TRAP]
   agent tried to approve its own proposals -> Forbidden
   generated dbt + semantic layer; sandbox build exit 0; 27/27 reconciliation checks passed (money exact to the cent)

See the recorded replay and full transcript. Reviewers in this demo are automated test identities. Diagnostic logs are saved beside the reports in var/demo/diagnostics.log; use uv run portco demo --verbose to show them.

Related MCP server: CodexPro Runtime

How it works

flowchart LR
    S[Read-only source] --> P[Aggregate profile]
    P --> M[Evidence-linked mapping]
    M --> R{Mapping review}
    R --> D[Generated dbt + metrics]
    D --> T[Sandbox + reconciliation]
    T --> C{Separate certification}
    C --> V[Versioned publication]
    O[Canonical ontology] -.-> M
    F[Independent reference calculations] -.-> T

The workflow is available through a CLI and typed MCP capabilities. An agent can discover and propose; deterministic code calculates; reviewer principals decide. Database state records every step, finding, approval and audit event so a conversation is never the source of truth.

Control

What it enforces

Explicit source contracts

Profiling exposes aggregates and approved category domains. Units, financial classifications and relationships require evidence.

Review gates

Ambiguous, metric-bearing, PII and unit-mismatched proposals require review. Unsupported metrics remain NEEDS_EVIDENCE.

Bound approvals

A reviewer approves a specific content hash. Changes, revocation and expiry invalidate authority; the run starter cannot approve its own run.

Independent reconciliation

Generated metrics execute in a disposable sandbox and are compared with Python reference calculations, with monetary values exact to the cent.

Recoverable publication

Execution leases fence stale workers; publication verifies the certified files and recovers across filesystem/database failure windows.

Architecture and design decisions explain the implementation and its trust boundaries.

What the October audit changed

A ten-agent audit found 23 numbered findings, including a case where account_type='Revenue' turned a 100.00 credit into 0.00 recognized revenue while every check passed. The SQL and Python calculators agreed because both assumed lowercase canonical categories. Independent arithmetic had not provided an independent check of accounting meaning.

The remediation makes financial categories executable contracts: unknown or null classifications block affected metrics, and case normalization requires a reviewed transform. It also repairs rejected relationships resurfacing in generated SQL, cached steps bypassing revoked approvals, and stale-worker publication. The remediation record maps the findings to fixes and regression coverage, including tests that reproduce the financial failure through actual dbt execution. The original audit and probes remain available.

Passing a fixture suite was not enough to catch those boundary failures. The release status identifies which revision and checks verify the repairs.

My role

I wanted to explore how AI-assisted data onboarding can remain auditable when financial definitions, source schemas and units disagree. I chose the portfolio direction, reviewed recommendations and decided which capabilities to pursue. I used AI coding tools extensively for implementation, tests, audits and documentation. I present the resulting prototype with its evidence and failures visible, and distinguish automated review from independent human validation.

Develop and operate

uv run poe fixtures       # synthetic source databases
uv run poe test           # general suite; PostgreSQL tests run separately
uv run poe eval           # pinned golden evaluation cases
uv run poe cov-metrics    # reference-calculator branch coverage
uv run poe lint
uv run poe typecheck

If uv is installed as a Python module but unavailable on PATH, use python -m uv.

For a manual run, export the review packet, record decisions as a separate reviewer, then resume:

uv run portco run --fixture portco_a
uv run portco review <run_id> --export review.yaml
uv run portco review <run_id> --import review.yaml --reviewer alice --default approve
uv run portco resume <run_id>

The blanket approval flag above is for the supported synthetic walkthrough. Inspect and edit individual decisions for other inputs. Certification is a separate gate before publication; the agent walkthrough and operations guide cover the complete workflow, MCP setup, identity, recovery and deployment configuration. Source contracts: CSV · PostgreSQL.

Evaluation and limits

Supported-fixture results demonstrate the workflow and its checks. Unfamiliar-schema experiments also preserve failed safety gates, wrong proposals and substantial review effort. The original probe matched 0/10 targets; later remediation on a frozen corpus is feedback-informed, not fresh held-out validation. Evaluation and limitations brings the results, denominators and evidence boundaries together.

The financial demonstration uses synthetic data. A real historical retail exercise proves bounded ingestion/profiling only. There is no accepted live backend, warehouse publication, independent human usability study or measured business impact. The optional LLM judge defaults off; the local semantic executor supports a bounded subset rather than full MetricFlow compatibility. The project runs locally with a free GitHub Pages presentation; paid hosting remains optional.

Release status is the source for version-specific verification. Documentation gives the reading path and operator references; the archive retains historical planning and acceptance records.

Available Tools

12 tools
certify_runA

Certify the generated bundle and its metrics. Reviewer principals only.

    `subject_hash` is the `subject_hash` of the pending certification items: it binds the approval to the
    exact packet under review (bundle, tests, waivers, open findings). `metric_decisions` maps
    metric -> approve|reject; unknown metric names are rejected, unlisted metrics are approved. Rejected
    metrics (and metrics derived from them) are not published.
    

Inputs: run_id (required), subject_hash (required), comment, bundle_decision, +1 more. Returns: gate, run_id, reviewer, decisions, +3 more

generate_dbt_artifactsA

Generate the dbt project and semantic layer from the reviewed mapping.

    Requires `approval_id` from submit_mapping_review; the server verifies it exists, is not revoked
    or expired, belongs to this run, and is bound to the current mapping content (no boolean flags).
    

Inputs: run_id (required), approval_id (required). Returns: files, models, run_id, status, +4 more

get_run_statusC
Read-onlyIdempotent

Current status, step history, gate and pending review items of a run.

Inputs: run_id (required). Returns: gate, error, steps, run_id, +8 more

healthcheckA
Read-onlyIdempotent

Return service health for diagnostics.

Inputs: no named parameters. Returns: status, version, database, schema_version

list_pending_reviewsC
Read-onlyIdempotent

Review items a human must decide before the run can continue.

Inputs: run_id (required). Returns: result

profile_schemaA

Profile a source read-only: row counts, null rates, distinct counts, patterns, PII classes.

    Aggregates only (`sample_rows=0` by construction); values never leave the source adapter.
    Starts a run that pauses after profiling; continue it with propose_canonical_mapping.
    

Inputs: connection_id (required), schemas. Returns: run_id, status, tables, findings, +3 more

propose_canonical_mappingA

Infer entities and joins and propose canonical mappings for a profiled run.

Deterministic scoring; anything uncertain, PII-bearing, metric-bearing or conflicting is routed to human review rather than guessed. Stops at the mapping-review gate.

Inputs: run_id (required). Returns: joins, run_id, status, proposals, +8 more

publish_runA
DestructiveIdempotent

Publish certified artifacts. Fails closed without a valid certification bound to the bundle.

Inputs: run_id (required), certification_id (required). Returns: path, reused, run_id, status, +4 more

resume_runA

Continue a paused or failed run. Gates re-check approvals; completed steps are reused, not recomputed.

Inputs: run_id (required). Returns: gate, error, steps, run_id, +8 more

run_sandbox_testsA

Build the generated project with dbt in a disposable sandbox and reconcile metrics exactly.

On success the run pauses at the certification gate; on failure at the test-failures gate.

Inputs: run_id (required). Returns: cached, passed, run_id, status, +6 more

start_onboarding_runA

Start read-only onboarding of a registered source (e.g. fixture:portco_a).

    Runs connection validation, profiling, entity and join inference and canonical mapping,
    then stops at the first human review gate. Returns the run status and pending review items.
    

Inputs: connection_id (required), company_id. Returns: gate, error, steps, run_id, +8 more

submit_mapping_reviewA

Record a reviewer's decisions for an observed mapping or test-failure packet.

    Decisions: approve | reject | approve_with_override (override keys: canonical_field, transform,
    pii_handling). Supply the exact subject_hash and gate returned by list_pending_reviews.
    Stale packets are rejected. Certification must use certify_run. Reviewer principals only.
    

Inputs: gate (required), run_id (required), decisions (required), subject_hash (required), +1 more. Returns: gate, run_id, reviewer, decisions, +3 more

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 12 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes along the pipeline (start, profile, propose, generate, test, publish). However, list_pending_reviews overlaps with get_run_status (both return pending review items), and submit_mapping_review vs certify_run both handle reviewer decisions with subject_hash, which could cause confusion without close reading.

    Naming Consistency4/5

    Nearly all tools follow a consistent verb_noun snake_case pattern (list_pending_reviews, start_onboarding_run, generate_dbt_artifacts). The lone outlier is healthcheck, which is a noun with no verb, a minor deviation.

    Tool Count5/5

    12 tools is well-scoped for a multi-stage data onboarding pipeline with human review gates, artifact generation, testing, and publishing. Each tool appears to own a distinct lifecycle step, with no redundant entries.

    Completeness4/5

    The core lifecycle is covered: start, status, resume, profile, propose, review, certify, generate, test, publish. Minor gaps exist, such as no cancel/abort run, no list-runs tool, and no way to retrieve generated artifacts or open findings directly for inspection.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      A deterministic MCP server that governs read-only queries across multiple data sources, returning answers with full provenance (every row cited) or a typed refusal, ensuring LLM answers are traceable and contract-enforced.
      1
      Apache 2.0
    • A
      license
      B
      quality
      D
      maintenance
      A local, evidence-driven MCP runtime and control plane for open-source maintainers that provides workspace-bounded tools including controlled file operations, command execution, validation primitives, durable execution records, and human review workflows via stdio and Streamable HTTP transports.
      33
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Local-first MCP server for data quality that finds suspicious data, explains findings with evidence, tracks drift, and supports human-approved, reversible repair workflows. Deterministic by default, with AI optional.
      25
      264 PyPI
      2
      Apache 2.0
    • F
      license
      A
      quality
      C
      maintenance
      An MCP server that exposes governance, trust-scoring, compliance, guardrail, cost, drift, and supply-chain scanning tools and resources to any MCP client over stdio, Streamable HTTP, or legacy HTTP+SSE. It lets agents route every tool call through a deterministic five-way decision (allow, redact, require approval, deny, or quarantine) with hash-chained evidence, human approval workflows, and in-agent trust gates for LangChain, LangGraph, and Google ADK.
      30
      -