Skip to content

chore: remove dead get_social_posts tool#1694

Closed
arpitgupta1214 wants to merge 5 commits into
testfrom
feat/chat-social-posts-migration
Closed

chore: remove dead get_social_posts tool#1694
arpitgupta1214 wants to merge 5 commits into
testfrom
feat/chat-social-posts-migration

Conversation

@arpitgupta1214

@arpitgupta1214 arpitgupta1214 commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Cut the get_social_posts AI tool off the legacy api.recoupable.com/api/social/posts URL and onto ${getClientApiBaseUrl()}/api/socials/{social_id}/posts with a Privy Authorization: Bearer header threaded through getMcpTools.

Test plan

  • API preview (row 18) deployed with /api/socials/{id}/posts live
  • E2E smoke — blocked-on-api-merge: tool() execute runs server-side, so the ?api=<preview> override (browser-only via sessionStorage) does not reach this fetch. Smoke will run once the api PR merges to test and chat preview rebuilds against recoup-api.vercel.app
  • Verify devtools / server logs: requests hit /api/socials/{social_id}/posts with Authorization: Bearer ...
  • Confirm posts[].post_url, posts[].updated_at, and pagination.total_count render unchanged via an agent prompt that chains get_artist_socialsget_social_posts

Summary by cubic

Removed the dead get_social_posts tool and the chat-hosted Posts docs so chat relies on the API MCP server for /api/socials/{id}/posts. This cleans up unused code and avoids drift with the canonical docs.

  • Refactors
    • Deleted lib/tools/getSocialPosts.ts and removed its registration from getMcpTools.
    • Updated getMcpTools to accept _accessToken (unused placeholder).
    • Removed /docs/posts page and constants; canonical docs live in the Mintlify docs submodule.

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

Cut the hardcoded https://api.recoupable.com/api/social/posts URL over to
${getClientApiBaseUrl()}/api/socials/${social_id}/posts. The social_id
moves from query param to path segment. Adds Authorization: Bearer header
sourced from the Privy access token threaded through getMcpTools.
@vercel

vercel Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
recoup-chat Ready Ready Preview Apr 22, 2026 9:27pm

Request Review

@coderabbitai

coderabbitai Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@arpitgupta1214 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 36 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 8 minutes and 36 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6a44c5b9-c001-4979-82ae-5838d91929b4

📥 Commits

Reviewing files that changed from the base of the PR and between 41350d2 and 9961374.

📒 Files selected for processing (2)
  • lib/tools/getMcpTools.ts
  • lib/tools/getSocialPosts.ts
📝 Walkthrough

Walkthrough

Documentation pages for the Posts API endpoint are removed entirely. The getSocialPosts tool is refactored into a higher-order function requiring an access token parameter, with the API endpoint restructured to use a dynamic base URL and path-based routing. Authentication is now passed via Bearer token headers.

Changes

Cohort / File(s) Summary
Documentation Removal
app/docs/posts/constants.ts, app/docs/posts/page.tsx
Deleted the entire Posts API documentation page and its supporting constants, including code examples, response samples, and schema descriptions.
Tool Authentication Refactoring
lib/tools/getMcpTools.ts, lib/tools/getSocialPosts.ts
Converted getSocialPosts to a higher-order function accepting accessToken parameter; updated API endpoint to use dynamic base URL and path-based routing (/api/socials/${social_id}/posts); added Bearer token authorization header; refactored getMcpTools to accept and pass accessToken to wrapped tool.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • recoupable/chat#1686 — Modifies getMcpTools.ts function signature and tool mappings in parallel.
  • recoupable/chat#1620 — Introduces getClientApiBaseUrl utility and refactors tooling/hooks to accept and propagate accessToken.

Suggested reviewers

  • sweetmantech

Poem

🔐 A token flows through tools anew,
From docs removed, the old bid adieu,
Dynamic paths and headers aligned,
Authentication fully refined! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Solid & Clean Code ❓ Inconclusive Unable to verify code structure without access to actual files or shell execution capability. Provide actual file contents or code snippets to analyze getMcpTools.ts implementation, usage patterns, and adherence to SOLID principles and clean code practices.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/chat-social-posts-migration

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@arpitgupta1214

Copy link
Copy Markdown
Collaborator Author

Smoke test — blocked-on-api-merge

Status: pending api preview

Reason: The AI SDK tool() execute runs server-side (inside Next.js route handlers, not the browser). chat's ?api=<url> override is wired through ApiOverrideSyncsessionStorage.recoup_api_overridegetClientApiBaseUrl() which only applies to browser-resolved calls. Server-side fetches inside tool.execute resolve getClientApiBaseUrl() against the build-time NEXT_PUBLIC_API_BASE_URL (currently recoup-api.vercel.app = test).

Plan: once api PR (row 18 of migration table) lands on test and chat preview rebuilds, run an end-to-end prompt that chains get_artist_socialsget_social_posts and verify:

  • Server logs show fetch against recoup-api.vercel.app/api/socials/<social_id>/posts (path-style, no social_id query param)
  • Request includes Authorization: Bearer <privy_token>
  • LLM response surfaces posts[].post_url, posts[].updated_at, pagination.total_count unchanged

@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.

1 issue found across 2 files

Confidence score: 4/5

  • This PR looks safe to merge overall, with a minor-to-moderate risk item rather than a clear merge blocker.
  • In lib/tools/getSocialPosts.ts, interpolating social_id directly into a URL path can produce malformed routes when IDs include reserved characters, which may cause request failures for some inputs.
  • Given the issue is severity 4/10 (with high confidence), the impact appears limited and straightforward to fix by encoding the path segment.
  • Pay close attention to lib/tools/getSocialPosts.ts - ensure social_id is encoded before building the URL path.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/tools/getSocialPosts.ts">

<violation number="1" location="lib/tools/getSocialPosts.ts:47">
P2: Encode `social_id` before interpolating it into the URL path segment to avoid malformed routes for IDs containing reserved characters.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread lib/tools/getSocialPosts.ts Outdated
Canonical API reference lives in the Mintlify docs submodule
(developers.recoupable.com). The chat-hosted /docs/posts page was
unreferenced (no nav link, no external href) and pointed at the
legacy api.recoupable.com service being retired in Capability 9.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/tools/getSocialPosts.ts (1)

33-60: Nice, clean factory + auth wiring.

Higher-order-function shape cleanly closes over accessToken, preserves the original input schema and error contract, and matches the getTasks/getConversations precedent for Bearer auth — SRP intact, no duplication introduced. One small nit you can take or leave: consider a cheap guard (e.g. throw early when accessToken is falsy) so a misconfigured caller fails loudly instead of sending a bare Authorization: Bearer header that the API will just 401 on.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/tools/getSocialPosts.ts` around lines 33 - 60, Add an early guard in the
getSocialPosts factory to throw if accessToken is falsy so callers fail fast
instead of sending an empty Authorization header; inside the getSocialPosts
function (the outer factory that returns tool({...}) and closes over
accessToken) validate accessToken at the top (before returning the tool or
inside the tool factory before making the fetch) and throw a clear Error (e.g.,
"Missing accessToken for getSocialPosts") so the execute implementation and
caller surface a loud, deterministic failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/tools/getSocialPosts.ts`:
- Around line 46-51: The URL path is built by interpolating social_id directly
into the template string in getSocialPosts (where you create new
URL(`${getClientApiBaseUrl()}/api/socials/${social_id}/posts`)), which can break
if social_id contains slashes or special chars; fix it by percent-encoding the
path segment before interpolation (use encodeURIComponent or an equivalent
path-segment encoder) so the constructed URL becomes
.../api/socials/${encodedSocialId}/posts and keep the rest of the searchParams
logic unchanged.

---

Nitpick comments:
In `@lib/tools/getSocialPosts.ts`:
- Around line 33-60: Add an early guard in the getSocialPosts factory to throw
if accessToken is falsy so callers fail fast instead of sending an empty
Authorization header; inside the getSocialPosts function (the outer factory that
returns tool({...}) and closes over accessToken) validate accessToken at the top
(before returning the tool or inside the tool factory before making the fetch)
and throw a clear Error (e.g., "Missing accessToken for getSocialPosts") so the
execute implementation and caller surface a loud, deterministic failure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b486bdfb-a17d-4465-a97a-0012b4d22b0d

📥 Commits

Reviewing files that changed from the base of the PR and between d31c6da and 41350d2.

📒 Files selected for processing (4)
  • app/docs/posts/constants.ts
  • app/docs/posts/page.tsx
  • lib/tools/getMcpTools.ts
  • lib/tools/getSocialPosts.ts
💤 Files with no reviewable changes (2)
  • app/docs/posts/constants.ts
  • app/docs/posts/page.tsx

Comment thread lib/tools/getSocialPosts.ts Outdated
@arpitgupta1214 arpitgupta1214 changed the title feat: migrate get_social_posts tool to mono/api base URL feat(chat): add GET /api/socials/{id}/posts Apr 22, 2026
The api now returns the canonical posts row (id == posts.id) plus a
derived platform field and the owning social_id. Drop the junction
post_id field; add platform and keep social_id.

@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.

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

The api PR converged on the single-helper selectPosts pattern with
per-post shape {id, post_url, updated_at} — same as the sibling
/api/artists/{id}/posts endpoint. Drop the platform + social_id
fields I briefly added.

@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.

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

The chat UI POSTs /api/chat to the api repo, which loads tools from
its MCP server (lib/mcp/tools/ over there). No get_social_posts tool
is registered there, and getMcpTools in this repo has no in-repo
callers — so this tool definition never executes at runtime. Drop
the dead file and its registration; the underscore on the unused
accessToken param keeps lint happy until the function itself is
cleaned up in a broader pass.

@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.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/tools/getMcpTools.ts">

<violation number="1" location="lib/tools/getMcpTools.ts:19">
P1: `getMcpTools` now ignores the access token and no longer exposes `get_social_posts`, which breaks the social-posts tool path instead of migrating it to the new authenticated endpoint.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread lib/tools/getMcpTools.ts
import getCatalogSongs from "./catalogs/getCatalogSongs";

export function getMcpTools(): ToolSet {
export function getMcpTools(_accessToken: string): ToolSet {

@cubic-dev-ai cubic-dev-ai Bot Apr 22, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: getMcpTools now ignores the access token and no longer exposes get_social_posts, which breaks the social-posts tool path instead of migrating it to the new authenticated endpoint.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At lib/tools/getMcpTools.ts, line 19:

<comment>`getMcpTools` now ignores the access token and no longer exposes `get_social_posts`, which breaks the social-posts tool path instead of migrating it to the new authenticated endpoint.</comment>

<file context>
@@ -17,9 +16,8 @@ import filesTools from "./files";
 import getCatalogSongs from "./catalogs/getCatalogSongs";
 
-export function getMcpTools(accessToken: string): ToolSet {
+export function getMcpTools(_accessToken: string): ToolSet {
   const tools = {
-    get_social_posts: getSocialPosts(accessToken),
</file context>
Fix with Cubic

@arpitgupta1214 arpitgupta1214 changed the title feat(chat): add GET /api/socials/{id}/posts chore: remove dead get_social_posts tool Apr 22, 2026
@arpitgupta1214

Copy link
Copy Markdown
Collaborator Author

Closing — the chat-side lib/tools/getSocialPosts.ts (and in fact the entire getMcpTools pipeline in this repo) has been dead since commit f0e40b7 (Jan 27, 2026), which moved tool setup to the api repo. A targeted removal of just this one tool is less useful than a broader cleanup of the stranded lib/tools/ surface — tracking that as a separate follow-up.

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