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