Repository navigation
feat(mcp): get_published_posts and get_published_post_stats tools - #1246
sweetmantech wants to merge 2 commits into
Conversation
Extract getPosts and getPostStats from the GET /api/posts and
GET /api/posts/{id}/stats handlers so REST and MCP share one read each.
Register both tools, classify them in the full OAuth policy, the OAuth
tool inventory and the qualification map.
Tracking: recoupable/app#2399
Contract: recoupable/docs#40
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pre-merge checks:
|
|
Preview checks against
Why not run: the preview host is behind Vercel Authentication and only answers through a share link, which works for plain GETs only. The MCP checks need authenticated POSTs from a sandbox with a preview credential, and that setup was refused in this session. The happy path also needs a credential for the account that owns Tom's posts. Locally, the unit tests cover every tool-error path and the full suite passes (1496 files, 9593 tests). Kept as draft; not merging. Generated by Claude Code |
|
MCP preview checks against
Note: like the other tools, a domain error comes back as Kept as draft; not merging. Generated by Claude Code |
Resolve fullOAuthToolPolicy and fullOAuthCatalog conflicts: adopt main's readOnly/destructive/openWorld policy shape, classify get_published_posts (closed world) and get_published_post_stats (LinkedIn, open world), and raise the delegated catalog counts to 96 tools, 95 non-app. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Before: an MCP agent could not list the posts Recoup published or read their LinkedIn numbers.
GET /api/postsandGET /api/posts/{id}/statsexisted only over REST, andget_artist_postsreturns scraped posts, which carry no post id that stats can take.After: two MCP tools mirror those routes.
get_published_postslists the credential account's posts with optionalartist_account_id,platform,status,limit(max 50) andoffset, in the REST{ status, posts }envelope.get_published_post_statstakes a postidand returns the REST{ status, stats }envelope: LinkedIn company-page posts only, credits checked before LinkedIn is called, $0.001 charged after a successful read. REST rejections come back as tool errors with the same message.How:
lib/publishing/getPosts.tsandlib/publishing/stats/getPostStats.tshold the reads the handlers used to do inline; both handlers now call them, with REST bodies and status codes unchanged.getPostStatsreturnsok,insufficient_creditsorrejected(with the REST status and message). It gates withcheckCreditsAvailable, and the handler builds the same 402 bodyensureCreditsOrShortCircuitdid, so the three handler test files now mockcheckCreditsAvailableinstead.lib/mcp/tools/posts/, registered fromlib/mcp/tools/index.ts. Noaccount_idinput; the account comes fromresolveAccountId.fullOAuthToolPolicy.ts(main'sreadOnly/destructive/openWorldshape):get_published_postsis read-only, not destructive, closed world;get_published_post_statsis read-only, not destructive, open world (LinkedIn via Composio) with a $0.001 notice. Both are pinned in thefullOAuthCatalogannotation table.tool-policy.json:mcp:readfor the list,mcp:read+mcp:spendfor stats (likesearch_web). Two rows indocs/mcp-oauth-tool-qualification.md. Delegated catalog 96 tools, 95 non-app (main is at 94/93).Tests (red first):
getPosts.test.ts,getPostStats.test.ts(each rejection, credit shortfall, LinkedIn 502, DB error), and register-tool tests for both tools. After merging main on Nov 18: full suite 1,531 files, 10,055 tests passed; eslint and prettier clean on changed files. Preview checks: see the results comment (run on the pre-merge commit; the tool code is unchanged by the merge).Merge sequencing: docs#40 (contract) -> this PR -> docs follow-up pinning the operation inventory.
Tracking: recoupable/app#2399
Generated by Claude Code