bundlesocial-mcp 1.0.0 → 1.1.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 CHANGED
@@ -1,3 +1,31 @@
1
+ # [1.1.0](https://github.com/bundleglobal/bundlesocial-mcp/compare/v1.0.1...v1.1.0) (2026-05-25)
2
+
3
+
4
+ ### Features
5
+
6
+ * additional reference ([5a5133f](https://github.com/bundleglobal/bundlesocial-mcp/commit/5a5133fc5d51f49e8d8dfe8d9effbee129989dc9))
7
+
8
+ ## [1.0.1](https://github.com/bundleglobal/bundlesocial-mcp/compare/v1.0.0...v1.0.1) (2026-05-17)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * build before release ([b7a6aa7](https://github.com/bundleglobal/bundlesocial-mcp/commit/b7a6aa7e74adc17ee3c3122bdaa9bfad07c727f0))
14
+
15
+ # 1.0.0 (2026-05-17)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * semantic release ([7a2f61e](https://github.com/bundleglobal/bundlesocial-mcp/commit/7a2f61ee298913d174836a3c4b523ced49b984b1))
21
+
22
+
23
+ ### Features
24
+
25
+ * additional methods ([0aa1af1](https://github.com/bundleglobal/bundlesocial-mcp/commit/0aa1af1cf4d65af5c781630cd3baad2d121ad665))
26
+ * bundle.social MCP server v1 ([3ed0235](https://github.com/bundleglobal/bundlesocial-mcp/commit/3ed0235902bf2ecd288cbfaf9976c6dcdaf9f160))
27
+ * update comment ([c0da8ca](https://github.com/bundleglobal/bundlesocial-mcp/commit/c0da8caaa797eb6542886dff53b82b715344e204))
28
+
1
29
  # Changelog
2
30
 
3
31
  All notable changes to `bundlesocial-mcp` are documented here. This file is
package/README.md CHANGED
@@ -21,6 +21,12 @@ 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 |
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import{StdioServerTransport as me}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as de}from"@modelcontextprotocol/sdk/server/mcp.js";var z={name:"bundlesocial-mcp",version:"1.0.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.47.0",zod:"^3.23.8"},devDependencies:{"@types/node":"^20.14.0",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,m=await t.client.team.teamGetTeam({id:r});return s({teamId:m.id,teamName:m.name,integrations:Q(m.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 m=await t.client.team.teamGetTeam({id:r.id});a.push({teamId:m.id,teamName:m.name,integrations:Q(m.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 m=await f(t,a),d={type:S(o),teamId:m,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(c=>S(c)),...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}}),m=await fetch(r.url,{method:"PUT",headers:{"content-type":a},body:new Uint8Array(n)});if(!m.ok)throw new u("LARGE_UPLOAD_FAILED",`Uploading the file to storage failed (HTTP ${m.status}).`,{status:m.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 m of i){let d=r.find(c=>c.id===m);if(!d)throw new u("INTEGRATION_NOT_FOUND",`No connected integration with id "${m}" in team ${t}. Call list_integrations to see ids, or use a platform name like "x" or "tiktok".`,{availableIntegrations:r.map(c=>({id:c.id,type:c.type,username:c.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:m,title:d,draft:c})=>{let h=await Tt(t,{teamId:o,content:n,platforms:i,media:a,platformSettings:r,data:m,title:d}),y=await t.client.post.postCreate({requestBody:{teamId:h.teamId,title:h.title,postDate:new Date().toISOString(),status:c?"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:m,data:d,title:c})=>{let h=B(n,"date"),y=await Tt(t,{teamId:o,content:i,platforms:a,media:r,platformSettings:m,data:d,title:c}),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:m,to:d,query:c,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:m?B(m,"from"):void 0,postDateTo:d?B(d,"to"):void 0,q:c,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:m,media:d,platformSettings:c,data:h,teamId:y})=>{let I=await f(t,y),b=r!==void 0||(d?.length??0)>0||c!==void 0||h!==void 0,w;if(m&&m.length>0)w=await k(t.client,I,m);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:c,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:m,teamId:d})=>{let c=await f(t,d),h;if(i&&i.length>0)h=lt(await k(t.client,c,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=m?"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:c,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:m,order:d,orderBy:c,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:m,order:d??void 0,orderBy:c??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:m,data:d})=>{let c=lt((m??[]).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),c.length>0&&(y.socialAccountTypes=c),h)if(d)y.data=d;else{if(c.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(c.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 m=await f(t,o);return s(await t.client.comment.commentImportGetList({teamId:m,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:m})=>{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:m??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),m=i?await t.client.analytics.analyticsGetSocialAccountAnalyticsRaw({teamId:a,platformType:r}):await t.client.analytics.analyticsGetSocialAccountAnalytics({teamId:a,platformType:r});return s(m)}),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,m,d,c,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=m.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:m.id,name:m.name},range:{from:n??null,to:i??null},usage:{posts:d,comments:c,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(()=>{}),[c,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:c,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:m,teamId:d})=>{let c=await f(t,d);return s(await t.client.postImport.postImportCreate({requestBody:{teamId:c,socialAccountType:S(o),count:n,...i!==void 0?{withAnalytics:i}:{},...a!==void 0?{importCarousels:a}:{},...r?{surface:r}:{},...m?{mediaType:m}:{}}}))}),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,c,h,y={})=>o.push({name:d,status:c,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(c=>({id:c.id,name:c.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 m;if(t.defaultTeamId?(m=t.defaultTeamId,n("team","ok","Using team from BUNDLESOCIAL_TEAM_ID / --team-id",{teamId:m})):a.length===1?(m=a[0].id,n("team","ok","Using the organization's only team",{teamId:m,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}),m)try{let c=(await t.client.team.teamGetTeam({id:m})).socialAccounts??[];n("integrations",c.length>0?"ok":"warn",c.length>0?`${c.length} connected integration(s)`:"No integrations connected \u2014 connect one in the dashboard before posting",{count:c.length,platforms:c.map(h=>h.type),connectUrl:gt})}catch(d){n("integrations","fail","Could not load the team's integrations",{teamId:m,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 mt(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 ct(e){process.stderr.write(`bundlesocial-mcp: ${e}
4
- `)}async function ce(){if(process.argv.includes("--version")||process.argv.includes("-v")){process.stdout.write(`${j}
5
- `);return}if(process.argv.includes("--help")||process.argv.includes("-h")){process.stdout.write(`bundlesocial-mcp ${j} \u2014 Model Context Protocol server for the bundle.social API.
2
+ import{StdioServerTransport as Et}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as bt}from"@modelcontextprotocol/sdk/server/mcp.js";var K={name:"bundlesocial-mcp",version:"1.1.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.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 Ye,OpenAPI as Ve}from"bundlesocial";import{ApiError as ge}from"bundlesocial";var u=class extends Error{code;details;constructor(e,o,a){super(o),this.name="McpToolError",this.code=e,this.details=a}};function je(t){if(t instanceof u)return{code:t.code,message:t.message,details:t.details};if(t instanceof ge){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 R(t){return t instanceof ge?`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 he(t){return{content:[{type:"text",text:JSON.stringify({error:je(t)},null,2)}],isError:!0}}var $="https://api.bundle.social",X="https://bundle.social/dashboard/organization/api-keys",ye="https://bundle.social/dashboard/general/social-accounts";function Ie(t,e=$){return new Ye(t,{...Ve,BASE:e})}async function f(t,e){if(e)return e;if(t.defaultTeamId)return t.defaultTeamId;let a=(await t.client.organization.organizationGetOrganization()).teams??[];if(a.length===1)return a[0].id;throw a.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 ${a.length} teams. Pass a "teamId" argument (or set BUNDLESOCIAL_TEAM_ID when starting the server).`,{teams:a.map(n=>({id:n.id,name:n.name}))})}import{z as b}from"zod";var _=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","TWITTER","THREADS","LINKEDIN","PINTEREST","REDDIT","MASTODON","DISCORD","SLACK","BLUESKY","GOOGLE_BUSINESS"],Te=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","REDDIT","PINTEREST","MASTODON","LINKEDIN","BLUESKY","GOOGLE_BUSINESS"],$e={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 k(t){return $e[t.trim().toUpperCase().replace(/\s+/g,"_")]}function T(t){let e=k(t);if(!e)throw new u("UNKNOWN_PLATFORM",`Unknown platform "${t}". Supported: ${_.join(", ")} (aliases like "x" and "gbp" are accepted too).`);return e}function Z(t){return Te.includes(t)}var B=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","LINKEDIN","REDDIT","MASTODON","DISCORD","SLACK","BLUESKY"];function J(t){return B.includes(t)}function U(t){let e=T(t);if(!Z(e))throw new u("ANALYTICS_NOT_SUPPORTED",`Analytics are not available for ${e}. Supported: ${Te.join(", ")}.`);return e}function l(t,e,o,a){t.registerTool(e,o,(async n=>{try{return await a(n??{})}catch(i){return he(i)}}))}var v=b.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),N=b.string().min(1).describe("Platform name/alias (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp).");function Q(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 Se(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,m=await e.client.team.teamGetTeam({id:s});return r({teamId:m.id,teamName:m.name,integrations:Q(m.socialAccounts)})}let a=await e.client.organization.organizationGetOrganization(),n=a.teams??[];if(n.length===1){let s=await e.client.team.teamGetTeam({id:n[0].id});return r({teamId:s.id,teamName:s.name,integrations:Q(s.socialAccounts)})}let i=[];for(let s of n){let m=await e.client.team.teamGetTeam({id:s.id});i.push({teamId:m.id,teamName:m.name,integrations:Q(m.socialAccounts)})}return r({organizationId:a.id,organizationName:a.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:N,redirectUrl:b.string().min(1).describe("URL bundle.social redirects to after the user finishes (or cancels) the OAuth flow."),serverUrl:b.string().optional().describe("Mastodon/Bluesky instance URL (required for those platforms)."),teamId:v,options:b.record(b.string(),b.unknown()).optional().describe('Advanced provider flags, e.g. {"instagramConnectionMethod":"INSTAGRAM","withBusinessScope":true,"disableAutoLogin":true,"forceBrowserOAuth":true}.')},annotations:{openWorldHint:!0}},async({platform:o,redirectUrl:a,serverUrl:n,teamId:i,options:s})=>{let m=await f(e,i),d={type:T(o),teamId:m,redirectUrl:a,...n?{serverUrl:n}:{},...s??{}};return r(await e.client.socialAccount.socialAccountConnect({requestBody:d}))}),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:N,teamId:v},annotations:{destructiveHint:!0,openWorldHint:!0}},async({platform:o,teamId:a})=>{let n=await f(e,a);return r(await e.client.socialAccount.socialAccountDisconnect({requestBody:{type:T(o),teamId:n}}))}),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:N,channelId:b.string().min(1).describe("Channel/page id to select."),teamId:v},annotations:{openWorldHint:!0}},async({platform:o,channelId:a,teamId:n})=>{let i=await f(e,n);return r(await e.client.socialAccount.socialAccountSetChannel({requestBody:{type:T(o),teamId:i,channelId:a}}))}),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:N,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:a})=>{let n=await f(e,a);return r(await e.client.socialAccount.socialAccountUnsetChannel({requestBody:{type:T(o),teamId:n}}))}),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:N,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:a})=>{let n=await f(e,a);return r(await e.client.socialAccount.socialAccountRefreshChannels({requestBody:{type:T(o),teamId:n}}))}),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:b.array(b.string().min(1)).min(1).describe("Platforms the portal should offer to connect (names/aliases)."),redirectUrl:b.string().optional().describe("URL to redirect to when the user finishes."),teamId:v,expiresInMinutes:b.number().int().min(5).max(2880).optional().describe("Link lifetime in minutes (5 min \u2013 48 h)."),options:b.record(b.string(),b.unknown()).optional().describe("Advanced portal options (logoUrl, userName, language, hidePoweredBy, maxSocialAccountsConnected, \u2026).")},annotations:{openWorldHint:!0}},async({platforms:o,redirectUrl:a,teamId:n,expiresInMinutes:i,options:s})=>{let d={teamId:await f(e,n),socialAccountTypes:o.map(p=>T(p)),...a?{redirectUrl:a}:{},...i?{expiresIn:i}:{},...s??{}};return r(await e.client.socialAccount.socialAccountCreatePortalLink({requestBody:d}))}),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:N,teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:a})=>{let n=await f(e,a);return r(await e.client.socialAccount.socialAccountConnectionCheck({requestBody:{type:T(o),teamId:n}}))}),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:N,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:a})=>{let n=await f(e,a);return r(await e.client.socialAccount.socialAccountProfileRefresh({requestBody:{type:T(o),teamId:n}}))}),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:N,teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:a})=>{let n=await f(e,a);return r(await e.client.socialAccount.socialAccountGetByType({teamId:n,type:T(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:b.string().min(1).describe("Source team id."),toTeamId:b.string().min(1).describe("Destination team id."),platforms:b.array(b.string().min(1)).min(1).describe("Platforms to copy (names/aliases)."),resetChannel:b.boolean().optional().describe("If true, the destination must re-select the page/channel.")},annotations:{openWorldHint:!0}},async({fromTeamId:o,toTeamId:a,platforms:n,resetChannel:i})=>r(await e.client.socialAccount.socialAccountCopy({requestBody:{fromTeamId:o,toTeamId:a,...i!==void 0?{resetChannel:i}:{},socialAccountTypes:n.map(s=>T(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:b.number().int().positive().optional().describe("Page (1-based)."),pageSize:b.number().int().positive().max(100).optional().describe("Page size.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({page:o,pageSize:a})=>r(await e.client.socialAccount.socialAccountGetAccountsToDelete({page:o,pageSize:a})))}import{z as g}from"zod";import Xe from"fs/promises";import q from"path";var Ze={".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 Je(t){return/^https?:\/\//i.test(t.trim())}var Qe=90*1024*1024,et={".jpg":"image/jpg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".mp4":"video/mp4",".pdf":"application/pdf"};async function ee(t,e,o){if(Je(o))return t.upload.uploadCreateFromUrl({requestBody:{teamId:e,url:o.trim()}});let a=q.resolve(o),n;try{n=await Xe.readFile(a)}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:a})}if(n.byteLength>Qe)return tt(t,e,a,n);let i=Ze[q.extname(a).toLowerCase()]??"application/octet-stream",s=new File([n],q.basename(a),{type:i});return t.upload.uploadCreate({formData:{teamId:e,file:s}})}async function tt(t,e,o,a){let n=q.extname(o).toLowerCase(),i=et[n];if(!i)throw new u("LARGE_UPLOAD_UNSUPPORTED_TYPE",`Large uploads (>90 MB) only support .jpg, .jpeg, .png, .gif, .mp4 and .pdf \u2014 got "${n||"no extension"}".`,{path:o});let s=await t.upload.uploadInitLargeUpload({requestBody:{teamId:e,fileName:q.basename(o),mimeType:i}}),m=await fetch(s.url,{method:"PUT",headers:{"content-type":i},body:new Uint8Array(a)});if(!m.ok)throw new u("LARGE_UPLOAD_FAILED",`Uploading the file to storage failed (HTTP ${m.status}).`,{status:m.status});return t.upload.uploadFinalizeLargeUpload({requestBody:{teamId:e,path:s.path}})}async function te(t,e,o){let a=[];for(let n of o){let i=await ee(t,e,n);a.push(i.id)}return a}function ot(t,e){if(typeof t!="object"||t===null||Array.isArray(t))throw new u("INVALID_INPUT",`${e} must be a JSON object.`);return t}async function G(t,e,o){let a=new Set,n=[];for(let i of o){let s=k(i);s?a.add(s):n.push(i.trim())}if(n.length>0){let s=(await t.team.teamGetTeam({id:e})).socialAccounts??[];for(let m of n){let d=s.find(p=>p.id===m);if(!d)throw new u("INTEGRATION_NOT_FOUND",`No connected integration with id "${m}" in team ${e}. Call list_integrations to see ids, or use a platform name like "x" or "tiktok".`,{availableIntegrations:s.map(p=>({id:p.id,type:p.type,username:p.username}))});a.add(d.type)}}return[...a]}function at(t){let e=Object.keys(t);return e.length>0&&e.every(o=>_.includes(o.trim().toUpperCase()))}function nt(t,e){let o=Object.fromEntries(e.map(a=>[a,{}]));if(!t)return o;if(at(t)){for(let[a,n]of Object.entries(t)){let i=a.trim().toUpperCase();i in o&&(o[i]={...o[i],...ot(n,`platformSettings.${a}`)})}return o}for(let a of e)o[a]={...t};return o}function oe(t,e){if(e.data)return e.data;let o=nt(e.platformSettings,t),a={};for(let n of t)a[n]={...e.content!==void 0?{text:e.content}:{},...e.mediaUploadIds.length>0?{uploadIds:e.mediaUploadIds}:{},...o[n]};return a}function ae(t){return Object.keys(t).map(e=>T(e))}function be(t,e){let o=(t??"").split(`
3
+ `).map(a=>a.trim()).find(a=>a.length>0);return o?o.length>80?`${o.slice(0,79)}\u2026`:o:e}function M(t,e){let o=new Date(t);if(Number.isNaN(o.getTime()))throw new u("INVALID_DATE",`${e} is not a valid ISO 8601 date/time: "${t}". Example: 2026-06-01T09:00:00Z`);return o.toISOString()}var z=g.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),ne=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.'),ie=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."),re=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`).'),se=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.'),Ee=g.string().min(1).optional().describe("Post title. Defaults to the first line of `content`. Also used as the YouTube video title.");async function Oe(t,e){let o=await f(t,e.teamId),a;if(e.platforms&&e.platforms.length>0)a=await G(t.client,o,e.platforms);else if(e.data)a=ae(e.data);else throw new u("NO_TARGET",'Provide "platforms" (platform names or integration ids), or a "data" object keyed by platform.');if(a.length===0)throw new u("NO_TARGET","Could not determine any target platform for this post.");let n=await te(t.client,o,e.media??[]),i=oe(a,{content:e.content,mediaUploadIds:n,platformSettings:e.platformSettings,data:e.data});return{teamId:o,socialAccountTypes:a,data:i,title:e.title??be(e.content,"Untitled post")}}function Ae(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:z,content:g.string().optional().describe("Post text, applied to every targeted platform."),platforms:ne,media:ie,platformSettings:re,data:se,title:Ee,draft:g.boolean().optional().default(!1).describe("If true, save as a DRAFT instead of publishing now.")},annotations:{openWorldHint:!0}},async({teamId:o,content:a,platforms:n,media:i,platformSettings:s,data:m,title:d,draft:p})=>{let h=await Oe(e,{teamId:o,content:a,platforms:n,media:i,platformSettings:s,data:m,title:d}),y=await e.client.post.postCreate({requestBody:{teamId:h.teamId,title:h.title,postDate:new Date().toISOString(),status:p?"DRAFT":"SCHEDULED",socialAccountTypes:h.socialAccountTypes,data:h.data}});return r(y)}),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:z,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:ne,media:ie,platformSettings:re,data:se,title:Ee},annotations:{openWorldHint:!0}},async({teamId:o,date:a,content:n,platforms:i,media:s,platformSettings:m,data:d,title:p})=>{let h=M(a,"date"),y=await Oe(e,{teamId:o,content:n,platforms:i,media:s,platformSettings:m,data:d,title:p}),S=await e.client.post.postCreate({requestBody:{teamId:y.teamId,title:y.title,postDate:h,status:"SCHEDULED",socialAccountTypes:y.socialAccountTypes,data:y.data}});return r(S)}),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:z,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:a,offset:n,status:i,platforms:s,from:m,to:d,query:p,order:h,orderBy:y})=>{let S=await f(e,o),I=(s??[]).map(T),E={teamId:S,limit:a,offset:n,status:i??void 0,platforms:I.length>0?I:void 0,postDateFrom:m?M(m,"from"):void 0,postDateTo:d?M(d,"to"):void 0,q:p,order:h??void 0,orderBy:y??void 0};return r(await e.client.post.postGetList(E))}),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:g.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:g.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: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:ne,media:ie,platformSettings:re,data:se,teamId:z},annotations:{openWorldHint:!0}},async({id:o,title:a,date:n,status:i,content:s,platforms:m,media:d,platformSettings:p,data:h,teamId:y})=>{let S=await f(e,y),I=s!==void 0||(d?.length??0)>0||p!==void 0||h!==void 0,E;if(m&&m.length>0)E=await G(e.client,S,m);else if(h)E=ae(h);else if(I){let C=await e.client.post.postGet({id:o});if(E=Object.keys(C.data??{}),E.length===0)throw new u("NO_TARGET","Could not determine the post's platforms \u2014 pass `platforms`.")}let A={};if(a!==void 0&&(A.title=a),n&&(A.postDate=M(n,"date")),i&&(A.status=i),E&&E.length>0&&(A.socialAccountTypes=E),I&&E&&E.length>0){let C=await te(e.client,S,d??[]);A.data=oe(E,{content:s,mediaUploadIds:C,platformSettings:p,data:h})}if(Object.keys(A).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 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:g.string().min(1).describe("Post id.")},annotations:{openWorldHint:!0}},async({id:o})=>r(await e.client.post.postRetry({id:o})))}import{z as c}from"zod";var it=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 le(t){let e=t.filter(o=>!J(o));if(e.length>0)throw new u("COMMENTS_NOT_SUPPORTED",`Comments are not available for ${e.join(", ")}. Supported: ${B.join(", ")}.`);return t}function rt(t){let e=new Date(t);if(Number.isNaN(e.getTime()))throw new u("INVALID_DATE",`date is not a valid ISO 8601 date/time: "${t}". Example: 2026-06-01T09:00:00Z`);return e.toISOString()}function we(t,e){l(t,"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:c.string().min(1).describe("Id of the post to comment on."),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,content:a,platforms:n,date:i,delayMinutes:s,draft:m,teamId:d})=>{let p=await f(e,d),h;if(n&&n.length>0)h=le(await G(e.client,p,n));else{let A=await e.client.post.postGet({id:o});if(h=Object.keys(A.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=m?"DRAFT":"SCHEDULED",S=i?new Date(rt(i)):new Date,I=[],E;for(let A=0;A<a.length;A+=1){let C=a[A],V=new Date(S.getTime()+A*(s??0)*6e4).toISOString(),Ke=Object.fromEntries(h.map(ze=>[ze,{text:C}])),fe=await e.client.comment.commentCreate({requestBody:{teamId:p,internalPostId:o,...E?{internalParentCommentId:E}:{},status:y,postDate:V,socialAccountTypes:h,data:Ke,text:C}});I.push(fe),E=fe.id}return r(I.length===1?I[0]:I)}),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:a,offset:n,status:i,platforms:s,query:m,order:d,orderBy:p,teamId:h})=>{let y=await f(e,h),S=le((s??[]).map(T)),I={teamId:y,postId:o,limit:a,offset:n,status:i??void 0,platforms:S.length>0?S:void 0,q:m,order:d??void 0,orderBy:p??void 0};return r(await e.client.comment.commentGetList(I))}),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:a,date:n,status:i,content:s,platforms:m,data:d})=>{let p=le((m??[]).map(T)),h=s!==void 0||d!==void 0,y={};if(a!==void 0&&(y.title=a),n){let S=new Date(n);if(Number.isNaN(S.getTime()))throw new u("INVALID_DATE",`date is not a valid ISO 8601 date/time: "${n}". Example: 2026-06-01T09:00:00Z`);y.postDate=S.toISOString()}if(i&&(y.status=i),p.length>0&&(y.socialAccountTypes=p),h)if(d)y.data=d;else{if(p.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 S=Object.fromEntries(p.map(I=>[I,{text:s}]));y.data=S}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 r(await e.client.comment.commentUpdate({id:o,requestBody:y}))}),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:a,teamId:n})=>{let i=await f(e,n);return r(await e.client.comment.commentImportCreate({requestBody:{teamId:i,postId:o,socialAccountType:T(a)}}))}),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:it.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:a,status:n,limit:i,offset:s})=>{let m=await f(e,o);return r(await e.client.comment.commentImportGetList({teamId:m,postId:a,status:n,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:a,socialAccountId:n,teamId:i,limit:s,offset:m})=>{let d=await f(e,i);return r(await e.client.comment.commentImportGetFetchedComments({teamId:d,postId:o,platform:a?T(a):void 0,socialAccountId:n,limit:s??null,offset:m??null}))})}import{z as P}from"zod";var W=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 Re(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:W,source:P.string().min(1).describe("A public https:// URL, or a local file path (stdio mode only).")},annotations:{openWorldHint:!0}},async({teamId:o,source:a})=>{let n=await f(e,o);return r(await ee(e.client,n,a))}),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:W,type:P.enum(["image","video","document"]).optional().describe("Filter by media type."),status:P.enum(["USED","UNUSED"]).optional().describe("Filter by whether the upload is attached to a post.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,type:a,status:n})=>{let i=await f(e,o);return r(await e.client.upload.uploadGetList({teamId:i,type:a??null,status:n??null}))}),l(t,"get_media",{title:"Get an upload by id",description:"Fetch a single media upload by its bundle.social id.",inputSchema:{id:P.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:P.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:P.array(P.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:W,fileName:P.string().min(1).describe("File name."),mimeType:P.enum(["image/jpg","image/jpeg","image/png","image/gif","video/mp4","application/pdf"]).describe("File MIME type.")},annotations:{openWorldHint:!0}},async({teamId:o,fileName:a,mimeType:n})=>{let i=await f(e,o);return r(await e.client.upload.uploadInitLargeUpload({requestBody:{teamId:i,fileName:a,mimeType:n}}))}),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:W,path:P.string().min(1).describe("The `path` returned by init_large_upload.")},annotations:{openWorldHint:!0}},async({teamId:o,path:a})=>{let n=await f(e,o);return r(await e.client.upload.uploadFinalizeLargeUpload({requestBody:{teamId:n,path:a}}))})}import{z as w}from"zod";var Pe=w.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function st(t,e,o){if(!e&&!o)return!0;if(!t)return!1;let a=new Date(t).getTime();return!(Number.isNaN(a)||e&&a<new Date(e).getTime()||o&&a>new Date(o).getTime())}function De(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:w.string().min(1).describe("Post id."),platform:w.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:w.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:a,raw:n})=>{let i=a?U(a):void 0,s=n?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:w.string().min(1).describe("Platform name/alias."),teamId:Pe,raw:w.boolean().optional().default(!1).describe("If true, return the raw provider analytics payload.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:a,raw:n})=>{let i=await f(e,a),s=U(o),m=n?await e.client.analytics.analyticsGetSocialAccountAnalyticsRaw({teamId:i,platformType:s}):await e.client.analytics.analyticsGetSocialAccountAnalytics({teamId:i,platformType:s});return r(m)}),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:w.array(w.string().min(1)).min(1).max(60).describe("Post ids (max 60)."),platform:w.string().min(1).describe("Platform name/alias the posts belong to."),page:w.number().int().positive().optional().describe("Page (1-based)."),limit:w.number().int().positive().max(20).optional().describe("Page size (max 20).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postIds:o,platform:a,page:n,limit:i})=>r(await e.client.analytics.analyticsGetBulkPostAnalytics({postIds:o,platformType:U(a),page:n,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:w.string().optional().describe("Post id to refresh analytics for."),importedPostId:w.string().optional().describe("Imported-post id to refresh analytics for (alternative to postId)."),platform:w.string().optional().describe("Platform name/alias to refresh a social-account's analytics for (used when postId/importedPostId are omitted)."),teamId:Pe},annotations:{openWorldHint:!0}},async({postId:o,importedPostId:a,platform:n,teamId:i})=>{if(o||a)return r(await e.client.analytics.analyticsForcePostAnalytics({requestBody:{postId:o??null,importedPostId:a??null,platformType:n?U(n):null}}));if(!n)throw new u("REFRESH_TARGET_REQUIRED","Pass either `postId`/`importedPostId` (to refresh a post) or `platform` (to refresh a social account).");let s=await f(e,i);return r(await e.client.analytics.analyticsForceSocialAccountAnalytics({requestBody:{teamId:s,platformType:U(n)}}))}),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:w.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),from:w.string().optional().describe("Start of the range used to select analytics snapshots (ISO 8601)."),to:w.string().optional().describe("End of the range used to select analytics snapshots (ISO 8601).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,from:a,to:n})=>{let i=await f(e,o),[s,m,d,p,h]=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)]),y=m.socialAccounts??[],S=[];for(let I of y){let E={id:I.id,type:I.type,username:I.username??null};if(!Z(I.type)){S.push({...E,analytics:null,note:"analytics not available for this platform"});continue}try{let C=((await e.client.analytics.analyticsGetSocialAccountAnalytics({teamId:i,platformType:I.type})).items??[]).filter(V=>st(V.createdAt,a,n));S.push({...E,latest:C[C.length-1]??null,dataPoints:C.length})}catch(A){S.push({...E,analytics:null,error:R(A)})}}return r({organization:{id:s.id,name:s.name??null},team:{id:m.id,name:m.name},range:{from:a??null,to:n??null},usage:{posts:d,comments:p,uploads:h},integrations:S})})}import{z as x}from"zod";var j=[{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:"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 Ce(){return j.map(t=>({method:t.id,platform:t.platform,description:t.description,requiredParams:t.requiredParams??[],optionalParams:t.optionalParams??[]}))}async function ve(t,e,o,a){let n=j.find(s=>s.id===o.trim().toLowerCase());if(!n)throw new u("UNKNOWN_INTEGRATION_TOOL",`Unknown integration tool "${o}". Available: ${j.map(s=>s.id).join(", ")}.`,{available:j.map(s=>s.id)});let i=(n.requiredParams??[]).filter(s=>a[s]===void 0||a[s]===null||a[s]==="");if(i.length>0)throw new u("MISSING_PARAMS",`Integration tool "${n.id}" requires: ${i.join(", ")}. Provide them in the params object.`,{method:n.id,requiredParams:n.requiredParams});return n.run(t,e,a)}var lt=x.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,"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:Ce()})),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:x.string().min(1).describe('Tool method id, e.g. "reddit:flairs", "youtube:categories", "linkedin:mentions" (call list_integration_tools first).'),params:x.record(x.string(),x.unknown()).optional().describe('Parameters for the tool as a JSON object, e.g. {"subreddit":"r/test"}.'),teamId:lt},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({method:o,params:a,teamId:n})=>{let i=await f(e,n);return r(await ve(e.client,i,o,a??{}))})}import{z as D}from"zod";function Le(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:D.number().int().positive().max(100).optional().describe("Max number of teams to return."),offset:D.number().int().nonnegative().optional().describe("Number of teams to skip (for pagination)."),search:D.string().optional().describe("Free-text search over team names.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({limit:o,offset:a,search:n})=>r(await e.client.team.teamGetList({limit:o??null,offset:a??null,search:n??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:D.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:D.string().min(1).describe("Team name."),avatarUrl:D.string().optional().describe("Optional avatar image URL."),copyTeamId:D.string().optional().describe("Optional id of an existing team to copy social accounts from.")},annotations:{openWorldHint:!0}},async({name:o,avatarUrl:a,copyTeamId:n})=>r(await e.client.team.teamCreateTeam({requestBody:{name:o,avatarUrl:a??null,copyTeamId:n??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:D.string().min(1).describe("Team id."),name:D.string().optional().describe("New team name."),avatarUrl:D.string().nullable().optional().describe("New avatar image URL, or null to clear it.")},annotations:{openWorldHint:!0}},async({id:o,name:a,avatarUrl:n})=>{let i={};if(a!==void 0&&(i.name=a),n!==void 0&&(i.avatarUrl=n),Object.keys(i).length===0)throw new u("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:D.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 H}from"zod";var dt=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 Ne(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:dt,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:a,socialAccountId:n,page:i,pageSize:s})=>{let d=o??e.defaultTeamId??await f(e,o).catch(()=>{}),[p,h,y,S]=await Promise.all([e.client.organization.organizationGetPostsUsage().catch(I=>({error:R(I)})),e.client.organization.organizationGetCommentsUsage().catch(I=>({error:R(I)})),e.client.organization.organizationGetUploadsUsage().catch(I=>({error:R(I)})),e.client.organization.organizationGetImportsUsage({page:i,pageSize:s,teamId:d,socialAccountType:a?T(a):void 0,socialAccountId:n}).catch(I=>({error:R(I)}))]);return r({posts:p,comments:h,uploads:y,imports:S})})}import{z as O}from"zod";var Ue=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 ke(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:Ue,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:a,withAnalytics:n,importCarousels:i,surface:s,mediaType:m,teamId:d})=>{let p=await f(e,d);return r(await e.client.postImport.postImportCreate({requestBody:{teamId:p,socialAccountType:T(o),count:a,...n!==void 0?{withAnalytics:n}:{},...i!==void 0?{importCarousels:i}:{},...s?{surface:s}:{},...m?{mediaType:m}:{}}}))}),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:a})=>{let n=await f(e,o);return r(await e.client.postImport.postImportGetStatus({teamId:n,socialAccountType:a?T(a):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:Ue,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:a,limit:n,offset:i})=>{let s=await f(e,a);return r(await e.client.postImport.postImportGetImportedPosts({teamId:s,socialAccountType:T(o),limit:n,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:a})=>{let n=await f(e,a);return r(await e.client.postImport.postImportDeleteImportedPosts({requestBody:{teamId:n,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:a})=>{let n=await f(e,a);return r(await e.client.postImport.postImportRetryImport({importId:o,requestBody:{teamId:n}}))})}import mt from"fs/promises";import de from"path";import{z as L}from"zod";function pt(t){return/^https?:\/\//i.test(t.trim())}async function ct(t){if(pt(t)){let a=await fetch(t.trim());if(!a.ok)throw new u("CSV_FETCH_FAILED",`Could not download the CSV from "${t}" (HTTP ${a.status}).`,{status:a.status});let n=Buffer.from(await a.arrayBuffer()),i=de.basename(new URL(t).pathname)||"import.csv";return new File([n],i,{type:"text/csv"})}let e=de.resolve(t),o;try{o=await mt.readFile(e)}catch{throw new u("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],de.basename(e),{type:"text/csv"})}function Be(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:L.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 a=await ct(o);return r(await e.client.postCsv.postCsvCreate({formData:{file:a}}))}),l(t,"list_post_csv_imports",{title:"List CSV imports",description:"List the post-CSV import history (paginated).",inputSchema:{limit:L.number().int().positive().max(100).optional(),offset:L.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({limit:o,offset:a})=>r(await e.client.postCsv.postCsvGetList({limit:o??null,offset:a??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:L.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:L.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:L.string().min(1).describe("CSV import id."),status:L.enum(["SUCCESS","FAILED"]).optional().describe("Filter rows by outcome."),limit:L.number().int().positive().max(100).optional(),offset:L.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o,status:a,limit:n,offset:i})=>r(await e.client.postCsv.postCsvGetRows({importId:o,status:a,limit:n??null,offset:i??null})))}var ut=K.version;function qe(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=[],a=(d,p,h,y={})=>o.push({name:d,status:p,message:h,...y}),n=()=>r({ok:o.every(d=>d.status!=="fail"),mcpVersion:ut,node:process.version,checks:o});a("api_key","ok","API key configured");try{let d=await e.client.app.appGetHealth();a("api_reachable","ok","API reachable",{health:d})}catch(d){return a("api_reachable","fail","Could not reach the bundle.social API",{error:R(d)}),n()}let i=[],s;try{let d=await e.client.organization.organizationGetOrganization();i=(d.teams??[]).map(p=>({id:p.id,name:p.name})),s=d.apiAccess,a("authentication","ok","API key is valid",{organizationId:d.id,organizationName:d.name??null})}catch(d){return a("authentication","fail","API key was rejected by the API",{error:R(d)}),n()}a("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 m;if(e.defaultTeamId?(m=e.defaultTeamId,a("team","ok","Using team from BUNDLESOCIAL_TEAM_ID / --team-id",{teamId:m})):i.length===1?(m=i[0].id,a("team","ok","Using the organization's only team",{teamId:m,teamName:i[0].name})):i.length===0?a("team","fail","Organization has no teams \u2014 create one in the dashboard"):a("team","warn",`Organization has ${i.length} teams; tools need a teamId argument (or set BUNDLESOCIAL_TEAM_ID)`,{teams:i}),m)try{let p=(await e.client.team.teamGetTeam({id:m})).socialAccounts??[];a("integrations",p.length>0?"ok":"warn",p.length>0?`${p.length} connected integration(s)`:"No integrations connected \u2014 connect one in the dashboard before posting",{count:p.length,platforms:p.map(h=>h.type),connectUrl:ye})}catch(d){a("integrations","fail","Could not load the team's integrations",{teamId:m,error:R(d)})}try{let d=await e.client.organization.organizationGetPostsUsage();a("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){a("posts_quota","warn","Could not read posts quota",{error:R(d)})}return n()})}import{z as Ge}from"zod";var ft=["FACEBOOK","INSTAGRAM","LINKEDIN","YOUTUBE","TIKTOK","REDDIT","THREADS","MASTODON","BLUESKY"],gt=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","REDDIT","PINTEREST","MASTODON","LINKEDIN","BLUESKY","GOOGLE_BUSINESS"];function ht(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 yt={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."}],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:"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)."}],example:{THREADS:{text:"Quick thought",mediaItems:[{uploadId:"<id>",altText:"chart"}]}}},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:"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."}],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:"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."}],example:{PINTEREST:{boardName:"Inspiration",text:"New idea",uploadIds:["<id>"],link:"https://bundle.social"}}}},It={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"]},Tt={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"},St={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)."],GOOGLE_BUSINESS:["Set the location up in the dashboard first; details/categories/hours are managed via integration helper tools."]},me=["Images: JPG / PNG / WEBP / GIF. Video: MP4 / MOV / WEBM.","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."],pe=Object.fromEntries(_.map(t=>{let e=B.includes(t),o={platform:t,label:Tt[t],aliases:It[t],capabilities:{posting:!0,comments:e,analytics:gt.includes(t),commentImports:ft.includes(t)},post:yt[t],...e?{comment:ht(t)}:{},notes:St[t]??[]};return[t,o]}));function Me(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 Fe(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:Ge.string().min(1).optional().describe('Platform name or alias (e.g. "reddit", "x", "tiktok", "gbp"). Omit to describe every platform.'),operation:Ge.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:a})=>{if(o){let n=k(o);return n?r({platform:Me(pe[n],a),mediaNotes:me}):r({error:{code:"UNKNOWN_PLATFORM",message:`Unknown platform "${o}". Supported: ${_.join(", ")} (aliases like "x" and "gbp" are accepted too).`,supportedPlatforms:_}})}return r({platforms:_.map(n=>Me(pe[n],a)),mediaNotes:me,hint:'Pass `platform` (e.g. "reddit") to focus on one platform, or `operation` ("post" | "comment") to narrow the response.'})})}function xe(t,e){Ne(t,e),Le(t,e),Se(t,e),Fe(t,e),Ae(t,e),we(t,e),Re(t,e),De(t,e),ke(t,e),Be(t,e),_e(t,e),qe(t,e)}var Y=K.version;function He(t){let e=new bt({name:"bundlesocial",version:Y},{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:Ie(t.apiKey,t.apiUrl??$),defaultTeamId:t.defaultTeamId};return xe(e,o),e}function ce(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(a=>a.startsWith(`--${t}=`));return o?o.slice(`--${t}=`.length):void 0}function ue(t){process.stderr.write(`bundlesocial-mcp: ${t}
4
+ `)}async function Ot(){if(process.argv.includes("--version")||process.argv.includes("-v")){process.stdout.write(`${Y}
5
+ `);return}if(process.argv.includes("--help")||process.argv.includes("-h")){process.stdout.write(`bundlesocial-mcp ${Y} \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 ${Y}
11
- `);return}let e=mt("api-key")??process.env.BUNDLESOCIAL_API_KEY;e||(ct(`missing API key. Set BUNDLESOCIAL_API_KEY (or pass --api-key). Create one at ${Y}`),process.exit(1));let t=Gt({apiKey:e,apiUrl:mt("api-url")??process.env.BUNDLESOCIAL_API_URL,defaultTeamId:mt("team-id")??process.env.BUNDLESOCIAL_TEAM_ID}),o=new me;await t.connect(o),ct("running on stdio");let n=()=>{t.close().finally(()=>process.exit(0))};process.on("SIGINT",n),process.on("SIGTERM",n)}ce().catch(e=>{ct(`fatal: ${e?.stack??e}`),process.exit(1)});
10
+ the flags above override them. Communicates over stdio (MCP). Create an API key at ${X}
11
+ `);return}let t=ce("api-key")??process.env.BUNDLESOCIAL_API_KEY;t||(ue(`missing API key. Set BUNDLESOCIAL_API_KEY (or pass --api-key). Create one at ${X}`),process.exit(1));let e=He({apiKey:t,apiUrl:ce("api-url")??process.env.BUNDLESOCIAL_API_URL,defaultTeamId:ce("team-id")??process.env.BUNDLESOCIAL_TEAM_ID}),o=new Et;await e.connect(o),ue("running on stdio");let a=()=>{e.close().finally(()=>process.exit(0))};process.on("SIGINT",a),process.on("SIGTERM",a)}Ot().catch(t=>{ue(`fatal: ${t?.stack??t}`),process.exit(1)});
12
12
  //# sourceMappingURL=index.js.map