Skip to content

feat: unify MCP slug availability across toolsets and mcp_endpoints - #5917

Merged
daviddanialy merged 5 commits into
mainfrom
daviddanialy/aim-22-unify-mcp-slug-availability
Sep 1, 2026
Merged

feat: unify MCP slug availability across toolsets and mcp_endpoints#5917
daviddanialy merged 5 commits into
mainfrom
daviddanialy/aim-22-unify-mcp-slug-availability

Conversation

@daviddanialy

@daviddanialy daviddanialy commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

AIM-22

Summary

  • Adds a single slug-availability check, mcpendpoints.CheckSlugAvailable, backed by a new CheckUnifiedSlugAvailability query that answers "is (custom_domain_id, slug) taken" against both mcp_endpoints.slug and toolsets.mcp_slug in the same address scope (platform vs custom domain). The endpoint-only CheckSlugAvailability query is deleted.
  • Two owner exclusions keep self-validation honest while both representations coexist: a toolset does not collide with its own row or its wrapper's endpoints, and a server does not collide with its own backing toolset.
  • Callers switched: both uniqueness branches in updateToolset, the toolsets availability handler (now platform-scoped rather than a cross-namespace global EXISTS; wire contract unchanged), and mcpendpoints create/update/check. Create checks inside the transaction after locks; update only re-checks when the (slug, domain) address actually changes.
  • Dashboard: useMcpEndpointSlugValidation drops its second RPC to toolsets.checkMCPSlugAvailability.

Motivation

toolsets.mcp_slug and mcp_endpoints.slug each had their own partial unique indexes and their own availability query, and neither saw the other table — while every public entry point resolves mcp_endpoints first and falls back to toolsets.mcp_slug. An endpoint created with a live hosted server's slug would silently take over that address. This makes availability a single namespace per scope for as long as the two representations coexist, and is the first step of the toolsets-under-mcp_servers migration (the toolset-side query is removed later with the runtime fallback).

🤖 Generated with Claude Code

https://claude.ai/code/session_01TCzhsvUYz5VMieXYaQUC2Z


Summary by cubic

Unifies MCP slug availability across toolsets.mcp_slug and mcp_endpoints.slug into one namespace per address scope (AIM-22). Previously each table checked only itself, so an endpoint could take over a slug a live hosted server still resolved under; now a slug held by either table blocks the other.

Refactors

  • Replaces the endpoint-only CheckSlugAvailability query with CheckUnifiedSlugAvailability, probing both tables in the same address scope, and adds a pg_advisory_xact_lock on write paths that serializes competing claims the per-table unique indexes can't catch.
  • Owner exclusions let a hosted server's mirrored address validate against itself; updateToolset re-probes on any effective (slug, domain) change and skips the domain-liveness guard so a rename under a soft-deleted domain still works.
  • mcpEndpoints create/update, SetRootMcpEndpoint, and toolset create/clone now take the lock and shared check; generated toolset slugs regenerate on collision. The dashboard drops its second RPC, while toolsets.checkMCPSlugAvailability stays for the inline editor — now deprecated, auth-gated, and faulting on endpoint slugs too.

Written for commit a5c0993. Summary will update on new commits.

Review in cubic

@daviddanialy daviddanialy added the enhancement New feature or request label Aug 31, 2026
@daviddanialy
daviddanialy requested a review from a team as a code owner August 31, 2026 22:06
@daviddanialy daviddanialy added the go Pull requests that update go code label Aug 31, 2026
@daviddanialy
daviddanialy requested a review from a team as a code owner August 31, 2026 22:06
@linear-code

linear-code Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

AIM-22

@changeset-bot

changeset-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a5c0993

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
server Patch
dashboard Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Running ultrareview automatically — This change unifies MCP slug availability across two tables with a complex cross-table SQL query and owner-exclusion logic; a subtle bug could silently break runtime address resolution or block legitimate operations, warranting deep review.. I'll post findings when complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ultrareview completed in 7m 47s

All reported issues were addressed across 9 files

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread server/internal/toolsets/impl.go Outdated
Comment thread server/internal/mcpendpoints/slugavailability.go
Comment thread server/internal/toolsets/impl.go Outdated
Comment thread server/internal/toolsets/impl.go Outdated
Comment thread server/internal/mcpendpoints/impl.go
Comment thread server/internal/mcpendpoints/impl.go
Comment thread server/internal/mcpendpoints/queries.sql
Comment thread client/dashboard/src/pages/mcp/x/useMcpEndpointSlugValidation.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 8 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread server/internal/mcpendpoints/queries.sql Outdated
Comment thread server/internal/toolsets/queries.sql
@daviddanialy

Copy link
Copy Markdown
Contributor Author

End-to-end verification (this PR's changes)

Context: all three Phase-1 branches (#5917, #5918, #5919) were merged into a scratch tree (zero conflicts), the full server suite ran on the merged tree — 14,334 tests, 1 failure: a pre-existing skills-subsystem clock flake, passes in isolation, unrelated to these PRs — and a local stack was booted from the merged tree with simulated backfill rows (a toolset-backed mcp_servers wrapper + mcp_endpoints row) to exercise the dormant paths over real HTTP.

Scenarios exercising this PR:

Scenario Result Evidence
RPC endpoint-create claiming a live toolset's mcp_slug PASS 409 conflict — on main this silently succeeds and the endpoint shadows the toolset at serve time
RPC toolset mcp_slug update into an existing endpoint's slug PASS 409 "this slug is already taken"; control update to a free slug → 200
Org-prefix rule (incidental) PASS un-prefixed platform slug → 422

No panics or unexpected errors in server logs. All test rows and flag changes were reverted after the run (verified by query).

🤖 Generated with Claude Code

@daviddanialy
daviddanialy added this pull request to the merge queue Sep 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 1, 2026
@daviddanialy
daviddanialy added this pull request to the merge queue Sep 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 1, 2026
@daviddanialy
daviddanialy added this pull request to the merge queue Sep 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 1, 2026
@daviddanialy
daviddanialy added this pull request to the merge queue Sep 1, 2026
@daviddanialy
daviddanialy removed this pull request from the merge queue due to a manual request Sep 1, 2026
@daviddanialy
daviddanialy added this pull request to the merge queue Sep 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 1, 2026
@daviddanialy
daviddanialy added this pull request to the merge queue Sep 1, 2026
Merged via the queue into main with commit 81e2a93 Sep 1, 2026
44 of 45 checks passed
@daviddanialy
daviddanialy deleted the daviddanialy/aim-22-unify-mcp-slug-availability branch September 1, 2026 17:43
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants