bundlesocial-mcp 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +17 -4
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.2.0](https://github.com/bundleglobal/bundlesocial-mcp/compare/v1.1.0...v1.2.0) (2026-07-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* catch up with bundle.social API and SDK 2.61.0 ([d49ee6b](https://github.com/bundleglobal/bundlesocial-mcp/commit/d49ee6b4cf022f8086ae1b725749d789968ff12c))
|
|
7
|
+
|
|
8
|
+
# [1.1.0](https://github.com/bundleglobal/bundlesocial-mcp/compare/v1.0.1...v1.1.0) (2026-05-25)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* additional reference ([5a5133f](https://github.com/bundleglobal/bundlesocial-mcp/commit/5a5133fc5d51f49e8d8dfe8d9effbee129989dc9))
|
|
14
|
+
|
|
1
15
|
## [1.0.1](https://github.com/bundleglobal/bundlesocial-mcp/compare/v1.0.0...v1.0.1) (2026-05-17)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# bundlesocial-mcp
|
|
2
2
|
|
|
3
|
-
[Model Context Protocol](https://modelcontextprotocol.io) server for the [bundle.social](https://bundle.social) social-media API. It lets MCP clients — Claude Desktop, Claude Code, Cursor, and anything else that speaks MCP — post, schedule, list and analyze content across
|
|
3
|
+
[Model Context Protocol](https://modelcontextprotocol.io) server for the [bundle.social](https://bundle.social) social-media API. It lets MCP clients — Claude Desktop, Claude Code, Cursor, and anything else that speaks MCP — post, schedule, list and analyze content across 15+ platforms (X, Instagram, TikTok, LinkedIn, YouTube, Facebook, Pinterest, Reddit, Threads, Bluesky, Mastodon, Discord, Slack, Google Business Profile, Snapchat).
|
|
4
4
|
|
|
5
5
|
It's a thin wrapper over the official [`bundlesocial`](https://www.npmjs.com/package/bundlesocial) Node SDK. Same surface as [`bundlesocial-cli`](https://www.npmjs.com/package/bundlesocial-cli) — posting, comments, media, analytics, team & integration management, and post-history/comment/CSV imports — exposed as MCP tools.
|
|
6
6
|
|
|
@@ -21,12 +21,19 @@ Team-scoped tools take an optional `teamId` — skip it when your org has one te
|
|
|
21
21
|
|---|---|
|
|
22
22
|
| `check_setup` | Self-diagnosis: API key present, API reachable, API key valid, org API access, team resolution, connected integrations, posts quota. Returns `{ ok, checks: [...] }`. Run it first. |
|
|
23
23
|
|
|
24
|
+
### Reference
|
|
25
|
+
|
|
26
|
+
| Tool | Description |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `describe_platform` | Look up the exact per-platform `data.<PLATFORM>` field schema for posts **and** comments — name, type, required flag, notes, capabilities and a ready-to-use example. Pass a `platform` (name/alias) or omit for all; `operation` (`post`/`comment`) narrows it. Call it before `create_post` / `create_comment` when unsure which fields a platform needs. |
|
|
29
|
+
|
|
24
30
|
### Organization & teams
|
|
25
31
|
|
|
26
32
|
| Tool | Description |
|
|
27
33
|
|---|---|
|
|
28
34
|
| `get_organization` | Fetch the organization — id, name, API-access flag, plan limits, teams. |
|
|
29
35
|
| `get_usage` | Posts / comments / uploads usage quotas + a paginated per-account post-import usage breakdown. |
|
|
36
|
+
| `get_daily_limits_usage` | One connected account's daily post/comment allowance (used/limit/remaining) for a day — check it before bulk-scheduling. |
|
|
30
37
|
| `list_teams` | List teams in the organization (paginated, searchable). |
|
|
31
38
|
| `get_team` | Fetch one team by id (incl. its connected integrations). |
|
|
32
39
|
| `create_team` | Create a team (optionally copy another team's social accounts via `copyTeamId`). |
|
|
@@ -49,7 +56,7 @@ Team-scoped tools take an optional `teamId` — skip it when your org has one te
|
|
|
49
56
|
| `copy_integration` | Copy connected accounts between teams (`fromTeamId` → `toTeamId`). |
|
|
50
57
|
| `list_integrations_to_delete` | List social accounts scheduled for deletion (paginated). |
|
|
51
58
|
| `list_integration_tools` | List the read-only platform helper methods callable via `trigger_integration_tool`. |
|
|
52
|
-
| `trigger_integration_tool` | Call a helper: subreddit flairs/requirements, YouTube categories/playlists/regions, LinkedIn mentions, Instagram locations, Google Business categories, TikTok trending music. Use it to discover values the API needs. |
|
|
59
|
+
| `trigger_integration_tool` | Call a helper: subreddit flairs/requirements, YouTube categories/playlists/regions, LinkedIn mentions, Instagram locations/audio/business discovery, Google Business categories, TikTok trending music. Use it to discover values the API needs. |
|
|
53
60
|
|
|
54
61
|
### Posts
|
|
55
62
|
|
|
@@ -62,16 +69,22 @@ Team-scoped tools take an optional `teamId` — skip it when your org has one te
|
|
|
62
69
|
| `delete_post` | Delete a post by id (destructive). |
|
|
63
70
|
| `update_post` | Update an existing post — only the fields you pass change; reuses the post's platforms when changing content without `platforms`. |
|
|
64
71
|
| `retry_post` | Re-attempt a post that ended in `ERROR`. |
|
|
72
|
+
| `get_post_by_reference_key` | Fetch a post by the `referenceKey` set on it, instead of its bundle.social id. |
|
|
73
|
+
| `list_reconnect_candidates` / `reconnect_posts` | List draft/scheduled posts that lost their social account after a disconnect, and reattach them to the newly connected account. |
|
|
74
|
+
|
|
75
|
+
`create_post` / `schedule_post` / `update_post` also take `referenceKey` (your own identifier for the post) and `firstComment` — a comment published as soon as the post goes live, either one string for every comment-capable target or an object keyed by platform.
|
|
65
76
|
|
|
66
77
|
### Comments
|
|
67
78
|
|
|
68
79
|
| Tool | Description |
|
|
69
80
|
|---|---|
|
|
70
|
-
| `create_comment` | Comment on a post — pass `content` multiple times for a chain of replies (X-style thread via comments). Comment-capable platforms: TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, LINKEDIN, REDDIT, MASTODON, DISCORD, SLACK, BLUESKY. |
|
|
81
|
+
| `create_comment` | Comment on a post — pass `content` multiple times for a chain of replies (X-style thread via comments). Comment-capable platforms: TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, LINKEDIN, REDDIT, MASTODON, DISCORD, SLACK, BLUESKY. Use `importedPostId` to comment on a post from `create_post_import` (with explicit `platforms`), or `fetchedParentCommentId` to reply to a comment from `create_comment_import`. |
|
|
71
82
|
| `list_comments` / `get_comment` / `delete_comment` | List, fetch, and delete comments. |
|
|
83
|
+
| `retry_comment` | Re-attempt a comment that ended in `ERROR`. |
|
|
72
84
|
| `create_comment_import` | Start an async import of a published post's (incoming) comments for one platform. |
|
|
73
85
|
| `list_comment_imports` / `get_comment_import` | List / fetch comment-import jobs. |
|
|
74
86
|
| `list_imported_comments` | List the comments fetched for a post via `create_comment_import`. |
|
|
87
|
+
| `act_on_imported_comment` | Moderate an imported comment — `DELETE`, `HIDE`, `UNHIDE`, `LIKE`, `UNLIKE`, `APPROVE`, `REJECT` (support varies by platform), optionally banning the author. |
|
|
75
88
|
|
|
76
89
|
### Media (uploads)
|
|
77
90
|
|
|
@@ -115,7 +128,7 @@ Team-scoped tools take an optional `teamId` — skip it when your org has one te
|
|
|
115
128
|
|
|
116
129
|
### Targeting platforms & per-platform fields
|
|
117
130
|
|
|
118
|
-
`create_post` / `schedule_post` target platforms by **name** (`x`, `tiktok`, `instagram`, `youtube`, `facebook`, `threads`, `linkedin`, `pinterest`, `reddit`, `mastodon`, `discord`, `slack`, `gbp`) or by **integration id** (from `list_integrations`). Put platform-required fields under `platformSettings` keyed by platform — e.g. Reddit `sr`, Pinterest `boardName`, TikTok `privacy`, YouTube `madeForKids`/`privacyStatus`, Instagram/Facebook `type` — or pass the full `data` object verbatim. The complete per-platform parameter reference is at **<https://docs.bundle.social/api-reference/platform-parameters>**.
|
|
131
|
+
`create_post` / `schedule_post` target platforms by **name** (`x`, `tiktok`, `instagram`, `youtube`, `facebook`, `threads`, `linkedin`, `pinterest`, `reddit`, `mastodon`, `discord`, `slack`, `bluesky`, `gbp`, `snapchat`) or by **integration id** (from `list_integrations`). Put platform-required fields under `platformSettings` keyed by platform — e.g. Reddit `sr`, Pinterest `boardName`, TikTok `privacy`, YouTube `madeForKids`/`privacyStatus`, Instagram/Facebook `type` — or pass the full `data` object verbatim. The complete per-platform parameter reference is at **<https://docs.bundle.social/api-reference/platform-parameters>**.
|
|
119
132
|
|
|
120
133
|
## Configuration
|
|
121
134
|
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{StdioServerTransport as ce}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as de}from"@modelcontextprotocol/sdk/server/mcp.js";var z={name:"bundlesocial-mcp",version:"1.0.1",mcpName:"io.github.bundleglobal/bundlesocial-mcp",description:"Model Context Protocol server for the bundle.social social-media API \u2014 post to 14+ platforms from Claude, Cursor and other MCP clients.",keywords:["bundle.social","bundlesocial","mcp","model context protocol","social media","api","agents","claude","cursor"],author:"bundle.global",license:"MIT",homepage:"https://github.com/bundleglobal/bundlesocial-mcp#readme",bugs:{url:"https://github.com/bundleglobal/bundlesocial-mcp/issues"},repository:{type:"git",url:"git+https://github.com/bundleglobal/bundlesocial-mcp.git"},type:"module",bin:{"bundlesocial-mcp":"./dist/index.js"},files:["dist/**","server.json","README.md","CHANGELOG.md","LICENSE"],engines:{node:">=20"},scripts:{build:"tsup",dev:"tsup --watch",typecheck:"tsc --noEmit",start:"node dist/index.js",test:"vitest run","test:watch":"vitest",prepublishOnly:"npm run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.12.0",bundlesocial:"^2.47.0",zod:"^3.23.8"},devDependencies:{"@semantic-release/changelog":"^6.0.3","@semantic-release/git":"^10.0.1","@types/node":"^20.14.0","semantic-release":"^25.0.2",tsup:"^8.2.4",typescript:"^5.5.4",vitest:"^2.0.5"}};import{Bundlesocial as qt,OpenAPI as Kt}from"bundlesocial";import{ApiError as ut}from"bundlesocial";var u=class extends Error{code;details;constructor(t,o,n){super(o),this.name="McpToolError",this.code=t,this.details=n}};function Ft(e){if(e instanceof u)return{code:e.code,message:e.message,details:e.details};if(e instanceof ut){let t=e.body,o=typeof t=="object"&&t&&typeof t.message=="string"&&t.message||typeof t=="object"&&t&&typeof t.error=="string"&&t.error||e.statusText||e.message||`HTTP ${e.status}`;return{code:`HTTP_${e.status}`,message:o,details:{status:e.status,url:e.url,body:e.body}}}return e instanceof Error?{code:"UNEXPECTED_ERROR",message:e.message||"Unexpected error",details:process.env.BUNDLESOCIAL_DEBUG?{stack:e.stack}:void 0}:{code:"UNEXPECTED_ERROR",message:String(e)}}function C(e){return e instanceof ut?`HTTP ${e.status}${e.statusText?` ${e.statusText}`:""}`:e instanceof Error?e.message:String(e)}function s(e){return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}function ft(e){return{content:[{type:"text",text:JSON.stringify({error:Ft(e)},null,2)}],isError:!0}}var x="https://api.bundle.social",Y="https://bundle.social/dashboard/organization/api-keys",gt="https://bundle.social/dashboard/general/social-accounts";function ht(e,t=x){return new qt(e,{...Kt,BASE:t})}async function f(e,t){if(t)return t;if(e.defaultTeamId)return e.defaultTeamId;let n=(await e.client.organization.organizationGetOrganization()).teams??[];if(n.length===1)return n[0].id;throw n.length===0?new u("NO_TEAMS","This organization has no teams yet. Create one in the bundle.social dashboard first."):new u("TEAM_ID_REQUIRED",`This organization has ${n.length} teams. Pass a "teamId" argument (or set BUNDLESOCIAL_TEAM_ID when starting the server).`,{teams:n.map(i=>({id:i.id,name:i.name}))})}import{z as T}from"zod";var $=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","TWITTER","THREADS","LINKEDIN","PINTEREST","REDDIT","MASTODON","DISCORD","SLACK","BLUESKY","GOOGLE_BUSINESS"],yt=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","REDDIT","PINTEREST","MASTODON","LINKEDIN","BLUESKY","GOOGLE_BUSINESS"],jt={X:"TWITTER",TWITTER:"TWITTER",TIKTOK:"TIKTOK",TT:"TIKTOK",YOUTUBE:"YOUTUBE",YT:"YOUTUBE",INSTAGRAM:"INSTAGRAM",IG:"INSTAGRAM",INSTA:"INSTAGRAM",FACEBOOK:"FACEBOOK",FB:"FACEBOOK",THREADS:"THREADS",LINKEDIN:"LINKEDIN",LI:"LINKEDIN",PINTEREST:"PINTEREST",PIN:"PINTEREST",REDDIT:"REDDIT",MASTODON:"MASTODON",MASTO:"MASTODON",DISCORD:"DISCORD",SLACK:"SLACK",BLUESKY:"BLUESKY",BSKY:"BLUESKY",GOOGLE_BUSINESS:"GOOGLE_BUSINESS","GOOGLE-BUSINESS":"GOOGLE_BUSINESS",GBP:"GOOGLE_BUSINESS",GOOGLEBUSINESS:"GOOGLE_BUSINESS",GMB:"GOOGLE_BUSINESS"};function V(e){return jt[e.trim().toUpperCase().replace(/\s+/g,"_")]}function S(e){let t=V(e);if(!t)throw new u("UNKNOWN_PLATFORM",`Unknown platform "${e}". Supported: ${$.join(", ")} (aliases like "x" and "gbp" are accepted too).`);return t}function Z(e){return yt.includes(e)}var X=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","LINKEDIN","REDDIT","MASTODON","DISCORD","SLACK","BLUESKY"];function J(e){return X.includes(e)}function U(e){let t=S(e);if(!Z(t))throw new u("ANALYTICS_NOT_SUPPORTED",`Analytics are not available for ${t}. Supported: ${yt.join(", ")}.`);return t}function l(e,t,o,n){e.registerTool(t,o,(async i=>{try{return await n(i??{})}catch(a){return ft(a)}}))}var v=T.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),L=T.string().min(1).describe("Platform name/alias (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp).");function Q(e){return(e??[]).map(t=>({id:t.id,type:t.type,username:t.username??null,displayName:t.displayName??null,avatarUrl:t.avatarUrl??null,channels:(t.channels??[]).map(o=>({id:o.id,name:o.name??null,username:o.username??null,address:o.address??null}))}))}function bt(e,t){l(e,"list_integrations",{title:"List connected integrations",description:"List the social-media integrations (accounts) connected to a bundle.social team \u2014 each with its `id`, `type` (platform), `username` and channels. Use this to discover which platforms are available and to get integration ids. Without a team id it lists every team in the organization.",inputSchema:{teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o})=>{if(o??t.defaultTeamId){let r=o??t.defaultTeamId,c=await t.client.team.teamGetTeam({id:r});return s({teamId:c.id,teamName:c.name,integrations:Q(c.socialAccounts)})}let n=await t.client.organization.organizationGetOrganization(),i=n.teams??[];if(i.length===1){let r=await t.client.team.teamGetTeam({id:i[0].id});return s({teamId:r.id,teamName:r.name,integrations:Q(r.socialAccounts)})}let a=[];for(let r of i){let c=await t.client.team.teamGetTeam({id:r.id});a.push({teamId:c.id,teamName:c.name,integrations:Q(c.socialAccounts)})}return s({organizationId:n.id,organizationName:n.name??null,teams:a})}),l(e,"connect_integration",{title:"Connect a social account",description:"Start connecting a social account to a team. Returns an OAuth `url` \u2014 open it in a browser to authorize the account; bundle.social redirects back to `redirectUrl` afterwards. For Mastodon/Bluesky pass `serverUrl`.",inputSchema:{platform:L,redirectUrl:T.string().min(1).describe("URL bundle.social redirects to after the user finishes (or cancels) the OAuth flow."),serverUrl:T.string().optional().describe("Mastodon/Bluesky instance URL (required for those platforms)."),teamId:v,options:T.record(T.string(),T.unknown()).optional().describe('Advanced provider flags, e.g. {"instagramConnectionMethod":"INSTAGRAM","withBusinessScope":true,"disableAutoLogin":true,"forceBrowserOAuth":true}.')},annotations:{openWorldHint:!0}},async({platform:o,redirectUrl:n,serverUrl:i,teamId:a,options:r})=>{let c=await f(t,a),d={type:S(o),teamId:c,redirectUrl:n,...i?{serverUrl:i}:{},...r??{}};return s(await t.client.socialAccount.socialAccountConnect({requestBody:d}))}),l(e,"disconnect_integration",{title:"Disconnect a social account",description:"Disconnect a social account of the given platform from a team. Destructive \u2014 also removes it from scheduled posts.",inputSchema:{platform:L,teamId:v},annotations:{destructiveHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountDisconnect({requestBody:{type:S(o),teamId:i}}))}),l(e,"set_integration_channel",{title:"Set a social account's channel/page",description:"Select the page/channel for a connected account (needed for FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, GOOGLE_BUSINESS). Get channel ids from list_integrations / refresh_integration_channels.",inputSchema:{platform:L,channelId:T.string().min(1).describe("Channel/page id to select."),teamId:v},annotations:{openWorldHint:!0}},async({platform:o,channelId:n,teamId:i})=>{let a=await f(t,i);return s(await t.client.socialAccount.socialAccountSetChannel({requestBody:{type:S(o),teamId:a,channelId:n}}))}),l(e,"unset_integration_channel",{title:"Clear a social account's channel/page",description:"Clear the selected page/channel for a connected account (FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, GOOGLE_BUSINESS) while keeping the authorization.",inputSchema:{platform:L,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountUnsetChannel({requestBody:{type:S(o),teamId:i}}))}),l(e,"refresh_integration_channels",{title:"Refresh a social account's channels",description:"Re-fetch the available channels for a connected account (needed for REDDIT, DISCORD, SLACK, PINTEREST and the page-based platforms).",inputSchema:{platform:L,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountRefreshChannels({requestBody:{type:S(o),teamId:i}}))}),l(e,"create_integration_portal_link",{title:"Create a connect-portal link",description:"Create a hosted bundle.social portal link a user can open to connect/manage social accounts without you implementing the OAuth flow. Returns a `url`.",inputSchema:{platforms:T.array(T.string().min(1)).min(1).describe("Platforms the portal should offer to connect (names/aliases)."),redirectUrl:T.string().optional().describe("URL to redirect to when the user finishes."),teamId:v,expiresInMinutes:T.number().int().min(5).max(2880).optional().describe("Link lifetime in minutes (5 min \u2013 48 h)."),options:T.record(T.string(),T.unknown()).optional().describe("Advanced portal options (logoUrl, userName, language, hidePoweredBy, maxSocialAccountsConnected, \u2026).")},annotations:{openWorldHint:!0}},async({platforms:o,redirectUrl:n,teamId:i,expiresInMinutes:a,options:r})=>{let d={teamId:await f(t,i),socialAccountTypes:o.map(m=>S(m)),...n?{redirectUrl:n}:{},...a?{expiresIn:a}:{},...r??{}};return s(await t.client.socialAccount.socialAccountCreatePortalLink({requestBody:d}))}),l(e,"check_integration_connection",{title:"Check a social account's connection",description:"Run an on-demand connection/disconnect health check for a connected account of the given platform.",inputSchema:{platform:L,teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountConnectionCheck({requestBody:{type:S(o),teamId:i}}))}),l(e,"refresh_integration_profile",{title:"Refresh a social account's profile",description:"Re-fetch the profile info (username, display name, avatar) for a connected account of the given platform.",inputSchema:{platform:L,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountProfileRefresh({requestBody:{type:S(o),teamId:i}}))}),l(e,"get_integration_by_type",{title:"Get a social account by platform",description:"Fetch the connected social account of a given platform for a team (including its channels).",inputSchema:{platform:L,teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountGetByType({teamId:i,type:S(o)}))}),l(e,"copy_integration",{title:"Copy social accounts between teams",description:"Copy connected social accounts of the given platforms from one team to another. Set `resetChannel` to require re-picking the page (Facebook/Instagram/LinkedIn/YouTube).",inputSchema:{fromTeamId:T.string().min(1).describe("Source team id."),toTeamId:T.string().min(1).describe("Destination team id."),platforms:T.array(T.string().min(1)).min(1).describe("Platforms to copy (names/aliases)."),resetChannel:T.boolean().optional().describe("If true, the destination must re-select the page/channel.")},annotations:{openWorldHint:!0}},async({fromTeamId:o,toTeamId:n,platforms:i,resetChannel:a})=>s(await t.client.socialAccount.socialAccountCopy({requestBody:{fromTeamId:o,toTeamId:n,...a!==void 0?{resetChannel:a}:{},socialAccountTypes:i.map(r=>S(r))}}))),l(e,"list_integrations_to_delete",{title:"List social accounts pending deletion",description:"List social accounts scheduled to be deleted (paginated) across the organization.",inputSchema:{page:T.number().int().positive().optional().describe("Page (1-based)."),pageSize:T.number().int().positive().max(100).optional().describe("Page size.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({page:o,pageSize:n})=>s(await t.client.socialAccount.socialAccountGetAccountsToDelete({page:o,pageSize:n})))}import{z as g}from"zod";import Wt from"fs/promises";import N from"path";var xt={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".tif":"image/tiff",".tiff":"image/tiff",".heic":"image/heic",".heif":"image/heif",".mp4":"video/mp4",".m4v":"video/x-m4v",".mov":"video/quicktime",".webm":"video/webm",".avi":"video/x-msvideo",".mkv":"video/x-matroska",".pdf":"application/pdf",".mp3":"audio/mpeg",".m4a":"audio/mp4",".wav":"audio/wav"};function Yt(e){return/^https?:\/\//i.test(e.trim())}var $t=90*1024*1024,Vt={".jpg":"image/jpg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".mp4":"video/mp4",".pdf":"application/pdf"};async function tt(e,t,o){if(Yt(o))return e.upload.uploadCreateFromUrl({requestBody:{teamId:t,url:o.trim()}});let n=N.resolve(o),i;try{i=await Wt.readFile(n)}catch{throw new u("MEDIA_NOT_FOUND",`Could not read media "${o}". Provide a public https:// URL, or a local file path that exists on the machine running this MCP server (stdio mode only).`,{path:n})}if(i.byteLength>$t)return Zt(e,t,n,i);let a=xt[N.extname(n).toLowerCase()]??"application/octet-stream",r=new File([i],N.basename(n),{type:a});return e.upload.uploadCreate({formData:{teamId:t,file:r}})}async function Zt(e,t,o,n){let i=N.extname(o).toLowerCase(),a=Vt[i];if(!a)throw new u("LARGE_UPLOAD_UNSUPPORTED_TYPE",`Large uploads (>90 MB) only support .jpg, .jpeg, .png, .gif, .mp4 and .pdf \u2014 got "${i||"no extension"}".`,{path:o});let r=await e.upload.uploadInitLargeUpload({requestBody:{teamId:t,fileName:N.basename(o),mimeType:a}}),c=await fetch(r.url,{method:"PUT",headers:{"content-type":a},body:new Uint8Array(n)});if(!c.ok)throw new u("LARGE_UPLOAD_FAILED",`Uploading the file to storage failed (HTTP ${c.status}).`,{status:c.status});return e.upload.uploadFinalizeLargeUpload({requestBody:{teamId:t,path:r.path}})}async function et(e,t,o){let n=[];for(let i of o){let a=await tt(e,t,i);n.push(a.id)}return n}function Xt(e,t){if(typeof e!="object"||e===null||Array.isArray(e))throw new u("INVALID_INPUT",`${t} must be a JSON object.`);return e}async function k(e,t,o){let n=new Set,i=[];for(let a of o){let r=V(a);r?n.add(r):i.push(a.trim())}if(i.length>0){let r=(await e.team.teamGetTeam({id:t})).socialAccounts??[];for(let c of i){let d=r.find(m=>m.id===c);if(!d)throw new u("INTEGRATION_NOT_FOUND",`No connected integration with id "${c}" in team ${t}. Call list_integrations to see ids, or use a platform name like "x" or "tiktok".`,{availableIntegrations:r.map(m=>({id:m.id,type:m.type,username:m.username}))});n.add(d.type)}}return[...n]}function Jt(e){let t=Object.keys(e);return t.length>0&&t.every(o=>$.includes(o.trim().toUpperCase()))}function Qt(e,t){let o=Object.fromEntries(t.map(n=>[n,{}]));if(!e)return o;if(Jt(e)){for(let[n,i]of Object.entries(e)){let a=n.trim().toUpperCase();a in o&&(o[a]={...o[a],...Xt(i,`platformSettings.${n}`)})}return o}for(let n of t)o[n]={...e};return o}function ot(e,t){if(t.data)return t.data;let o=Qt(t.platformSettings,e),n={};for(let i of e)n[i]={...t.content!==void 0?{text:t.content}:{},...t.mediaUploadIds.length>0?{uploadIds:t.mediaUploadIds}:{},...o[i]};return n}function nt(e){return Object.keys(e).map(t=>S(t))}function St(e,t){let o=(e??"").split(`
|
|
3
|
-
`).map(n=>n.trim()).find(n=>n.length>0);return o?o.length>80?`${o.slice(0,79)}\u2026`:o:t}function B(e,t){let o=new Date(e);if(Number.isNaN(o.getTime()))throw new u("INVALID_DATE",`${t} is not a valid ISO 8601 date/time: "${e}". Example: 2026-06-01T09:00:00Z`);return o.toISOString()}var F=g.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),it=g.array(g.string().min(1)).optional().describe('Target platforms \u2014 names/aliases (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp) and/or connected integration ids from list_integrations. Required unless "data" is provided with platform keys.'),at=g.array(g.string().min(1)).optional().describe("Media to attach: public https:// URLs (or local file paths when this server runs in stdio mode). Uploaded automatically and attached to every targeted platform. For per-platform media, use upload_media + the `data` argument instead."),rt=g.record(g.string(),g.unknown()).optional().describe('Per-platform options. Either keyed by platform name, e.g. {"TIKTOK":{"privacy":"PUBLIC_TO_EVERYONE"},"YOUTUBE":{"type":"SHORT","privacyStatus":"PUBLIC","madeForKids":false}}, or a flat object applied to every targeted platform. Use this for platform-required fields (Reddit `sr`, Pinterest `boardName`, TikTok `privacy`, YouTube `madeForKids`/`privacyStatus`, Instagram/Facebook `type`).'),st=g.record(g.string(),g.unknown()).optional().describe('Advanced: the full post `data` object keyed by platform, e.g. {"REDDIT":{"sr":"r/test","text":"hello","uploadIds":["<uploadId>"]}}. Overrides content/media/platformSettings. Targeted platforms are inferred from its keys unless `platforms` is also given.'),It=g.string().min(1).optional().describe("Post title. Defaults to the first line of `content`. Also used as the YouTube video title.");async function Tt(e,t){let o=await f(e,t.teamId),n;if(t.platforms&&t.platforms.length>0)n=await k(e.client,o,t.platforms);else if(t.data)n=nt(t.data);else throw new u("NO_TARGET",'Provide "platforms" (platform names or integration ids), or a "data" object keyed by platform.');if(n.length===0)throw new u("NO_TARGET","Could not determine any target platform for this post.");let i=await et(e.client,o,t.media??[]),a=ot(n,{content:t.content,mediaUploadIds:i,platformSettings:t.platformSettings,data:t.data});return{teamId:o,socialAccountTypes:n,data:a,title:t.title??St(t.content,"Untitled post")}}function wt(e,t){l(e,"create_post",{title:"Create a post (publish now)",description:"Publish a post immediately to one or more connected social-media integrations. Returns the created post (with its id and status). Set `draft: true` to save it as a draft instead of publishing. For a future-dated post use schedule_post.",inputSchema:{teamId:F,content:g.string().optional().describe("Post text, applied to every targeted platform."),platforms:it,media:at,platformSettings:rt,data:st,title:It,draft:g.boolean().optional().default(!1).describe("If true, save as a DRAFT instead of publishing now.")},annotations:{openWorldHint:!0}},async({teamId:o,content:n,platforms:i,media:a,platformSettings:r,data:c,title:d,draft:m})=>{let h=await Tt(t,{teamId:o,content:n,platforms:i,media:a,platformSettings:r,data:c,title:d}),y=await t.client.post.postCreate({requestBody:{teamId:h.teamId,title:h.title,postDate:new Date().toISOString(),status:m?"DRAFT":"SCHEDULED",socialAccountTypes:h.socialAccountTypes,data:h.data}});return s(y)}),l(e,"schedule_post",{title:"Schedule a post for later",description:"Schedule a post to be published at a specific date/time on one or more connected integrations. Same inputs as create_post plus a required ISO-8601 `date`. Returns the scheduled post.",inputSchema:{teamId:F,date:g.string().min(1).describe("When to publish \u2014 ISO 8601, e.g. 2026-06-01T09:00:00Z."),content:g.string().optional().describe("Post text, applied to every targeted platform."),platforms:it,media:at,platformSettings:rt,data:st,title:It},annotations:{openWorldHint:!0}},async({teamId:o,date:n,content:i,platforms:a,media:r,platformSettings:c,data:d,title:m})=>{let h=B(n,"date"),y=await Tt(t,{teamId:o,content:i,platforms:a,media:r,platformSettings:c,data:d,title:m}),I=await t.client.post.postCreate({requestBody:{teamId:y.teamId,title:y.title,postDate:h,status:"SCHEDULED",socialAccountTypes:y.socialAccountTypes,data:y.data}});return s(I)}),l(e,"list_posts",{title:"List recent posts",description:"List recent posts for a team, newest first, with optional filters by status, platform, date range and free-text query.",inputSchema:{teamId:F,limit:g.number().int().positive().max(100).optional().default(20).describe("Max number of posts to return (default 20, max 100)."),offset:g.number().int().nonnegative().optional().describe("Number of posts to skip (for pagination)."),status:g.enum(["DRAFT","SCHEDULED","POSTED","ERROR","DELETED","PROCESSING","REVIEW","RETRYING"]).optional().describe("Filter by post status."),platforms:g.array(g.string().min(1)).optional().describe("Filter by platform name/alias."),from:g.string().optional().describe("Only posts with postDate on/after this ISO-8601 date."),to:g.string().optional().describe("Only posts with postDate on/before this ISO-8601 date."),query:g.string().optional().describe("Free-text search over post titles/content."),order:g.enum(["ASC","DESC"]).optional().describe("Sort direction (default DESC)."),orderBy:g.enum(["createdAt","updatedAt","postDate","postedDate","deletedAt"]).optional().describe("Sort field (default postDate).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,limit:n,offset:i,status:a,platforms:r,from:c,to:d,query:m,order:h,orderBy:y})=>{let I=await f(t,o),b=(r??[]).map(S),w={teamId:I,limit:n,offset:i,status:a??void 0,platforms:b.length>0?b:void 0,postDateFrom:c?B(c,"from"):void 0,postDateTo:d?B(d,"to"):void 0,q:m,order:h??void 0,orderBy:y??void 0};return s(await t.client.post.postGetList(w))}),l(e,"get_post",{title:"Get a post by id",description:"Fetch a single post by its bundle.social id, including its per-platform data and status.",inputSchema:{id:g.string().min(1).describe("Post id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.post.postGet({id:o}))),l(e,"delete_post",{title:"Delete a post",description:"Delete a post by its bundle.social id. This is destructive and cannot be undone.",inputSchema:{id:g.string().min(1).describe("Post id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.post.postDelete({id:o}))),l(e,"update_post",{title:"Update a post",description:"Update an existing post by id \u2014 change its title, publish date, status (DRAFT/SCHEDULED), targeted platforms and/or per-platform content. Only the fields you pass are changed. If you change content/media without `platforms`, the post's current platforms are reused.",inputSchema:{id:g.string().min(1).describe("Post id."),title:g.string().optional().describe("New post title."),date:g.string().optional().describe("New publish date, ISO 8601."),status:g.enum(["DRAFT","SCHEDULED"]).optional().describe("New status."),content:g.string().optional().describe("New post text, applied to every targeted platform."),platforms:it,media:at,platformSettings:rt,data:st,teamId:F},annotations:{openWorldHint:!0}},async({id:o,title:n,date:i,status:a,content:r,platforms:c,media:d,platformSettings:m,data:h,teamId:y})=>{let I=await f(t,y),b=r!==void 0||(d?.length??0)>0||m!==void 0||h!==void 0,w;if(c&&c.length>0)w=await k(t.client,I,c);else if(h)w=nt(h);else if(b){let P=await t.client.post.postGet({id:o});if(w=Object.keys(P.data??{}),w.length===0)throw new u("NO_TARGET","Could not determine the post's platforms \u2014 pass `platforms`.")}let E={};if(n!==void 0&&(E.title=n),i&&(E.postDate=B(i,"date")),a&&(E.status=a),w&&w.length>0&&(E.socialAccountTypes=w),b&&w&&w.length>0){let P=await et(t.client,I,d??[]);E.data=ot(w,{content:r,mediaUploadIds:P,platformSettings:m,data:h})}if(Object.keys(E).length===0)throw new u("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of title, date, status, content, media, platformSettings, data, platforms.");return s(await t.client.post.postUpdate({id:o,requestBody:E}))}),l(e,"retry_post",{title:"Retry a failed post",description:"Retry publishing a post that ended in the ERROR state.",inputSchema:{id:g.string().min(1).describe("Post id.")},annotations:{openWorldHint:!0}},async({id:o})=>s(await t.client.post.postRetry({id:o})))}import{z as p}from"zod";var te=p.enum(["PENDING","FETCHING","RETRYING","COMPLETED","SKIPPED","FAILED","RATE_LIMITED"]),G=p.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function lt(e){let t=e.filter(o=>!J(o));if(t.length>0)throw new u("COMMENTS_NOT_SUPPORTED",`Comments are not available for ${t.join(", ")}. Supported: ${X.join(", ")}.`);return e}function ee(e){let t=new Date(e);if(Number.isNaN(t.getTime()))throw new u("INVALID_DATE",`date is not a valid ISO 8601 date/time: "${e}". Example: 2026-06-01T09:00:00Z`);return t.toISOString()}function At(e,t){l(e,"create_comment",{title:"Comment on a post",description:"Post one or more comments on an existing post. Pass `content` multiple times to create a chain (the first replies to the post, each subsequent one replies to the previous comment) \u2014 useful for X-style threads via comments. Comments are supported on TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, LINKEDIN, REDDIT, MASTODON, DISCORD, SLACK, BLUESKY. Returns the created comment(s).",inputSchema:{postId:p.string().min(1).describe("Id of the post to comment on."),content:p.array(p.string().min(1)).min(1).describe("Comment text. Pass multiple to create a chain of replies."),platforms:p.array(p.string().min(1)).optional().describe("Target comment-capable platform names/aliases and/or integration ids. Defaults to the post's platforms (filtered to comment-capable ones)."),date:p.string().optional().describe("When to post the (first) comment, ISO 8601. Default: now."),delayMinutes:p.number().int().nonnegative().optional().default(0).describe("For a chain, minutes to wait between each comment."),draft:p.boolean().optional().default(!1).describe("If true, create the comment(s) as DRAFT instead of posting."),teamId:G},annotations:{openWorldHint:!0}},async({postId:o,content:n,platforms:i,date:a,delayMinutes:r,draft:c,teamId:d})=>{let m=await f(t,d),h;if(i&&i.length>0)h=lt(await k(t.client,m,i));else{let E=await t.client.post.postGet({id:o});if(h=Object.keys(E.data??{}).filter(J),h.length===0)throw new u("NO_TARGET","Could not determine comment platforms from the post \u2014 pass `platforms` (comment-capable only).")}let y=c?"DRAFT":"SCHEDULED",I=a?new Date(ee(a)):new Date,b=[],w;for(let E=0;E<n.length;E+=1){let P=n[E],W=new Date(I.getTime()+E*(r??0)*6e4).toISOString(),Mt=Object.fromEntries(h.map(Ht=>[Ht,{text:P}])),pt=await t.client.comment.commentCreate({requestBody:{teamId:m,internalPostId:o,...w?{internalParentCommentId:w}:{},status:y,postDate:W,socialAccountTypes:h,data:Mt,text:P}});b.push(pt),w=pt.id}return s(b.length===1?b[0]:b)}),l(e,"list_comments",{title:"List comments",description:"List comments for a team, optionally filtered by post, status and platform.",inputSchema:{postId:p.string().optional().describe("Only comments on this post."),limit:p.number().int().positive().max(100).optional().default(20),offset:p.number().int().nonnegative().optional(),status:p.enum(["DRAFT","SCHEDULED","POSTED","ERROR","DELETED","PROCESSING","RETRYING"]).optional(),platforms:p.array(p.string().min(1)).optional().describe("Filter by comment-capable platform name/alias."),query:p.string().optional(),order:p.enum(["ASC","DESC"]).optional(),orderBy:p.enum(["createdAt","updatedAt","deletedAt"]).optional(),teamId:G},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postId:o,limit:n,offset:i,status:a,platforms:r,query:c,order:d,orderBy:m,teamId:h})=>{let y=await f(t,h),I=lt((r??[]).map(S)),b={teamId:y,postId:o,limit:n,offset:i,status:a??void 0,platforms:I.length>0?I:void 0,q:c,order:d??void 0,orderBy:m??void 0};return s(await t.client.comment.commentGetList(b))}),l(e,"get_comment",{title:"Get a comment by id",description:"Fetch a single comment by its bundle.social id.",inputSchema:{id:p.string().min(1).describe("Comment id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.comment.commentGet({id:o}))),l(e,"delete_comment",{title:"Delete a comment",description:"Delete a comment by its bundle.social id. Destructive.",inputSchema:{id:p.string().min(1).describe("Comment id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.comment.commentDelete({id:o}))),l(e,"update_comment",{title:"Update a comment",description:"Update an existing comment by id \u2014 change its title, scheduled date, status (DRAFT/SCHEDULED), targeted platforms and/or per-platform text. Only the fields you pass are changed. Use `data` for the full per-platform object, or `content` + `platforms` for a same-text-everywhere change.",inputSchema:{id:p.string().min(1).describe("Comment id."),title:p.string().optional().describe("New title."),date:p.string().optional().describe("New scheduled date, ISO 8601."),status:p.enum(["DRAFT","SCHEDULED"]).optional().describe("New status."),content:p.string().optional().describe("New comment text, applied to every platform in `platforms`."),platforms:p.array(p.string().min(1)).optional().describe("Comment-capable platform name/alias. Required when changing `content` without supplying `data`."),data:p.record(p.string(),p.unknown()).optional().describe('Advanced: the full comment `data` object keyed by platform, e.g. {"LINKEDIN":{"text":"new"}}.')},annotations:{openWorldHint:!0}},async({id:o,title:n,date:i,status:a,content:r,platforms:c,data:d})=>{let m=lt((c??[]).map(S)),h=r!==void 0||d!==void 0,y={};if(n!==void 0&&(y.title=n),i){let I=new Date(i);if(Number.isNaN(I.getTime()))throw new u("INVALID_DATE",`date is not a valid ISO 8601 date/time: "${i}". Example: 2026-06-01T09:00:00Z`);y.postDate=I.toISOString()}if(a&&(y.status=a),m.length>0&&(y.socialAccountTypes=m),h)if(d)y.data=d;else{if(m.length===0)throw new u("NO_TARGET","Pass `platforms` when changing `content` (the per-platform comment text needs to know which platforms to target).");let I=Object.fromEntries(m.map(b=>[b,{text:r}]));y.data=I}if(Object.keys(y).length===0)throw new u("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of title, date, status, content (+ platforms), data.");return s(await t.client.comment.commentUpdate({id:o,requestBody:y}))}),l(e,"create_comment_import",{title:"Import comments on a post",description:"Start an async import of the (incoming) comments on a published post for one platform. Comment imports are available on FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, TIKTOK, REDDIT, THREADS, MASTODON, BLUESKY. Poll get_comment_import / list_comment_imports for status and list_imported_comments for the fetched comments.",inputSchema:{postId:p.string().min(1).describe("Id of the published post to import comments for."),platform:p.string().min(1).describe("Platform name/alias to import comments from."),teamId:G},annotations:{openWorldHint:!0}},async({postId:o,platform:n,teamId:i})=>{let a=await f(t,i);return s(await t.client.comment.commentImportCreate({requestBody:{teamId:a,postId:o,socialAccountType:S(n)}}))}),l(e,"list_comment_imports",{title:"List comment imports",description:"List comment-import jobs for a team, optionally filtered by post and status.",inputSchema:{teamId:G,postId:p.string().optional().describe("Only imports for this post."),status:te.optional().describe("Filter by import status."),limit:p.number().int().positive().max(100).optional(),offset:p.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,postId:n,status:i,limit:a,offset:r})=>{let c=await f(t,o);return s(await t.client.comment.commentImportGetList({teamId:c,postId:n,status:i,limit:a??null,offset:r??null}))}),l(e,"get_comment_import",{title:"Get a comment import by id",description:"Fetch a single comment-import job by its id, including its status and the number of comments imported.",inputSchema:{importId:p.string().min(1).describe("Comment import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.comment.commentImportGetById({importId:o}))),l(e,"list_imported_comments",{title:"List imported comments for a post",description:"List the comments fetched by comment imports for a post, optionally filtered by platform / social account.",inputSchema:{postId:p.string().min(1).describe("Id of the post whose imported comments to list."),platform:p.string().optional().describe("Filter by platform name/alias."),socialAccountId:p.string().optional().describe("Filter by social-account id."),teamId:G,limit:p.number().int().positive().max(100).optional(),offset:p.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postId:o,platform:n,socialAccountId:i,teamId:a,limit:r,offset:c})=>{let d=await f(t,a);return s(await t.client.comment.commentImportGetFetchedComments({teamId:d,postId:o,platform:n?S(n):void 0,socialAccountId:i,limit:r??null,offset:c??null}))})}import{z as D}from"zod";var q=D.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function Et(e,t){l(e,"upload_media",{title:"Upload media",description:'Upload a media file (image, video or document) to a bundle.social team from a public https:// URL \u2014 or, when this server runs in stdio mode, a local file path. Local files larger than ~90 MB are uploaded via the large-upload flow automatically (only .jpg/.jpeg/.png/.gif/.mp4/.pdf are supported above that size). Returns the upload object; pass its `id` to create_post/schedule_post via the `data` argument (e.g. {"TWITTER":{"text":"hi","uploadIds":["<id>"]}}).',inputSchema:{teamId:q,source:D.string().min(1).describe("A public https:// URL, or a local file path (stdio mode only).")},annotations:{openWorldHint:!0}},async({teamId:o,source:n})=>{let i=await f(t,o);return s(await tt(t.client,i,n))}),l(e,"list_media",{title:"List uploaded media",description:"List media uploads for a team, optionally filtered by type (image/video/document) and usage status (USED/UNUSED).",inputSchema:{teamId:q,type:D.enum(["image","video","document"]).optional().describe("Filter by media type."),status:D.enum(["USED","UNUSED"]).optional().describe("Filter by whether the upload is attached to a post.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,type:n,status:i})=>{let a=await f(t,o);return s(await t.client.upload.uploadGetList({teamId:a,type:n??null,status:i??null}))}),l(e,"get_media",{title:"Get an upload by id",description:"Fetch a single media upload by its bundle.social id.",inputSchema:{id:D.string().min(1).describe("Upload id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.upload.uploadGet({id:o}))),l(e,"delete_media",{title:"Delete an upload",description:"Delete a media upload by its bundle.social id. Destructive.",inputSchema:{id:D.string().min(1).describe("Upload id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.upload.uploadDelete({id:o}))),l(e,"delete_media_many",{title:"Delete multiple uploads",description:"Delete several media uploads at once by their ids. Destructive.",inputSchema:{ids:D.array(D.string().min(1)).min(1).describe("Upload ids to delete.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({ids:o})=>s(await t.client.upload.uploadDeleteMany({requestBody:{ids:o}}))),l(e,"init_large_upload",{title:"Initialize a large upload",description:"Low-level: start a >90 MB upload. Returns a signed `url` (PUT the file bytes there with the matching content-type) and a `path` to pass to finalize_large_upload. Prefer `upload_media` with a local file path in stdio mode \u2014 it does this automatically.",inputSchema:{teamId:q,fileName:D.string().min(1).describe("File name."),mimeType:D.enum(["image/jpg","image/jpeg","image/png","image/gif","video/mp4","application/pdf"]).describe("File MIME type.")},annotations:{openWorldHint:!0}},async({teamId:o,fileName:n,mimeType:i})=>{let a=await f(t,o);return s(await t.client.upload.uploadInitLargeUpload({requestBody:{teamId:a,fileName:n,mimeType:i}}))}),l(e,"finalize_large_upload",{title:"Finalize a large upload",description:"Low-level: finalize a >90 MB upload after the bytes have been PUT to the signed URL from init_large_upload. Returns the upload object.",inputSchema:{teamId:q,path:D.string().min(1).describe("The `path` returned by init_large_upload.")},annotations:{openWorldHint:!0}},async({teamId:o,path:n})=>{let i=await f(t,o);return s(await t.client.upload.uploadFinalizeLargeUpload({requestBody:{teamId:i,path:n}}))})}import{z as O}from"zod";var Ot=O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function oe(e,t,o){if(!t&&!o)return!0;if(!e)return!1;let n=new Date(e).getTime();return!(Number.isNaN(n)||t&&n<new Date(t).getTime()||o&&n>new Date(o).getTime())}function Ct(e,t){l(e,"get_post_analytics",{title:"Get post analytics",description:"Get engagement metrics (impressions, views, likes, comments, \u2026) for a single post by its bundle.social id. Optionally limit to one platform. Set `raw: true` for the unprocessed provider payload.",inputSchema:{id:O.string().min(1).describe("Post id."),platform:O.string().optional().describe("Limit to a single platform name/alias (e.g. instagram, tiktok, youtube). Analytics are not available for X/Twitter, Discord or Slack."),raw:O.boolean().optional().default(!1).describe("If true, return the raw provider analytics payload instead of the normalized metrics.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o,platform:n,raw:i})=>{let a=n?U(n):void 0,r=i?await t.client.analytics.analyticsGetPostAnalyticsRaw({postId:o,platformType:a}):await t.client.analytics.analyticsGetPostAnalytics({postId:o,platformType:a});return s(r)}),l(e,"get_account_analytics",{title:"Get social-account analytics",description:"Get the analytics time-series (followers, impressions, likes, \u2026) for a connected account on the given platform. Analytics are available on TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, REDDIT, PINTEREST, MASTODON, LINKEDIN, BLUESKY, GOOGLE_BUSINESS. Set `raw: true` for the unprocessed provider payload.",inputSchema:{platform:O.string().min(1).describe("Platform name/alias."),teamId:Ot,raw:O.boolean().optional().default(!1).describe("If true, return the raw provider analytics payload.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n,raw:i})=>{let a=await f(t,n),r=U(o),c=i?await t.client.analytics.analyticsGetSocialAccountAnalyticsRaw({teamId:a,platformType:r}):await t.client.analytics.analyticsGetSocialAccountAnalytics({teamId:a,platformType:r});return s(c)}),l(e,"get_bulk_post_analytics",{title:"Get analytics for multiple posts",description:"Get analytics for up to 60 posts in one request (paginated, 20 per page) for a single platform.",inputSchema:{postIds:O.array(O.string().min(1)).min(1).max(60).describe("Post ids (max 60)."),platform:O.string().min(1).describe("Platform name/alias the posts belong to."),page:O.number().int().positive().optional().describe("Page (1-based)."),limit:O.number().int().positive().max(20).optional().describe("Page size (max 20).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postIds:o,platform:n,page:i,limit:a})=>s(await t.client.analytics.analyticsGetBulkPostAnalytics({postIds:o,platformType:U(n),page:i,limit:a}))),l(e,"refresh_analytics",{title:"Force-refresh analytics",description:"Force an immediate analytics refresh. Pass `postId` to refresh that post's analytics; otherwise pass `platform` to refresh a connected account's analytics for the team.",inputSchema:{postId:O.string().optional().describe("Post id to refresh analytics for."),importedPostId:O.string().optional().describe("Imported-post id to refresh analytics for (alternative to postId)."),platform:O.string().optional().describe("Platform name/alias to refresh a social-account's analytics for (used when postId/importedPostId are omitted)."),teamId:Ot},annotations:{openWorldHint:!0}},async({postId:o,importedPostId:n,platform:i,teamId:a})=>{if(o||n)return s(await t.client.analytics.analyticsForcePostAnalytics({requestBody:{postId:o??null,importedPostId:n??null,platformType:i?U(i):null}}));if(!i)throw new u("REFRESH_TARGET_REQUIRED","Pass either `postId`/`importedPostId` (to refresh a post) or `platform` (to refresh a social account).");let r=await f(t,a);return s(await t.client.analytics.analyticsForceSocialAccountAnalytics({requestBody:{teamId:r,platformType:U(i)}}))}),l(e,"get_analytics_summary",{title:"Get analytics summary",description:"Organization-level analytics summary: posts/comments/uploads usage quotas for the organization, plus the latest analytics snapshot (followers, impressions, likes, \u2026) for each connected integration on the team. Use `from`/`to` to select the snapshot from a date range.",inputSchema:{teamId:O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),from:O.string().optional().describe("Start of the range used to select analytics snapshots (ISO 8601)."),to:O.string().optional().describe("End of the range used to select analytics snapshots (ISO 8601).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,from:n,to:i})=>{let a=await f(t,o),[r,c,d,m,h]=await Promise.all([t.client.organization.organizationGetOrganization(),t.client.team.teamGetTeam({id:a}),t.client.organization.organizationGetPostsUsage().catch(()=>null),t.client.organization.organizationGetCommentsUsage().catch(()=>null),t.client.organization.organizationGetUploadsUsage().catch(()=>null)]),y=c.socialAccounts??[],I=[];for(let b of y){let w={id:b.id,type:b.type,username:b.username??null};if(!Z(b.type)){I.push({...w,analytics:null,note:"analytics not available for this platform"});continue}try{let P=((await t.client.analytics.analyticsGetSocialAccountAnalytics({teamId:a,platformType:b.type})).items??[]).filter(W=>oe(W.createdAt,n,i));I.push({...w,latest:P[P.length-1]??null,dataPoints:P.length})}catch(E){I.push({...w,analytics:null,error:C(E)})}}return s({organization:{id:r.id,name:r.name??null},team:{id:c.id,name:c.name},range:{from:n??null,to:i??null},usage:{posts:d,comments:m,uploads:h},integrations:I})})}import{z as M}from"zod";var K=[{id:"reddit:flairs",platform:"REDDIT",description:"List the post flairs available in a subreddit (use the returned flair id when creating a Reddit post that requires a flair).",requiredParams:["subreddit"],run:(e,t,o)=>e.misc.miscRedditGetSubredditFlairs({teamId:t,subreddit:String(o.subreddit)})},{id:"reddit:requirements",platform:"REDDIT",description:"Get a subreddit's posting requirements (title length, flair requirement, allowed post types, etc.).",requiredParams:["subreddit"],run:(e,t,o)=>e.misc.miscRedditGetPostRequirements({teamId:t,subreddit:String(o.subreddit)})},{id:"youtube:categories",platform:"YOUTUBE",description:"List YouTube video categories for a region (use the returned category id as `categoryId` when posting a YouTube video).",optionalParams:["regionCode"],run:(e,t,o)=>e.misc.miscYoutubeGetVideoCategories({teamId:t,...o.regionCode?{regionCode:String(o.regionCode)}:{}})},{id:"youtube:playlists",platform:"YOUTUBE",description:"List the connected YouTube channel's playlists (use a playlist id to add the posted video to it).",optionalParams:["maxResults"],run:(e,t,o)=>e.misc.miscYoutubeGetChannelPlaylist({teamId:t,...o.maxResults!==void 0?{maxResults:Number(o.maxResults)}:{}})},{id:"youtube:regions",platform:"YOUTUBE",description:"List YouTube content regions (i18n region codes).",run:(e,t)=>e.misc.miscYoutubeGetRegions({teamId:t})},{id:"linkedin:mentions",platform:"LINKEDIN",description:"Search LinkedIn people/organizations to mention in a post (use the returned URN in the post text).",requiredParams:["q"],optionalParams:["scope"],run:(e,t,o)=>e.misc.miscLinkedinGetTags({teamId:t,q:String(o.q),...o.scope?{scope:String(o.scope)}:{}})},{id:"instagram:locations",platform:"INSTAGRAM",description:"Search Instagram locations (use the returned location id as `locationId` when posting).",requiredParams:["q"],optionalParams:["limit"],run:(e,t,o)=>e.misc.miscInstagramSearchLocations({teamId:t,q:String(o.q),...o.limit!==void 0?{limit:Number(o.limit)}:{}})},{id:"gbp:location",platform:"GOOGLE_BUSINESS",description:"Get the connected Google Business Profile location's details.",optionalParams:["fields"],run:(e,t,o)=>e.misc.miscGoogleBusinessGetLocation({teamId:t,...Array.isArray(o.fields)?{fields:o.fields}:{}})},{id:"gbp:categories",platform:"GOOGLE_BUSINESS",description:"List Google Business Profile categories for a region/language (use a category id when updating the location).",requiredParams:["languageCode","regionCode"],optionalParams:["filter","pageSize","pageToken","view"],run:(e,t,o)=>e.misc.miscGoogleBusinessListCategories({teamId:t,languageCode:String(o.languageCode),regionCode:String(o.regionCode),...o.filter?{filter:String(o.filter)}:{},...o.pageSize!==void 0?{pageSize:Number(o.pageSize)}:{},...o.pageToken?{pageToken:String(o.pageToken)}:{},...o.view?{view:String(o.view)}:{}})},{id:"tiktok:trending-music",platform:"TIKTOK",description:"List trending tracks from TikTok's commercial music library (use a track id in the TikTok post settings).",optionalParams:["dateRange","genre"],run:(e,t,o)=>e.misc.miscTiktokGetCommercialMusicTrendingList({teamId:t,...o.dateRange?{dateRange:String(o.dateRange)}:{},...o.genre?{genre:String(o.genre)}:{}})}];function Dt(){return K.map(e=>({method:e.id,platform:e.platform,description:e.description,requiredParams:e.requiredParams??[],optionalParams:e.optionalParams??[]}))}async function _t(e,t,o,n){let i=K.find(r=>r.id===o.trim().toLowerCase());if(!i)throw new u("UNKNOWN_INTEGRATION_TOOL",`Unknown integration tool "${o}". Available: ${K.map(r=>r.id).join(", ")}.`,{available:K.map(r=>r.id)});let a=(i.requiredParams??[]).filter(r=>n[r]===void 0||n[r]===null||n[r]==="");if(a.length>0)throw new u("MISSING_PARAMS",`Integration tool "${i.id}" requires: ${a.join(", ")}. Provide them in the params object.`,{method:i.id,requiredParams:i.requiredParams});return i.run(e,t,n)}var ne=M.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function Pt(e,t){l(e,"list_integration_tools",{title:"List integration helper tools",description:"List the read-only platform helper tools callable via trigger_integration_tool \u2014 e.g. fetch subreddit flairs, YouTube categories/playlists/regions, LinkedIn mentions, Instagram locations, Google Business categories, TikTok trending music. Each entry has a `method` id and the params it accepts. Use these to discover values the API needs (flair ids, category ids, mention URNs, \u2026).",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>s({tools:Dt()})),l(e,"trigger_integration_tool",{title:"Call an integration helper tool",description:'Call one of the platform helper tools (see list_integration_tools), e.g. method "reddit:flairs" with params {"subreddit":"r/test"}. Returns the raw result.',inputSchema:{method:M.string().min(1).describe('Tool method id, e.g. "reddit:flairs", "youtube:categories", "linkedin:mentions" (call list_integration_tools first).'),params:M.record(M.string(),M.unknown()).optional().describe('Parameters for the tool as a JSON object, e.g. {"subreddit":"r/test"}.'),teamId:ne},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({method:o,params:n,teamId:i})=>{let a=await f(t,i);return s(await _t(t.client,a,o,n??{}))})}import{z as _}from"zod";function vt(e,t){l(e,"list_teams",{title:"List teams",description:"List the teams in the organization (paginated). Use this to discover team ids for the optional `teamId` argument on other tools.",inputSchema:{limit:_.number().int().positive().max(100).optional().describe("Max number of teams to return."),offset:_.number().int().nonnegative().optional().describe("Number of teams to skip (for pagination)."),search:_.string().optional().describe("Free-text search over team names.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({limit:o,offset:n,search:i})=>s(await t.client.team.teamGetList({limit:o??null,offset:n??null,search:i??null}))),l(e,"get_team",{title:"Get a team by id",description:"Fetch a single team by id, including its connected social accounts/integrations.",inputSchema:{id:_.string().min(1).describe("Team id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.team.teamGetTeam({id:o}))),l(e,"create_team",{title:"Create a team",description:"Create a new team in the organization. Optionally copy the connected social accounts from an existing team via `copyTeamId`.",inputSchema:{name:_.string().min(1).describe("Team name."),avatarUrl:_.string().optional().describe("Optional avatar image URL."),copyTeamId:_.string().optional().describe("Optional id of an existing team to copy social accounts from.")},annotations:{openWorldHint:!0}},async({name:o,avatarUrl:n,copyTeamId:i})=>s(await t.client.team.teamCreateTeam({requestBody:{name:o,avatarUrl:n??null,copyTeamId:i??null}}))),l(e,"update_team",{title:"Update a team",description:"Update a team's name and/or avatar. Only the fields you pass are changed.",inputSchema:{id:_.string().min(1).describe("Team id."),name:_.string().optional().describe("New team name."),avatarUrl:_.string().nullable().optional().describe("New avatar image URL, or null to clear it.")},annotations:{openWorldHint:!0}},async({id:o,name:n,avatarUrl:i})=>{let a={};if(n!==void 0&&(a.name=n),i!==void 0&&(a.avatarUrl=i),Object.keys(a).length===0)throw new u("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of name, avatarUrl.");return s(await t.client.team.teamUpdateTeam({id:o,requestBody:a}))}),l(e,"delete_team",{title:"Delete a team",description:"Delete a team by id. This is destructive and cannot be undone \u2014 it removes the team and its scheduled content.",inputSchema:{id:_.string().min(1).describe("Team id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.team.teamDeleteTeam({id:o})))}import{z as H}from"zod";var ie=H.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function Rt(e,t){l(e,"get_organization",{title:"Get the organization",description:"Fetch the current organization \u2014 its id, name, API-access flag, plan limits and the list of teams.",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>s(await t.client.organization.organizationGetOrganization())),l(e,"get_usage",{title:"Get usage quotas",description:"Organization usage quotas: posts, comments and uploads (used/limit/remaining), plus a paginated per-social-account breakdown of post-history import usage. Use the pagination/filter args for the imports breakdown.",inputSchema:{teamId:ie,platform:H.string().optional().describe("Filter the imports breakdown to one platform name/alias (e.g. instagram, tiktok)."),socialAccountId:H.string().optional().describe("Filter the imports breakdown to one social-account id."),page:H.number().int().positive().optional().describe("Page of the imports breakdown (1-based)."),pageSize:H.number().int().positive().max(100).optional().describe("Page size of the imports breakdown.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,platform:n,socialAccountId:i,page:a,pageSize:r})=>{let d=o??t.defaultTeamId??await f(t,o).catch(()=>{}),[m,h,y,I]=await Promise.all([t.client.organization.organizationGetPostsUsage().catch(b=>({error:C(b)})),t.client.organization.organizationGetCommentsUsage().catch(b=>({error:C(b)})),t.client.organization.organizationGetUploadsUsage().catch(b=>({error:C(b)})),t.client.organization.organizationGetImportsUsage({page:a,pageSize:r,teamId:d,socialAccountType:n?S(n):void 0,socialAccountId:i}).catch(b=>({error:C(b)}))]);return s({posts:m,comments:h,uploads:y,imports:I})})}import{z as A}from"zod";var Lt=A.string().min(1).describe("Platform name/alias. Post-history import is available on FACEBOOK, INSTAGRAM, THREADS, TIKTOK, YOUTUBE, LINKEDIN, PINTEREST, REDDIT, MASTODON, BLUESKY.");function Ut(e,t){l(e,"create_post_import",{title:"Import post history",description:"Start an async import of a connected account's recent posts (optionally with analytics) for one platform. Poll list_post_imports / get_post_import for status and list_imported_posts for the imported posts.",inputSchema:{platform:Lt,count:A.number().int().positive().describe("How many recent posts to import."),withAnalytics:A.boolean().optional().describe("Also fetch analytics for the imported posts."),importCarousels:A.boolean().optional().describe("Include carousel/album posts (Instagram)."),surface:A.enum(["PROFILE_GRID","NON_GRID","STORY","ALL"]).optional().describe("Which surface to import from (Instagram)."),mediaType:A.enum(["VIDEO","IMAGE"]).optional().describe("Restrict to one media type."),teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{openWorldHint:!0}},async({platform:o,count:n,withAnalytics:i,importCarousels:a,surface:r,mediaType:c,teamId:d})=>{let m=await f(t,d);return s(await t.client.postImport.postImportCreate({requestBody:{teamId:m,socialAccountType:S(o),count:n,...i!==void 0?{withAnalytics:i}:{},...a!==void 0?{importCarousels:a}:{},...r?{surface:r}:{},...c?{mediaType:c}:{}}}))}),l(e,"list_post_imports",{title:"List post-history imports",description:"List post-history import jobs for a team, optionally filtered by platform.",inputSchema:{teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),platform:A.string().optional().describe("Filter by platform name/alias.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,platform:n})=>{let i=await f(t,o);return s(await t.client.postImport.postImportGetStatus({teamId:i,socialAccountType:n?S(n):void 0}))}),l(e,"get_post_import",{title:"Get a post-history import by id",description:"Fetch a single post-history import job by its id, including its status and counts.",inputSchema:{importId:A.string().min(1).describe("Post import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.postImport.postImportGetById({importId:o}))),l(e,"list_imported_posts",{title:"List imported posts for a platform",description:"List the posts imported (with analytics, when available) for a connected account on the given platform.",inputSchema:{platform:Lt,teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),limit:A.number().int().positive().max(100).optional(),offset:A.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n,limit:i,offset:a})=>{let r=await f(t,n);return s(await t.client.postImport.postImportGetImportedPosts({teamId:r,socialAccountType:S(o),limit:i,offset:a??null}))}),l(e,"delete_imported_posts",{title:"Delete imported posts",description:"Bulk-delete imported posts (and their analytics) by id. Destructive.",inputSchema:{postIds:A.array(A.string().min(1)).min(1).describe("Imported-post ids to delete."),teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({postIds:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.postImport.postImportDeleteImportedPosts({requestBody:{teamId:i,postIds:o}}))}),l(e,"retry_post_import",{title:"Retry a post-history import",description:"Retry a post-history import job that ended in FAILED / RATE_LIMITED.",inputSchema:{importId:A.string().min(1).describe("Post import id."),teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{openWorldHint:!0}},async({importId:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.postImport.postImportRetryImport({importId:o,requestBody:{teamId:i}}))})}import ae from"fs/promises";import dt from"path";import{z as R}from"zod";function re(e){return/^https?:\/\//i.test(e.trim())}async function se(e){if(re(e)){let n=await fetch(e.trim());if(!n.ok)throw new u("CSV_FETCH_FAILED",`Could not download the CSV from "${e}" (HTTP ${n.status}).`,{status:n.status});let i=Buffer.from(await n.arrayBuffer()),a=dt.basename(new URL(e).pathname)||"import.csv";return new File([i],a,{type:"text/csv"})}let t=dt.resolve(e),o;try{o=await ae.readFile(t)}catch{throw new u("CSV_NOT_FOUND",`Could not read CSV "${e}". Provide a public https:// URL, or a local file path that exists on the machine running this MCP server (stdio mode only).`,{path:t})}return new File([o],dt.basename(t),{type:"text/csv"})}function Nt(e,t){l(e,"create_post_csv_import",{title:"Bulk-import posts from a CSV",description:"Upload a CSV for async bulk post import. Accepts a public https:// URL to the CSV, or a local file path when this server runs in stdio mode. Poll get_post_csv_import_status / get_post_csv_import_rows for progress and per-row results.",inputSchema:{source:R.string().min(1).describe("Public https:// URL of the CSV, or a local file path (stdio mode only).")},annotations:{openWorldHint:!0}},async({source:o})=>{let n=await se(o);return s(await t.client.postCsv.postCsvCreate({formData:{file:n}}))}),l(e,"list_post_csv_imports",{title:"List CSV imports",description:"List the post-CSV import history (paginated).",inputSchema:{limit:R.number().int().positive().max(100).optional(),offset:R.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({limit:o,offset:n})=>s(await t.client.postCsv.postCsvGetList({limit:o??null,offset:n??null}))),l(e,"get_post_csv_import",{title:"Get a CSV import by id",description:"Fetch a single post-CSV import by its id, including counts and status.",inputSchema:{importId:R.string().min(1).describe("CSV import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.postCsv.postCsvGetById({importId:o}))),l(e,"get_post_csv_import_status",{title:"Get a CSV import's processing status",description:"Fetch the processing status of a post-CSV import (rows processed/succeeded/failed).",inputSchema:{importId:R.string().min(1).describe("CSV import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.postCsv.postCsvGetStatus({importId:o}))),l(e,"get_post_csv_import_rows",{title:"Get a CSV import's row results",description:"List per-row results of a post-CSV import (the raw row, normalized payload, created post id or error), optionally filtered by SUCCESS/FAILED.",inputSchema:{importId:R.string().min(1).describe("CSV import id."),status:R.enum(["SUCCESS","FAILED"]).optional().describe("Filter rows by outcome."),limit:R.number().int().positive().max(100).optional(),offset:R.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o,status:n,limit:i,offset:a})=>s(await t.client.postCsv.postCsvGetRows({importId:o,status:n,limit:i??null,offset:a??null})))}var le=z.version;function kt(e,t){l(e,"check_setup",{title:"Check the bundle.social setup",description:"Diagnose this MCP server's setup: API key present, API reachable, API key valid, organization API access, team resolution, connected integrations and posts quota. Always returns a structured diagnostic object ({ ok, checks: [...] }).",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>{let o=[],n=(d,m,h,y={})=>o.push({name:d,status:m,message:h,...y}),i=()=>s({ok:o.every(d=>d.status!=="fail"),mcpVersion:le,node:process.version,checks:o});n("api_key","ok","API key configured");try{let d=await t.client.app.appGetHealth();n("api_reachable","ok","API reachable",{health:d})}catch(d){return n("api_reachable","fail","Could not reach the bundle.social API",{error:C(d)}),i()}let a=[],r;try{let d=await t.client.organization.organizationGetOrganization();a=(d.teams??[]).map(m=>({id:m.id,name:m.name})),r=d.apiAccess,n("authentication","ok","API key is valid",{organizationId:d.id,organizationName:d.name??null})}catch(d){return n("authentication","fail","API key was rejected by the API",{error:C(d)}),i()}n("api_access",r?"ok":"fail",r?"Organization has API access enabled":"Organization does not have API access enabled \u2014 upgrade your plan or contact bundle.social support");let c;if(t.defaultTeamId?(c=t.defaultTeamId,n("team","ok","Using team from BUNDLESOCIAL_TEAM_ID / --team-id",{teamId:c})):a.length===1?(c=a[0].id,n("team","ok","Using the organization's only team",{teamId:c,teamName:a[0].name})):a.length===0?n("team","fail","Organization has no teams \u2014 create one in the dashboard"):n("team","warn",`Organization has ${a.length} teams; tools need a teamId argument (or set BUNDLESOCIAL_TEAM_ID)`,{teams:a}),c)try{let m=(await t.client.team.teamGetTeam({id:c})).socialAccounts??[];n("integrations",m.length>0?"ok":"warn",m.length>0?`${m.length} connected integration(s)`:"No integrations connected \u2014 connect one in the dashboard before posting",{count:m.length,platforms:m.map(h=>h.type),connectUrl:gt})}catch(d){n("integrations","fail","Could not load the team's integrations",{teamId:c,error:C(d)})}try{let d=await t.client.organization.organizationGetPostsUsage();n("posts_quota",d.remaining>0?"ok":"warn",`Posts quota: ${d.used}/${d.limit} used, ${d.remaining} remaining`,{used:d.used,limit:d.limit,remaining:d.remaining})}catch(d){n("posts_quota","warn","Could not read posts quota",{error:C(d)})}return i()})}function Bt(e,t){Rt(e,t),vt(e,t),bt(e,t),wt(e,t),At(e,t),Et(e,t),Ct(e,t),Ut(e,t),Nt(e,t),Pt(e,t),kt(e,t)}var j=z.version;function Gt(e){let t=new de({name:"bundlesocial",version:j},{capabilities:{tools:{}},instructions:"Tools for the bundle.social API: posting/scheduling to 14+ social platforms, comments, media uploads, analytics, team & integration management, and bulk/history imports (post-history, comment, CSV). Run check_setup first to verify the API key, org access and team. Use list_integrations to see connected accounts and their ids. create_post / schedule_post target platforms by name (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp) or by integration id; put platform-required fields (Reddit `sr`, Pinterest `boardName`, TikTok `privacy`, YouTube `madeForKids`/`privacyStatus`) under `platformSettings` keyed by platform \u2014 per-platform fields are documented at https://docs.bundle.social/api-reference/platform-parameters. Team-scoped tools take an optional `teamId` (resolved automatically when the org has one team or BUNDLESOCIAL_TEAM_ID is set). Errors come back as { error: { code, message, details } } with isError: true."}),o={client:ht(e.apiKey,e.apiUrl??x),defaultTeamId:e.defaultTeamId};return Bt(t,o),t}function ct(e){let t=process.argv.indexOf(`--${e}`);if(t!==-1&&t+1<process.argv.length)return process.argv[t+1];let o=process.argv.find(n=>n.startsWith(`--${e}=`));return o?o.slice(`--${e}=`.length):void 0}function mt(e){process.stderr.write(`bundlesocial-mcp: ${e}
|
|
4
|
-
`)}async function
|
|
5
|
-
`);return}if(process.argv.includes("--help")||process.argv.includes("-h")){process.stdout.write(`bundlesocial-mcp ${
|
|
2
|
+
import{StdioServerTransport as Rt}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as Pt}from"@modelcontextprotocol/sdk/server/mcp.js";var j={name:"bundlesocial-mcp",version:"1.2.0",mcpName:"io.github.bundleglobal/bundlesocial-mcp",description:"Model Context Protocol server for the bundle.social social-media API \u2014 post to 14+ platforms from Claude, Cursor and other MCP clients.",keywords:["bundle.social","bundlesocial","mcp","model context protocol","social media","api","agents","claude","cursor"],author:"bundle.global",license:"MIT",homepage:"https://github.com/bundleglobal/bundlesocial-mcp#readme",bugs:{url:"https://github.com/bundleglobal/bundlesocial-mcp/issues"},repository:{type:"git",url:"git+https://github.com/bundleglobal/bundlesocial-mcp.git"},type:"module",bin:{"bundlesocial-mcp":"./dist/index.js"},files:["dist/**","server.json","README.md","CHANGELOG.md","LICENSE"],engines:{node:">=20"},scripts:{build:"tsup",dev:"tsup --watch",typecheck:"tsc --noEmit",start:"node dist/index.js",test:"vitest run","test:watch":"vitest",prepublishOnly:"npm run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.12.0",bundlesocial:"^2.61.0",zod:"^3.23.8"},devDependencies:{"@semantic-release/changelog":"^6.0.3","@semantic-release/git":"^10.0.1","@types/node":"^20.14.0","semantic-release":"^25.0.2",tsup:"^8.2.4",typescript:"^5.5.4",vitest:"^2.0.5"}};import{Bundlesocial as Qe,OpenAPI as Je}from"bundlesocial";import{ApiError as Se}from"bundlesocial";var f=class extends Error{code;details;constructor(e,o,n){super(o),this.name="McpToolError",this.code=e,this.details=n}};function Ze(t){if(t instanceof f)return{code:t.code,message:t.message,details:t.details};if(t instanceof Se){let e=t.body,o=typeof e=="object"&&e&&typeof e.message=="string"&&e.message||typeof e=="object"&&e&&typeof e.error=="string"&&e.error||t.statusText||t.message||`HTTP ${t.status}`;return{code:`HTTP_${t.status}`,message:o,details:{status:t.status,url:t.url,body:t.body}}}return t instanceof Error?{code:"UNEXPECTED_ERROR",message:t.message||"Unexpected error",details:process.env.BUNDLESOCIAL_DEBUG?{stack:t.stack}:void 0}:{code:"UNEXPECTED_ERROR",message:String(t)}}function C(t){return t instanceof Se?`HTTP ${t.status}${t.statusText?` ${t.statusText}`:""}`:t instanceof Error?t.message:String(t)}function r(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function Te(t){return{content:[{type:"text",text:JSON.stringify({error:Ze(t)},null,2)}],isError:!0}}var Z="https://api.bundle.social",Q="https://bundle.social/dashboard/organization/api-keys",Ie="https://bundle.social/dashboard/general/social-accounts";function Ee(t,e=Z){return new Qe(t,{...Je,BASE:e})}async function g(t,e){if(e)return e;if(t.defaultTeamId)return t.defaultTeamId;let n=(await t.client.organization.organizationGetOrganization()).teams??[];if(n.length===1)return n[0].id;throw n.length===0?new f("NO_TEAMS","This organization has no teams yet. Create one in the bundle.social dashboard first."):new f("TEAM_ID_REQUIRED",`This organization has ${n.length} teams. Pass a "teamId" argument (or set BUNDLESOCIAL_TEAM_ID when starting the server).`,{teams:n.map(a=>({id:a.id,name:a.name}))})}import{z as I}from"zod";var L=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","TWITTER","THREADS","LINKEDIN","PINTEREST","REDDIT","MASTODON","DISCORD","SLACK","BLUESKY","GOOGLE_BUSINESS","SNAPCHAT"],Ae=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","REDDIT","PINTEREST","MASTODON","LINKEDIN","BLUESKY","GOOGLE_BUSINESS","SNAPCHAT"],et={X:"TWITTER",TWITTER:"TWITTER",TIKTOK:"TIKTOK",TT:"TIKTOK",YOUTUBE:"YOUTUBE",YT:"YOUTUBE",INSTAGRAM:"INSTAGRAM",IG:"INSTAGRAM",INSTA:"INSTAGRAM",FACEBOOK:"FACEBOOK",FB:"FACEBOOK",THREADS:"THREADS",LINKEDIN:"LINKEDIN",LI:"LINKEDIN",PINTEREST:"PINTEREST",PIN:"PINTEREST",REDDIT:"REDDIT",MASTODON:"MASTODON",MASTO:"MASTODON",DISCORD:"DISCORD",SLACK:"SLACK",BLUESKY:"BLUESKY",BSKY:"BLUESKY",GOOGLE_BUSINESS:"GOOGLE_BUSINESS","GOOGLE-BUSINESS":"GOOGLE_BUSINESS",GBP:"GOOGLE_BUSINESS",GOOGLEBUSINESS:"GOOGLE_BUSINESS",GMB:"GOOGLE_BUSINESS",SNAPCHAT:"SNAPCHAT",SNAP:"SNAPCHAT"};function x(t){return et[t.trim().toUpperCase().replace(/\s+/g,"_")]}function b(t){let e=x(t);if(!e)throw new f("UNKNOWN_PLATFORM",`Unknown platform "${t}". Supported: ${L.join(", ")} (aliases like "x" and "gbp" are accepted too).`);return e}function J(t){return Ae.includes(t)}var k=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","LINKEDIN","REDDIT","MASTODON","DISCORD","SLACK","BLUESKY"];function G(t){return k.includes(t)}function M(t){let e=b(t);if(!J(e))throw new f("ANALYTICS_NOT_SUPPORTED",`Analytics are not available for ${e}. Supported: ${Ae.join(", ")}.`);return e}function l(t,e,o,n){t.registerTool(e,o,(async a=>{try{return await n(a??{})}catch(i){return Te(i)}}))}var v=I.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),B=I.string().min(1).describe("Platform name/alias (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp).");function ee(t){return(t??[]).map(e=>({id:e.id,type:e.type,username:e.username??null,displayName:e.displayName??null,avatarUrl:e.avatarUrl??null,channels:(e.channels??[]).map(o=>({id:o.id,name:o.name??null,username:o.username??null,address:o.address??null}))}))}function Oe(t,e){l(t,"list_integrations",{title:"List connected integrations",description:"List the social-media integrations (accounts) connected to a bundle.social team \u2014 each with its `id`, `type` (platform), `username` and channels. Use this to discover which platforms are available and to get integration ids. Without a team id it lists every team in the organization.",inputSchema:{teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o})=>{if(o??e.defaultTeamId){let s=o??e.defaultTeamId,d=await e.client.team.teamGetTeam({id:s});return r({teamId:d.id,teamName:d.name,integrations:ee(d.socialAccounts)})}let n=await e.client.organization.organizationGetOrganization(),a=n.teams??[];if(a.length===1){let s=await e.client.team.teamGetTeam({id:a[0].id});return r({teamId:s.id,teamName:s.name,integrations:ee(s.socialAccounts)})}let i=[];for(let s of a){let d=await e.client.team.teamGetTeam({id:s.id});i.push({teamId:d.id,teamName:d.name,integrations:ee(d.socialAccounts)})}return r({organizationId:n.id,organizationName:n.name??null,teams:i})}),l(t,"connect_integration",{title:"Connect a social account",description:"Start connecting a social account to a team. Returns an OAuth `url` \u2014 open it in a browser to authorize the account; bundle.social redirects back to `redirectUrl` afterwards. For Mastodon/Bluesky pass `serverUrl`.",inputSchema:{platform:B,redirectUrl:I.string().min(1).describe("URL bundle.social redirects to after the user finishes (or cancels) the OAuth flow."),serverUrl:I.string().optional().describe("Mastodon/Bluesky instance URL (required for those platforms)."),teamId:v,options:I.record(I.string(),I.unknown()).optional().describe('Advanced provider flags, e.g. {"instagramConnectionMethod":"INSTAGRAM","withBusinessScope":true,"disableAutoLogin":true,"forceBrowserOAuth":true,"tiktokForceLogin":true}. `withBusinessScope` also unlocks YouTube monetization analytics; `tiktokForceLogin` (experimental) forces TikTok\'s account picker when it keeps reusing the wrong active account.')},annotations:{openWorldHint:!0}},async({platform:o,redirectUrl:n,serverUrl:a,teamId:i,options:s})=>{let d=await g(e,i),m={type:b(o),teamId:d,redirectUrl:n,...a?{serverUrl:a}:{},...s??{}};return r(await e.client.socialAccount.socialAccountConnect({requestBody:m}))}),l(t,"disconnect_integration",{title:"Disconnect a social account",description:"Disconnect a social account of the given platform from a team. Destructive \u2014 also removes it from scheduled posts.",inputSchema:{platform:B,teamId:v},annotations:{destructiveHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let a=await g(e,n);return r(await e.client.socialAccount.socialAccountDisconnect({requestBody:{type:b(o),teamId:a}}))}),l(t,"set_integration_channel",{title:"Set a social account's channel/page",description:"Select the page/channel for a connected account (needed for FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, GOOGLE_BUSINESS). Get channel ids from list_integrations / refresh_integration_channels.",inputSchema:{platform:B,channelId:I.string().min(1).describe("Channel/page id to select."),teamId:v},annotations:{openWorldHint:!0}},async({platform:o,channelId:n,teamId:a})=>{let i=await g(e,a);return r(await e.client.socialAccount.socialAccountSetChannel({requestBody:{type:b(o),teamId:i,channelId:n}}))}),l(t,"unset_integration_channel",{title:"Clear a social account's channel/page",description:"Clear the selected page/channel for a connected account (FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, GOOGLE_BUSINESS) while keeping the authorization.",inputSchema:{platform:B,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let a=await g(e,n);return r(await e.client.socialAccount.socialAccountUnsetChannel({requestBody:{type:b(o),teamId:a}}))}),l(t,"refresh_integration_channels",{title:"Refresh a social account's channels",description:"Re-fetch the available channels for a connected account (needed for REDDIT, DISCORD, SLACK, PINTEREST and the page-based platforms).",inputSchema:{platform:B,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let a=await g(e,n);return r(await e.client.socialAccount.socialAccountRefreshChannels({requestBody:{type:b(o),teamId:a}}))}),l(t,"create_integration_portal_link",{title:"Create a connect-portal link",description:"Create a hosted bundle.social portal link a user can open to connect/manage social accounts without you implementing the OAuth flow. Returns a `url`.",inputSchema:{platforms:I.array(I.string().min(1)).min(1).describe("Platforms the portal should offer to connect (names/aliases)."),redirectUrl:I.string().optional().describe("URL to redirect to when the user finishes."),teamId:v,expiresInMinutes:I.number().int().min(5).max(2880).optional().describe("Link lifetime in minutes (5 min \u2013 48 h)."),options:I.record(I.string(),I.unknown()).optional().describe("Advanced portal options \u2014 branding (logoUrl, userLogoUrl, userName, goBackButtonText, hidePoweredBy, hideGoBackButton, hideUserLogo, hideUserName, hideLanguageSwitcher, showModalOnConnectSuccess, language, maxSocialAccountsConnected) and the same OAuth flags as connect_integration (serverUrl, instagramConnectionMethod, withBusinessScope, disableAutoLogin, forceBrowserOAuth, tiktokForceLogin).")},annotations:{openWorldHint:!0}},async({platforms:o,redirectUrl:n,teamId:a,expiresInMinutes:i,options:s})=>{let m={teamId:await g(e,a),socialAccountTypes:o.map(u=>b(u)),...n?{redirectUrl:n}:{},...i?{expiresIn:i}:{},...s??{}};return r(await e.client.socialAccount.socialAccountCreatePortalLink({requestBody:m}))}),l(t,"check_integration_connection",{title:"Check a social account's connection",description:"Run an on-demand connection/disconnect health check for a connected account of the given platform.",inputSchema:{platform:B,teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let a=await g(e,n);return r(await e.client.socialAccount.socialAccountConnectionCheck({requestBody:{type:b(o),teamId:a}}))}),l(t,"refresh_integration_profile",{title:"Refresh a social account's profile",description:"Re-fetch the profile info (username, display name, avatar) for a connected account of the given platform.",inputSchema:{platform:B,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let a=await g(e,n);return r(await e.client.socialAccount.socialAccountProfileRefresh({requestBody:{type:b(o),teamId:a}}))}),l(t,"get_integration_by_type",{title:"Get a social account by platform",description:"Fetch the connected social account of a given platform for a team (including its channels).",inputSchema:{platform:B,teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let a=await g(e,n);return r(await e.client.socialAccount.socialAccountGetByType({teamId:a,type:b(o)}))}),l(t,"copy_integration",{title:"Copy social accounts between teams",description:"Copy connected social accounts of the given platforms from one team to another. Set `resetChannel` to require re-picking the page (Facebook/Instagram/LinkedIn/YouTube).",inputSchema:{fromTeamId:I.string().min(1).describe("Source team id."),toTeamId:I.string().min(1).describe("Destination team id."),platforms:I.array(I.string().min(1)).min(1).describe("Platforms to copy (names/aliases)."),resetChannel:I.boolean().optional().describe("If true, the destination must re-select the page/channel.")},annotations:{openWorldHint:!0}},async({fromTeamId:o,toTeamId:n,platforms:a,resetChannel:i})=>r(await e.client.socialAccount.socialAccountCopy({requestBody:{fromTeamId:o,toTeamId:n,...i!==void 0?{resetChannel:i}:{},socialAccountTypes:a.map(s=>b(s))}}))),l(t,"list_integrations_to_delete",{title:"List social accounts pending deletion",description:"List social accounts scheduled to be deleted (paginated) across the organization.",inputSchema:{page:I.number().int().positive().optional().describe("Page (1-based)."),pageSize:I.number().int().positive().max(100).optional().describe("Page size.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({page:o,pageSize:n})=>r(await e.client.socialAccount.socialAccountGetAccountsToDelete({page:o,pageSize:n})))}import{z as p}from"zod";import tt from"fs/promises";import K from"path";var ot={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".tif":"image/tiff",".tiff":"image/tiff",".heic":"image/heic",".heif":"image/heif",".mp4":"video/mp4",".m4v":"video/x-m4v",".mov":"video/quicktime",".webm":"video/webm",".avi":"video/x-msvideo",".mkv":"video/x-matroska",".pdf":"application/pdf",".mp3":"audio/mpeg",".m4a":"audio/mp4",".wav":"audio/wav"};function nt(t){return/^https?:\/\//i.test(t.trim())}var at=90*1024*1024,it={".jpg":"image/jpg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".mp4":"video/mp4",".pdf":"application/pdf"};async function te(t,e,o){if(nt(o))return t.upload.uploadCreateFromUrl({requestBody:{teamId:e,url:o.trim()}});let n=K.resolve(o),a;try{a=await tt.readFile(n)}catch{throw new f("MEDIA_NOT_FOUND",`Could not read media "${o}". Provide a public https:// URL, or a local file path that exists on the machine running this MCP server (stdio mode only).`,{path:n})}if(a.byteLength>at)return rt(t,e,n,a);let i=ot[K.extname(n).toLowerCase()]??"application/octet-stream",s=new File([a],K.basename(n),{type:i});return t.upload.uploadCreate({formData:{teamId:e,file:s}})}async function rt(t,e,o,n){let a=K.extname(o).toLowerCase(),i=it[a];if(!i)throw new f("LARGE_UPLOAD_UNSUPPORTED_TYPE",`Large uploads (>90 MB) only support .jpg, .jpeg, .png, .gif, .mp4 and .pdf \u2014 got "${a||"no extension"}".`,{path:o});let s=await t.upload.uploadInitLargeUpload({requestBody:{teamId:e,fileName:K.basename(o),mimeType:i}}),d=await fetch(s.url,{method:"PUT",headers:{"content-type":i},body:new Uint8Array(n)});if(!d.ok)throw new f("LARGE_UPLOAD_FAILED",`Uploading the file to storage failed (HTTP ${d.status}).`,{status:d.status});return t.upload.uploadFinalizeLargeUpload({requestBody:{teamId:e,path:s.path}})}async function oe(t,e,o){let n=[];for(let a of o){let i=await te(t,e,a);n.push(i.id)}return n}function st(t,e){if(typeof t!="object"||t===null||Array.isArray(t))throw new f("INVALID_INPUT",`${e} must be a JSON object.`);return t}async function z(t,e,o){let n=new Set,a=[];for(let i of o){let s=x(i);s?n.add(s):a.push(i.trim())}if(a.length>0){let s=(await t.team.teamGetTeam({id:e})).socialAccounts??[];for(let d of a){let m=s.find(u=>u.id===d);if(!m)throw new f("INTEGRATION_NOT_FOUND",`No connected integration with id "${d}" in team ${e}. Call list_integrations to see ids, or use a platform name like "x" or "tiktok".`,{availableIntegrations:s.map(u=>({id:u.id,type:u.type,username:u.username}))});n.add(m.type)}}return[...n]}function lt(t){let e=Object.keys(t);return e.length>0&&e.every(o=>L.includes(o.trim().toUpperCase()))}function dt(t,e){let o=Object.fromEntries(e.map(n=>[n,{}]));if(!t)return o;if(lt(t)){for(let[n,a]of Object.entries(t)){let i=n.trim().toUpperCase();i in o&&(o[i]={...o[i],...st(a,`platformSettings.${n}`)})}return o}for(let n of e)o[n]={...t};return o}function ne(t,e){if(e.data)return e.data;let o=dt(e.platformSettings,t),n={};for(let a of t)n[a]={...e.content!==void 0?{text:e.content}:{},...e.mediaUploadIds.length>0?{uploadIds:e.mediaUploadIds}:{},...o[a]};return n}function ae(t){return Object.keys(t).map(e=>b(e))}function we(t,e){let o=(t??"").split(`
|
|
3
|
+
`).map(n=>n.trim()).find(n=>n.length>0);return o?o.length>80?`${o.slice(0,79)}\u2026`:o:e}function W(t,e){let o=new Date(t);if(Number.isNaN(o.getTime()))throw new f("INVALID_DATE",`${e} is not a valid ISO 8601 date/time: "${t}". Example: 2026-06-01T09:00:00Z`);return o.toISOString()}function ie(t,e){if(t===void 0)return;if(typeof t=="string"){let n=e.filter(G);if(n.length===0)throw new f("COMMENTS_NOT_SUPPORTED",`None of the targeted platforms support comments, so firstComment has no effect. Supported: ${k.join(", ")}.`);let a={};for(let i of n)a[i]=t;return a}let o={};for(let[n,a]of Object.entries(t)){let i=b(n);if(!G(i))throw new f("COMMENTS_NOT_SUPPORTED",`A first comment is not supported on ${i}. Supported: ${k.join(", ")}.`);o[i]=a}return o}var re=p.string().min(1).optional().describe("Your own identifier for this post. Look the post up later with get_post_by_reference_key."),se=p.union([p.string().min(1),p.record(p.string(),p.string())]).optional().describe('Comment published as soon as the post itself goes live. A string applies to every comment-capable target; a platform-keyed object targets specific platforms, e.g. {"INSTAGRAM":"more below \u{1F447}"}. Supported on TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, LINKEDIN, REDDIT, MASTODON, DISCORD, SLACK, BLUESKY.'),H=p.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),le=p.array(p.string().min(1)).optional().describe('Target platforms \u2014 names/aliases (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, bluesky, gbp, snapchat) and/or connected integration ids from list_integrations. Required unless "data" is provided with platform keys.'),de=p.array(p.string().min(1)).optional().describe("Media to attach: public https:// URLs (or local file paths when this server runs in stdio mode). Uploaded automatically and attached to every targeted platform. For per-platform media, use upload_media + the `data` argument instead."),me=p.record(p.string(),p.unknown()).optional().describe('Per-platform options. Either keyed by platform name, e.g. {"TIKTOK":{"privacy":"PUBLIC_TO_EVERYONE"},"YOUTUBE":{"type":"SHORT","privacyStatus":"PUBLIC","madeForKids":false}}, or a flat object applied to every targeted platform. Use this for platform-required fields (Reddit `sr`, Pinterest `boardName`, TikTok `privacy`, YouTube `madeForKids`/`privacyStatus`, Instagram/Facebook `type`).'),ce=p.record(p.string(),p.unknown()).optional().describe('Advanced: the full post `data` object keyed by platform, e.g. {"REDDIT":{"sr":"r/test","text":"hello","uploadIds":["<uploadId>"]}}. Overrides content/media/platformSettings. Targeted platforms are inferred from its keys unless `platforms` is also given.'),Pe=p.string().min(1).optional().describe("Post title. Defaults to the first line of `content`. Also used as the YouTube video title.");async function Re(t,e){let o=await g(t,e.teamId),n;if(e.platforms&&e.platforms.length>0)n=await z(t.client,o,e.platforms);else if(e.data)n=ae(e.data);else throw new f("NO_TARGET",'Provide "platforms" (platform names or integration ids), or a "data" object keyed by platform.');if(n.length===0)throw new f("NO_TARGET","Could not determine any target platform for this post.");let a=await oe(t.client,o,e.media??[]),i=ne(n,{content:e.content,mediaUploadIds:a,platformSettings:e.platformSettings,data:e.data});return{teamId:o,socialAccountTypes:n,data:i,title:e.title??we(e.content,"Untitled post")}}function Ce(t,e){l(t,"create_post",{title:"Create a post (publish now)",description:"Publish a post immediately to one or more connected social-media integrations. Returns the created post (with its id and status). Set `draft: true` to save it as a draft instead of publishing. For a future-dated post use schedule_post.",inputSchema:{teamId:H,content:p.string().optional().describe("Post text, applied to every targeted platform."),platforms:le,media:de,platformSettings:me,data:ce,title:Pe,referenceKey:re,firstComment:se,draft:p.boolean().optional().default(!1).describe("If true, save as a DRAFT instead of publishing now.")},annotations:{openWorldHint:!0}},async({teamId:o,content:n,platforms:a,media:i,platformSettings:s,data:d,title:m,referenceKey:u,firstComment:T,draft:S})=>{let y=await Re(e,{teamId:o,content:n,platforms:a,media:i,platformSettings:s,data:d,title:m}),h={teamId:y.teamId,title:y.title,postDate:new Date().toISOString(),status:S?"DRAFT":"SCHEDULED",socialAccountTypes:y.socialAccountTypes,data:y.data};u!==void 0&&(h.referenceKey=u);let w=ie(T,y.socialAccountTypes);return w&&(h.firstComment=w),r(await e.client.post.postCreate({requestBody:h}))}),l(t,"schedule_post",{title:"Schedule a post for later",description:"Schedule a post to be published at a specific date/time on one or more connected integrations. Same inputs as create_post plus a required ISO-8601 `date`. Returns the scheduled post.",inputSchema:{teamId:H,date:p.string().min(1).describe("When to publish \u2014 ISO 8601, e.g. 2026-06-01T09:00:00Z."),content:p.string().optional().describe("Post text, applied to every targeted platform."),platforms:le,media:de,platformSettings:me,data:ce,title:Pe,referenceKey:re,firstComment:se},annotations:{openWorldHint:!0}},async({teamId:o,date:n,content:a,platforms:i,media:s,platformSettings:d,data:m,title:u,referenceKey:T,firstComment:S})=>{let y=W(n,"date"),h=await Re(e,{teamId:o,content:a,platforms:i,media:s,platformSettings:d,data:m,title:u}),w={teamId:h.teamId,title:h.title,postDate:y,status:"SCHEDULED",socialAccountTypes:h.socialAccountTypes,data:h.data};T!==void 0&&(w.referenceKey=T);let R=ie(S,h.socialAccountTypes);return R&&(w.firstComment=R),r(await e.client.post.postCreate({requestBody:w}))}),l(t,"list_posts",{title:"List recent posts",description:"List recent posts for a team, newest first, with optional filters by status, platform, date range and free-text query.",inputSchema:{teamId:H,limit:p.number().int().positive().max(100).optional().default(20).describe("Max number of posts to return (default 20, max 100)."),offset:p.number().int().nonnegative().optional().describe("Number of posts to skip (for pagination)."),status:p.enum(["DRAFT","SCHEDULED","POSTED","ERROR","DELETED","PROCESSING","REVIEW","RETRYING"]).optional().describe("Filter by post status."),platforms:p.array(p.string().min(1)).optional().describe("Filter by platform name/alias."),from:p.string().optional().describe("Only posts with postDate on/after this ISO-8601 date."),to:p.string().optional().describe("Only posts with postDate on/before this ISO-8601 date."),query:p.string().optional().describe("Free-text search over post titles/content."),order:p.enum(["ASC","DESC"]).optional().describe("Sort direction (default DESC)."),orderBy:p.enum(["createdAt","updatedAt","postDate","postedDate","deletedAt"]).optional().describe("Sort field (default postDate).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,limit:n,offset:a,status:i,platforms:s,from:d,to:m,query:u,order:T,orderBy:S})=>{let y=await g(e,o),h=(s??[]).map(b),w={teamId:y,limit:n,offset:a,status:i??void 0,platforms:h.length>0?h:void 0,postDateFrom:d?W(d,"from"):void 0,postDateTo:m?W(m,"to"):void 0,q:u,order:T??void 0,orderBy:S??void 0};return r(await e.client.post.postGetList(w))}),l(t,"get_post",{title:"Get a post by id",description:"Fetch a single post by its bundle.social id, including its per-platform data and status.",inputSchema:{id:p.string().min(1).describe("Post id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>r(await e.client.post.postGet({id:o}))),l(t,"delete_post",{title:"Delete a post",description:"Delete a post by its bundle.social id. This is destructive and cannot be undone.",inputSchema:{id:p.string().min(1).describe("Post id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>r(await e.client.post.postDelete({id:o}))),l(t,"update_post",{title:"Update a post",description:"Update an existing post by id \u2014 change its title, publish date, status (DRAFT/SCHEDULED), targeted platforms and/or per-platform content. Only the fields you pass are changed. If you change content/media without `platforms`, the post's current platforms are reused.",inputSchema:{id:p.string().min(1).describe("Post id."),title:p.string().optional().describe("New post title."),date:p.string().optional().describe("New publish date, ISO 8601."),status:p.enum(["DRAFT","SCHEDULED"]).optional().describe("New status."),content:p.string().optional().describe("New post text, applied to every targeted platform."),platforms:le,media:de,platformSettings:me,data:ce,referenceKey:re,firstComment:se,teamId:H},annotations:{openWorldHint:!0}},async({id:o,title:n,date:a,status:i,content:s,platforms:d,media:m,platformSettings:u,data:T,referenceKey:S,firstComment:y,teamId:h})=>{let w=await g(e,h),R=s!==void 0||(m?.length??0)>0||u!==void 0||T!==void 0,E;if(d&&d.length>0)E=await z(e.client,w,d);else if(T)E=ae(T);else if(R){let U=await e.client.post.postGet({id:o});if(E=Object.keys(U.data??{}),E.length===0)throw new f("NO_TARGET","Could not determine the post's platforms \u2014 pass `platforms`.")}let A={};if(n!==void 0&&(A.title=n),S!==void 0&&(A.referenceKey=S),y!==void 0){let U=E??Object.keys((await e.client.post.postGet({id:o})).data??{});A.firstComment=ie(y,U)}if(a&&(A.postDate=W(a,"date")),i&&(A.status=i),E&&E.length>0&&(A.socialAccountTypes=E),R&&E&&E.length>0){let U=await oe(e.client,w,m??[]);A.data=ne(E,{content:s,mediaUploadIds:U,platformSettings:u,data:T})}if(Object.keys(A).length===0)throw new f("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of title, date, status, content, media, platformSettings, data, referenceKey, firstComment, platforms.");return r(await e.client.post.postUpdate({id:o,requestBody:A}))}),l(t,"retry_post",{title:"Retry a failed post",description:"Retry publishing a post that ended in the ERROR state.",inputSchema:{id:p.string().min(1).describe("Post id.")},annotations:{openWorldHint:!0}},async({id:o})=>r(await e.client.post.postRetry({id:o}))),l(t,"get_post_by_reference_key",{title:"Get a post by reference key",description:"Fetch a single post by the `referenceKey` set when it was created, instead of by bundle.social post id. Use this when you track posts under your own identifiers.",inputSchema:{referenceKey:p.string().min(1).describe("The reference key you set on the post.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({referenceKey:o})=>r(await e.client.post.postGetByReferenceKey({referenceKey:o}))),l(t,"list_reconnect_candidates",{title:"List posts waiting for a reconnected account",description:"List draft/scheduled posts that lost their link to a social account after a disconnect and can be reattached to a newly connected account of the same platform. Pair with reconnect_posts.",inputSchema:{teamId:H,platform:p.string().min(1).describe("Platform of the reconnected account (name or alias)."),limit:p.number().int().positive().max(100).optional().describe("Max number of posts to return."),offset:p.number().int().nonnegative().optional().describe("Number of posts to skip.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,platform:n,limit:a,offset:i})=>{let d={teamId:await g(e,o),type:b(n),limit:a,offset:i};return r(await e.client.post.postGetReconnectSocialAccountCandidates(d))}),l(t,"reconnect_posts",{title:"Reattach posts to a reconnected account",description:"Attach a newly connected social account to posts that lost their link to the previous account of that platform. Without `postIds`, every candidate is reattached.",inputSchema:{teamId:H,platform:p.string().min(1).describe("Platform of the reconnected account (name or alias)."),postIds:p.array(p.string().min(1)).optional().describe("Only reattach these post ids. Defaults to every candidate.")},annotations:{openWorldHint:!0}},async({teamId:o,platform:n,postIds:a})=>{let i=await g(e,o);return r(await e.client.post.postReconnectSocialAccount({requestBody:{teamId:i,type:b(n),...a&&a.length>0?{postIds:a}:{}}}))})}import{z as c}from"zod";var mt=c.enum(["PENDING","FETCHING","RETRYING","COMPLETED","SKIPPED","FAILED","RATE_LIMITED"]),F=c.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function pe(t){let e=t.filter(o=>!G(o));if(e.length>0)throw new f("COMMENTS_NOT_SUPPORTED",`Comments are not available for ${e.join(", ")}. Supported: ${k.join(", ")}.`);return t}function ct(t){let e=new Date(t);if(Number.isNaN(e.getTime()))throw new f("INVALID_DATE",`date is not a valid ISO 8601 date/time: "${t}". Example: 2026-06-01T09:00:00Z`);return e.toISOString()}function De(t,e){l(t,"create_comment",{title:"Comment on a post",description:"Post one or more comments on a post you created (`postId`) or on a post brought in by create_post_import (`importedPostId`). Pass `content` multiple times to create a chain (the first replies to the post, each subsequent one replies to the previous comment) \u2014 useful for X-style threads via comments. Use `fetchedParentCommentId` to reply to a comment pulled in by create_comment_import. Comments are supported on TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, LINKEDIN, REDDIT, MASTODON, DISCORD, SLACK, BLUESKY. Returns the created comment(s).",inputSchema:{postId:c.string().min(1).optional().describe("Id of the bundle.social post to comment on. Either this or importedPostId is required."),importedPostId:c.string().min(1).optional().describe("Id of an imported (post-history) post to comment on instead of postId. Requires `platforms`."),fetchedParentCommentId:c.string().min(1).optional().describe("Reply to a comment fetched by create_comment_import (its imported-comment id) instead of to the post itself."),content:c.array(c.string().min(1)).min(1).describe("Comment text. Pass multiple to create a chain of replies."),platforms:c.array(c.string().min(1)).optional().describe("Target comment-capable platform names/aliases and/or integration ids. Defaults to the post's platforms (filtered to comment-capable ones)."),date:c.string().optional().describe("When to post the (first) comment, ISO 8601. Default: now."),delayMinutes:c.number().int().nonnegative().optional().default(0).describe("For a chain, minutes to wait between each comment."),draft:c.boolean().optional().default(!1).describe("If true, create the comment(s) as DRAFT instead of posting."),teamId:F},annotations:{openWorldHint:!0}},async({postId:o,importedPostId:n,fetchedParentCommentId:a,content:i,platforms:s,date:d,delayMinutes:m,draft:u,teamId:T})=>{let S=await g(e,T);if(!o&&!n)throw new f("NO_POST","Pass `postId` (a bundle.social post) or `importedPostId` (a post brought in by create_post_import).");let y;if(s&&s.length>0)y=pe(await z(e.client,S,s));else if(o){let A=await e.client.post.postGet({id:o});if(y=Object.keys(A.data??{}).filter(G),y.length===0)throw new f("NO_TARGET","Could not determine comment platforms from the post \u2014 pass `platforms` (comment-capable only).")}else throw new f("NO_TARGET","Pass `platforms` when commenting on an imported post (comment-capable only).");let h=u?"DRAFT":"SCHEDULED",w=d?new Date(ct(d)):new Date,R=[],E;for(let A=0;A<i.length;A+=1){let U=i[A],je=new Date(w.getTime()+A*(m??0)*6e4).toISOString(),Ve=Object.fromEntries(y.map($e=>[$e,{text:U}])),be=await e.client.comment.commentCreate({requestBody:{teamId:S,...o?{internalPostId:o}:{importedPostId:n},...E?{internalParentCommentId:E}:{},...!E&&a?{fetchedParentCommentId:a}:{},status:h,postDate:je,socialAccountTypes:y,data:Ve,text:U}});R.push(be),E=be.id}return r(R.length===1?R[0]:R)}),l(t,"list_comments",{title:"List comments",description:"List comments for a team, optionally filtered by post, status and platform.",inputSchema:{postId:c.string().optional().describe("Only comments on this post."),limit:c.number().int().positive().max(100).optional().default(20),offset:c.number().int().nonnegative().optional(),status:c.enum(["DRAFT","SCHEDULED","POSTED","ERROR","DELETED","PROCESSING","RETRYING"]).optional(),platforms:c.array(c.string().min(1)).optional().describe("Filter by comment-capable platform name/alias."),query:c.string().optional(),order:c.enum(["ASC","DESC"]).optional(),orderBy:c.enum(["createdAt","updatedAt","deletedAt"]).optional(),teamId:F},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postId:o,limit:n,offset:a,status:i,platforms:s,query:d,order:m,orderBy:u,teamId:T})=>{let S=await g(e,T),y=pe((s??[]).map(b)),h={teamId:S,postId:o,limit:n,offset:a,status:i??void 0,platforms:y.length>0?y:void 0,q:d,order:m??void 0,orderBy:u??void 0};return r(await e.client.comment.commentGetList(h))}),l(t,"get_comment",{title:"Get a comment by id",description:"Fetch a single comment by its bundle.social id.",inputSchema:{id:c.string().min(1).describe("Comment id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>r(await e.client.comment.commentGet({id:o}))),l(t,"delete_comment",{title:"Delete a comment",description:"Delete a comment by its bundle.social id. Destructive.",inputSchema:{id:c.string().min(1).describe("Comment id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>r(await e.client.comment.commentDelete({id:o}))),l(t,"update_comment",{title:"Update a comment",description:"Update an existing comment by id \u2014 change its title, scheduled date, status (DRAFT/SCHEDULED), targeted platforms and/or per-platform text. Only the fields you pass are changed. Use `data` for the full per-platform object, or `content` + `platforms` for a same-text-everywhere change.",inputSchema:{id:c.string().min(1).describe("Comment id."),title:c.string().optional().describe("New title."),date:c.string().optional().describe("New scheduled date, ISO 8601."),status:c.enum(["DRAFT","SCHEDULED"]).optional().describe("New status."),content:c.string().optional().describe("New comment text, applied to every platform in `platforms`."),platforms:c.array(c.string().min(1)).optional().describe("Comment-capable platform name/alias. Required when changing `content` without supplying `data`."),data:c.record(c.string(),c.unknown()).optional().describe('Advanced: the full comment `data` object keyed by platform, e.g. {"LINKEDIN":{"text":"new"}}.')},annotations:{openWorldHint:!0}},async({id:o,title:n,date:a,status:i,content:s,platforms:d,data:m})=>{let u=pe((d??[]).map(b)),T=s!==void 0||m!==void 0,S={};if(n!==void 0&&(S.title=n),a){let y=new Date(a);if(Number.isNaN(y.getTime()))throw new f("INVALID_DATE",`date is not a valid ISO 8601 date/time: "${a}". Example: 2026-06-01T09:00:00Z`);S.postDate=y.toISOString()}if(i&&(S.status=i),u.length>0&&(S.socialAccountTypes=u),T)if(m)S.data=m;else{if(u.length===0)throw new f("NO_TARGET","Pass `platforms` when changing `content` (the per-platform comment text needs to know which platforms to target).");let y=Object.fromEntries(u.map(h=>[h,{text:s}]));S.data=y}if(Object.keys(S).length===0)throw new f("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of title, date, status, content (+ platforms), data.");return r(await e.client.comment.commentUpdate({id:o,requestBody:S}))}),l(t,"retry_comment",{title:"Retry a failed comment",description:"Retry publishing a comment that ended in the ERROR state.",inputSchema:{id:c.string().min(1).describe("Comment id.")},annotations:{openWorldHint:!0}},async({id:o})=>r(await e.client.comment.commentRetry({id:o}))),l(t,"create_comment_import",{title:"Import comments on a post",description:"Start an async import of the (incoming) comments on a published post for one platform. Comment imports are available on FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, TIKTOK, REDDIT, THREADS, MASTODON, BLUESKY. Poll get_comment_import / list_comment_imports for status and list_imported_comments for the fetched comments.",inputSchema:{postId:c.string().min(1).describe("Id of the published post to import comments for."),platform:c.string().min(1).describe("Platform name/alias to import comments from."),teamId:F},annotations:{openWorldHint:!0}},async({postId:o,platform:n,teamId:a})=>{let i=await g(e,a);return r(await e.client.comment.commentImportCreate({requestBody:{teamId:i,postId:o,socialAccountType:b(n)}}))}),l(t,"list_comment_imports",{title:"List comment imports",description:"List comment-import jobs for a team, optionally filtered by post and status.",inputSchema:{teamId:F,postId:c.string().optional().describe("Only imports for this post."),status:mt.optional().describe("Filter by import status."),limit:c.number().int().positive().max(100).optional(),offset:c.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,postId:n,status:a,limit:i,offset:s})=>{let d=await g(e,o);return r(await e.client.comment.commentImportGetList({teamId:d,postId:n,status:a,limit:i??null,offset:s??null}))}),l(t,"get_comment_import",{title:"Get a comment import by id",description:"Fetch a single comment-import job by its id, including its status and the number of comments imported.",inputSchema:{importId:c.string().min(1).describe("Comment import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>r(await e.client.comment.commentImportGetById({importId:o}))),l(t,"list_imported_comments",{title:"List imported comments for a post",description:"List the comments fetched by comment imports for a post, optionally filtered by platform / social account.",inputSchema:{postId:c.string().min(1).describe("Id of the post whose imported comments to list."),platform:c.string().optional().describe("Filter by platform name/alias."),socialAccountId:c.string().optional().describe("Filter by social-account id."),teamId:F,limit:c.number().int().positive().max(100).optional(),offset:c.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postId:o,platform:n,socialAccountId:a,teamId:i,limit:s,offset:d})=>{let m=await g(e,i);return r(await e.client.comment.commentImportGetFetchedComments({teamId:m,postId:o,platform:n?b(n):void 0,socialAccountId:a,limit:s??null,offset:d??null}))}),l(t,"act_on_imported_comment",{title:"Moderate an imported comment",description:"Act on a comment fetched by a comment import \u2014 delete, hide/unhide, like/unlike, or approve/reject it. Supported actions vary by platform; DELETE and HIDE are the widely available ones.",inputSchema:{commentId:c.string().min(1).describe("Id of the fetched (imported) comment."),action:c.enum(["DELETE","HIDE","UNHIDE","LIKE","UNLIKE","APPROVE","REJECT"]).describe("What to do with the comment."),reason:c.string().optional().describe("Optional reason recorded with the action."),banAuthor:c.boolean().optional().describe("Also ban the comment's author, where the platform supports it."),teamId:F},annotations:{destructiveHint:!0,openWorldHint:!0}},async({commentId:o,action:n,reason:a,banAuthor:i,teamId:s})=>{let d=await g(e,s);return r(await e.client.comment.commentImportActionFetchedComment({commentId:o,requestBody:{teamId:d,action:n,...a!==void 0?{reason:a}:{},...i?{banAuthor:!0}:{}}}))})}import{z as D}from"zod";var V=D.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function _e(t,e){l(t,"upload_media",{title:"Upload media",description:'Upload a media file (image, video or document) to a bundle.social team from a public https:// URL \u2014 or, when this server runs in stdio mode, a local file path. Local files larger than ~90 MB are uploaded via the large-upload flow automatically (only .jpg/.jpeg/.png/.gif/.mp4/.pdf are supported above that size). Returns the upload object; pass its `id` to create_post/schedule_post via the `data` argument (e.g. {"TWITTER":{"text":"hi","uploadIds":["<id>"]}}).',inputSchema:{teamId:V,source:D.string().min(1).describe("A public https:// URL, or a local file path (stdio mode only).")},annotations:{openWorldHint:!0}},async({teamId:o,source:n})=>{let a=await g(e,o);return r(await te(e.client,a,n))}),l(t,"list_media",{title:"List uploaded media",description:"List media uploads for a team, optionally filtered by type (image/video/document) and usage status (USED/UNUSED).",inputSchema:{teamId:V,type:D.enum(["image","video","document"]).optional().describe("Filter by media type."),status:D.enum(["USED","UNUSED"]).optional().describe("Filter by whether the upload is attached to a post.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,type:n,status:a})=>{let i=await g(e,o);return r(await e.client.upload.uploadGetList({teamId:i,type:n??null,status:a??null}))}),l(t,"get_media",{title:"Get an upload by id",description:"Fetch a single media upload by its bundle.social id.",inputSchema:{id:D.string().min(1).describe("Upload id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>r(await e.client.upload.uploadGet({id:o}))),l(t,"delete_media",{title:"Delete an upload",description:"Delete a media upload by its bundle.social id. Destructive.",inputSchema:{id:D.string().min(1).describe("Upload id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>r(await e.client.upload.uploadDelete({id:o}))),l(t,"delete_media_many",{title:"Delete multiple uploads",description:"Delete several media uploads at once by their ids. Destructive.",inputSchema:{ids:D.array(D.string().min(1)).min(1).describe("Upload ids to delete.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({ids:o})=>r(await e.client.upload.uploadDeleteMany({requestBody:{ids:o}}))),l(t,"init_large_upload",{title:"Initialize a large upload",description:"Low-level: start a >90 MB upload. Returns a signed `url` (PUT the file bytes there with the matching content-type) and a `path` to pass to finalize_large_upload. Prefer `upload_media` with a local file path in stdio mode \u2014 it does this automatically.",inputSchema:{teamId:V,fileName:D.string().min(1).describe("File name."),mimeType:D.enum(["image/jpg","image/jpeg","image/png","image/gif","video/mp4","application/pdf"]).describe("File MIME type.")},annotations:{openWorldHint:!0}},async({teamId:o,fileName:n,mimeType:a})=>{let i=await g(e,o);return r(await e.client.upload.uploadInitLargeUpload({requestBody:{teamId:i,fileName:n,mimeType:a}}))}),l(t,"finalize_large_upload",{title:"Finalize a large upload",description:"Low-level: finalize a >90 MB upload after the bytes have been PUT to the signed URL from init_large_upload. Returns the upload object.",inputSchema:{teamId:V,path:D.string().min(1).describe("The `path` returned by init_large_upload.")},annotations:{openWorldHint:!0}},async({teamId:o,path:n})=>{let a=await g(e,o);return r(await e.client.upload.uploadFinalizeLargeUpload({requestBody:{teamId:a,path:n}}))})}import{z as P}from"zod";var ve=P.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function pt(t,e,o){if(!e&&!o)return!0;if(!t)return!1;let n=new Date(t).getTime();return!(Number.isNaN(n)||e&&n<new Date(e).getTime()||o&&n>new Date(o).getTime())}function Le(t,e){l(t,"get_post_analytics",{title:"Get post analytics",description:"Get engagement metrics (impressions, views, likes, comments, \u2026) for a single post by its bundle.social id. Optionally limit to one platform. Set `raw: true` for the unprocessed provider payload.",inputSchema:{id:P.string().min(1).describe("Post id."),platform:P.string().optional().describe("Limit to a single platform name/alias (e.g. instagram, tiktok, youtube). Analytics are not available for X/Twitter, Discord or Slack."),raw:P.boolean().optional().default(!1).describe("If true, return the raw provider analytics payload instead of the normalized metrics.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o,platform:n,raw:a})=>{let i=n?M(n):void 0,s=a?await e.client.analytics.analyticsGetPostAnalyticsRaw({postId:o,platformType:i}):await e.client.analytics.analyticsGetPostAnalytics({postId:o,platformType:i});return r(s)}),l(t,"get_account_analytics",{title:"Get social-account analytics",description:"Get the analytics time-series (followers, impressions, likes, \u2026) for a connected account on the given platform. Analytics are available on TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, REDDIT, PINTEREST, MASTODON, LINKEDIN, BLUESKY, GOOGLE_BUSINESS. Set `raw: true` for the unprocessed provider payload.",inputSchema:{platform:P.string().min(1).describe("Platform name/alias."),teamId:ve,raw:P.boolean().optional().default(!1).describe("If true, return the raw provider analytics payload.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n,raw:a})=>{let i=await g(e,n),s=M(o),d=a?await e.client.analytics.analyticsGetSocialAccountAnalyticsRaw({teamId:i,platformType:s}):await e.client.analytics.analyticsGetSocialAccountAnalytics({teamId:i,platformType:s});return r(d)}),l(t,"get_bulk_post_analytics",{title:"Get analytics for multiple posts",description:"Get analytics for up to 60 posts in one request (paginated, 20 per page) for a single platform.",inputSchema:{postIds:P.array(P.string().min(1)).min(1).max(60).describe("Post ids (max 60)."),platform:P.string().min(1).describe("Platform name/alias the posts belong to."),page:P.number().int().positive().optional().describe("Page (1-based)."),limit:P.number().int().positive().max(20).optional().describe("Page size (max 20).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postIds:o,platform:n,page:a,limit:i})=>r(await e.client.analytics.analyticsGetBulkPostAnalytics({postIds:o,platformType:M(n),page:a,limit:i}))),l(t,"refresh_analytics",{title:"Force-refresh analytics",description:"Force an immediate analytics refresh. Pass `postId` to refresh that post's analytics; otherwise pass `platform` to refresh a connected account's analytics for the team.",inputSchema:{postId:P.string().optional().describe("Post id to refresh analytics for."),importedPostId:P.string().optional().describe("Imported-post id to refresh analytics for (alternative to postId)."),platform:P.string().optional().describe("Platform name/alias to refresh a social-account's analytics for (used when postId/importedPostId are omitted)."),teamId:ve},annotations:{openWorldHint:!0}},async({postId:o,importedPostId:n,platform:a,teamId:i})=>{if(o||n)return r(await e.client.analytics.analyticsForcePostAnalytics({requestBody:{postId:o??null,importedPostId:n??null,platformType:a?M(a):null}}));if(!a)throw new f("REFRESH_TARGET_REQUIRED","Pass either `postId`/`importedPostId` (to refresh a post) or `platform` (to refresh a social account).");let s=await g(e,i);return r(await e.client.analytics.analyticsForceSocialAccountAnalytics({requestBody:{teamId:s,platformType:M(a)}}))}),l(t,"get_analytics_summary",{title:"Get analytics summary",description:"Organization-level analytics summary: posts/comments/uploads usage quotas for the organization, plus the latest analytics snapshot (followers, impressions, likes, \u2026) for each connected integration on the team. Use `from`/`to` to select the snapshot from a date range.",inputSchema:{teamId:P.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),from:P.string().optional().describe("Start of the range used to select analytics snapshots (ISO 8601)."),to:P.string().optional().describe("End of the range used to select analytics snapshots (ISO 8601).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,from:n,to:a})=>{let i=await g(e,o),[s,d,m,u,T]=await Promise.all([e.client.organization.organizationGetOrganization(),e.client.team.teamGetTeam({id:i}),e.client.organization.organizationGetPostsUsage().catch(()=>null),e.client.organization.organizationGetCommentsUsage().catch(()=>null),e.client.organization.organizationGetUploadsUsage().catch(()=>null)]),S=d.socialAccounts??[],y=[];for(let h of S){let w={id:h.id,type:h.type,username:h.username??null};if(!J(h.type)){y.push({...w,analytics:null,note:"analytics not available for this platform"});continue}try{let E=((await e.client.analytics.analyticsGetSocialAccountAnalytics({teamId:i,platformType:h.type})).items??[]).filter(A=>pt(A.createdAt,n,a));y.push({...w,latest:E[E.length-1]??null,dataPoints:E.length})}catch(R){y.push({...w,analytics:null,error:C(R)})}}return r({organization:{id:s.id,name:s.name??null},team:{id:d.id,name:d.name},range:{from:n??null,to:a??null},usage:{posts:m,comments:u,uploads:T},integrations:y})})}import{z as Y}from"zod";var $=[{id:"reddit:flairs",platform:"REDDIT",description:"List the post flairs available in a subreddit (use the returned flair id when creating a Reddit post that requires a flair).",requiredParams:["subreddit"],run:(t,e,o)=>t.misc.miscRedditGetSubredditFlairs({teamId:e,subreddit:String(o.subreddit)})},{id:"reddit:requirements",platform:"REDDIT",description:"Get a subreddit's posting requirements (title length, flair requirement, allowed post types, etc.).",requiredParams:["subreddit"],run:(t,e,o)=>t.misc.miscRedditGetPostRequirements({teamId:e,subreddit:String(o.subreddit)})},{id:"youtube:categories",platform:"YOUTUBE",description:"List YouTube video categories for a region (use the returned category id as `categoryId` when posting a YouTube video).",optionalParams:["regionCode"],run:(t,e,o)=>t.misc.miscYoutubeGetVideoCategories({teamId:e,...o.regionCode?{regionCode:String(o.regionCode)}:{}})},{id:"youtube:playlists",platform:"YOUTUBE",description:"List the connected YouTube channel's playlists (use a playlist id to add the posted video to it).",optionalParams:["maxResults"],run:(t,e,o)=>t.misc.miscYoutubeGetChannelPlaylist({teamId:e,...o.maxResults!==void 0?{maxResults:Number(o.maxResults)}:{}})},{id:"youtube:regions",platform:"YOUTUBE",description:"List YouTube content regions (i18n region codes).",run:(t,e)=>t.misc.miscYoutubeGetRegions({teamId:e})},{id:"linkedin:mentions",platform:"LINKEDIN",description:"Search LinkedIn people/organizations to mention in a post (use the returned URN in the post text).",requiredParams:["q"],optionalParams:["scope"],run:(t,e,o)=>t.misc.miscLinkedinGetTags({teamId:e,q:String(o.q),...o.scope?{scope:String(o.scope)}:{}})},{id:"instagram:locations",platform:"INSTAGRAM",description:"Search Instagram locations (use the returned location id as `locationId` when posting).",requiredParams:["q"],optionalParams:["limit"],run:(t,e,o)=>t.misc.miscInstagramSearchLocations({teamId:e,q:String(o.q),...o.limit!==void 0?{limit:Number(o.limit)}:{}})},{id:"gbp:location",platform:"GOOGLE_BUSINESS",description:"Get the connected Google Business Profile location's details.",optionalParams:["fields"],run:(t,e,o)=>t.misc.miscGoogleBusinessGetLocation({teamId:e,...Array.isArray(o.fields)?{fields:o.fields}:{}})},{id:"gbp:categories",platform:"GOOGLE_BUSINESS",description:"List Google Business Profile categories for a region/language (use a category id when updating the location).",requiredParams:["languageCode","regionCode"],optionalParams:["filter","pageSize","pageToken","view"],run:(t,e,o)=>t.misc.miscGoogleBusinessListCategories({teamId:e,languageCode:String(o.languageCode),regionCode:String(o.regionCode),...o.filter?{filter:String(o.filter)}:{},...o.pageSize!==void 0?{pageSize:Number(o.pageSize)}:{},...o.pageToken?{pageToken:String(o.pageToken)}:{},...o.view?{view:String(o.view)}:{}})},{id:"instagram:audio",platform:"INSTAGRAM",description:"Search the Instagram audio catalogue (use the returned audio_id as `musicSoundInfo.musicSoundId` when posting a Reel).",requiredParams:["audioType"],optionalParams:["searchQuery"],run:(t,e,o)=>t.misc.miscInstagramSearchAudio({teamId:e,audioType:String(o.audioType),...o.searchQuery?{searchQuery:String(o.searchQuery)}:{}})},{id:"instagram:business-discovery",platform:"INSTAGRAM",description:"Look up a public Instagram Business/Creator profile by username (followers, media count, recent public media). Requires an account connected via Facebook Login.",requiredParams:["username"],run:(t,e,o)=>t.misc.miscInstagramBusinessDiscovery({teamId:e,username:String(o.username)})},{id:"tiktok:trending-music",platform:"TIKTOK",description:"List trending tracks from TikTok's commercial music library (use a track id in the TikTok post settings).",optionalParams:["dateRange","genre"],run:(t,e,o)=>t.misc.miscTiktokGetCommercialMusicTrendingList({teamId:e,...o.dateRange?{dateRange:String(o.dateRange)}:{},...o.genre?{genre:String(o.genre)}:{}})}];function Ne(){return $.map(t=>({method:t.id,platform:t.platform,description:t.description,requiredParams:t.requiredParams??[],optionalParams:t.optionalParams??[]}))}async function Ue(t,e,o,n){let a=$.find(s=>s.id===o.trim().toLowerCase());if(!a)throw new f("UNKNOWN_INTEGRATION_TOOL",`Unknown integration tool "${o}". Available: ${$.map(s=>s.id).join(", ")}.`,{available:$.map(s=>s.id)});let i=(a.requiredParams??[]).filter(s=>n[s]===void 0||n[s]===null||n[s]==="");if(i.length>0)throw new f("MISSING_PARAMS",`Integration tool "${a.id}" requires: ${i.join(", ")}. Provide them in the params object.`,{method:a.id,requiredParams:a.requiredParams});return a.run(t,e,n)}var ut=Y.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function ke(t,e){l(t,"list_integration_tools",{title:"List integration helper tools",description:"List the read-only platform helper tools callable via trigger_integration_tool \u2014 e.g. fetch subreddit flairs, YouTube categories/playlists/regions, LinkedIn mentions, Instagram locations, Google Business categories, TikTok trending music. Each entry has a `method` id and the params it accepts. Use these to discover values the API needs (flair ids, category ids, mention URNs, \u2026).",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>r({tools:Ne()})),l(t,"trigger_integration_tool",{title:"Call an integration helper tool",description:'Call one of the platform helper tools (see list_integration_tools), e.g. method "reddit:flairs" with params {"subreddit":"r/test"}. Returns the raw result.',inputSchema:{method:Y.string().min(1).describe('Tool method id, e.g. "reddit:flairs", "youtube:categories", "linkedin:mentions" (call list_integration_tools first).'),params:Y.record(Y.string(),Y.unknown()).optional().describe('Parameters for the tool as a JSON object, e.g. {"subreddit":"r/test"}.'),teamId:ut},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({method:o,params:n,teamId:a})=>{let i=await g(e,a);return r(await Ue(e.client,i,o,n??{}))})}import{z as _}from"zod";function Be(t,e){l(t,"list_teams",{title:"List teams",description:"List the teams in the organization (paginated). Use this to discover team ids for the optional `teamId` argument on other tools.",inputSchema:{limit:_.number().int().positive().max(100).optional().describe("Max number of teams to return."),offset:_.number().int().nonnegative().optional().describe("Number of teams to skip (for pagination)."),search:_.string().optional().describe("Free-text search over team names.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({limit:o,offset:n,search:a})=>r(await e.client.team.teamGetList({limit:o??null,offset:n??null,search:a??null}))),l(t,"get_team",{title:"Get a team by id",description:"Fetch a single team by id, including its connected social accounts/integrations.",inputSchema:{id:_.string().min(1).describe("Team id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>r(await e.client.team.teamGetTeam({id:o}))),l(t,"create_team",{title:"Create a team",description:"Create a new team in the organization. Optionally copy the connected social accounts from an existing team via `copyTeamId`.",inputSchema:{name:_.string().min(1).describe("Team name."),avatarUrl:_.string().optional().describe("Optional avatar image URL."),copyTeamId:_.string().optional().describe("Optional id of an existing team to copy social accounts from.")},annotations:{openWorldHint:!0}},async({name:o,avatarUrl:n,copyTeamId:a})=>r(await e.client.team.teamCreateTeam({requestBody:{name:o,avatarUrl:n??null,copyTeamId:a??null}}))),l(t,"update_team",{title:"Update a team",description:"Update a team's name and/or avatar. Only the fields you pass are changed.",inputSchema:{id:_.string().min(1).describe("Team id."),name:_.string().optional().describe("New team name."),avatarUrl:_.string().nullable().optional().describe("New avatar image URL, or null to clear it.")},annotations:{openWorldHint:!0}},async({id:o,name:n,avatarUrl:a})=>{let i={};if(n!==void 0&&(i.name=n),a!==void 0&&(i.avatarUrl=a),Object.keys(i).length===0)throw new f("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of name, avatarUrl.");return r(await e.client.team.teamUpdateTeam({id:o,requestBody:i}))}),l(t,"delete_team",{title:"Delete a team",description:"Delete a team by id. This is destructive and cannot be undone \u2014 it removes the team and its scheduled content.",inputSchema:{id:_.string().min(1).describe("Team id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>r(await e.client.team.teamDeleteTeam({id:o})))}import{z as q}from"zod";var ft=q.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function qe(t,e){l(t,"get_organization",{title:"Get the organization",description:"Fetch the current organization \u2014 its id, name, API-access flag, plan limits and the list of teams.",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>r(await e.client.organization.organizationGetOrganization())),l(t,"get_usage",{title:"Get usage quotas",description:"Organization usage quotas: posts, comments and uploads (used/limit/remaining), plus a paginated per-social-account breakdown of post-history import usage. Use the pagination/filter args for the imports breakdown.",inputSchema:{teamId:ft,platform:q.string().optional().describe("Filter the imports breakdown to one platform name/alias (e.g. instagram, tiktok)."),socialAccountId:q.string().optional().describe("Filter the imports breakdown to one social-account id."),page:q.number().int().positive().optional().describe("Page of the imports breakdown (1-based)."),pageSize:q.number().int().positive().max(100).optional().describe("Page size of the imports breakdown.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,platform:n,socialAccountId:a,page:i,pageSize:s})=>{let m=o??e.defaultTeamId??await g(e,o).catch(()=>{}),[u,T,S,y]=await Promise.all([e.client.organization.organizationGetPostsUsage().catch(h=>({error:C(h)})),e.client.organization.organizationGetCommentsUsage().catch(h=>({error:C(h)})),e.client.organization.organizationGetUploadsUsage().catch(h=>({error:C(h)})),e.client.organization.organizationGetImportsUsage({page:i,pageSize:s,teamId:m,socialAccountType:n?b(n):void 0,socialAccountId:a}).catch(h=>({error:C(h)}))]);return r({posts:u,comments:T,uploads:S,imports:y})}),l(t,"get_daily_limits_usage",{title:"Get a connected account's daily limits",description:"How much of one connected account's daily post and comment allowance has been used on a given day (defaults to today, UTC). Use it before bulk-scheduling to avoid hitting a per-account daily cap.",inputSchema:{socialAccountId:q.string().min(1).describe("Connected social account id (see list_integrations)."),date:q.string().optional().describe("Day to report on, YYYY-MM-DD. Defaults to today.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({socialAccountId:o,date:n})=>r(await e.client.organization.organizationGetDailyLimitsUsage({socialAccountId:o,...n?{date:n}:{}})))}import{z as O}from"zod";var Ge=O.string().min(1).describe("Platform name/alias. Post-history import is available on FACEBOOK, INSTAGRAM, THREADS, TIKTOK, YOUTUBE, LINKEDIN, PINTEREST, REDDIT, MASTODON, BLUESKY.");function Me(t,e){l(t,"create_post_import",{title:"Import post history",description:"Start an async import of a connected account's recent posts (optionally with analytics) for one platform. Poll list_post_imports / get_post_import for status and list_imported_posts for the imported posts.",inputSchema:{platform:Ge,count:O.number().int().positive().describe("How many recent posts to import."),withAnalytics:O.boolean().optional().describe("Also fetch analytics for the imported posts."),importCarousels:O.boolean().optional().describe("Include carousel/album posts (Instagram)."),surface:O.enum(["PROFILE_GRID","NON_GRID","STORY","ALL"]).optional().describe("Which surface to import from (Instagram)."),mediaType:O.enum(["VIDEO","IMAGE"]).optional().describe("Restrict to one media type."),teamId:O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{openWorldHint:!0}},async({platform:o,count:n,withAnalytics:a,importCarousels:i,surface:s,mediaType:d,teamId:m})=>{let u=await g(e,m);return r(await e.client.postImport.postImportCreate({requestBody:{teamId:u,socialAccountType:b(o),count:n,...a!==void 0?{withAnalytics:a}:{},...i!==void 0?{importCarousels:i}:{},...s?{surface:s}:{},...d?{mediaType:d}:{}}}))}),l(t,"list_post_imports",{title:"List post-history imports",description:"List post-history import jobs for a team, optionally filtered by platform.",inputSchema:{teamId:O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),platform:O.string().optional().describe("Filter by platform name/alias.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,platform:n})=>{let a=await g(e,o);return r(await e.client.postImport.postImportGetStatus({teamId:a,socialAccountType:n?b(n):void 0}))}),l(t,"get_post_import",{title:"Get a post-history import by id",description:"Fetch a single post-history import job by its id, including its status and counts.",inputSchema:{importId:O.string().min(1).describe("Post import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>r(await e.client.postImport.postImportGetById({importId:o}))),l(t,"list_imported_posts",{title:"List imported posts for a platform",description:"List the posts imported (with analytics, when available) for a connected account on the given platform.",inputSchema:{platform:Ge,teamId:O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),limit:O.number().int().positive().max(100).optional(),offset:O.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n,limit:a,offset:i})=>{let s=await g(e,n);return r(await e.client.postImport.postImportGetImportedPosts({teamId:s,socialAccountType:b(o),limit:a,offset:i??null}))}),l(t,"delete_imported_posts",{title:"Delete imported posts",description:"Bulk-delete imported posts (and their analytics) by id. Destructive.",inputSchema:{postIds:O.array(O.string().min(1)).min(1).describe("Imported-post ids to delete."),teamId:O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({postIds:o,teamId:n})=>{let a=await g(e,n);return r(await e.client.postImport.postImportDeleteImportedPosts({requestBody:{teamId:a,postIds:o}}))}),l(t,"retry_post_import",{title:"Retry a post-history import",description:"Retry a post-history import job that ended in FAILED / RATE_LIMITED.",inputSchema:{importId:O.string().min(1).describe("Post import id."),teamId:O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{openWorldHint:!0}},async({importId:o,teamId:n})=>{let a=await g(e,n);return r(await e.client.postImport.postImportRetryImport({importId:o,requestBody:{teamId:a}}))})}import gt from"fs/promises";import ue from"path";import{z as N}from"zod";function ht(t){return/^https?:\/\//i.test(t.trim())}async function yt(t){if(ht(t)){let n=await fetch(t.trim());if(!n.ok)throw new f("CSV_FETCH_FAILED",`Could not download the CSV from "${t}" (HTTP ${n.status}).`,{status:n.status});let a=Buffer.from(await n.arrayBuffer()),i=ue.basename(new URL(t).pathname)||"import.csv";return new File([a],i,{type:"text/csv"})}let e=ue.resolve(t),o;try{o=await gt.readFile(e)}catch{throw new f("CSV_NOT_FOUND",`Could not read CSV "${t}". Provide a public https:// URL, or a local file path that exists on the machine running this MCP server (stdio mode only).`,{path:e})}return new File([o],ue.basename(e),{type:"text/csv"})}function He(t,e){l(t,"create_post_csv_import",{title:"Bulk-import posts from a CSV",description:"Upload a CSV for async bulk post import. Accepts a public https:// URL to the CSV, or a local file path when this server runs in stdio mode. Poll get_post_csv_import_status / get_post_csv_import_rows for progress and per-row results.",inputSchema:{source:N.string().min(1).describe("Public https:// URL of the CSV, or a local file path (stdio mode only).")},annotations:{openWorldHint:!0}},async({source:o})=>{let n=await yt(o);return r(await e.client.postCsv.postCsvCreate({formData:{file:n}}))}),l(t,"list_post_csv_imports",{title:"List CSV imports",description:"List the post-CSV import history (paginated).",inputSchema:{limit:N.number().int().positive().max(100).optional(),offset:N.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({limit:o,offset:n})=>r(await e.client.postCsv.postCsvGetList({limit:o??null,offset:n??null}))),l(t,"get_post_csv_import",{title:"Get a CSV import by id",description:"Fetch a single post-CSV import by its id, including counts and status.",inputSchema:{importId:N.string().min(1).describe("CSV import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>r(await e.client.postCsv.postCsvGetById({importId:o}))),l(t,"get_post_csv_import_status",{title:"Get a CSV import's processing status",description:"Fetch the processing status of a post-CSV import (rows processed/succeeded/failed).",inputSchema:{importId:N.string().min(1).describe("CSV import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>r(await e.client.postCsv.postCsvGetStatus({importId:o}))),l(t,"get_post_csv_import_rows",{title:"Get a CSV import's row results",description:"List per-row results of a post-CSV import (the raw row, normalized payload, created post id or error), optionally filtered by SUCCESS/FAILED.",inputSchema:{importId:N.string().min(1).describe("CSV import id."),status:N.enum(["SUCCESS","FAILED"]).optional().describe("Filter rows by outcome."),limit:N.number().int().positive().max(100).optional(),offset:N.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o,status:n,limit:a,offset:i})=>r(await e.client.postCsv.postCsvGetRows({importId:o,status:n,limit:a??null,offset:i??null})))}var bt=j.version;function Fe(t,e){l(t,"check_setup",{title:"Check the bundle.social setup",description:"Diagnose this MCP server's setup: API key present, API reachable, API key valid, organization API access, team resolution, connected integrations and posts quota. Always returns a structured diagnostic object ({ ok, checks: [...] }).",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>{let o=[],n=(m,u,T,S={})=>o.push({name:m,status:u,message:T,...S}),a=()=>r({ok:o.every(m=>m.status!=="fail"),mcpVersion:bt,node:process.version,checks:o});n("api_key","ok","API key configured");try{let m=await e.client.app.appGetHealth();n("api_reachable","ok","API reachable",{health:m})}catch(m){return n("api_reachable","fail","Could not reach the bundle.social API",{error:C(m)}),a()}let i=[],s;try{let m=await e.client.organization.organizationGetOrganization();i=(m.teams??[]).map(u=>({id:u.id,name:u.name})),s=m.apiAccess,n("authentication","ok","API key is valid",{organizationId:m.id,organizationName:m.name??null})}catch(m){return n("authentication","fail","API key was rejected by the API",{error:C(m)}),a()}n("api_access",s?"ok":"fail",s?"Organization has API access enabled":"Organization does not have API access enabled \u2014 upgrade your plan or contact bundle.social support");let d;if(e.defaultTeamId?(d=e.defaultTeamId,n("team","ok","Using team from BUNDLESOCIAL_TEAM_ID / --team-id",{teamId:d})):i.length===1?(d=i[0].id,n("team","ok","Using the organization's only team",{teamId:d,teamName:i[0].name})):i.length===0?n("team","fail","Organization has no teams \u2014 create one in the dashboard"):n("team","warn",`Organization has ${i.length} teams; tools need a teamId argument (or set BUNDLESOCIAL_TEAM_ID)`,{teams:i}),d)try{let u=(await e.client.team.teamGetTeam({id:d})).socialAccounts??[];n("integrations",u.length>0?"ok":"warn",u.length>0?`${u.length} connected integration(s)`:"No integrations connected \u2014 connect one in the dashboard before posting",{count:u.length,platforms:u.map(T=>T.type),connectUrl:Ie})}catch(m){n("integrations","fail","Could not load the team's integrations",{teamId:d,error:C(m)})}try{let m=await e.client.organization.organizationGetPostsUsage();n("posts_quota",m.remaining>0?"ok":"warn",`Posts quota: ${m.used}/${m.limit} used, ${m.remaining} remaining`,{used:m.used,limit:m.limit,remaining:m.remaining})}catch(m){n("posts_quota","warn","Could not read posts quota",{error:C(m)})}return a()})}import{z as xe}from"zod";var St=["FACEBOOK","INSTAGRAM","LINKEDIN","YOUTUBE","TIKTOK","REDDIT","THREADS","MASTODON","BLUESKY"],Tt=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","REDDIT","PINTEREST","MASTODON","LINKEDIN","BLUESKY","GOOGLE_BUSINESS","SNAPCHAT"];function It(t){return{dataKey:`data.${t}`,summary:"Comment/reply on a post. The per-platform comment object only carries the comment body.",fields:[{name:"text",type:"string",required:!0,notes:"The comment body."}],example:{[t]:{text:"Great write-up \u2014 thanks for sharing!"}}}}var Et={TWITTER:{dataKey:"data.TWITTER",summary:"Post a tweet. For a thread, post the first tweet then add replies via create_comment.",fields:[{name:"text",type:"string",required:!1,notes:"Post text. ~280 chars (longer if the connected account is X Premium)."},{name:"uploadIds",type:"string[]",required:!1,notes:"Up to 4 images OR 1 video/GIF."},{name:"replySettings",type:"EVERYONE | FOLLOWING | MENTIONED_USERS | SUBSCRIBERS | VERIFIED",required:!1,notes:"Who can reply to the tweet."},{name:"isAiGenerated",type:"boolean",required:!1,notes:`Adds X's "made with AI" label to a post with AI-generated media.`}],example:{TWITTER:{text:"Shipping day \u{1F680}",replySettings:"EVERYONE"}}},BLUESKY:{dataKey:"data.BLUESKY",summary:"Post to Bluesky.",fields:[{name:"text",type:"string",required:!1,notes:"~300 chars."},{name:"uploadIds",type:"string[]",required:!1,notes:"Up to 4 images, or 1 video (set videoAlt)."},{name:"tags",type:"string[]",required:!1,notes:"Extra hashtags (without `#`), up to 8."},{name:"labels",type:"(!no-unauthenticated | porn | sexual | nudity | graphic-media)[]",required:!1,notes:"Self-labels / content warnings."},{name:"quoteUri",type:"string",required:!1,notes:"AT-URI of a post to quote (at://\u2026/app.bsky.feed.post/<rkey>)."},{name:"externalUrl",type:"string (URL)",required:!1,notes:"External link card URL."},{name:"externalTitle",type:"string",required:!1,notes:"External link card title."},{name:"externalDescription",type:"string",required:!1,notes:"External link card description."},{name:"thumbnail",type:"string (URL)",required:!1,notes:"Image for the external link card (a public bundle.social upload URL)."},{name:"videoAlt",type:"string",required:!1,notes:"Alt text for a video embed."}],example:{BLUESKY:{text:"New post",tags:["launch","indie"],externalUrl:"https://bundle.social"}}},MASTODON:{dataKey:"data.MASTODON",summary:"Post a status to Mastodon.",fields:[{name:"text",type:"string",required:!1,notes:"Length depends on the connected instance (commonly ~500)."},{name:"uploadIds",type:"string[]",required:!1,notes:"Up to 4 images OR 1 video."},{name:"privacy",type:"PUBLIC | UNLISTED | PRIVATE | DIRECT",required:!1,notes:"Visibility."},{name:"spoiler",type:"string",required:!1,notes:"Content-warning text (collapses the post behind it)."},{name:"thumbnail",type:"string (URL)",required:!1,notes:"Cover image for a video."}],example:{MASTODON:{text:"Hello fediverse",privacy:"PUBLIC",spoiler:"long read"}}},THREADS:{dataKey:"data.THREADS",summary:"Post to Threads.",fields:[{name:"text",type:"string",required:!1,notes:"~500 chars."},{name:"uploadIds",type:"string[]",required:!1,notes:"Up to ~10 images, or 1 video."},{name:"mediaItems",type:"{ uploadId: string, altText?: string }[]",required:!1,notes:"Per-image alt text (alternative to uploadIds)."},{name:"topicTag",type:"string",required:!1,notes:"One topic tag shown in the post header. 1\u201350 chars, no periods (.) or ampersands (&)."},{name:"replyControl",type:"everyone | accounts_you_follow | mentioned_only | parent_post_author_only | followers_only",required:!1,notes:"Who can reply. Threads defaults to everyone."},{name:"linkAttachment",type:"string (URL)",required:!1,notes:"Link preview card. Text-only posts (no uploadIds)."},{name:"poll",type:"{ optionA: string, optionB: string, optionC?: string, optionD?: string }",required:!1,notes:"2\u20134 options, 1\u201325 chars each. Text-only posts, and not together with `gif`."},{name:"gif",type:'{ gifId: string, provider?: "GIPHY" }',required:!1,notes:"GIF attachment (GIPHY is the only provider). Text-only posts, and not together with `poll`."},{name:"allowlistedCountryCodes",type:"string[]",required:!1,notes:"Restrict visibility to these ISO 3166-1 alpha-2 codes. Requires Meta account eligibility."},{name:"crosspostToInstagramStory",type:"boolean",required:!1,notes:"Also share the post to the linked Instagram account as a Story."},{name:"crosspostToInstagramStoryDarkMode",type:"boolean",required:!1,notes:"Cross-post the Instagram Story in dark mode."}],example:{THREADS:{text:"Quick thought",topicTag:"shipping",replyControl:"everyone"}}},LINKEDIN:{dataKey:"data.LINKEDIN",summary:"Post to a LinkedIn personal profile or company page (depends on the connected account).",fields:[{name:"text",type:"string",required:!0,notes:"Required. ~3000 chars."},{name:"uploadIds",type:"string[]",required:!1,notes:"Images, a single video, or a document/PDF."},{name:"link",type:"string (URL)",required:!1,notes:"For an article-preview post."},{name:"thumbnail",type:"string (URL)",required:!1,notes:"Cover image (a public bundle.social upload URL)."},{name:"mediaTitle",type:"string",required:!1,notes:"Title for a video or document post."},{name:"privacy",type:"CONNECTIONS | PUBLIC | LOGGED_IN | CONTAINER",required:!1,notes:"Visibility."},{name:"hideFromFeed",type:"boolean",required:!1,notes:"Don't show in the main feed."},{name:"disableReshare",type:"boolean",required:!1,notes:"Disallow resharing."}],example:{LINKEDIN:{text:"We just shipped X.",privacy:"PUBLIC",mediaTitle:"Demo"}}},FACEBOOK:{dataKey:"data.FACEBOOK",summary:"Post to a Facebook Page.",fields:[{name:"type",type:"POST | REEL | STORY",required:!1,notes:"Default POST."},{name:"text",type:"string",required:!1,notes:"Caption / message."},{name:"uploadIds",type:"string[]",required:!1,notes:"Images, or a single video."},{name:"mediaItems",type:"{ uploadId: string, altText?: string }[]",required:!1,notes:"Per-image alt text."},{name:"link",type:"string (URL)",required:!1,notes:"Link attachment \u2014 `type: POST` only."},{name:"mediaTitle",type:"string",required:!1,notes:"Video title \u2014 `type: POST` with a video only (not REEL/STORY)."},{name:"thumbnail",type:"string (URL)",required:!1,notes:"Video cover image."},{name:"nativeScheduleTime",type:"string (ISO 8601, local)",required:!1,notes:"Schedule directly in Meta's scheduler instead of publishing now; max 30 days ahead."}],example:{FACEBOOK:{type:"POST",text:"Look at this",link:"https://bundle.social"}}},INSTAGRAM:{dataKey:"data.INSTAGRAM",summary:"Post to Instagram (feed post, carousel, Reel or Story).",fields:[{name:"type",type:"POST | REEL | STORY",required:!1,notes:"POST = single image, carousel (carouselItems) or feed video; REEL = single video; STORY = image or short video."},{name:"text",type:"string",required:!1,notes:"Caption."},{name:"uploadIds",type:"string[]",required:!1,notes:"Single image/video for POST/REEL/STORY. Square \u22651080\xD71080 or portrait 4:5; Reels 9:16, up to 90s."},{name:"altText",type:"string",required:!1,notes:"Alt text for a single-image post."},{name:"carouselItems",type:"{ uploadId: string, altText?: string, tagged?: { username, x, y }[] }[]",required:!1,notes:"Carousel slides (for `type: POST`)."},{name:"thumbnailOffset",type:"number (ms)",required:!1,notes:"Frame to use as the published video's cover."},{name:"thumbnail",type:"string (URL)",required:!1,notes:"Cover image (alternative to thumbnailOffset)."},{name:"shareToFeed",type:"boolean",required:!1,notes:"Reels only \u2014 also show in the Feed tab."},{name:"collaborators",type:"string[]",required:!1,notes:"Usernames to invite as collaborators."},{name:"tagged",type:"{ username: string, x?: number, y?: number }[]",required:!1,notes:"People tags for a single-image post."},{name:"locationId",type:"string",required:!1,notes:'A location id \u2014 discover with trigger_integration_tool method "instagram:locations".'},{name:"autoFitImage",type:"boolean",required:!1,notes:"Let bundle.social fit the image to a valid aspect ratio."},{name:"autoCropImage",type:"boolean",required:!1,notes:"Let bundle.social crop the image to a valid aspect ratio."},{name:"trialParams",type:'{ graduationStrategy: "MANUAL" | "SS_PERFORMANCE" }',required:!1,notes:"Reels only \u2014 trial reels are shown to non-followers first."},{name:"isPaidPartnership",type:"boolean",required:!1,notes:'Adds the native "Paid partnership" label. Implied by brandedContentSponsors; use alone for a label without a named sponsor.'},{name:"brandedContentSponsors",type:"string[]",required:!1,notes:"Up to 2 Instagram usernames to tag as paid-partnership sponsors. Accounts connected via Facebook Login only."},{name:"musicSoundInfo",type:"{ musicSoundId, musicSoundVolume?, videoOriginalSoundVolume? }",required:!1,notes:'Reels only \u2014 get an audio_id from trigger_integration_tool method "instagram:audio". Volumes 0\u2013100.'},{name:"isAiGenerated",type:"boolean",required:!1,notes:"Adds Instagram's AI content label."}],example:{INSTAGRAM:{type:"REEL",text:"BTS",shareToFeed:!0,thumbnailOffset:1500}}},TIKTOK:{dataKey:"data.TIKTOK",summary:"Post a video or photo carousel to TikTok.",fields:[{name:"type",type:"VIDEO | IMAGE",required:!1,notes:"VIDEO = 1 video; IMAGE = photo carousel."},{name:"privacy",type:"PUBLIC_TO_EVERYONE | MUTUAL_FOLLOW_FRIENDS | FOLLOWER_OF_CREATOR | SELF_ONLY",required:!0,notes:"Effectively required by TikTok."},{name:"text",type:"string",required:!1,notes:"Caption."},{name:"uploadIds",type:"string[]",required:!1,notes:"The video, or the photos for `type: IMAGE`. Video: MP4/MOV/WEBM, \u2265540p, portrait 9:16 recommended, up to ~10 min."},{name:"photoCoverIndex",type:"number",required:!1,notes:"Which photo is the cover (for `type: IMAGE`)."},{name:"thumbnailOffset",type:"number (ms)",required:!1,notes:"Frame to use as the video cover."},{name:"thumbnail",type:"string (URL)",required:!1,notes:"Cover image (alternative to thumbnailOffset)."},{name:"isBrandContent",type:"boolean",required:!1,notes:"Disclosure: paid third-party partnership."},{name:"isOrganicBrandContent",type:"boolean",required:!1,notes:"Disclosure: promoting your own business."},{name:"disableComments",type:"boolean",required:!1,notes:"Interaction restriction."},{name:"disableDuet",type:"boolean",required:!1,notes:"Interaction restriction."},{name:"disableStitch",type:"boolean",required:!1,notes:"Interaction restriction."},{name:"isAiGenerated",type:"boolean",required:!1,notes:"Mark the video as AI-generated."},{name:"autoAddMusic",type:"boolean",required:!1,notes:"Let TikTok add music to photos."},{name:"autoScale",type:"boolean",required:!1,notes:"Auto-scale the video."},{name:"uploadToDraft",type:"boolean",required:!1,notes:"Upload as a TikTok draft instead of publishing."},{name:"musicSoundInfo",type:"{ musicSoundId, musicSoundVolume?, musicSoundStart?, musicSoundEnd?, videoOriginalSoundVolume? }",required:!1,notes:'Commercial music \u2014 get a song_clip_id from trigger_integration_tool method "tiktok:trending-music". Volumes 0\u2013100; start/end in ms.'}],example:{TIKTOK:{type:"VIDEO",text:"Launch BTS",privacy:"PUBLIC_TO_EVERYONE",disableStitch:!0}}},YOUTUBE:{dataKey:"data.YOUTUBE",summary:"Upload a video or Short to YouTube.",fields:[{name:"type",type:"VIDEO | SHORT",required:!1,notes:"SHORT = vertical \u226460s; VIDEO = full upload."},{name:"uploadIds",type:"string[]",required:!1,notes:"One video."},{name:"text",type:"string",required:!1,notes:"The video TITLE (the post `title` field also maps here)."},{name:"description",type:"string",required:!1,notes:"Video description."},{name:"thumbnail",type:"string (URL)",required:!1,notes:"Custom thumbnail (`type: VIDEO`)."},{name:"privacy",type:"PUBLIC | UNLISTED | PRIVATE",required:!1,notes:"Visibility."},{name:"defaultLanguage",type:"string (BCP-47)",required:!1,notes:'Language of the title and description, e.g. "en" or "pl".'},{name:"defaultAudioLanguage",type:"string (BCP-47)",required:!1,notes:`Language of the video's default audio track, e.g. "en" or "pl".`},{name:"madeForKids",type:"boolean",required:!0,notes:"Required-ish \u2014 YouTube needs you to declare this."},{name:"containsSyntheticMedia",type:"boolean",required:!1,notes:"Mark AI-generated content."},{name:"hasPaidProductPlacement",type:"boolean",required:!1,notes:"Declare paid placements."}],example:{YOUTUBE:{type:"SHORT",text:"Launch BTS",description:"Behind the scenes\u2026",privacy:"PUBLIC",madeForKids:!1}}},REDDIT:{dataKey:"data.REDDIT",summary:"Submit a post to a subreddit (or your profile).",fields:[{name:"sr",type:"string",required:!0,notes:"Subreddit (`r/subredditName`) or `u/username`."},{name:"text",type:"string",required:!0,notes:`The post title for link/text posts (Reddit's "title").`},{name:"description",type:"string",required:!1,notes:"The body for a self post."},{name:"uploadIds",type:"string[]",required:!1,notes:"An image or video."},{name:"link",type:"string (URL)",required:!1,notes:"Link post target."},{name:"nsfw",type:"boolean",required:!1,notes:"Mark NSFW."},{name:"flairId",type:"string",required:!1,notes:'Required if the subreddit requires a flair \u2014 get options with trigger_integration_tool method "reddit:flairs".'}],example:{REDDIT:{sr:"r/dataisbeautiful",text:"Our 2026 growth, visualized",uploadIds:["<id>"],flairId:"<flair-id>"}}},DISCORD:{dataKey:"data.DISCORD",summary:"Post a message to a connected Discord channel.",fields:[{name:"channelId",type:"string",required:!0,notes:'The connected server channel (an integration "channel" id \u2014 see list_integrations).'},{name:"text",type:"string",required:!1,notes:"Message content. \u22642000 chars."},{name:"uploadIds",type:"string[]",required:!1,notes:"Attachments."},{name:"username",type:"string",required:!1,notes:"Override the author name shown (webhook)."},{name:"avatarUrl",type:"string (URL)",required:!1,notes:"Override the author avatar (webhook)."}],example:{DISCORD:{channelId:"<channel-id>",text:"New release \u{1F389}"}}},SLACK:{dataKey:"data.SLACK",summary:"Post a message to a connected Slack channel.",fields:[{name:"channelId",type:"string",required:!0,notes:'The connected workspace channel (an integration "channel" id \u2014 see list_integrations).'},{name:"text",type:"string",required:!1,notes:"Message text."},{name:"uploadIds",type:"string[]",required:!1,notes:"Attachments."},{name:"username",type:"string",required:!1,notes:"Override the author name shown."},{name:"avatarUrl",type:"string (URL)",required:!1,notes:"Override the author avatar."}],example:{SLACK:{channelId:"<channel-id>",text:"Standup notes\u2026"}}},GOOGLE_BUSINESS:{dataKey:"data.GOOGLE_BUSINESS",summary:"Publish an update to a Google Business Profile location.",fields:[{name:"text",type:"string",required:!1,notes:"The update body."},{name:"uploadIds",type:"string[]",required:!1,notes:"Images/videos."},{name:"topicType",type:"STANDARD | EVENT | OFFER | ALERT",required:!1,notes:"Post kind."},{name:"languageCode",type:"string",required:!1,notes:"Language tag like `en` / `en-US`."},{name:"callToActionType",type:"BOOK | ORDER | SHOP | LEARN_MORE | SIGN_UP | CALL",required:!1,notes:"CTA button."},{name:"callToActionUrl",type:"string (URL)",required:!1,notes:"CTA target."},{name:"eventTitle",type:"string",required:!1,notes:"For `topicType: EVENT`."},{name:"eventStartDate",type:"string",required:!1,notes:"For `topicType: EVENT`."},{name:"eventEndDate",type:"string",required:!1,notes:"For `topicType: EVENT`."},{name:"offerCouponCode",type:"string",required:!1,notes:"For `topicType: OFFER`."},{name:"offerRedeemOnlineUrl",type:"string",required:!1,notes:"For `topicType: OFFER`."},{name:"offerTermsConditions",type:"string",required:!1,notes:"For `topicType: OFFER`."},{name:"alertType",type:"COVID_19",required:!1,notes:"For `topicType: ALERT`."}],example:{GOOGLE_BUSINESS:{text:"Now open Saturdays!",topicType:"STANDARD",callToActionType:"LEARN_MORE",callToActionUrl:"https://example.com"}}},PINTEREST:{dataKey:"data.PINTEREST",summary:"Create a Pin on a board.",fields:[{name:"boardName",type:"string",required:!0,notes:"The board to pin to."},{name:"uploadIds",type:"string[]",required:!1,notes:"One image (or video)."},{name:"text",type:"string",required:!1,notes:"The Pin title."},{name:"description",type:"string",required:!1,notes:"Pin description."},{name:"link",type:"string (URL)",required:!1,notes:"Where the Pin links to."},{name:"altText",type:"string",required:!1,notes:"Image alt text."},{name:"note",type:"string",required:!1,notes:"Private note (not public)."},{name:"thumbnail",type:"string (URL)",required:!1,notes:"Cover image."},{name:"dominantColor",type:"string",required:!1,notes:"Hex color used as a placeholder before the image loads."},{name:"isAiGenerated",type:"boolean",required:!1,notes:"Adds Pinterest's AI disclosure label."}],example:{PINTEREST:{boardName:"Inspiration",text:"New idea",uploadIds:["<id>"],link:"https://bundle.social"}}},SNAPCHAT:{dataKey:"data.SNAPCHAT",summary:"Post a Story or a Spotlight to a Snapchat Public Profile.",fields:[{name:"type",type:"STORY | SPOTLIGHT",required:!1,notes:"Default STORY."},{name:"uploadIds",type:"string[]",required:!1,notes:"One image or video. Video: 5\u2013180s, \u2265540\xD7960, up to 100 MB. Images are Story-only."},{name:"text",type:"string",required:!1,notes:"Alias for `description` (Spotlight). \u2264160 chars."},{name:"description",type:"string",required:!1,notes:"Spotlight description. \u2264160 chars."},{name:"locale",type:"string",required:!1,notes:"Spotlight locale in `en_US` form. Default en_US."},{name:"skipSaveToProfile",type:"boolean",required:!1,notes:"Spotlight only \u2014 don't save the post to the profile."}],example:{SNAPCHAT:{type:"SPOTLIGHT",description:"Launch day",locale:"en_US"}}}},At={TWITTER:["x","twitter"],BLUESKY:["bluesky","bsky"],MASTODON:["mastodon","masto"],THREADS:["threads"],LINKEDIN:["linkedin","li"],FACEBOOK:["facebook","fb"],INSTAGRAM:["instagram","ig","insta"],TIKTOK:["tiktok","tt"],YOUTUBE:["youtube","yt"],REDDIT:["reddit"],DISCORD:["discord"],SLACK:["slack"],GOOGLE_BUSINESS:["gbp","google-business","google_business","gmb"],PINTEREST:["pinterest","pin"],SNAPCHAT:["snapchat","snap"]},Ot={TWITTER:"X / Twitter",BLUESKY:"Bluesky",MASTODON:"Mastodon",THREADS:"Threads",LINKEDIN:"LinkedIn",FACEBOOK:"Facebook (Page)",INSTAGRAM:"Instagram",TIKTOK:"TikTok",YOUTUBE:"YouTube",REDDIT:"Reddit",DISCORD:"Discord",SLACK:"Slack",GOOGLE_BUSINESS:"Google Business Profile",PINTEREST:"Pinterest",SNAPCHAT:"Snapchat (Public Profile)"},wt={TWITTER:["For an X thread, post the first tweet, then add the rest as replies \u2014 note the API does not expose comments for X, so chain them as separate posts.","No analytics surface for X."],LINKEDIN:['Discover mention URNs with trigger_integration_tool method "linkedin:mentions" and put them in `text`.'],REDDIT:['Before posting, run trigger_integration_tool method "reddit:requirements" to learn title length limits, allowed post types and whether a flair is required.'],YOUTUBE:['There is no `categoryId` in the post `data`; fetch categories with trigger_integration_tool method "youtube:categories".'],INSTAGRAM:["Account types are connected via Facebook or directly via Instagram (instagramConnectionMethod on the integration).","brandedContentSponsors and business discovery only work for accounts connected through Facebook Login."],GOOGLE_BUSINESS:["Set the location up in the dashboard first; details/categories/hours are managed via integration helper tools."],SNAPCHAT:["Requires a Snapchat Public Profile. Stories take an image or a video; Spotlights are video-only.","No comments API surface for Snapchat."],THREADS:["Polls, GIFs and link attachments are mutually exclusive with media \u2014 Threads only allows them on text-only posts."]},fe=["Images: JPG / PNG / WEBP / GIF. Video: MP4 / MOV / WEBM, up to 5 GB via the large-upload flow.","Upload media first (upload_media \u2192 id), or let create_post's `media` arg do it; then put ids in `uploadIds` (and carouselItems[].uploadId / mediaItems[].uploadId).","Large videos can take a while to process server-side after upload \u2014 a newly created post may sit in PROCESSING before going POSTED. Use get_post to check status; retry_post for a transient platform failure."],ge=Object.fromEntries(L.map(t=>{let e=k.includes(t),o={platform:t,label:Ot[t],aliases:At[t],capabilities:{posting:!0,comments:e,analytics:Tt.includes(t),commentImports:St.includes(t)},post:Et[t],...e?{comment:It(t)}:{},notes:wt[t]??[]};return[t,o]}));function Ke(t,e){let o={platform:t.platform,label:t.label,aliases:t.aliases,capabilities:t.capabilities,notes:t.notes};return e==="post"?{...o,post:t.post}:e==="comment"?{...o,comment:t.comment??{supported:!1,message:`Comments are not available on ${t.label} via the bundle.social API.`}}:{...o,post:t.post,...t.comment?{comment:t.comment}:{}}}function ze(t,e){l(t,"describe_platform",{title:"Describe a platform's field schema",description:'Look up the exact per-platform `data.<PLATFORM>` fields the bundle.social API accepts \u2014 for posting AND commenting \u2014 so you can build a correct `data` / `platformSettings` object instead of guessing. Pass `platform` (name or alias, e.g. "reddit", "x", "gbp") for one platform, or omit it to get every platform. Pass `operation` ("post" or "comment") to narrow the response. Each field lists its name, type, whether it is required, and notes; each platform also reports its capabilities (posting / comments / analytics / comment imports) and a ready-to-use example. Call this before create_post / schedule_post / update_post / create_comment / update_comment whenever you are unsure which fields a platform needs.',inputSchema:{platform:xe.string().min(1).optional().describe('Platform name or alias (e.g. "reddit", "x", "tiktok", "gbp"). Omit to describe every platform.'),operation:xe.enum(["post","comment"]).optional().describe('Which operation to describe. "post" = create/schedule/update a post; "comment" = create/update a comment. Omit for both.')},annotations:{readOnlyHint:!0}},async({platform:o,operation:n})=>{if(o){let a=x(o);return a?r({platform:Ke(ge[a],n),mediaNotes:fe}):r({error:{code:"UNKNOWN_PLATFORM",message:`Unknown platform "${o}". Supported: ${L.join(", ")} (aliases like "x" and "gbp" are accepted too).`,supportedPlatforms:L}})}return r({platforms:L.map(a=>Ke(ge[a],n)),mediaNotes:fe,hint:'Pass `platform` (e.g. "reddit") to focus on one platform, or `operation` ("post" | "comment") to narrow the response.'})})}function We(t,e){qe(t,e),Be(t,e),Oe(t,e),ze(t,e),Ce(t,e),De(t,e),_e(t,e),Le(t,e),Me(t,e),He(t,e),ke(t,e),Fe(t,e)}var X=j.version;function Ye(t){let e=new Pt({name:"bundlesocial",version:X},{capabilities:{tools:{}},instructions:"Tools for the bundle.social API: posting/scheduling to 14+ social platforms, comments, media uploads, analytics, team & integration management, and bulk/history imports (post-history, comment, CSV). Run check_setup first to verify the API key, org access and team. Use list_integrations to see connected accounts and their ids. create_post / schedule_post target platforms by name (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp) or by integration id; put platform-required fields (Reddit `sr`, Pinterest `boardName`, TikTok `privacy`, YouTube `madeForKids`/`privacyStatus`) under `platformSettings` keyed by platform. Call describe_platform to get the exact per-platform `data.<PLATFORM>` field schema (for posts and comments) before building a `data` / `platformSettings` object; the same fields are documented at https://docs.bundle.social/api-reference/platform-parameters. Team-scoped tools take an optional `teamId` (resolved automatically when the org has one team or BUNDLESOCIAL_TEAM_ID is set). Errors come back as { error: { code, message, details } } with isError: true."}),o={client:Ee(t.apiKey,t.apiUrl??Z),defaultTeamId:t.defaultTeamId};return We(e,o),e}function he(t){let e=process.argv.indexOf(`--${t}`);if(e!==-1&&e+1<process.argv.length)return process.argv[e+1];let o=process.argv.find(n=>n.startsWith(`--${t}=`));return o?o.slice(`--${t}=`.length):void 0}function ye(t){process.stderr.write(`bundlesocial-mcp: ${t}
|
|
4
|
+
`)}async function Ct(){if(process.argv.includes("--version")||process.argv.includes("-v")){process.stdout.write(`${X}
|
|
5
|
+
`);return}if(process.argv.includes("--help")||process.argv.includes("-h")){process.stdout.write(`bundlesocial-mcp ${X} \u2014 Model Context Protocol server for the bundle.social API.
|
|
6
6
|
|
|
7
7
|
Usage: bundlesocial-mcp [--api-key <key>] [--api-url <url>] [--team-id <id>]
|
|
8
8
|
|
|
9
9
|
Reads BUNDLESOCIAL_API_KEY (required), BUNDLESOCIAL_API_URL and BUNDLESOCIAL_TEAM_ID from the environment;
|
|
10
|
-
the flags above override them. Communicates over stdio (MCP). Create an API key at ${
|
|
11
|
-
`);return}let
|
|
10
|
+
the flags above override them. Communicates over stdio (MCP). Create an API key at ${Q}
|
|
11
|
+
`);return}let t=he("api-key")??process.env.BUNDLESOCIAL_API_KEY;t||(ye(`missing API key. Set BUNDLESOCIAL_API_KEY (or pass --api-key). Create one at ${Q}`),process.exit(1));let e=Ye({apiKey:t,apiUrl:he("api-url")??process.env.BUNDLESOCIAL_API_URL,defaultTeamId:he("team-id")??process.env.BUNDLESOCIAL_TEAM_ID}),o=new Rt;await e.connect(o),ye("running on stdio");let n=()=>{e.close().finally(()=>process.exit(0))};process.on("SIGINT",n),process.on("SIGTERM",n)}Ct().catch(t=>{ye(`fatal: ${t?.stack??t}`),process.exit(1)});
|
|
12
12
|
//# sourceMappingURL=index.js.map
|