Skip to content

Fix artist socials calls over full MCP OAuth - #1300

Merged
sidneyswift merged 1 commit into
mainfrom
codex/mcp-artist-socials
Nov 26, 2026
Merged

sidneyswift merged 1 commit into
mainfrom
codex/mcp-artist-socials

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Full OAuth now wraps raw registered Zod field maps in an object schema before its own validation. get_artist_socials was discoverable because the MCP SDK accepts a field map, but execution failed before the ownership check because that map has no .parse() method. The tool description now points callers to the artist account_id returned by list_artists.

Evidence

  • Reproduced the generic failure using an artist account ID returned by the connected production account.
  • A regression test using the real artist-socials registrar failed before the fix and now returns the saved profile response with the correct defaults, accepts explicit pagination and history, and rejects an access denial and caller-supplied owner override before executing the read.
  • The OAuth suite passed 335 tests. Targeted route, registry and ownership tests, OAuth typechecking, lint and formatting also passed.
  • Production readback with the same connected account is pending deployment. The OpenAI draft remains unsubmitted.

Merge Danger

Door Two-way. The fix changes schema normalization in the full OAuth adapter. Existing object and discriminated-union schemas, ownership checks, scopes and tool handlers are retained.


Summary by cubic

Fixes get_artist_socials failing under full MCP OAuth. The SDK accepts raw Zod field maps, but the OAuth adapter needs an object schema to validate and parse arguments, so execution failed before the ownership check. The fix wraps raw shapes in z.object() during registration, and the tool notice now points callers to the artist account_id returned by list_artists.

Written for commit 0dcca78. Summary will update on new commits.

View guided diff Turn on auto-fix

@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
api Ready Ready Preview Nov 26, 2026 6:34pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T18:36:14.408539Z 0dcca78 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3 issues found across 3 files

Confidence score: 3/5

  • fullOAuthToolPolicy.ts tells callers to use an account_id, but list_artists returns id; callers may fail to identify the artist account. Update the guidance to use the returned id as artist_account_id.
  • fullOAuthToolPolicy.ts and registerFullOAuthTools.ts are both well over the 100-line limit, making the policy inventory and registration logic harder to maintain. Split them into smaller, focused modules.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/mcp/oauth/registerFullOAuthTools.ts">

<violation number="1" location="lib/mcp/oauth/registerFullOAuthTools.ts:110">
P2: Custom agent: **Enforce Clear Code Style and Maintainability Practices**

This module is 283 lines, well over Rule 3’s 100-line limit, and combines schema normalization, policy selection, authorization, and tool registration. Split these responsibilities into focused modules under the limit.</violation>
</file>

<file name="lib/mcp/oauth/fullOAuthToolPolicy.ts">

<violation number="1" location="lib/mcp/oauth/fullOAuthToolPolicy.ts:47">
P2: Custom agent: **Enforce Clear Code Style and Maintainability Practices**

This policy file is 239 lines, well above the rule’s 100-line limit, and this entry expands it further. Split the policy inventory into smaller modules.</violation>

<violation number="2" location="lib/mcp/oauth/fullOAuthToolPolicy.ts:47">
P2: Custom agent: **Flag AI Slop and Fabricated Changes**

`list_artists` returns each artist as `{ id, name }`, not with an `account_id` field. Tell callers to use the returned `id` as `artist_account_id`.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant Client as MCP Client
    participant SDK as MCP SDK
    participant Adapter as OAuth Adapter (registerFullOAuthTools)
    participant Policy as Tool Policy (fullOAuthToolPolicy)
    participant Handler as Tool Handler (getArtistSocials)
    participant Data as Data Layer (Supabase)

    Note over Client,Data: get_artist_socials via Full MCP OAuth

    Client->>SDK: Call get_artist_socials with args
    SDK->>Adapter: Invoke registered tool
    Adapter->>Adapter: Normalize input schema
    alt Raw Zod shape (e.g. field map)
        Adapter->>Adapter: Wrap in z.object() for validation
    else Object schema
        Adapter->>Adapter: Use as-is
    end

    Adapter->>Adapter: Validate and parse args (z.object().parse())
    alt Valid args
        Adapter->>Policy: Check tool policy
        Policy-->>Adapter: readOnly, openWorld=false, notice
        alt Ownership check
            Adapter->>Adapter: Verify account_id belongs to connected owner
            alt Owned account
                Adapter->>Handler: Execute getArtistSocials({ artist_account_id, page, limit, history })
                Handler->>Data: Query artist socials
                Data-->>Handler: Profile with socials + pagination
                Handler-->>Adapter: Return profile
                Adapter-->>SDK: CallToolResult (success)
                SDK-->>Client: Socials profile
            else Unauthorized account
                Adapter-->>SDK: Error (access denied)
                SDK-->>Client: Tool error
            end
        end
    else Invalid args
        Adapter-->>SDK: Validation error
        SDK-->>Client: Invalid arguments
    end

    Note over Client: Caller should use artist_account_id from list_artists
Loading

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

View guided diff | Turn on auto-fix | Re-trigger cubic

@@ -36,7 +36,11 @@ export function registerFullOAuthTools(
) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Custom agent: Enforce Clear Code Style and Maintainability Practices

This module is 283 lines, well over Rule 3’s 100-line limit, and combines schema normalization, policy selection, authorization, and tool registration. Split these responsibilities into focused modules under the limit.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/mcp/oauth/registerFullOAuthTools.ts, line 110:

<comment>This module is 283 lines, well over Rule 3’s 100-line limit, and combines schema normalization, policy selection, authorization, and tool registration. Split these responsibilities into focused modules under the limit.</comment>

<file context>
@@ -102,13 +106,15 @@ export function registerFullOAuthTools(
-    const originalObject =
-      config.inputSchema instanceof z.ZodObject ? config.inputSchema : undefined;
+    // The MCP SDK accepts raw Zod shapes. The OAuth adapter also parses them itself.
+    const registeredSchema =
+      config.inputSchema instanceof z.ZodType ? config.inputSchema : z.object(config.inputSchema);
+    const originalObject = registeredSchema instanceof z.ZodObject ? registeredSchema : undefined;
</file context>

readOnly: true,
destructive: false,
openWorld: false,
notice: "Use the artist account_id returned by list_artists as artist_account_id.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Custom agent: Enforce Clear Code Style and Maintainability Practices

This policy file is 239 lines, well above the rule’s 100-line limit, and this entry expands it further. Split the policy inventory into smaller modules.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/mcp/oauth/fullOAuthToolPolicy.ts, line 47:

<comment>This policy file is 239 lines, well above the rule’s 100-line limit, and this entry expands it further. Split the policy inventory into smaller modules.</comment>

<file context>
@@ -40,7 +40,12 @@ export const fullOAuthToolPolicy: Record<string, ToolPolicy> = {
+    readOnly: true,
+    destructive: false,
+    openWorld: false,
+    notice: "Use the artist account_id returned by list_artists as artist_account_id.",
+  },
   artist_deep_research: { readOnly: true, destructive: false, openWorld: false },
</file context>

readOnly: true,
destructive: false,
openWorld: false,
notice: "Use the artist account_id returned by list_artists as artist_account_id.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Custom agent: Flag AI Slop and Fabricated Changes

list_artists returns each artist as { id, name }, not with an account_id field. Tell callers to use the returned id as artist_account_id.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/mcp/oauth/fullOAuthToolPolicy.ts, line 47:

<comment>`list_artists` returns each artist as `{ id, name }`, not with an `account_id` field. Tell callers to use the returned `id` as `artist_account_id`.</comment>

<file context>
@@ -40,7 +40,12 @@ export const fullOAuthToolPolicy: Record<string, ToolPolicy> = {
+    readOnly: true,
+    destructive: false,
+    openWorld: false,
+    notice: "Use the artist account_id returned by list_artists as artist_account_id.",
+  },
   artist_deep_research: { readOnly: true, destructive: false, openWorld: false },
</file context>
Suggested change
notice: "Use the artist account_id returned by list_artists as artist_account_id.",
+ notice: "Use the artist id returned by list_artists as artist_account_id.",

@sidneyswift
sidneyswift merged commit 36ec307 into main Nov 26, 2026
9 checks passed

This branch was successfully deployed

1 active deployment
Preview — 0dcca78a Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant