Skip to content

feat(mcp-server-supabase): add bounded cost lifecycle observations - #428

Merged
barryroodt merged 37 commits into
mainfrom
feat/mcp-observability-cost
Oct 14, 2026
Merged

barryroodt merged 37 commits into
mainfrom
feat/mcp-observability-cost

Conversation

@barryroodt

@barryroodt barryroodt commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Why

Platform measures how Supabase cost confirmations for create_project and create_branch behave, without shipping payloads. This is part of AI-1273, building on #427, with #455 adding SQL confirmation facts.

What changed

  • Supabase owns concrete tool and fact types plus observer aliases, and classifies tools with a CURRENT_ELICITATION_TOOLS lookup; mcp-utils supplies the generic core.
  • create_project and create_branch report confirmation decisions and protected-operation durations that exclude observer recording latency. Consumed responses set the outcome before fact dispatch or changed-quote validation.
  • Built-in facts contain bounded values without raw arguments, results, state or errors. Custom fact producers remain responsible for privacy.
  • Existing confirmation behavior stays intact. With no observer, no facts or timings are recorded.

How to test

pnpm test:packed-platform-consumer

All 3 packed-consumer checks pass.

Trade-offs

  • Hosts own collection; synchronous observers can block despite failure isolation.
  • Packed checks don't cover branch or cancellation paths.

@barryroodt barryroodt self-assigned this Sep 11, 2026
@barryroodt barryroodt added the publish-preview Runs `publish-preview` workflow to publish preview packages via https://pkg.pr.new/ label Sep 30, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/@supabase/mcp-server-postgrest@8fa5166
pnpm add https://pkg.pr.new/@supabase/mcp-server-supabase@8fa5166
pnpm add https://pkg.pr.new/@supabase/mcp-utils@8fa5166

commit: 8fa5166

@barryroodt
barryroodt marked this pull request as ready for review October 5, 2026 14:57
@barryroodt
barryroodt requested a review from a team as a code owner October 5, 2026 14:57
Comment thread CONTRIBUTING.md Resolved
Comment thread README.md

## Observability

Pass an `observer` to `createMcpServer` to collect request lifecycle results and facts recorded by your tools:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why renaming createMcpServer to createSupabaseMcpServer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a rename: #427 documents the generic createMcpServer from mcp-utils; this PR wires the observer into the Supabase server, so the root README now shows createSupabaseMcpServer.

@barryroodt
barryroodt requested a review from raulb October 6, 2026 14:26

@raulb raulb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barryroodt approved with some small nits.

barryroodt added a commit that referenced this pull request Oct 14, 2026
## Why

Platform measures hosted MCP request lifecycles (attempts, outcomes and
durations) without shipping request payloads. This adds the generic core
for that work in
[AI-1273](https://linear.app/supabase/issue/AI-1273/observability-for-mcp-elicitations-and-requests),
and [#428](#428) supplies
Supabase-owned types and cost facts.

## What changed

- `createMcpServer` accepts an optional `observer` and an optional
`classifyTool` function that maps a tool name to a host-defined bucket
or `other`. Only `tools/call` contexts include a tool bucket; other
contexts contain only the method.
- Tools receive an optional handle with `record` and `setOutcome`.
Outcomes don't depend on fact contents. Errors and `input_required`
retain precedence.
- Core forwards no request payloads automatically. Custom fact producers
remain responsible for privacy.
- With no observer, no facts or timings are recorded. `onToolCall` stays
unchanged.

## How to test

```sh
pnpm --filter @supabase/mcp-utils exec vitest run
```

36 tests pass.

## Trade-offs

- The host owns collection and export; duration excludes transport and
human waiting.
- Observer factory, `classifyTool` and sink failures are isolated, but
synchronous observer and classifier work can still block requests.
@barryroodt
barryroodt changed the base branch from feat/mcp-observability-lifecycle to main October 14, 2026 08:47
…y-cost

# Conflicts:
#	README.md
#	packages/mcp-server-supabase/src/tools/account-tools.ts
#	packages/mcp-server-supabase/src/tools/branching-tools.ts
#	scripts/fixtures/packed-platform-consumer/types-check.ts
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 38538780174

Warning

No base build found for commit 443170f on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 97.275%

Details

  • Patch coverage: 173 of 173 lines across 5 files are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 4616
Covered Lines: 4512
Line Coverage: 97.75%
Relevant Branches: 779
Covered Branches: 736
Branch Coverage: 94.48%
Branches in Coverage %: Yes
Coverage Strength: 95.36 hits per line

💛 - Coveralls

@barryroodt
barryroodt merged commit 657d1f3 into main Oct 14, 2026
6 checks passed
@supabase-releaser supabase-releaser Bot mentioned this pull request Oct 14, 2026
barryroodt added a commit that referenced this pull request Oct 14, 2026
## Why

Platform measures destructive-SQL confirmations for `execute_sql` and
`apply_migration` alongside cost confirmations. This adds those facts
for
[AI-1273](https://linear.app/supabase/issue/AI-1273/observability-for-mcp-elicitations-and-requests),
stacked on [#428](#428).

## What changed

`execute_sql` and `apply_migration` report confirmation decisions,
successful issuance, consumed responses, resume validation, and backend
operations. Supabase owns these concrete facts; `mcp-utils` stays
generic.

The shared SQL gate stages confirmation facts and outcomes, applying
outcomes before dispatching facts. A non-destructive bypass discards
both. Accepted valid resumes still skip classification, preserving
existing SQL policy and cost behavior.

Built-in facts contain finite values and durations without payloads or
IDs; custom producers remain responsible for privacy. Outcomes stay
independent of fact contents. With no observer, no facts or timings are
recorded.

## How to test

```sh
pnpm test:packed-platform-consumer
```

All 3 packed-consumer checks pass, including ESM/CJS SQL confirmation
flows.

## Trade-offs

- Hosts own collection; [platform
#39142](supabase/platform#39142) includes SQL
observations. Secret collection belongs in a separate PR stacked on this
one.
- Synchronous observers can block despite failure isolation.
barryroodt pushed a commit that referenced this pull request Oct 14, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>mcp-utils: 0.9.0</summary>

##
[0.9.0](mcp-utils-v0.8.0...mcp-utils-v0.9.0)
(2026-10-14)


### Features

* **mcp-utils:** add bounded request lifecycle observations
([#427](#427))
([b11d62b](b11d62b))
</details>

<details><summary>mcp-server-supabase: 0.14.0</summary>

##
[0.14.0](mcp-server-supabase-v0.13.0...mcp-server-supabase-v0.14.0)
(2026-10-14)


### Features

* **advisors:** add health advisor support
([#420](#420))
([8a26508](8a26508))
* **mcp-server-supabase:** add bounded cost lifecycle observations
([#428](#428))
([657d1f3](657d1f3))
* **mcp-server-supabase:** add destructive SQL observations
([#455](#455))
([4595698](4595698))


### Bug Fixes

* **mcp:** clarify cost and deploy tool descriptions for OpenAI scanner
([#467](#467))
([1f9da03](1f9da03))
* **mcp:** stop double cost confirmation on create_project and
create_branch ([#468](#468))
([3c3b1fc](3c3b1fc))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

publish-preview Runs `publish-preview` workflow to publish preview packages via https://pkg.pr.new/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants