bundlesocial-mcp 1.0.0 → 1.0.1
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 +21 -0
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [1.0.1](https://github.com/bundleglobal/bundlesocial-mcp/compare/v1.0.0...v1.0.1) (2026-05-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* build before release ([b7a6aa7](https://github.com/bundleglobal/bundlesocial-mcp/commit/b7a6aa7e74adc17ee3c3122bdaa9bfad07c727f0))
|
|
7
|
+
|
|
8
|
+
# 1.0.0 (2026-05-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* semantic release ([7a2f61e](https://github.com/bundleglobal/bundlesocial-mcp/commit/7a2f61ee298913d174836a3c4b523ced49b984b1))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* additional methods ([0aa1af1](https://github.com/bundleglobal/bundlesocial-mcp/commit/0aa1af1cf4d65af5c781630cd3baad2d121ad665))
|
|
19
|
+
* bundle.social MCP server v1 ([3ed0235](https://github.com/bundleglobal/bundlesocial-mcp/commit/3ed0235902bf2ecd288cbfaf9976c6dcdaf9f160))
|
|
20
|
+
* update comment ([c0da8ca](https://github.com/bundleglobal/bundlesocial-mcp/commit/c0da8caaa797eb6542886dff53b82b715344e204))
|
|
21
|
+
|
|
1
22
|
# Changelog
|
|
2
23
|
|
|
3
24
|
All notable changes to `bundlesocial-mcp` are documented here. This file is
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{StdioServerTransport as me}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as de}from"@modelcontextprotocol/sdk/server/mcp.js";var z={name:"bundlesocial-mcp",version:"1.0.0",mcpName:"io.github.bundleglobal/bundlesocial-mcp",description:"Model Context Protocol server for the bundle.social social-media API \u2014 post to 14+ platforms from Claude, Cursor and other MCP clients.",keywords:["bundle.social","bundlesocial","mcp","model context protocol","social media","api","agents","claude","cursor"],author:"bundle.global",license:"MIT",homepage:"https://github.com/bundleglobal/bundlesocial-mcp#readme",bugs:{url:"https://github.com/bundleglobal/bundlesocial-mcp/issues"},repository:{type:"git",url:"git+https://github.com/bundleglobal/bundlesocial-mcp.git"},type:"module",bin:{"bundlesocial-mcp":"./dist/index.js"},files:["dist/**","server.json","README.md","CHANGELOG.md","LICENSE"],engines:{node:">=20"},scripts:{build:"tsup",dev:"tsup --watch",typecheck:"tsc --noEmit",start:"node dist/index.js",test:"vitest run","test:watch":"vitest",prepublishOnly:"npm run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.12.0",bundlesocial:"^2.47.0",zod:"^3.23.8"},devDependencies:{"@types/node":"^20.14.0",tsup:"^8.2.4",typescript:"^5.5.4",vitest:"^2.0.5"}};import{Bundlesocial as qt,OpenAPI as Kt}from"bundlesocial";import{ApiError as ut}from"bundlesocial";var u=class extends Error{code;details;constructor(t,o,n){super(o),this.name="McpToolError",this.code=t,this.details=n}};function Ft(e){if(e instanceof u)return{code:e.code,message:e.message,details:e.details};if(e instanceof ut){let t=e.body,o=typeof t=="object"&&t&&typeof t.message=="string"&&t.message||typeof t=="object"&&t&&typeof t.error=="string"&&t.error||e.statusText||e.message||`HTTP ${e.status}`;return{code:`HTTP_${e.status}`,message:o,details:{status:e.status,url:e.url,body:e.body}}}return e instanceof Error?{code:"UNEXPECTED_ERROR",message:e.message||"Unexpected error",details:process.env.BUNDLESOCIAL_DEBUG?{stack:e.stack}:void 0}:{code:"UNEXPECTED_ERROR",message:String(e)}}function C(e){return e instanceof ut?`HTTP ${e.status}${e.statusText?` ${e.statusText}`:""}`:e instanceof Error?e.message:String(e)}function s(e){return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}function ft(e){return{content:[{type:"text",text:JSON.stringify({error:Ft(e)},null,2)}],isError:!0}}var x="https://api.bundle.social",Y="https://bundle.social/dashboard/organization/api-keys",gt="https://bundle.social/dashboard/general/social-accounts";function ht(e,t=x){return new qt(e,{...Kt,BASE:t})}async function f(e,t){if(t)return t;if(e.defaultTeamId)return e.defaultTeamId;let n=(await e.client.organization.organizationGetOrganization()).teams??[];if(n.length===1)return n[0].id;throw n.length===0?new u("NO_TEAMS","This organization has no teams yet. Create one in the bundle.social dashboard first."):new u("TEAM_ID_REQUIRED",`This organization has ${n.length} teams. Pass a "teamId" argument (or set BUNDLESOCIAL_TEAM_ID when starting the server).`,{teams:n.map(i=>({id:i.id,name:i.name}))})}import{z as T}from"zod";var $=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","TWITTER","THREADS","LINKEDIN","PINTEREST","REDDIT","MASTODON","DISCORD","SLACK","BLUESKY","GOOGLE_BUSINESS"],yt=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","REDDIT","PINTEREST","MASTODON","LINKEDIN","BLUESKY","GOOGLE_BUSINESS"],jt={X:"TWITTER",TWITTER:"TWITTER",TIKTOK:"TIKTOK",TT:"TIKTOK",YOUTUBE:"YOUTUBE",YT:"YOUTUBE",INSTAGRAM:"INSTAGRAM",IG:"INSTAGRAM",INSTA:"INSTAGRAM",FACEBOOK:"FACEBOOK",FB:"FACEBOOK",THREADS:"THREADS",LINKEDIN:"LINKEDIN",LI:"LINKEDIN",PINTEREST:"PINTEREST",PIN:"PINTEREST",REDDIT:"REDDIT",MASTODON:"MASTODON",MASTO:"MASTODON",DISCORD:"DISCORD",SLACK:"SLACK",BLUESKY:"BLUESKY",BSKY:"BLUESKY",GOOGLE_BUSINESS:"GOOGLE_BUSINESS","GOOGLE-BUSINESS":"GOOGLE_BUSINESS",GBP:"GOOGLE_BUSINESS",GOOGLEBUSINESS:"GOOGLE_BUSINESS",GMB:"GOOGLE_BUSINESS"};function V(e){return jt[e.trim().toUpperCase().replace(/\s+/g,"_")]}function S(e){let t=V(e);if(!t)throw new u("UNKNOWN_PLATFORM",`Unknown platform "${e}". Supported: ${$.join(", ")} (aliases like "x" and "gbp" are accepted too).`);return t}function Z(e){return yt.includes(e)}var X=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","LINKEDIN","REDDIT","MASTODON","DISCORD","SLACK","BLUESKY"];function J(e){return X.includes(e)}function U(e){let t=S(e);if(!Z(t))throw new u("ANALYTICS_NOT_SUPPORTED",`Analytics are not available for ${t}. Supported: ${yt.join(", ")}.`);return t}function l(e,t,o,n){e.registerTool(t,o,(async i=>{try{return await n(i??{})}catch(a){return ft(a)}}))}var v=T.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),L=T.string().min(1).describe("Platform name/alias (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp).");function Q(e){return(e??[]).map(t=>({id:t.id,type:t.type,username:t.username??null,displayName:t.displayName??null,avatarUrl:t.avatarUrl??null,channels:(t.channels??[]).map(o=>({id:o.id,name:o.name??null,username:o.username??null,address:o.address??null}))}))}function bt(e,t){l(e,"list_integrations",{title:"List connected integrations",description:"List the social-media integrations (accounts) connected to a bundle.social team \u2014 each with its `id`, `type` (platform), `username` and channels. Use this to discover which platforms are available and to get integration ids. Without a team id it lists every team in the organization.",inputSchema:{teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o})=>{if(o??t.defaultTeamId){let r=o??t.defaultTeamId,m=await t.client.team.teamGetTeam({id:r});return s({teamId:m.id,teamName:m.name,integrations:Q(m.socialAccounts)})}let n=await t.client.organization.organizationGetOrganization(),i=n.teams??[];if(i.length===1){let r=await t.client.team.teamGetTeam({id:i[0].id});return s({teamId:r.id,teamName:r.name,integrations:Q(r.socialAccounts)})}let a=[];for(let r of i){let m=await t.client.team.teamGetTeam({id:r.id});a.push({teamId:m.id,teamName:m.name,integrations:Q(m.socialAccounts)})}return s({organizationId:n.id,organizationName:n.name??null,teams:a})}),l(e,"connect_integration",{title:"Connect a social account",description:"Start connecting a social account to a team. Returns an OAuth `url` \u2014 open it in a browser to authorize the account; bundle.social redirects back to `redirectUrl` afterwards. For Mastodon/Bluesky pass `serverUrl`.",inputSchema:{platform:L,redirectUrl:T.string().min(1).describe("URL bundle.social redirects to after the user finishes (or cancels) the OAuth flow."),serverUrl:T.string().optional().describe("Mastodon/Bluesky instance URL (required for those platforms)."),teamId:v,options:T.record(T.string(),T.unknown()).optional().describe('Advanced provider flags, e.g. {"instagramConnectionMethod":"INSTAGRAM","withBusinessScope":true,"disableAutoLogin":true,"forceBrowserOAuth":true}.')},annotations:{openWorldHint:!0}},async({platform:o,redirectUrl:n,serverUrl:i,teamId:a,options:r})=>{let m=await f(t,a),d={type:S(o),teamId:m,redirectUrl:n,...i?{serverUrl:i}:{},...r??{}};return s(await t.client.socialAccount.socialAccountConnect({requestBody:d}))}),l(e,"disconnect_integration",{title:"Disconnect a social account",description:"Disconnect a social account of the given platform from a team. Destructive \u2014 also removes it from scheduled posts.",inputSchema:{platform:L,teamId:v},annotations:{destructiveHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountDisconnect({requestBody:{type:S(o),teamId:i}}))}),l(e,"set_integration_channel",{title:"Set a social account's channel/page",description:"Select the page/channel for a connected account (needed for FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, GOOGLE_BUSINESS). Get channel ids from list_integrations / refresh_integration_channels.",inputSchema:{platform:L,channelId:T.string().min(1).describe("Channel/page id to select."),teamId:v},annotations:{openWorldHint:!0}},async({platform:o,channelId:n,teamId:i})=>{let a=await f(t,i);return s(await t.client.socialAccount.socialAccountSetChannel({requestBody:{type:S(o),teamId:a,channelId:n}}))}),l(e,"unset_integration_channel",{title:"Clear a social account's channel/page",description:"Clear the selected page/channel for a connected account (FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, GOOGLE_BUSINESS) while keeping the authorization.",inputSchema:{platform:L,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountUnsetChannel({requestBody:{type:S(o),teamId:i}}))}),l(e,"refresh_integration_channels",{title:"Refresh a social account's channels",description:"Re-fetch the available channels for a connected account (needed for REDDIT, DISCORD, SLACK, PINTEREST and the page-based platforms).",inputSchema:{platform:L,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountRefreshChannels({requestBody:{type:S(o),teamId:i}}))}),l(e,"create_integration_portal_link",{title:"Create a connect-portal link",description:"Create a hosted bundle.social portal link a user can open to connect/manage social accounts without you implementing the OAuth flow. Returns a `url`.",inputSchema:{platforms:T.array(T.string().min(1)).min(1).describe("Platforms the portal should offer to connect (names/aliases)."),redirectUrl:T.string().optional().describe("URL to redirect to when the user finishes."),teamId:v,expiresInMinutes:T.number().int().min(5).max(2880).optional().describe("Link lifetime in minutes (5 min \u2013 48 h)."),options:T.record(T.string(),T.unknown()).optional().describe("Advanced portal options (logoUrl, userName, language, hidePoweredBy, maxSocialAccountsConnected, \u2026).")},annotations:{openWorldHint:!0}},async({platforms:o,redirectUrl:n,teamId:i,expiresInMinutes:a,options:r})=>{let d={teamId:await f(t,i),socialAccountTypes:o.map(c=>S(c)),...n?{redirectUrl:n}:{},...a?{expiresIn:a}:{},...r??{}};return s(await t.client.socialAccount.socialAccountCreatePortalLink({requestBody:d}))}),l(e,"check_integration_connection",{title:"Check a social account's connection",description:"Run an on-demand connection/disconnect health check for a connected account of the given platform.",inputSchema:{platform:L,teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountConnectionCheck({requestBody:{type:S(o),teamId:i}}))}),l(e,"refresh_integration_profile",{title:"Refresh a social account's profile",description:"Re-fetch the profile info (username, display name, avatar) for a connected account of the given platform.",inputSchema:{platform:L,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountProfileRefresh({requestBody:{type:S(o),teamId:i}}))}),l(e,"get_integration_by_type",{title:"Get a social account by platform",description:"Fetch the connected social account of a given platform for a team (including its channels).",inputSchema:{platform:L,teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountGetByType({teamId:i,type:S(o)}))}),l(e,"copy_integration",{title:"Copy social accounts between teams",description:"Copy connected social accounts of the given platforms from one team to another. Set `resetChannel` to require re-picking the page (Facebook/Instagram/LinkedIn/YouTube).",inputSchema:{fromTeamId:T.string().min(1).describe("Source team id."),toTeamId:T.string().min(1).describe("Destination team id."),platforms:T.array(T.string().min(1)).min(1).describe("Platforms to copy (names/aliases)."),resetChannel:T.boolean().optional().describe("If true, the destination must re-select the page/channel.")},annotations:{openWorldHint:!0}},async({fromTeamId:o,toTeamId:n,platforms:i,resetChannel:a})=>s(await t.client.socialAccount.socialAccountCopy({requestBody:{fromTeamId:o,toTeamId:n,...a!==void 0?{resetChannel:a}:{},socialAccountTypes:i.map(r=>S(r))}}))),l(e,"list_integrations_to_delete",{title:"List social accounts pending deletion",description:"List social accounts scheduled to be deleted (paginated) across the organization.",inputSchema:{page:T.number().int().positive().optional().describe("Page (1-based)."),pageSize:T.number().int().positive().max(100).optional().describe("Page size.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({page:o,pageSize:n})=>s(await t.client.socialAccount.socialAccountGetAccountsToDelete({page:o,pageSize:n})))}import{z as g}from"zod";import Wt from"fs/promises";import N from"path";var xt={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".tif":"image/tiff",".tiff":"image/tiff",".heic":"image/heic",".heif":"image/heif",".mp4":"video/mp4",".m4v":"video/x-m4v",".mov":"video/quicktime",".webm":"video/webm",".avi":"video/x-msvideo",".mkv":"video/x-matroska",".pdf":"application/pdf",".mp3":"audio/mpeg",".m4a":"audio/mp4",".wav":"audio/wav"};function Yt(e){return/^https?:\/\//i.test(e.trim())}var $t=90*1024*1024,Vt={".jpg":"image/jpg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".mp4":"video/mp4",".pdf":"application/pdf"};async function tt(e,t,o){if(Yt(o))return e.upload.uploadCreateFromUrl({requestBody:{teamId:t,url:o.trim()}});let n=N.resolve(o),i;try{i=await Wt.readFile(n)}catch{throw new u("MEDIA_NOT_FOUND",`Could not read media "${o}". Provide a public https:// URL, or a local file path that exists on the machine running this MCP server (stdio mode only).`,{path:n})}if(i.byteLength>$t)return Zt(e,t,n,i);let a=xt[N.extname(n).toLowerCase()]??"application/octet-stream",r=new File([i],N.basename(n),{type:a});return e.upload.uploadCreate({formData:{teamId:t,file:r}})}async function Zt(e,t,o,n){let i=N.extname(o).toLowerCase(),a=Vt[i];if(!a)throw new u("LARGE_UPLOAD_UNSUPPORTED_TYPE",`Large uploads (>90 MB) only support .jpg, .jpeg, .png, .gif, .mp4 and .pdf \u2014 got "${i||"no extension"}".`,{path:o});let r=await e.upload.uploadInitLargeUpload({requestBody:{teamId:t,fileName:N.basename(o),mimeType:a}}),m=await fetch(r.url,{method:"PUT",headers:{"content-type":a},body:new Uint8Array(n)});if(!m.ok)throw new u("LARGE_UPLOAD_FAILED",`Uploading the file to storage failed (HTTP ${m.status}).`,{status:m.status});return e.upload.uploadFinalizeLargeUpload({requestBody:{teamId:t,path:r.path}})}async function et(e,t,o){let n=[];for(let i of o){let a=await tt(e,t,i);n.push(a.id)}return n}function Xt(e,t){if(typeof e!="object"||e===null||Array.isArray(e))throw new u("INVALID_INPUT",`${t} must be a JSON object.`);return e}async function k(e,t,o){let n=new Set,i=[];for(let a of o){let r=V(a);r?n.add(r):i.push(a.trim())}if(i.length>0){let r=(await e.team.teamGetTeam({id:t})).socialAccounts??[];for(let m of i){let d=r.find(c=>c.id===m);if(!d)throw new u("INTEGRATION_NOT_FOUND",`No connected integration with id "${m}" in team ${t}. Call list_integrations to see ids, or use a platform name like "x" or "tiktok".`,{availableIntegrations:r.map(c=>({id:c.id,type:c.type,username:c.username}))});n.add(d.type)}}return[...n]}function Jt(e){let t=Object.keys(e);return t.length>0&&t.every(o=>$.includes(o.trim().toUpperCase()))}function Qt(e,t){let o=Object.fromEntries(t.map(n=>[n,{}]));if(!e)return o;if(Jt(e)){for(let[n,i]of Object.entries(e)){let a=n.trim().toUpperCase();a in o&&(o[a]={...o[a],...Xt(i,`platformSettings.${n}`)})}return o}for(let n of t)o[n]={...e};return o}function ot(e,t){if(t.data)return t.data;let o=Qt(t.platformSettings,e),n={};for(let i of e)n[i]={...t.content!==void 0?{text:t.content}:{},...t.mediaUploadIds.length>0?{uploadIds:t.mediaUploadIds}:{},...o[i]};return n}function nt(e){return Object.keys(e).map(t=>S(t))}function St(e,t){let o=(e??"").split(`
|
|
3
|
-
`).map(n=>n.trim()).find(n=>n.length>0);return o?o.length>80?`${o.slice(0,79)}\u2026`:o:t}function B(e,t){let o=new Date(e);if(Number.isNaN(o.getTime()))throw new u("INVALID_DATE",`${t} is not a valid ISO 8601 date/time: "${e}". Example: 2026-06-01T09:00:00Z`);return o.toISOString()}var F=g.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),it=g.array(g.string().min(1)).optional().describe('Target platforms \u2014 names/aliases (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp) and/or connected integration ids from list_integrations. Required unless "data" is provided with platform keys.'),at=g.array(g.string().min(1)).optional().describe("Media to attach: public https:// URLs (or local file paths when this server runs in stdio mode). Uploaded automatically and attached to every targeted platform. For per-platform media, use upload_media + the `data` argument instead."),rt=g.record(g.string(),g.unknown()).optional().describe('Per-platform options. Either keyed by platform name, e.g. {"TIKTOK":{"privacy":"PUBLIC_TO_EVERYONE"},"YOUTUBE":{"type":"SHORT","privacyStatus":"PUBLIC","madeForKids":false}}, or a flat object applied to every targeted platform. Use this for platform-required fields (Reddit `sr`, Pinterest `boardName`, TikTok `privacy`, YouTube `madeForKids`/`privacyStatus`, Instagram/Facebook `type`).'),st=g.record(g.string(),g.unknown()).optional().describe('Advanced: the full post `data` object keyed by platform, e.g. {"REDDIT":{"sr":"r/test","text":"hello","uploadIds":["<uploadId>"]}}. Overrides content/media/platformSettings. Targeted platforms are inferred from its keys unless `platforms` is also given.'),It=g.string().min(1).optional().describe("Post title. Defaults to the first line of `content`. Also used as the YouTube video title.");async function Tt(e,t){let o=await f(e,t.teamId),n;if(t.platforms&&t.platforms.length>0)n=await k(e.client,o,t.platforms);else if(t.data)n=nt(t.data);else throw new u("NO_TARGET",'Provide "platforms" (platform names or integration ids), or a "data" object keyed by platform.');if(n.length===0)throw new u("NO_TARGET","Could not determine any target platform for this post.");let i=await et(e.client,o,t.media??[]),a=ot(n,{content:t.content,mediaUploadIds:i,platformSettings:t.platformSettings,data:t.data});return{teamId:o,socialAccountTypes:n,data:a,title:t.title??St(t.content,"Untitled post")}}function wt(e,t){l(e,"create_post",{title:"Create a post (publish now)",description:"Publish a post immediately to one or more connected social-media integrations. Returns the created post (with its id and status). Set `draft: true` to save it as a draft instead of publishing. For a future-dated post use schedule_post.",inputSchema:{teamId:F,content:g.string().optional().describe("Post text, applied to every targeted platform."),platforms:it,media:at,platformSettings:rt,data:st,title:It,draft:g.boolean().optional().default(!1).describe("If true, save as a DRAFT instead of publishing now.")},annotations:{openWorldHint:!0}},async({teamId:o,content:n,platforms:i,media:a,platformSettings:r,data:m,title:d,draft:c})=>{let h=await Tt(t,{teamId:o,content:n,platforms:i,media:a,platformSettings:r,data:m,title:d}),y=await t.client.post.postCreate({requestBody:{teamId:h.teamId,title:h.title,postDate:new Date().toISOString(),status:c?"DRAFT":"SCHEDULED",socialAccountTypes:h.socialAccountTypes,data:h.data}});return s(y)}),l(e,"schedule_post",{title:"Schedule a post for later",description:"Schedule a post to be published at a specific date/time on one or more connected integrations. Same inputs as create_post plus a required ISO-8601 `date`. Returns the scheduled post.",inputSchema:{teamId:F,date:g.string().min(1).describe("When to publish \u2014 ISO 8601, e.g. 2026-06-01T09:00:00Z."),content:g.string().optional().describe("Post text, applied to every targeted platform."),platforms:it,media:at,platformSettings:rt,data:st,title:It},annotations:{openWorldHint:!0}},async({teamId:o,date:n,content:i,platforms:a,media:r,platformSettings:m,data:d,title:c})=>{let h=B(n,"date"),y=await Tt(t,{teamId:o,content:i,platforms:a,media:r,platformSettings:m,data:d,title:c}),I=await t.client.post.postCreate({requestBody:{teamId:y.teamId,title:y.title,postDate:h,status:"SCHEDULED",socialAccountTypes:y.socialAccountTypes,data:y.data}});return s(I)}),l(e,"list_posts",{title:"List recent posts",description:"List recent posts for a team, newest first, with optional filters by status, platform, date range and free-text query.",inputSchema:{teamId:F,limit:g.number().int().positive().max(100).optional().default(20).describe("Max number of posts to return (default 20, max 100)."),offset:g.number().int().nonnegative().optional().describe("Number of posts to skip (for pagination)."),status:g.enum(["DRAFT","SCHEDULED","POSTED","ERROR","DELETED","PROCESSING","REVIEW","RETRYING"]).optional().describe("Filter by post status."),platforms:g.array(g.string().min(1)).optional().describe("Filter by platform name/alias."),from:g.string().optional().describe("Only posts with postDate on/after this ISO-8601 date."),to:g.string().optional().describe("Only posts with postDate on/before this ISO-8601 date."),query:g.string().optional().describe("Free-text search over post titles/content."),order:g.enum(["ASC","DESC"]).optional().describe("Sort direction (default DESC)."),orderBy:g.enum(["createdAt","updatedAt","postDate","postedDate","deletedAt"]).optional().describe("Sort field (default postDate).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,limit:n,offset:i,status:a,platforms:r,from:m,to:d,query:c,order:h,orderBy:y})=>{let I=await f(t,o),b=(r??[]).map(S),w={teamId:I,limit:n,offset:i,status:a??void 0,platforms:b.length>0?b:void 0,postDateFrom:m?B(m,"from"):void 0,postDateTo:d?B(d,"to"):void 0,q:c,order:h??void 0,orderBy:y??void 0};return s(await t.client.post.postGetList(w))}),l(e,"get_post",{title:"Get a post by id",description:"Fetch a single post by its bundle.social id, including its per-platform data and status.",inputSchema:{id:g.string().min(1).describe("Post id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.post.postGet({id:o}))),l(e,"delete_post",{title:"Delete a post",description:"Delete a post by its bundle.social id. This is destructive and cannot be undone.",inputSchema:{id:g.string().min(1).describe("Post id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.post.postDelete({id:o}))),l(e,"update_post",{title:"Update a post",description:"Update an existing post by id \u2014 change its title, publish date, status (DRAFT/SCHEDULED), targeted platforms and/or per-platform content. Only the fields you pass are changed. If you change content/media without `platforms`, the post's current platforms are reused.",inputSchema:{id:g.string().min(1).describe("Post id."),title:g.string().optional().describe("New post title."),date:g.string().optional().describe("New publish date, ISO 8601."),status:g.enum(["DRAFT","SCHEDULED"]).optional().describe("New status."),content:g.string().optional().describe("New post text, applied to every targeted platform."),platforms:it,media:at,platformSettings:rt,data:st,teamId:F},annotations:{openWorldHint:!0}},async({id:o,title:n,date:i,status:a,content:r,platforms:m,media:d,platformSettings:c,data:h,teamId:y})=>{let I=await f(t,y),b=r!==void 0||(d?.length??0)>0||c!==void 0||h!==void 0,w;if(m&&m.length>0)w=await k(t.client,I,m);else if(h)w=nt(h);else if(b){let P=await t.client.post.postGet({id:o});if(w=Object.keys(P.data??{}),w.length===0)throw new u("NO_TARGET","Could not determine the post's platforms \u2014 pass `platforms`.")}let E={};if(n!==void 0&&(E.title=n),i&&(E.postDate=B(i,"date")),a&&(E.status=a),w&&w.length>0&&(E.socialAccountTypes=w),b&&w&&w.length>0){let P=await et(t.client,I,d??[]);E.data=ot(w,{content:r,mediaUploadIds:P,platformSettings:c,data:h})}if(Object.keys(E).length===0)throw new u("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of title, date, status, content, media, platformSettings, data, platforms.");return s(await t.client.post.postUpdate({id:o,requestBody:E}))}),l(e,"retry_post",{title:"Retry a failed post",description:"Retry publishing a post that ended in the ERROR state.",inputSchema:{id:g.string().min(1).describe("Post id.")},annotations:{openWorldHint:!0}},async({id:o})=>s(await t.client.post.postRetry({id:o})))}import{z as p}from"zod";var te=p.enum(["PENDING","FETCHING","RETRYING","COMPLETED","SKIPPED","FAILED","RATE_LIMITED"]),G=p.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function lt(e){let t=e.filter(o=>!J(o));if(t.length>0)throw new u("COMMENTS_NOT_SUPPORTED",`Comments are not available for ${t.join(", ")}. Supported: ${X.join(", ")}.`);return e}function ee(e){let t=new Date(e);if(Number.isNaN(t.getTime()))throw new u("INVALID_DATE",`date is not a valid ISO 8601 date/time: "${e}". Example: 2026-06-01T09:00:00Z`);return t.toISOString()}function At(e,t){l(e,"create_comment",{title:"Comment on a post",description:"Post one or more comments on an existing post. Pass `content` multiple times to create a chain (the first replies to the post, each subsequent one replies to the previous comment) \u2014 useful for X-style threads via comments. Comments are supported on TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, LINKEDIN, REDDIT, MASTODON, DISCORD, SLACK, BLUESKY. Returns the created comment(s).",inputSchema:{postId:p.string().min(1).describe("Id of the post to comment on."),content:p.array(p.string().min(1)).min(1).describe("Comment text. Pass multiple to create a chain of replies."),platforms:p.array(p.string().min(1)).optional().describe("Target comment-capable platform names/aliases and/or integration ids. Defaults to the post's platforms (filtered to comment-capable ones)."),date:p.string().optional().describe("When to post the (first) comment, ISO 8601. Default: now."),delayMinutes:p.number().int().nonnegative().optional().default(0).describe("For a chain, minutes to wait between each comment."),draft:p.boolean().optional().default(!1).describe("If true, create the comment(s) as DRAFT instead of posting."),teamId:G},annotations:{openWorldHint:!0}},async({postId:o,content:n,platforms:i,date:a,delayMinutes:r,draft:m,teamId:d})=>{let c=await f(t,d),h;if(i&&i.length>0)h=lt(await k(t.client,c,i));else{let E=await t.client.post.postGet({id:o});if(h=Object.keys(E.data??{}).filter(J),h.length===0)throw new u("NO_TARGET","Could not determine comment platforms from the post \u2014 pass `platforms` (comment-capable only).")}let y=m?"DRAFT":"SCHEDULED",I=a?new Date(ee(a)):new Date,b=[],w;for(let E=0;E<n.length;E+=1){let P=n[E],W=new Date(I.getTime()+E*(r??0)*6e4).toISOString(),Mt=Object.fromEntries(h.map(Ht=>[Ht,{text:P}])),pt=await t.client.comment.commentCreate({requestBody:{teamId:c,internalPostId:o,...w?{internalParentCommentId:w}:{},status:y,postDate:W,socialAccountTypes:h,data:Mt,text:P}});b.push(pt),w=pt.id}return s(b.length===1?b[0]:b)}),l(e,"list_comments",{title:"List comments",description:"List comments for a team, optionally filtered by post, status and platform.",inputSchema:{postId:p.string().optional().describe("Only comments on this post."),limit:p.number().int().positive().max(100).optional().default(20),offset:p.number().int().nonnegative().optional(),status:p.enum(["DRAFT","SCHEDULED","POSTED","ERROR","DELETED","PROCESSING","RETRYING"]).optional(),platforms:p.array(p.string().min(1)).optional().describe("Filter by comment-capable platform name/alias."),query:p.string().optional(),order:p.enum(["ASC","DESC"]).optional(),orderBy:p.enum(["createdAt","updatedAt","deletedAt"]).optional(),teamId:G},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postId:o,limit:n,offset:i,status:a,platforms:r,query:m,order:d,orderBy:c,teamId:h})=>{let y=await f(t,h),I=lt((r??[]).map(S)),b={teamId:y,postId:o,limit:n,offset:i,status:a??void 0,platforms:I.length>0?I:void 0,q:m,order:d??void 0,orderBy:c??void 0};return s(await t.client.comment.commentGetList(b))}),l(e,"get_comment",{title:"Get a comment by id",description:"Fetch a single comment by its bundle.social id.",inputSchema:{id:p.string().min(1).describe("Comment id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.comment.commentGet({id:o}))),l(e,"delete_comment",{title:"Delete a comment",description:"Delete a comment by its bundle.social id. Destructive.",inputSchema:{id:p.string().min(1).describe("Comment id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.comment.commentDelete({id:o}))),l(e,"update_comment",{title:"Update a comment",description:"Update an existing comment by id \u2014 change its title, scheduled date, status (DRAFT/SCHEDULED), targeted platforms and/or per-platform text. Only the fields you pass are changed. Use `data` for the full per-platform object, or `content` + `platforms` for a same-text-everywhere change.",inputSchema:{id:p.string().min(1).describe("Comment id."),title:p.string().optional().describe("New title."),date:p.string().optional().describe("New scheduled date, ISO 8601."),status:p.enum(["DRAFT","SCHEDULED"]).optional().describe("New status."),content:p.string().optional().describe("New comment text, applied to every platform in `platforms`."),platforms:p.array(p.string().min(1)).optional().describe("Comment-capable platform name/alias. Required when changing `content` without supplying `data`."),data:p.record(p.string(),p.unknown()).optional().describe('Advanced: the full comment `data` object keyed by platform, e.g. {"LINKEDIN":{"text":"new"}}.')},annotations:{openWorldHint:!0}},async({id:o,title:n,date:i,status:a,content:r,platforms:m,data:d})=>{let c=lt((m??[]).map(S)),h=r!==void 0||d!==void 0,y={};if(n!==void 0&&(y.title=n),i){let I=new Date(i);if(Number.isNaN(I.getTime()))throw new u("INVALID_DATE",`date is not a valid ISO 8601 date/time: "${i}". Example: 2026-06-01T09:00:00Z`);y.postDate=I.toISOString()}if(a&&(y.status=a),c.length>0&&(y.socialAccountTypes=c),h)if(d)y.data=d;else{if(c.length===0)throw new u("NO_TARGET","Pass `platforms` when changing `content` (the per-platform comment text needs to know which platforms to target).");let I=Object.fromEntries(c.map(b=>[b,{text:r}]));y.data=I}if(Object.keys(y).length===0)throw new u("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of title, date, status, content (+ platforms), data.");return s(await t.client.comment.commentUpdate({id:o,requestBody:y}))}),l(e,"create_comment_import",{title:"Import comments on a post",description:"Start an async import of the (incoming) comments on a published post for one platform. Comment imports are available on FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, TIKTOK, REDDIT, THREADS, MASTODON, BLUESKY. Poll get_comment_import / list_comment_imports for status and list_imported_comments for the fetched comments.",inputSchema:{postId:p.string().min(1).describe("Id of the published post to import comments for."),platform:p.string().min(1).describe("Platform name/alias to import comments from."),teamId:G},annotations:{openWorldHint:!0}},async({postId:o,platform:n,teamId:i})=>{let a=await f(t,i);return s(await t.client.comment.commentImportCreate({requestBody:{teamId:a,postId:o,socialAccountType:S(n)}}))}),l(e,"list_comment_imports",{title:"List comment imports",description:"List comment-import jobs for a team, optionally filtered by post and status.",inputSchema:{teamId:G,postId:p.string().optional().describe("Only imports for this post."),status:te.optional().describe("Filter by import status."),limit:p.number().int().positive().max(100).optional(),offset:p.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,postId:n,status:i,limit:a,offset:r})=>{let m=await f(t,o);return s(await t.client.comment.commentImportGetList({teamId:m,postId:n,status:i,limit:a??null,offset:r??null}))}),l(e,"get_comment_import",{title:"Get a comment import by id",description:"Fetch a single comment-import job by its id, including its status and the number of comments imported.",inputSchema:{importId:p.string().min(1).describe("Comment import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.comment.commentImportGetById({importId:o}))),l(e,"list_imported_comments",{title:"List imported comments for a post",description:"List the comments fetched by comment imports for a post, optionally filtered by platform / social account.",inputSchema:{postId:p.string().min(1).describe("Id of the post whose imported comments to list."),platform:p.string().optional().describe("Filter by platform name/alias."),socialAccountId:p.string().optional().describe("Filter by social-account id."),teamId:G,limit:p.number().int().positive().max(100).optional(),offset:p.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postId:o,platform:n,socialAccountId:i,teamId:a,limit:r,offset:m})=>{let d=await f(t,a);return s(await t.client.comment.commentImportGetFetchedComments({teamId:d,postId:o,platform:n?S(n):void 0,socialAccountId:i,limit:r??null,offset:m??null}))})}import{z as D}from"zod";var q=D.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function Et(e,t){l(e,"upload_media",{title:"Upload media",description:'Upload a media file (image, video or document) to a bundle.social team from a public https:// URL \u2014 or, when this server runs in stdio mode, a local file path. Local files larger than ~90 MB are uploaded via the large-upload flow automatically (only .jpg/.jpeg/.png/.gif/.mp4/.pdf are supported above that size). Returns the upload object; pass its `id` to create_post/schedule_post via the `data` argument (e.g. {"TWITTER":{"text":"hi","uploadIds":["<id>"]}}).',inputSchema:{teamId:q,source:D.string().min(1).describe("A public https:// URL, or a local file path (stdio mode only).")},annotations:{openWorldHint:!0}},async({teamId:o,source:n})=>{let i=await f(t,o);return s(await tt(t.client,i,n))}),l(e,"list_media",{title:"List uploaded media",description:"List media uploads for a team, optionally filtered by type (image/video/document) and usage status (USED/UNUSED).",inputSchema:{teamId:q,type:D.enum(["image","video","document"]).optional().describe("Filter by media type."),status:D.enum(["USED","UNUSED"]).optional().describe("Filter by whether the upload is attached to a post.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,type:n,status:i})=>{let a=await f(t,o);return s(await t.client.upload.uploadGetList({teamId:a,type:n??null,status:i??null}))}),l(e,"get_media",{title:"Get an upload by id",description:"Fetch a single media upload by its bundle.social id.",inputSchema:{id:D.string().min(1).describe("Upload id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.upload.uploadGet({id:o}))),l(e,"delete_media",{title:"Delete an upload",description:"Delete a media upload by its bundle.social id. Destructive.",inputSchema:{id:D.string().min(1).describe("Upload id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.upload.uploadDelete({id:o}))),l(e,"delete_media_many",{title:"Delete multiple uploads",description:"Delete several media uploads at once by their ids. Destructive.",inputSchema:{ids:D.array(D.string().min(1)).min(1).describe("Upload ids to delete.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({ids:o})=>s(await t.client.upload.uploadDeleteMany({requestBody:{ids:o}}))),l(e,"init_large_upload",{title:"Initialize a large upload",description:"Low-level: start a >90 MB upload. Returns a signed `url` (PUT the file bytes there with the matching content-type) and a `path` to pass to finalize_large_upload. Prefer `upload_media` with a local file path in stdio mode \u2014 it does this automatically.",inputSchema:{teamId:q,fileName:D.string().min(1).describe("File name."),mimeType:D.enum(["image/jpg","image/jpeg","image/png","image/gif","video/mp4","application/pdf"]).describe("File MIME type.")},annotations:{openWorldHint:!0}},async({teamId:o,fileName:n,mimeType:i})=>{let a=await f(t,o);return s(await t.client.upload.uploadInitLargeUpload({requestBody:{teamId:a,fileName:n,mimeType:i}}))}),l(e,"finalize_large_upload",{title:"Finalize a large upload",description:"Low-level: finalize a >90 MB upload after the bytes have been PUT to the signed URL from init_large_upload. Returns the upload object.",inputSchema:{teamId:q,path:D.string().min(1).describe("The `path` returned by init_large_upload.")},annotations:{openWorldHint:!0}},async({teamId:o,path:n})=>{let i=await f(t,o);return s(await t.client.upload.uploadFinalizeLargeUpload({requestBody:{teamId:i,path:n}}))})}import{z as O}from"zod";var Ot=O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function oe(e,t,o){if(!t&&!o)return!0;if(!e)return!1;let n=new Date(e).getTime();return!(Number.isNaN(n)||t&&n<new Date(t).getTime()||o&&n>new Date(o).getTime())}function Ct(e,t){l(e,"get_post_analytics",{title:"Get post analytics",description:"Get engagement metrics (impressions, views, likes, comments, \u2026) for a single post by its bundle.social id. Optionally limit to one platform. Set `raw: true` for the unprocessed provider payload.",inputSchema:{id:O.string().min(1).describe("Post id."),platform:O.string().optional().describe("Limit to a single platform name/alias (e.g. instagram, tiktok, youtube). Analytics are not available for X/Twitter, Discord or Slack."),raw:O.boolean().optional().default(!1).describe("If true, return the raw provider analytics payload instead of the normalized metrics.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o,platform:n,raw:i})=>{let a=n?U(n):void 0,r=i?await t.client.analytics.analyticsGetPostAnalyticsRaw({postId:o,platformType:a}):await t.client.analytics.analyticsGetPostAnalytics({postId:o,platformType:a});return s(r)}),l(e,"get_account_analytics",{title:"Get social-account analytics",description:"Get the analytics time-series (followers, impressions, likes, \u2026) for a connected account on the given platform. Analytics are available on TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, REDDIT, PINTEREST, MASTODON, LINKEDIN, BLUESKY, GOOGLE_BUSINESS. Set `raw: true` for the unprocessed provider payload.",inputSchema:{platform:O.string().min(1).describe("Platform name/alias."),teamId:Ot,raw:O.boolean().optional().default(!1).describe("If true, return the raw provider analytics payload.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n,raw:i})=>{let a=await f(t,n),r=U(o),m=i?await t.client.analytics.analyticsGetSocialAccountAnalyticsRaw({teamId:a,platformType:r}):await t.client.analytics.analyticsGetSocialAccountAnalytics({teamId:a,platformType:r});return s(m)}),l(e,"get_bulk_post_analytics",{title:"Get analytics for multiple posts",description:"Get analytics for up to 60 posts in one request (paginated, 20 per page) for a single platform.",inputSchema:{postIds:O.array(O.string().min(1)).min(1).max(60).describe("Post ids (max 60)."),platform:O.string().min(1).describe("Platform name/alias the posts belong to."),page:O.number().int().positive().optional().describe("Page (1-based)."),limit:O.number().int().positive().max(20).optional().describe("Page size (max 20).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postIds:o,platform:n,page:i,limit:a})=>s(await t.client.analytics.analyticsGetBulkPostAnalytics({postIds:o,platformType:U(n),page:i,limit:a}))),l(e,"refresh_analytics",{title:"Force-refresh analytics",description:"Force an immediate analytics refresh. Pass `postId` to refresh that post's analytics; otherwise pass `platform` to refresh a connected account's analytics for the team.",inputSchema:{postId:O.string().optional().describe("Post id to refresh analytics for."),importedPostId:O.string().optional().describe("Imported-post id to refresh analytics for (alternative to postId)."),platform:O.string().optional().describe("Platform name/alias to refresh a social-account's analytics for (used when postId/importedPostId are omitted)."),teamId:Ot},annotations:{openWorldHint:!0}},async({postId:o,importedPostId:n,platform:i,teamId:a})=>{if(o||n)return s(await t.client.analytics.analyticsForcePostAnalytics({requestBody:{postId:o??null,importedPostId:n??null,platformType:i?U(i):null}}));if(!i)throw new u("REFRESH_TARGET_REQUIRED","Pass either `postId`/`importedPostId` (to refresh a post) or `platform` (to refresh a social account).");let r=await f(t,a);return s(await t.client.analytics.analyticsForceSocialAccountAnalytics({requestBody:{teamId:r,platformType:U(i)}}))}),l(e,"get_analytics_summary",{title:"Get analytics summary",description:"Organization-level analytics summary: posts/comments/uploads usage quotas for the organization, plus the latest analytics snapshot (followers, impressions, likes, \u2026) for each connected integration on the team. Use `from`/`to` to select the snapshot from a date range.",inputSchema:{teamId:O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),from:O.string().optional().describe("Start of the range used to select analytics snapshots (ISO 8601)."),to:O.string().optional().describe("End of the range used to select analytics snapshots (ISO 8601).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,from:n,to:i})=>{let a=await f(t,o),[r,m,d,c,h]=await Promise.all([t.client.organization.organizationGetOrganization(),t.client.team.teamGetTeam({id:a}),t.client.organization.organizationGetPostsUsage().catch(()=>null),t.client.organization.organizationGetCommentsUsage().catch(()=>null),t.client.organization.organizationGetUploadsUsage().catch(()=>null)]),y=m.socialAccounts??[],I=[];for(let b of y){let w={id:b.id,type:b.type,username:b.username??null};if(!Z(b.type)){I.push({...w,analytics:null,note:"analytics not available for this platform"});continue}try{let P=((await t.client.analytics.analyticsGetSocialAccountAnalytics({teamId:a,platformType:b.type})).items??[]).filter(W=>oe(W.createdAt,n,i));I.push({...w,latest:P[P.length-1]??null,dataPoints:P.length})}catch(E){I.push({...w,analytics:null,error:C(E)})}}return s({organization:{id:r.id,name:r.name??null},team:{id:m.id,name:m.name},range:{from:n??null,to:i??null},usage:{posts:d,comments:c,uploads:h},integrations:I})})}import{z as M}from"zod";var K=[{id:"reddit:flairs",platform:"REDDIT",description:"List the post flairs available in a subreddit (use the returned flair id when creating a Reddit post that requires a flair).",requiredParams:["subreddit"],run:(e,t,o)=>e.misc.miscRedditGetSubredditFlairs({teamId:t,subreddit:String(o.subreddit)})},{id:"reddit:requirements",platform:"REDDIT",description:"Get a subreddit's posting requirements (title length, flair requirement, allowed post types, etc.).",requiredParams:["subreddit"],run:(e,t,o)=>e.misc.miscRedditGetPostRequirements({teamId:t,subreddit:String(o.subreddit)})},{id:"youtube:categories",platform:"YOUTUBE",description:"List YouTube video categories for a region (use the returned category id as `categoryId` when posting a YouTube video).",optionalParams:["regionCode"],run:(e,t,o)=>e.misc.miscYoutubeGetVideoCategories({teamId:t,...o.regionCode?{regionCode:String(o.regionCode)}:{}})},{id:"youtube:playlists",platform:"YOUTUBE",description:"List the connected YouTube channel's playlists (use a playlist id to add the posted video to it).",optionalParams:["maxResults"],run:(e,t,o)=>e.misc.miscYoutubeGetChannelPlaylist({teamId:t,...o.maxResults!==void 0?{maxResults:Number(o.maxResults)}:{}})},{id:"youtube:regions",platform:"YOUTUBE",description:"List YouTube content regions (i18n region codes).",run:(e,t)=>e.misc.miscYoutubeGetRegions({teamId:t})},{id:"linkedin:mentions",platform:"LINKEDIN",description:"Search LinkedIn people/organizations to mention in a post (use the returned URN in the post text).",requiredParams:["q"],optionalParams:["scope"],run:(e,t,o)=>e.misc.miscLinkedinGetTags({teamId:t,q:String(o.q),...o.scope?{scope:String(o.scope)}:{}})},{id:"instagram:locations",platform:"INSTAGRAM",description:"Search Instagram locations (use the returned location id as `locationId` when posting).",requiredParams:["q"],optionalParams:["limit"],run:(e,t,o)=>e.misc.miscInstagramSearchLocations({teamId:t,q:String(o.q),...o.limit!==void 0?{limit:Number(o.limit)}:{}})},{id:"gbp:location",platform:"GOOGLE_BUSINESS",description:"Get the connected Google Business Profile location's details.",optionalParams:["fields"],run:(e,t,o)=>e.misc.miscGoogleBusinessGetLocation({teamId:t,...Array.isArray(o.fields)?{fields:o.fields}:{}})},{id:"gbp:categories",platform:"GOOGLE_BUSINESS",description:"List Google Business Profile categories for a region/language (use a category id when updating the location).",requiredParams:["languageCode","regionCode"],optionalParams:["filter","pageSize","pageToken","view"],run:(e,t,o)=>e.misc.miscGoogleBusinessListCategories({teamId:t,languageCode:String(o.languageCode),regionCode:String(o.regionCode),...o.filter?{filter:String(o.filter)}:{},...o.pageSize!==void 0?{pageSize:Number(o.pageSize)}:{},...o.pageToken?{pageToken:String(o.pageToken)}:{},...o.view?{view:String(o.view)}:{}})},{id:"tiktok:trending-music",platform:"TIKTOK",description:"List trending tracks from TikTok's commercial music library (use a track id in the TikTok post settings).",optionalParams:["dateRange","genre"],run:(e,t,o)=>e.misc.miscTiktokGetCommercialMusicTrendingList({teamId:t,...o.dateRange?{dateRange:String(o.dateRange)}:{},...o.genre?{genre:String(o.genre)}:{}})}];function Dt(){return K.map(e=>({method:e.id,platform:e.platform,description:e.description,requiredParams:e.requiredParams??[],optionalParams:e.optionalParams??[]}))}async function _t(e,t,o,n){let i=K.find(r=>r.id===o.trim().toLowerCase());if(!i)throw new u("UNKNOWN_INTEGRATION_TOOL",`Unknown integration tool "${o}". Available: ${K.map(r=>r.id).join(", ")}.`,{available:K.map(r=>r.id)});let a=(i.requiredParams??[]).filter(r=>n[r]===void 0||n[r]===null||n[r]==="");if(a.length>0)throw new u("MISSING_PARAMS",`Integration tool "${i.id}" requires: ${a.join(", ")}. Provide them in the params object.`,{method:i.id,requiredParams:i.requiredParams});return i.run(e,t,n)}var ne=M.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function Pt(e,t){l(e,"list_integration_tools",{title:"List integration helper tools",description:"List the read-only platform helper tools callable via trigger_integration_tool \u2014 e.g. fetch subreddit flairs, YouTube categories/playlists/regions, LinkedIn mentions, Instagram locations, Google Business categories, TikTok trending music. Each entry has a `method` id and the params it accepts. Use these to discover values the API needs (flair ids, category ids, mention URNs, \u2026).",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>s({tools:Dt()})),l(e,"trigger_integration_tool",{title:"Call an integration helper tool",description:'Call one of the platform helper tools (see list_integration_tools), e.g. method "reddit:flairs" with params {"subreddit":"r/test"}. Returns the raw result.',inputSchema:{method:M.string().min(1).describe('Tool method id, e.g. "reddit:flairs", "youtube:categories", "linkedin:mentions" (call list_integration_tools first).'),params:M.record(M.string(),M.unknown()).optional().describe('Parameters for the tool as a JSON object, e.g. {"subreddit":"r/test"}.'),teamId:ne},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({method:o,params:n,teamId:i})=>{let a=await f(t,i);return s(await _t(t.client,a,o,n??{}))})}import{z as _}from"zod";function vt(e,t){l(e,"list_teams",{title:"List teams",description:"List the teams in the organization (paginated). Use this to discover team ids for the optional `teamId` argument on other tools.",inputSchema:{limit:_.number().int().positive().max(100).optional().describe("Max number of teams to return."),offset:_.number().int().nonnegative().optional().describe("Number of teams to skip (for pagination)."),search:_.string().optional().describe("Free-text search over team names.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({limit:o,offset:n,search:i})=>s(await t.client.team.teamGetList({limit:o??null,offset:n??null,search:i??null}))),l(e,"get_team",{title:"Get a team by id",description:"Fetch a single team by id, including its connected social accounts/integrations.",inputSchema:{id:_.string().min(1).describe("Team id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.team.teamGetTeam({id:o}))),l(e,"create_team",{title:"Create a team",description:"Create a new team in the organization. Optionally copy the connected social accounts from an existing team via `copyTeamId`.",inputSchema:{name:_.string().min(1).describe("Team name."),avatarUrl:_.string().optional().describe("Optional avatar image URL."),copyTeamId:_.string().optional().describe("Optional id of an existing team to copy social accounts from.")},annotations:{openWorldHint:!0}},async({name:o,avatarUrl:n,copyTeamId:i})=>s(await t.client.team.teamCreateTeam({requestBody:{name:o,avatarUrl:n??null,copyTeamId:i??null}}))),l(e,"update_team",{title:"Update a team",description:"Update a team's name and/or avatar. Only the fields you pass are changed.",inputSchema:{id:_.string().min(1).describe("Team id."),name:_.string().optional().describe("New team name."),avatarUrl:_.string().nullable().optional().describe("New avatar image URL, or null to clear it.")},annotations:{openWorldHint:!0}},async({id:o,name:n,avatarUrl:i})=>{let a={};if(n!==void 0&&(a.name=n),i!==void 0&&(a.avatarUrl=i),Object.keys(a).length===0)throw new u("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of name, avatarUrl.");return s(await t.client.team.teamUpdateTeam({id:o,requestBody:a}))}),l(e,"delete_team",{title:"Delete a team",description:"Delete a team by id. This is destructive and cannot be undone \u2014 it removes the team and its scheduled content.",inputSchema:{id:_.string().min(1).describe("Team id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.team.teamDeleteTeam({id:o})))}import{z as H}from"zod";var ie=H.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function Rt(e,t){l(e,"get_organization",{title:"Get the organization",description:"Fetch the current organization \u2014 its id, name, API-access flag, plan limits and the list of teams.",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>s(await t.client.organization.organizationGetOrganization())),l(e,"get_usage",{title:"Get usage quotas",description:"Organization usage quotas: posts, comments and uploads (used/limit/remaining), plus a paginated per-social-account breakdown of post-history import usage. Use the pagination/filter args for the imports breakdown.",inputSchema:{teamId:ie,platform:H.string().optional().describe("Filter the imports breakdown to one platform name/alias (e.g. instagram, tiktok)."),socialAccountId:H.string().optional().describe("Filter the imports breakdown to one social-account id."),page:H.number().int().positive().optional().describe("Page of the imports breakdown (1-based)."),pageSize:H.number().int().positive().max(100).optional().describe("Page size of the imports breakdown.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,platform:n,socialAccountId:i,page:a,pageSize:r})=>{let d=o??t.defaultTeamId??await f(t,o).catch(()=>{}),[c,h,y,I]=await Promise.all([t.client.organization.organizationGetPostsUsage().catch(b=>({error:C(b)})),t.client.organization.organizationGetCommentsUsage().catch(b=>({error:C(b)})),t.client.organization.organizationGetUploadsUsage().catch(b=>({error:C(b)})),t.client.organization.organizationGetImportsUsage({page:a,pageSize:r,teamId:d,socialAccountType:n?S(n):void 0,socialAccountId:i}).catch(b=>({error:C(b)}))]);return s({posts:c,comments:h,uploads:y,imports:I})})}import{z as A}from"zod";var Lt=A.string().min(1).describe("Platform name/alias. Post-history import is available on FACEBOOK, INSTAGRAM, THREADS, TIKTOK, YOUTUBE, LINKEDIN, PINTEREST, REDDIT, MASTODON, BLUESKY.");function Ut(e,t){l(e,"create_post_import",{title:"Import post history",description:"Start an async import of a connected account's recent posts (optionally with analytics) for one platform. Poll list_post_imports / get_post_import for status and list_imported_posts for the imported posts.",inputSchema:{platform:Lt,count:A.number().int().positive().describe("How many recent posts to import."),withAnalytics:A.boolean().optional().describe("Also fetch analytics for the imported posts."),importCarousels:A.boolean().optional().describe("Include carousel/album posts (Instagram)."),surface:A.enum(["PROFILE_GRID","NON_GRID","STORY","ALL"]).optional().describe("Which surface to import from (Instagram)."),mediaType:A.enum(["VIDEO","IMAGE"]).optional().describe("Restrict to one media type."),teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{openWorldHint:!0}},async({platform:o,count:n,withAnalytics:i,importCarousels:a,surface:r,mediaType:m,teamId:d})=>{let c=await f(t,d);return s(await t.client.postImport.postImportCreate({requestBody:{teamId:c,socialAccountType:S(o),count:n,...i!==void 0?{withAnalytics:i}:{},...a!==void 0?{importCarousels:a}:{},...r?{surface:r}:{},...m?{mediaType:m}:{}}}))}),l(e,"list_post_imports",{title:"List post-history imports",description:"List post-history import jobs for a team, optionally filtered by platform.",inputSchema:{teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),platform:A.string().optional().describe("Filter by platform name/alias.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,platform:n})=>{let i=await f(t,o);return s(await t.client.postImport.postImportGetStatus({teamId:i,socialAccountType:n?S(n):void 0}))}),l(e,"get_post_import",{title:"Get a post-history import by id",description:"Fetch a single post-history import job by its id, including its status and counts.",inputSchema:{importId:A.string().min(1).describe("Post import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.postImport.postImportGetById({importId:o}))),l(e,"list_imported_posts",{title:"List imported posts for a platform",description:"List the posts imported (with analytics, when available) for a connected account on the given platform.",inputSchema:{platform:Lt,teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),limit:A.number().int().positive().max(100).optional(),offset:A.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n,limit:i,offset:a})=>{let r=await f(t,n);return s(await t.client.postImport.postImportGetImportedPosts({teamId:r,socialAccountType:S(o),limit:i,offset:a??null}))}),l(e,"delete_imported_posts",{title:"Delete imported posts",description:"Bulk-delete imported posts (and their analytics) by id. Destructive.",inputSchema:{postIds:A.array(A.string().min(1)).min(1).describe("Imported-post ids to delete."),teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({postIds:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.postImport.postImportDeleteImportedPosts({requestBody:{teamId:i,postIds:o}}))}),l(e,"retry_post_import",{title:"Retry a post-history import",description:"Retry a post-history import job that ended in FAILED / RATE_LIMITED.",inputSchema:{importId:A.string().min(1).describe("Post import id."),teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{openWorldHint:!0}},async({importId:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.postImport.postImportRetryImport({importId:o,requestBody:{teamId:i}}))})}import ae from"fs/promises";import dt from"path";import{z as R}from"zod";function re(e){return/^https?:\/\//i.test(e.trim())}async function se(e){if(re(e)){let n=await fetch(e.trim());if(!n.ok)throw new u("CSV_FETCH_FAILED",`Could not download the CSV from "${e}" (HTTP ${n.status}).`,{status:n.status});let i=Buffer.from(await n.arrayBuffer()),a=dt.basename(new URL(e).pathname)||"import.csv";return new File([i],a,{type:"text/csv"})}let t=dt.resolve(e),o;try{o=await ae.readFile(t)}catch{throw new u("CSV_NOT_FOUND",`Could not read CSV "${e}". Provide a public https:// URL, or a local file path that exists on the machine running this MCP server (stdio mode only).`,{path:t})}return new File([o],dt.basename(t),{type:"text/csv"})}function Nt(e,t){l(e,"create_post_csv_import",{title:"Bulk-import posts from a CSV",description:"Upload a CSV for async bulk post import. Accepts a public https:// URL to the CSV, or a local file path when this server runs in stdio mode. Poll get_post_csv_import_status / get_post_csv_import_rows for progress and per-row results.",inputSchema:{source:R.string().min(1).describe("Public https:// URL of the CSV, or a local file path (stdio mode only).")},annotations:{openWorldHint:!0}},async({source:o})=>{let n=await se(o);return s(await t.client.postCsv.postCsvCreate({formData:{file:n}}))}),l(e,"list_post_csv_imports",{title:"List CSV imports",description:"List the post-CSV import history (paginated).",inputSchema:{limit:R.number().int().positive().max(100).optional(),offset:R.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({limit:o,offset:n})=>s(await t.client.postCsv.postCsvGetList({limit:o??null,offset:n??null}))),l(e,"get_post_csv_import",{title:"Get a CSV import by id",description:"Fetch a single post-CSV import by its id, including counts and status.",inputSchema:{importId:R.string().min(1).describe("CSV import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.postCsv.postCsvGetById({importId:o}))),l(e,"get_post_csv_import_status",{title:"Get a CSV import's processing status",description:"Fetch the processing status of a post-CSV import (rows processed/succeeded/failed).",inputSchema:{importId:R.string().min(1).describe("CSV import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.postCsv.postCsvGetStatus({importId:o}))),l(e,"get_post_csv_import_rows",{title:"Get a CSV import's row results",description:"List per-row results of a post-CSV import (the raw row, normalized payload, created post id or error), optionally filtered by SUCCESS/FAILED.",inputSchema:{importId:R.string().min(1).describe("CSV import id."),status:R.enum(["SUCCESS","FAILED"]).optional().describe("Filter rows by outcome."),limit:R.number().int().positive().max(100).optional(),offset:R.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o,status:n,limit:i,offset:a})=>s(await t.client.postCsv.postCsvGetRows({importId:o,status:n,limit:i??null,offset:a??null})))}var le=z.version;function kt(e,t){l(e,"check_setup",{title:"Check the bundle.social setup",description:"Diagnose this MCP server's setup: API key present, API reachable, API key valid, organization API access, team resolution, connected integrations and posts quota. Always returns a structured diagnostic object ({ ok, checks: [...] }).",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>{let o=[],n=(d,c,h,y={})=>o.push({name:d,status:c,message:h,...y}),i=()=>s({ok:o.every(d=>d.status!=="fail"),mcpVersion:le,node:process.version,checks:o});n("api_key","ok","API key configured");try{let d=await t.client.app.appGetHealth();n("api_reachable","ok","API reachable",{health:d})}catch(d){return n("api_reachable","fail","Could not reach the bundle.social API",{error:C(d)}),i()}let a=[],r;try{let d=await t.client.organization.organizationGetOrganization();a=(d.teams??[]).map(c=>({id:c.id,name:c.name})),r=d.apiAccess,n("authentication","ok","API key is valid",{organizationId:d.id,organizationName:d.name??null})}catch(d){return n("authentication","fail","API key was rejected by the API",{error:C(d)}),i()}n("api_access",r?"ok":"fail",r?"Organization has API access enabled":"Organization does not have API access enabled \u2014 upgrade your plan or contact bundle.social support");let m;if(t.defaultTeamId?(m=t.defaultTeamId,n("team","ok","Using team from BUNDLESOCIAL_TEAM_ID / --team-id",{teamId:m})):a.length===1?(m=a[0].id,n("team","ok","Using the organization's only team",{teamId:m,teamName:a[0].name})):a.length===0?n("team","fail","Organization has no teams \u2014 create one in the dashboard"):n("team","warn",`Organization has ${a.length} teams; tools need a teamId argument (or set BUNDLESOCIAL_TEAM_ID)`,{teams:a}),m)try{let c=(await t.client.team.teamGetTeam({id:m})).socialAccounts??[];n("integrations",c.length>0?"ok":"warn",c.length>0?`${c.length} connected integration(s)`:"No integrations connected \u2014 connect one in the dashboard before posting",{count:c.length,platforms:c.map(h=>h.type),connectUrl:gt})}catch(d){n("integrations","fail","Could not load the team's integrations",{teamId:m,error:C(d)})}try{let d=await t.client.organization.organizationGetPostsUsage();n("posts_quota",d.remaining>0?"ok":"warn",`Posts quota: ${d.used}/${d.limit} used, ${d.remaining} remaining`,{used:d.used,limit:d.limit,remaining:d.remaining})}catch(d){n("posts_quota","warn","Could not read posts quota",{error:C(d)})}return i()})}function Bt(e,t){Rt(e,t),vt(e,t),bt(e,t),wt(e,t),At(e,t),Et(e,t),Ct(e,t),Ut(e,t),Nt(e,t),Pt(e,t),kt(e,t)}var j=z.version;function Gt(e){let t=new de({name:"bundlesocial",version:j},{capabilities:{tools:{}},instructions:"Tools for the bundle.social API: posting/scheduling to 14+ social platforms, comments, media uploads, analytics, team & integration management, and bulk/history imports (post-history, comment, CSV). Run check_setup first to verify the API key, org access and team. Use list_integrations to see connected accounts and their ids. create_post / schedule_post target platforms by name (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp) or by integration id; put platform-required fields (Reddit `sr`, Pinterest `boardName`, TikTok `privacy`, YouTube `madeForKids`/`privacyStatus`) under `platformSettings` keyed by platform \u2014 per-platform fields are documented at https://docs.bundle.social/api-reference/platform-parameters. Team-scoped tools take an optional `teamId` (resolved automatically when the org has one team or BUNDLESOCIAL_TEAM_ID is set). Errors come back as { error: { code, message, details } } with isError: true."}),o={client:ht(e.apiKey,e.apiUrl??x),defaultTeamId:e.defaultTeamId};return Bt(t,o),t}function mt(e){let t=process.argv.indexOf(`--${e}`);if(t!==-1&&t+1<process.argv.length)return process.argv[t+1];let o=process.argv.find(n=>n.startsWith(`--${e}=`));return o?o.slice(`--${e}=`.length):void 0}function ct(e){process.stderr.write(`bundlesocial-mcp: ${e}
|
|
4
|
-
`)}async function
|
|
2
|
+
import{StdioServerTransport as ce}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as de}from"@modelcontextprotocol/sdk/server/mcp.js";var z={name:"bundlesocial-mcp",version:"1.0.1",mcpName:"io.github.bundleglobal/bundlesocial-mcp",description:"Model Context Protocol server for the bundle.social social-media API \u2014 post to 14+ platforms from Claude, Cursor and other MCP clients.",keywords:["bundle.social","bundlesocial","mcp","model context protocol","social media","api","agents","claude","cursor"],author:"bundle.global",license:"MIT",homepage:"https://github.com/bundleglobal/bundlesocial-mcp#readme",bugs:{url:"https://github.com/bundleglobal/bundlesocial-mcp/issues"},repository:{type:"git",url:"git+https://github.com/bundleglobal/bundlesocial-mcp.git"},type:"module",bin:{"bundlesocial-mcp":"./dist/index.js"},files:["dist/**","server.json","README.md","CHANGELOG.md","LICENSE"],engines:{node:">=20"},scripts:{build:"tsup",dev:"tsup --watch",typecheck:"tsc --noEmit",start:"node dist/index.js",test:"vitest run","test:watch":"vitest",prepublishOnly:"npm run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.12.0",bundlesocial:"^2.47.0",zod:"^3.23.8"},devDependencies:{"@semantic-release/changelog":"^6.0.3","@semantic-release/git":"^10.0.1","@types/node":"^20.14.0","semantic-release":"^25.0.2",tsup:"^8.2.4",typescript:"^5.5.4",vitest:"^2.0.5"}};import{Bundlesocial as qt,OpenAPI as Kt}from"bundlesocial";import{ApiError as ut}from"bundlesocial";var u=class extends Error{code;details;constructor(t,o,n){super(o),this.name="McpToolError",this.code=t,this.details=n}};function Ft(e){if(e instanceof u)return{code:e.code,message:e.message,details:e.details};if(e instanceof ut){let t=e.body,o=typeof t=="object"&&t&&typeof t.message=="string"&&t.message||typeof t=="object"&&t&&typeof t.error=="string"&&t.error||e.statusText||e.message||`HTTP ${e.status}`;return{code:`HTTP_${e.status}`,message:o,details:{status:e.status,url:e.url,body:e.body}}}return e instanceof Error?{code:"UNEXPECTED_ERROR",message:e.message||"Unexpected error",details:process.env.BUNDLESOCIAL_DEBUG?{stack:e.stack}:void 0}:{code:"UNEXPECTED_ERROR",message:String(e)}}function C(e){return e instanceof ut?`HTTP ${e.status}${e.statusText?` ${e.statusText}`:""}`:e instanceof Error?e.message:String(e)}function s(e){return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}function ft(e){return{content:[{type:"text",text:JSON.stringify({error:Ft(e)},null,2)}],isError:!0}}var x="https://api.bundle.social",Y="https://bundle.social/dashboard/organization/api-keys",gt="https://bundle.social/dashboard/general/social-accounts";function ht(e,t=x){return new qt(e,{...Kt,BASE:t})}async function f(e,t){if(t)return t;if(e.defaultTeamId)return e.defaultTeamId;let n=(await e.client.organization.organizationGetOrganization()).teams??[];if(n.length===1)return n[0].id;throw n.length===0?new u("NO_TEAMS","This organization has no teams yet. Create one in the bundle.social dashboard first."):new u("TEAM_ID_REQUIRED",`This organization has ${n.length} teams. Pass a "teamId" argument (or set BUNDLESOCIAL_TEAM_ID when starting the server).`,{teams:n.map(i=>({id:i.id,name:i.name}))})}import{z as T}from"zod";var $=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","TWITTER","THREADS","LINKEDIN","PINTEREST","REDDIT","MASTODON","DISCORD","SLACK","BLUESKY","GOOGLE_BUSINESS"],yt=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","REDDIT","PINTEREST","MASTODON","LINKEDIN","BLUESKY","GOOGLE_BUSINESS"],jt={X:"TWITTER",TWITTER:"TWITTER",TIKTOK:"TIKTOK",TT:"TIKTOK",YOUTUBE:"YOUTUBE",YT:"YOUTUBE",INSTAGRAM:"INSTAGRAM",IG:"INSTAGRAM",INSTA:"INSTAGRAM",FACEBOOK:"FACEBOOK",FB:"FACEBOOK",THREADS:"THREADS",LINKEDIN:"LINKEDIN",LI:"LINKEDIN",PINTEREST:"PINTEREST",PIN:"PINTEREST",REDDIT:"REDDIT",MASTODON:"MASTODON",MASTO:"MASTODON",DISCORD:"DISCORD",SLACK:"SLACK",BLUESKY:"BLUESKY",BSKY:"BLUESKY",GOOGLE_BUSINESS:"GOOGLE_BUSINESS","GOOGLE-BUSINESS":"GOOGLE_BUSINESS",GBP:"GOOGLE_BUSINESS",GOOGLEBUSINESS:"GOOGLE_BUSINESS",GMB:"GOOGLE_BUSINESS"};function V(e){return jt[e.trim().toUpperCase().replace(/\s+/g,"_")]}function S(e){let t=V(e);if(!t)throw new u("UNKNOWN_PLATFORM",`Unknown platform "${e}". Supported: ${$.join(", ")} (aliases like "x" and "gbp" are accepted too).`);return t}function Z(e){return yt.includes(e)}var X=["TIKTOK","YOUTUBE","INSTAGRAM","FACEBOOK","THREADS","LINKEDIN","REDDIT","MASTODON","DISCORD","SLACK","BLUESKY"];function J(e){return X.includes(e)}function U(e){let t=S(e);if(!Z(t))throw new u("ANALYTICS_NOT_SUPPORTED",`Analytics are not available for ${t}. Supported: ${yt.join(", ")}.`);return t}function l(e,t,o,n){e.registerTool(t,o,(async i=>{try{return await n(i??{})}catch(a){return ft(a)}}))}var v=T.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),L=T.string().min(1).describe("Platform name/alias (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp).");function Q(e){return(e??[]).map(t=>({id:t.id,type:t.type,username:t.username??null,displayName:t.displayName??null,avatarUrl:t.avatarUrl??null,channels:(t.channels??[]).map(o=>({id:o.id,name:o.name??null,username:o.username??null,address:o.address??null}))}))}function bt(e,t){l(e,"list_integrations",{title:"List connected integrations",description:"List the social-media integrations (accounts) connected to a bundle.social team \u2014 each with its `id`, `type` (platform), `username` and channels. Use this to discover which platforms are available and to get integration ids. Without a team id it lists every team in the organization.",inputSchema:{teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o})=>{if(o??t.defaultTeamId){let r=o??t.defaultTeamId,c=await t.client.team.teamGetTeam({id:r});return s({teamId:c.id,teamName:c.name,integrations:Q(c.socialAccounts)})}let n=await t.client.organization.organizationGetOrganization(),i=n.teams??[];if(i.length===1){let r=await t.client.team.teamGetTeam({id:i[0].id});return s({teamId:r.id,teamName:r.name,integrations:Q(r.socialAccounts)})}let a=[];for(let r of i){let c=await t.client.team.teamGetTeam({id:r.id});a.push({teamId:c.id,teamName:c.name,integrations:Q(c.socialAccounts)})}return s({organizationId:n.id,organizationName:n.name??null,teams:a})}),l(e,"connect_integration",{title:"Connect a social account",description:"Start connecting a social account to a team. Returns an OAuth `url` \u2014 open it in a browser to authorize the account; bundle.social redirects back to `redirectUrl` afterwards. For Mastodon/Bluesky pass `serverUrl`.",inputSchema:{platform:L,redirectUrl:T.string().min(1).describe("URL bundle.social redirects to after the user finishes (or cancels) the OAuth flow."),serverUrl:T.string().optional().describe("Mastodon/Bluesky instance URL (required for those platforms)."),teamId:v,options:T.record(T.string(),T.unknown()).optional().describe('Advanced provider flags, e.g. {"instagramConnectionMethod":"INSTAGRAM","withBusinessScope":true,"disableAutoLogin":true,"forceBrowserOAuth":true}.')},annotations:{openWorldHint:!0}},async({platform:o,redirectUrl:n,serverUrl:i,teamId:a,options:r})=>{let c=await f(t,a),d={type:S(o),teamId:c,redirectUrl:n,...i?{serverUrl:i}:{},...r??{}};return s(await t.client.socialAccount.socialAccountConnect({requestBody:d}))}),l(e,"disconnect_integration",{title:"Disconnect a social account",description:"Disconnect a social account of the given platform from a team. Destructive \u2014 also removes it from scheduled posts.",inputSchema:{platform:L,teamId:v},annotations:{destructiveHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountDisconnect({requestBody:{type:S(o),teamId:i}}))}),l(e,"set_integration_channel",{title:"Set a social account's channel/page",description:"Select the page/channel for a connected account (needed for FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, GOOGLE_BUSINESS). Get channel ids from list_integrations / refresh_integration_channels.",inputSchema:{platform:L,channelId:T.string().min(1).describe("Channel/page id to select."),teamId:v},annotations:{openWorldHint:!0}},async({platform:o,channelId:n,teamId:i})=>{let a=await f(t,i);return s(await t.client.socialAccount.socialAccountSetChannel({requestBody:{type:S(o),teamId:a,channelId:n}}))}),l(e,"unset_integration_channel",{title:"Clear a social account's channel/page",description:"Clear the selected page/channel for a connected account (FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, GOOGLE_BUSINESS) while keeping the authorization.",inputSchema:{platform:L,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountUnsetChannel({requestBody:{type:S(o),teamId:i}}))}),l(e,"refresh_integration_channels",{title:"Refresh a social account's channels",description:"Re-fetch the available channels for a connected account (needed for REDDIT, DISCORD, SLACK, PINTEREST and the page-based platforms).",inputSchema:{platform:L,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountRefreshChannels({requestBody:{type:S(o),teamId:i}}))}),l(e,"create_integration_portal_link",{title:"Create a connect-portal link",description:"Create a hosted bundle.social portal link a user can open to connect/manage social accounts without you implementing the OAuth flow. Returns a `url`.",inputSchema:{platforms:T.array(T.string().min(1)).min(1).describe("Platforms the portal should offer to connect (names/aliases)."),redirectUrl:T.string().optional().describe("URL to redirect to when the user finishes."),teamId:v,expiresInMinutes:T.number().int().min(5).max(2880).optional().describe("Link lifetime in minutes (5 min \u2013 48 h)."),options:T.record(T.string(),T.unknown()).optional().describe("Advanced portal options (logoUrl, userName, language, hidePoweredBy, maxSocialAccountsConnected, \u2026).")},annotations:{openWorldHint:!0}},async({platforms:o,redirectUrl:n,teamId:i,expiresInMinutes:a,options:r})=>{let d={teamId:await f(t,i),socialAccountTypes:o.map(m=>S(m)),...n?{redirectUrl:n}:{},...a?{expiresIn:a}:{},...r??{}};return s(await t.client.socialAccount.socialAccountCreatePortalLink({requestBody:d}))}),l(e,"check_integration_connection",{title:"Check a social account's connection",description:"Run an on-demand connection/disconnect health check for a connected account of the given platform.",inputSchema:{platform:L,teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountConnectionCheck({requestBody:{type:S(o),teamId:i}}))}),l(e,"refresh_integration_profile",{title:"Refresh a social account's profile",description:"Re-fetch the profile info (username, display name, avatar) for a connected account of the given platform.",inputSchema:{platform:L,teamId:v},annotations:{openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountProfileRefresh({requestBody:{type:S(o),teamId:i}}))}),l(e,"get_integration_by_type",{title:"Get a social account by platform",description:"Fetch the connected social account of a given platform for a team (including its channels).",inputSchema:{platform:L,teamId:v},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.socialAccount.socialAccountGetByType({teamId:i,type:S(o)}))}),l(e,"copy_integration",{title:"Copy social accounts between teams",description:"Copy connected social accounts of the given platforms from one team to another. Set `resetChannel` to require re-picking the page (Facebook/Instagram/LinkedIn/YouTube).",inputSchema:{fromTeamId:T.string().min(1).describe("Source team id."),toTeamId:T.string().min(1).describe("Destination team id."),platforms:T.array(T.string().min(1)).min(1).describe("Platforms to copy (names/aliases)."),resetChannel:T.boolean().optional().describe("If true, the destination must re-select the page/channel.")},annotations:{openWorldHint:!0}},async({fromTeamId:o,toTeamId:n,platforms:i,resetChannel:a})=>s(await t.client.socialAccount.socialAccountCopy({requestBody:{fromTeamId:o,toTeamId:n,...a!==void 0?{resetChannel:a}:{},socialAccountTypes:i.map(r=>S(r))}}))),l(e,"list_integrations_to_delete",{title:"List social accounts pending deletion",description:"List social accounts scheduled to be deleted (paginated) across the organization.",inputSchema:{page:T.number().int().positive().optional().describe("Page (1-based)."),pageSize:T.number().int().positive().max(100).optional().describe("Page size.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({page:o,pageSize:n})=>s(await t.client.socialAccount.socialAccountGetAccountsToDelete({page:o,pageSize:n})))}import{z as g}from"zod";import Wt from"fs/promises";import N from"path";var xt={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".tif":"image/tiff",".tiff":"image/tiff",".heic":"image/heic",".heif":"image/heif",".mp4":"video/mp4",".m4v":"video/x-m4v",".mov":"video/quicktime",".webm":"video/webm",".avi":"video/x-msvideo",".mkv":"video/x-matroska",".pdf":"application/pdf",".mp3":"audio/mpeg",".m4a":"audio/mp4",".wav":"audio/wav"};function Yt(e){return/^https?:\/\//i.test(e.trim())}var $t=90*1024*1024,Vt={".jpg":"image/jpg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".mp4":"video/mp4",".pdf":"application/pdf"};async function tt(e,t,o){if(Yt(o))return e.upload.uploadCreateFromUrl({requestBody:{teamId:t,url:o.trim()}});let n=N.resolve(o),i;try{i=await Wt.readFile(n)}catch{throw new u("MEDIA_NOT_FOUND",`Could not read media "${o}". Provide a public https:// URL, or a local file path that exists on the machine running this MCP server (stdio mode only).`,{path:n})}if(i.byteLength>$t)return Zt(e,t,n,i);let a=xt[N.extname(n).toLowerCase()]??"application/octet-stream",r=new File([i],N.basename(n),{type:a});return e.upload.uploadCreate({formData:{teamId:t,file:r}})}async function Zt(e,t,o,n){let i=N.extname(o).toLowerCase(),a=Vt[i];if(!a)throw new u("LARGE_UPLOAD_UNSUPPORTED_TYPE",`Large uploads (>90 MB) only support .jpg, .jpeg, .png, .gif, .mp4 and .pdf \u2014 got "${i||"no extension"}".`,{path:o});let r=await e.upload.uploadInitLargeUpload({requestBody:{teamId:t,fileName:N.basename(o),mimeType:a}}),c=await fetch(r.url,{method:"PUT",headers:{"content-type":a},body:new Uint8Array(n)});if(!c.ok)throw new u("LARGE_UPLOAD_FAILED",`Uploading the file to storage failed (HTTP ${c.status}).`,{status:c.status});return e.upload.uploadFinalizeLargeUpload({requestBody:{teamId:t,path:r.path}})}async function et(e,t,o){let n=[];for(let i of o){let a=await tt(e,t,i);n.push(a.id)}return n}function Xt(e,t){if(typeof e!="object"||e===null||Array.isArray(e))throw new u("INVALID_INPUT",`${t} must be a JSON object.`);return e}async function k(e,t,o){let n=new Set,i=[];for(let a of o){let r=V(a);r?n.add(r):i.push(a.trim())}if(i.length>0){let r=(await e.team.teamGetTeam({id:t})).socialAccounts??[];for(let c of i){let d=r.find(m=>m.id===c);if(!d)throw new u("INTEGRATION_NOT_FOUND",`No connected integration with id "${c}" in team ${t}. Call list_integrations to see ids, or use a platform name like "x" or "tiktok".`,{availableIntegrations:r.map(m=>({id:m.id,type:m.type,username:m.username}))});n.add(d.type)}}return[...n]}function Jt(e){let t=Object.keys(e);return t.length>0&&t.every(o=>$.includes(o.trim().toUpperCase()))}function Qt(e,t){let o=Object.fromEntries(t.map(n=>[n,{}]));if(!e)return o;if(Jt(e)){for(let[n,i]of Object.entries(e)){let a=n.trim().toUpperCase();a in o&&(o[a]={...o[a],...Xt(i,`platformSettings.${n}`)})}return o}for(let n of t)o[n]={...e};return o}function ot(e,t){if(t.data)return t.data;let o=Qt(t.platformSettings,e),n={};for(let i of e)n[i]={...t.content!==void 0?{text:t.content}:{},...t.mediaUploadIds.length>0?{uploadIds:t.mediaUploadIds}:{},...o[i]};return n}function nt(e){return Object.keys(e).map(t=>S(t))}function St(e,t){let o=(e??"").split(`
|
|
3
|
+
`).map(n=>n.trim()).find(n=>n.length>0);return o?o.length>80?`${o.slice(0,79)}\u2026`:o:t}function B(e,t){let o=new Date(e);if(Number.isNaN(o.getTime()))throw new u("INVALID_DATE",`${t} is not a valid ISO 8601 date/time: "${e}". Example: 2026-06-01T09:00:00Z`);return o.toISOString()}var F=g.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),it=g.array(g.string().min(1)).optional().describe('Target platforms \u2014 names/aliases (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp) and/or connected integration ids from list_integrations. Required unless "data" is provided with platform keys.'),at=g.array(g.string().min(1)).optional().describe("Media to attach: public https:// URLs (or local file paths when this server runs in stdio mode). Uploaded automatically and attached to every targeted platform. For per-platform media, use upload_media + the `data` argument instead."),rt=g.record(g.string(),g.unknown()).optional().describe('Per-platform options. Either keyed by platform name, e.g. {"TIKTOK":{"privacy":"PUBLIC_TO_EVERYONE"},"YOUTUBE":{"type":"SHORT","privacyStatus":"PUBLIC","madeForKids":false}}, or a flat object applied to every targeted platform. Use this for platform-required fields (Reddit `sr`, Pinterest `boardName`, TikTok `privacy`, YouTube `madeForKids`/`privacyStatus`, Instagram/Facebook `type`).'),st=g.record(g.string(),g.unknown()).optional().describe('Advanced: the full post `data` object keyed by platform, e.g. {"REDDIT":{"sr":"r/test","text":"hello","uploadIds":["<uploadId>"]}}. Overrides content/media/platformSettings. Targeted platforms are inferred from its keys unless `platforms` is also given.'),It=g.string().min(1).optional().describe("Post title. Defaults to the first line of `content`. Also used as the YouTube video title.");async function Tt(e,t){let o=await f(e,t.teamId),n;if(t.platforms&&t.platforms.length>0)n=await k(e.client,o,t.platforms);else if(t.data)n=nt(t.data);else throw new u("NO_TARGET",'Provide "platforms" (platform names or integration ids), or a "data" object keyed by platform.');if(n.length===0)throw new u("NO_TARGET","Could not determine any target platform for this post.");let i=await et(e.client,o,t.media??[]),a=ot(n,{content:t.content,mediaUploadIds:i,platformSettings:t.platformSettings,data:t.data});return{teamId:o,socialAccountTypes:n,data:a,title:t.title??St(t.content,"Untitled post")}}function wt(e,t){l(e,"create_post",{title:"Create a post (publish now)",description:"Publish a post immediately to one or more connected social-media integrations. Returns the created post (with its id and status). Set `draft: true` to save it as a draft instead of publishing. For a future-dated post use schedule_post.",inputSchema:{teamId:F,content:g.string().optional().describe("Post text, applied to every targeted platform."),platforms:it,media:at,platformSettings:rt,data:st,title:It,draft:g.boolean().optional().default(!1).describe("If true, save as a DRAFT instead of publishing now.")},annotations:{openWorldHint:!0}},async({teamId:o,content:n,platforms:i,media:a,platformSettings:r,data:c,title:d,draft:m})=>{let h=await Tt(t,{teamId:o,content:n,platforms:i,media:a,platformSettings:r,data:c,title:d}),y=await t.client.post.postCreate({requestBody:{teamId:h.teamId,title:h.title,postDate:new Date().toISOString(),status:m?"DRAFT":"SCHEDULED",socialAccountTypes:h.socialAccountTypes,data:h.data}});return s(y)}),l(e,"schedule_post",{title:"Schedule a post for later",description:"Schedule a post to be published at a specific date/time on one or more connected integrations. Same inputs as create_post plus a required ISO-8601 `date`. Returns the scheduled post.",inputSchema:{teamId:F,date:g.string().min(1).describe("When to publish \u2014 ISO 8601, e.g. 2026-06-01T09:00:00Z."),content:g.string().optional().describe("Post text, applied to every targeted platform."),platforms:it,media:at,platformSettings:rt,data:st,title:It},annotations:{openWorldHint:!0}},async({teamId:o,date:n,content:i,platforms:a,media:r,platformSettings:c,data:d,title:m})=>{let h=B(n,"date"),y=await Tt(t,{teamId:o,content:i,platforms:a,media:r,platformSettings:c,data:d,title:m}),I=await t.client.post.postCreate({requestBody:{teamId:y.teamId,title:y.title,postDate:h,status:"SCHEDULED",socialAccountTypes:y.socialAccountTypes,data:y.data}});return s(I)}),l(e,"list_posts",{title:"List recent posts",description:"List recent posts for a team, newest first, with optional filters by status, platform, date range and free-text query.",inputSchema:{teamId:F,limit:g.number().int().positive().max(100).optional().default(20).describe("Max number of posts to return (default 20, max 100)."),offset:g.number().int().nonnegative().optional().describe("Number of posts to skip (for pagination)."),status:g.enum(["DRAFT","SCHEDULED","POSTED","ERROR","DELETED","PROCESSING","REVIEW","RETRYING"]).optional().describe("Filter by post status."),platforms:g.array(g.string().min(1)).optional().describe("Filter by platform name/alias."),from:g.string().optional().describe("Only posts with postDate on/after this ISO-8601 date."),to:g.string().optional().describe("Only posts with postDate on/before this ISO-8601 date."),query:g.string().optional().describe("Free-text search over post titles/content."),order:g.enum(["ASC","DESC"]).optional().describe("Sort direction (default DESC)."),orderBy:g.enum(["createdAt","updatedAt","postDate","postedDate","deletedAt"]).optional().describe("Sort field (default postDate).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,limit:n,offset:i,status:a,platforms:r,from:c,to:d,query:m,order:h,orderBy:y})=>{let I=await f(t,o),b=(r??[]).map(S),w={teamId:I,limit:n,offset:i,status:a??void 0,platforms:b.length>0?b:void 0,postDateFrom:c?B(c,"from"):void 0,postDateTo:d?B(d,"to"):void 0,q:m,order:h??void 0,orderBy:y??void 0};return s(await t.client.post.postGetList(w))}),l(e,"get_post",{title:"Get a post by id",description:"Fetch a single post by its bundle.social id, including its per-platform data and status.",inputSchema:{id:g.string().min(1).describe("Post id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.post.postGet({id:o}))),l(e,"delete_post",{title:"Delete a post",description:"Delete a post by its bundle.social id. This is destructive and cannot be undone.",inputSchema:{id:g.string().min(1).describe("Post id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.post.postDelete({id:o}))),l(e,"update_post",{title:"Update a post",description:"Update an existing post by id \u2014 change its title, publish date, status (DRAFT/SCHEDULED), targeted platforms and/or per-platform content. Only the fields you pass are changed. If you change content/media without `platforms`, the post's current platforms are reused.",inputSchema:{id:g.string().min(1).describe("Post id."),title:g.string().optional().describe("New post title."),date:g.string().optional().describe("New publish date, ISO 8601."),status:g.enum(["DRAFT","SCHEDULED"]).optional().describe("New status."),content:g.string().optional().describe("New post text, applied to every targeted platform."),platforms:it,media:at,platformSettings:rt,data:st,teamId:F},annotations:{openWorldHint:!0}},async({id:o,title:n,date:i,status:a,content:r,platforms:c,media:d,platformSettings:m,data:h,teamId:y})=>{let I=await f(t,y),b=r!==void 0||(d?.length??0)>0||m!==void 0||h!==void 0,w;if(c&&c.length>0)w=await k(t.client,I,c);else if(h)w=nt(h);else if(b){let P=await t.client.post.postGet({id:o});if(w=Object.keys(P.data??{}),w.length===0)throw new u("NO_TARGET","Could not determine the post's platforms \u2014 pass `platforms`.")}let E={};if(n!==void 0&&(E.title=n),i&&(E.postDate=B(i,"date")),a&&(E.status=a),w&&w.length>0&&(E.socialAccountTypes=w),b&&w&&w.length>0){let P=await et(t.client,I,d??[]);E.data=ot(w,{content:r,mediaUploadIds:P,platformSettings:m,data:h})}if(Object.keys(E).length===0)throw new u("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of title, date, status, content, media, platformSettings, data, platforms.");return s(await t.client.post.postUpdate({id:o,requestBody:E}))}),l(e,"retry_post",{title:"Retry a failed post",description:"Retry publishing a post that ended in the ERROR state.",inputSchema:{id:g.string().min(1).describe("Post id.")},annotations:{openWorldHint:!0}},async({id:o})=>s(await t.client.post.postRetry({id:o})))}import{z as p}from"zod";var te=p.enum(["PENDING","FETCHING","RETRYING","COMPLETED","SKIPPED","FAILED","RATE_LIMITED"]),G=p.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function lt(e){let t=e.filter(o=>!J(o));if(t.length>0)throw new u("COMMENTS_NOT_SUPPORTED",`Comments are not available for ${t.join(", ")}. Supported: ${X.join(", ")}.`);return e}function ee(e){let t=new Date(e);if(Number.isNaN(t.getTime()))throw new u("INVALID_DATE",`date is not a valid ISO 8601 date/time: "${e}". Example: 2026-06-01T09:00:00Z`);return t.toISOString()}function At(e,t){l(e,"create_comment",{title:"Comment on a post",description:"Post one or more comments on an existing post. Pass `content` multiple times to create a chain (the first replies to the post, each subsequent one replies to the previous comment) \u2014 useful for X-style threads via comments. Comments are supported on TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, LINKEDIN, REDDIT, MASTODON, DISCORD, SLACK, BLUESKY. Returns the created comment(s).",inputSchema:{postId:p.string().min(1).describe("Id of the post to comment on."),content:p.array(p.string().min(1)).min(1).describe("Comment text. Pass multiple to create a chain of replies."),platforms:p.array(p.string().min(1)).optional().describe("Target comment-capable platform names/aliases and/or integration ids. Defaults to the post's platforms (filtered to comment-capable ones)."),date:p.string().optional().describe("When to post the (first) comment, ISO 8601. Default: now."),delayMinutes:p.number().int().nonnegative().optional().default(0).describe("For a chain, minutes to wait between each comment."),draft:p.boolean().optional().default(!1).describe("If true, create the comment(s) as DRAFT instead of posting."),teamId:G},annotations:{openWorldHint:!0}},async({postId:o,content:n,platforms:i,date:a,delayMinutes:r,draft:c,teamId:d})=>{let m=await f(t,d),h;if(i&&i.length>0)h=lt(await k(t.client,m,i));else{let E=await t.client.post.postGet({id:o});if(h=Object.keys(E.data??{}).filter(J),h.length===0)throw new u("NO_TARGET","Could not determine comment platforms from the post \u2014 pass `platforms` (comment-capable only).")}let y=c?"DRAFT":"SCHEDULED",I=a?new Date(ee(a)):new Date,b=[],w;for(let E=0;E<n.length;E+=1){let P=n[E],W=new Date(I.getTime()+E*(r??0)*6e4).toISOString(),Mt=Object.fromEntries(h.map(Ht=>[Ht,{text:P}])),pt=await t.client.comment.commentCreate({requestBody:{teamId:m,internalPostId:o,...w?{internalParentCommentId:w}:{},status:y,postDate:W,socialAccountTypes:h,data:Mt,text:P}});b.push(pt),w=pt.id}return s(b.length===1?b[0]:b)}),l(e,"list_comments",{title:"List comments",description:"List comments for a team, optionally filtered by post, status and platform.",inputSchema:{postId:p.string().optional().describe("Only comments on this post."),limit:p.number().int().positive().max(100).optional().default(20),offset:p.number().int().nonnegative().optional(),status:p.enum(["DRAFT","SCHEDULED","POSTED","ERROR","DELETED","PROCESSING","RETRYING"]).optional(),platforms:p.array(p.string().min(1)).optional().describe("Filter by comment-capable platform name/alias."),query:p.string().optional(),order:p.enum(["ASC","DESC"]).optional(),orderBy:p.enum(["createdAt","updatedAt","deletedAt"]).optional(),teamId:G},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postId:o,limit:n,offset:i,status:a,platforms:r,query:c,order:d,orderBy:m,teamId:h})=>{let y=await f(t,h),I=lt((r??[]).map(S)),b={teamId:y,postId:o,limit:n,offset:i,status:a??void 0,platforms:I.length>0?I:void 0,q:c,order:d??void 0,orderBy:m??void 0};return s(await t.client.comment.commentGetList(b))}),l(e,"get_comment",{title:"Get a comment by id",description:"Fetch a single comment by its bundle.social id.",inputSchema:{id:p.string().min(1).describe("Comment id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.comment.commentGet({id:o}))),l(e,"delete_comment",{title:"Delete a comment",description:"Delete a comment by its bundle.social id. Destructive.",inputSchema:{id:p.string().min(1).describe("Comment id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.comment.commentDelete({id:o}))),l(e,"update_comment",{title:"Update a comment",description:"Update an existing comment by id \u2014 change its title, scheduled date, status (DRAFT/SCHEDULED), targeted platforms and/or per-platform text. Only the fields you pass are changed. Use `data` for the full per-platform object, or `content` + `platforms` for a same-text-everywhere change.",inputSchema:{id:p.string().min(1).describe("Comment id."),title:p.string().optional().describe("New title."),date:p.string().optional().describe("New scheduled date, ISO 8601."),status:p.enum(["DRAFT","SCHEDULED"]).optional().describe("New status."),content:p.string().optional().describe("New comment text, applied to every platform in `platforms`."),platforms:p.array(p.string().min(1)).optional().describe("Comment-capable platform name/alias. Required when changing `content` without supplying `data`."),data:p.record(p.string(),p.unknown()).optional().describe('Advanced: the full comment `data` object keyed by platform, e.g. {"LINKEDIN":{"text":"new"}}.')},annotations:{openWorldHint:!0}},async({id:o,title:n,date:i,status:a,content:r,platforms:c,data:d})=>{let m=lt((c??[]).map(S)),h=r!==void 0||d!==void 0,y={};if(n!==void 0&&(y.title=n),i){let I=new Date(i);if(Number.isNaN(I.getTime()))throw new u("INVALID_DATE",`date is not a valid ISO 8601 date/time: "${i}". Example: 2026-06-01T09:00:00Z`);y.postDate=I.toISOString()}if(a&&(y.status=a),m.length>0&&(y.socialAccountTypes=m),h)if(d)y.data=d;else{if(m.length===0)throw new u("NO_TARGET","Pass `platforms` when changing `content` (the per-platform comment text needs to know which platforms to target).");let I=Object.fromEntries(m.map(b=>[b,{text:r}]));y.data=I}if(Object.keys(y).length===0)throw new u("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of title, date, status, content (+ platforms), data.");return s(await t.client.comment.commentUpdate({id:o,requestBody:y}))}),l(e,"create_comment_import",{title:"Import comments on a post",description:"Start an async import of the (incoming) comments on a published post for one platform. Comment imports are available on FACEBOOK, INSTAGRAM, LINKEDIN, YOUTUBE, TIKTOK, REDDIT, THREADS, MASTODON, BLUESKY. Poll get_comment_import / list_comment_imports for status and list_imported_comments for the fetched comments.",inputSchema:{postId:p.string().min(1).describe("Id of the published post to import comments for."),platform:p.string().min(1).describe("Platform name/alias to import comments from."),teamId:G},annotations:{openWorldHint:!0}},async({postId:o,platform:n,teamId:i})=>{let a=await f(t,i);return s(await t.client.comment.commentImportCreate({requestBody:{teamId:a,postId:o,socialAccountType:S(n)}}))}),l(e,"list_comment_imports",{title:"List comment imports",description:"List comment-import jobs for a team, optionally filtered by post and status.",inputSchema:{teamId:G,postId:p.string().optional().describe("Only imports for this post."),status:te.optional().describe("Filter by import status."),limit:p.number().int().positive().max(100).optional(),offset:p.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,postId:n,status:i,limit:a,offset:r})=>{let c=await f(t,o);return s(await t.client.comment.commentImportGetList({teamId:c,postId:n,status:i,limit:a??null,offset:r??null}))}),l(e,"get_comment_import",{title:"Get a comment import by id",description:"Fetch a single comment-import job by its id, including its status and the number of comments imported.",inputSchema:{importId:p.string().min(1).describe("Comment import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.comment.commentImportGetById({importId:o}))),l(e,"list_imported_comments",{title:"List imported comments for a post",description:"List the comments fetched by comment imports for a post, optionally filtered by platform / social account.",inputSchema:{postId:p.string().min(1).describe("Id of the post whose imported comments to list."),platform:p.string().optional().describe("Filter by platform name/alias."),socialAccountId:p.string().optional().describe("Filter by social-account id."),teamId:G,limit:p.number().int().positive().max(100).optional(),offset:p.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postId:o,platform:n,socialAccountId:i,teamId:a,limit:r,offset:c})=>{let d=await f(t,a);return s(await t.client.comment.commentImportGetFetchedComments({teamId:d,postId:o,platform:n?S(n):void 0,socialAccountId:i,limit:r??null,offset:c??null}))})}import{z as D}from"zod";var q=D.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function Et(e,t){l(e,"upload_media",{title:"Upload media",description:'Upload a media file (image, video or document) to a bundle.social team from a public https:// URL \u2014 or, when this server runs in stdio mode, a local file path. Local files larger than ~90 MB are uploaded via the large-upload flow automatically (only .jpg/.jpeg/.png/.gif/.mp4/.pdf are supported above that size). Returns the upload object; pass its `id` to create_post/schedule_post via the `data` argument (e.g. {"TWITTER":{"text":"hi","uploadIds":["<id>"]}}).',inputSchema:{teamId:q,source:D.string().min(1).describe("A public https:// URL, or a local file path (stdio mode only).")},annotations:{openWorldHint:!0}},async({teamId:o,source:n})=>{let i=await f(t,o);return s(await tt(t.client,i,n))}),l(e,"list_media",{title:"List uploaded media",description:"List media uploads for a team, optionally filtered by type (image/video/document) and usage status (USED/UNUSED).",inputSchema:{teamId:q,type:D.enum(["image","video","document"]).optional().describe("Filter by media type."),status:D.enum(["USED","UNUSED"]).optional().describe("Filter by whether the upload is attached to a post.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,type:n,status:i})=>{let a=await f(t,o);return s(await t.client.upload.uploadGetList({teamId:a,type:n??null,status:i??null}))}),l(e,"get_media",{title:"Get an upload by id",description:"Fetch a single media upload by its bundle.social id.",inputSchema:{id:D.string().min(1).describe("Upload id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.upload.uploadGet({id:o}))),l(e,"delete_media",{title:"Delete an upload",description:"Delete a media upload by its bundle.social id. Destructive.",inputSchema:{id:D.string().min(1).describe("Upload id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.upload.uploadDelete({id:o}))),l(e,"delete_media_many",{title:"Delete multiple uploads",description:"Delete several media uploads at once by their ids. Destructive.",inputSchema:{ids:D.array(D.string().min(1)).min(1).describe("Upload ids to delete.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({ids:o})=>s(await t.client.upload.uploadDeleteMany({requestBody:{ids:o}}))),l(e,"init_large_upload",{title:"Initialize a large upload",description:"Low-level: start a >90 MB upload. Returns a signed `url` (PUT the file bytes there with the matching content-type) and a `path` to pass to finalize_large_upload. Prefer `upload_media` with a local file path in stdio mode \u2014 it does this automatically.",inputSchema:{teamId:q,fileName:D.string().min(1).describe("File name."),mimeType:D.enum(["image/jpg","image/jpeg","image/png","image/gif","video/mp4","application/pdf"]).describe("File MIME type.")},annotations:{openWorldHint:!0}},async({teamId:o,fileName:n,mimeType:i})=>{let a=await f(t,o);return s(await t.client.upload.uploadInitLargeUpload({requestBody:{teamId:a,fileName:n,mimeType:i}}))}),l(e,"finalize_large_upload",{title:"Finalize a large upload",description:"Low-level: finalize a >90 MB upload after the bytes have been PUT to the signed URL from init_large_upload. Returns the upload object.",inputSchema:{teamId:q,path:D.string().min(1).describe("The `path` returned by init_large_upload.")},annotations:{openWorldHint:!0}},async({teamId:o,path:n})=>{let i=await f(t,o);return s(await t.client.upload.uploadFinalizeLargeUpload({requestBody:{teamId:i,path:n}}))})}import{z as O}from"zod";var Ot=O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function oe(e,t,o){if(!t&&!o)return!0;if(!e)return!1;let n=new Date(e).getTime();return!(Number.isNaN(n)||t&&n<new Date(t).getTime()||o&&n>new Date(o).getTime())}function Ct(e,t){l(e,"get_post_analytics",{title:"Get post analytics",description:"Get engagement metrics (impressions, views, likes, comments, \u2026) for a single post by its bundle.social id. Optionally limit to one platform. Set `raw: true` for the unprocessed provider payload.",inputSchema:{id:O.string().min(1).describe("Post id."),platform:O.string().optional().describe("Limit to a single platform name/alias (e.g. instagram, tiktok, youtube). Analytics are not available for X/Twitter, Discord or Slack."),raw:O.boolean().optional().default(!1).describe("If true, return the raw provider analytics payload instead of the normalized metrics.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o,platform:n,raw:i})=>{let a=n?U(n):void 0,r=i?await t.client.analytics.analyticsGetPostAnalyticsRaw({postId:o,platformType:a}):await t.client.analytics.analyticsGetPostAnalytics({postId:o,platformType:a});return s(r)}),l(e,"get_account_analytics",{title:"Get social-account analytics",description:"Get the analytics time-series (followers, impressions, likes, \u2026) for a connected account on the given platform. Analytics are available on TIKTOK, YOUTUBE, INSTAGRAM, FACEBOOK, THREADS, REDDIT, PINTEREST, MASTODON, LINKEDIN, BLUESKY, GOOGLE_BUSINESS. Set `raw: true` for the unprocessed provider payload.",inputSchema:{platform:O.string().min(1).describe("Platform name/alias."),teamId:Ot,raw:O.boolean().optional().default(!1).describe("If true, return the raw provider analytics payload.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n,raw:i})=>{let a=await f(t,n),r=U(o),c=i?await t.client.analytics.analyticsGetSocialAccountAnalyticsRaw({teamId:a,platformType:r}):await t.client.analytics.analyticsGetSocialAccountAnalytics({teamId:a,platformType:r});return s(c)}),l(e,"get_bulk_post_analytics",{title:"Get analytics for multiple posts",description:"Get analytics for up to 60 posts in one request (paginated, 20 per page) for a single platform.",inputSchema:{postIds:O.array(O.string().min(1)).min(1).max(60).describe("Post ids (max 60)."),platform:O.string().min(1).describe("Platform name/alias the posts belong to."),page:O.number().int().positive().optional().describe("Page (1-based)."),limit:O.number().int().positive().max(20).optional().describe("Page size (max 20).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({postIds:o,platform:n,page:i,limit:a})=>s(await t.client.analytics.analyticsGetBulkPostAnalytics({postIds:o,platformType:U(n),page:i,limit:a}))),l(e,"refresh_analytics",{title:"Force-refresh analytics",description:"Force an immediate analytics refresh. Pass `postId` to refresh that post's analytics; otherwise pass `platform` to refresh a connected account's analytics for the team.",inputSchema:{postId:O.string().optional().describe("Post id to refresh analytics for."),importedPostId:O.string().optional().describe("Imported-post id to refresh analytics for (alternative to postId)."),platform:O.string().optional().describe("Platform name/alias to refresh a social-account's analytics for (used when postId/importedPostId are omitted)."),teamId:Ot},annotations:{openWorldHint:!0}},async({postId:o,importedPostId:n,platform:i,teamId:a})=>{if(o||n)return s(await t.client.analytics.analyticsForcePostAnalytics({requestBody:{postId:o??null,importedPostId:n??null,platformType:i?U(i):null}}));if(!i)throw new u("REFRESH_TARGET_REQUIRED","Pass either `postId`/`importedPostId` (to refresh a post) or `platform` (to refresh a social account).");let r=await f(t,a);return s(await t.client.analytics.analyticsForceSocialAccountAnalytics({requestBody:{teamId:r,platformType:U(i)}}))}),l(e,"get_analytics_summary",{title:"Get analytics summary",description:"Organization-level analytics summary: posts/comments/uploads usage quotas for the organization, plus the latest analytics snapshot (followers, impressions, likes, \u2026) for each connected integration on the team. Use `from`/`to` to select the snapshot from a date range.",inputSchema:{teamId:O.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),from:O.string().optional().describe("Start of the range used to select analytics snapshots (ISO 8601)."),to:O.string().optional().describe("End of the range used to select analytics snapshots (ISO 8601).")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,from:n,to:i})=>{let a=await f(t,o),[r,c,d,m,h]=await Promise.all([t.client.organization.organizationGetOrganization(),t.client.team.teamGetTeam({id:a}),t.client.organization.organizationGetPostsUsage().catch(()=>null),t.client.organization.organizationGetCommentsUsage().catch(()=>null),t.client.organization.organizationGetUploadsUsage().catch(()=>null)]),y=c.socialAccounts??[],I=[];for(let b of y){let w={id:b.id,type:b.type,username:b.username??null};if(!Z(b.type)){I.push({...w,analytics:null,note:"analytics not available for this platform"});continue}try{let P=((await t.client.analytics.analyticsGetSocialAccountAnalytics({teamId:a,platformType:b.type})).items??[]).filter(W=>oe(W.createdAt,n,i));I.push({...w,latest:P[P.length-1]??null,dataPoints:P.length})}catch(E){I.push({...w,analytics:null,error:C(E)})}}return s({organization:{id:r.id,name:r.name??null},team:{id:c.id,name:c.name},range:{from:n??null,to:i??null},usage:{posts:d,comments:m,uploads:h},integrations:I})})}import{z as M}from"zod";var K=[{id:"reddit:flairs",platform:"REDDIT",description:"List the post flairs available in a subreddit (use the returned flair id when creating a Reddit post that requires a flair).",requiredParams:["subreddit"],run:(e,t,o)=>e.misc.miscRedditGetSubredditFlairs({teamId:t,subreddit:String(o.subreddit)})},{id:"reddit:requirements",platform:"REDDIT",description:"Get a subreddit's posting requirements (title length, flair requirement, allowed post types, etc.).",requiredParams:["subreddit"],run:(e,t,o)=>e.misc.miscRedditGetPostRequirements({teamId:t,subreddit:String(o.subreddit)})},{id:"youtube:categories",platform:"YOUTUBE",description:"List YouTube video categories for a region (use the returned category id as `categoryId` when posting a YouTube video).",optionalParams:["regionCode"],run:(e,t,o)=>e.misc.miscYoutubeGetVideoCategories({teamId:t,...o.regionCode?{regionCode:String(o.regionCode)}:{}})},{id:"youtube:playlists",platform:"YOUTUBE",description:"List the connected YouTube channel's playlists (use a playlist id to add the posted video to it).",optionalParams:["maxResults"],run:(e,t,o)=>e.misc.miscYoutubeGetChannelPlaylist({teamId:t,...o.maxResults!==void 0?{maxResults:Number(o.maxResults)}:{}})},{id:"youtube:regions",platform:"YOUTUBE",description:"List YouTube content regions (i18n region codes).",run:(e,t)=>e.misc.miscYoutubeGetRegions({teamId:t})},{id:"linkedin:mentions",platform:"LINKEDIN",description:"Search LinkedIn people/organizations to mention in a post (use the returned URN in the post text).",requiredParams:["q"],optionalParams:["scope"],run:(e,t,o)=>e.misc.miscLinkedinGetTags({teamId:t,q:String(o.q),...o.scope?{scope:String(o.scope)}:{}})},{id:"instagram:locations",platform:"INSTAGRAM",description:"Search Instagram locations (use the returned location id as `locationId` when posting).",requiredParams:["q"],optionalParams:["limit"],run:(e,t,o)=>e.misc.miscInstagramSearchLocations({teamId:t,q:String(o.q),...o.limit!==void 0?{limit:Number(o.limit)}:{}})},{id:"gbp:location",platform:"GOOGLE_BUSINESS",description:"Get the connected Google Business Profile location's details.",optionalParams:["fields"],run:(e,t,o)=>e.misc.miscGoogleBusinessGetLocation({teamId:t,...Array.isArray(o.fields)?{fields:o.fields}:{}})},{id:"gbp:categories",platform:"GOOGLE_BUSINESS",description:"List Google Business Profile categories for a region/language (use a category id when updating the location).",requiredParams:["languageCode","regionCode"],optionalParams:["filter","pageSize","pageToken","view"],run:(e,t,o)=>e.misc.miscGoogleBusinessListCategories({teamId:t,languageCode:String(o.languageCode),regionCode:String(o.regionCode),...o.filter?{filter:String(o.filter)}:{},...o.pageSize!==void 0?{pageSize:Number(o.pageSize)}:{},...o.pageToken?{pageToken:String(o.pageToken)}:{},...o.view?{view:String(o.view)}:{}})},{id:"tiktok:trending-music",platform:"TIKTOK",description:"List trending tracks from TikTok's commercial music library (use a track id in the TikTok post settings).",optionalParams:["dateRange","genre"],run:(e,t,o)=>e.misc.miscTiktokGetCommercialMusicTrendingList({teamId:t,...o.dateRange?{dateRange:String(o.dateRange)}:{},...o.genre?{genre:String(o.genre)}:{}})}];function Dt(){return K.map(e=>({method:e.id,platform:e.platform,description:e.description,requiredParams:e.requiredParams??[],optionalParams:e.optionalParams??[]}))}async function _t(e,t,o,n){let i=K.find(r=>r.id===o.trim().toLowerCase());if(!i)throw new u("UNKNOWN_INTEGRATION_TOOL",`Unknown integration tool "${o}". Available: ${K.map(r=>r.id).join(", ")}.`,{available:K.map(r=>r.id)});let a=(i.requiredParams??[]).filter(r=>n[r]===void 0||n[r]===null||n[r]==="");if(a.length>0)throw new u("MISSING_PARAMS",`Integration tool "${i.id}" requires: ${a.join(", ")}. Provide them in the params object.`,{method:i.id,requiredParams:i.requiredParams});return i.run(e,t,n)}var ne=M.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function Pt(e,t){l(e,"list_integration_tools",{title:"List integration helper tools",description:"List the read-only platform helper tools callable via trigger_integration_tool \u2014 e.g. fetch subreddit flairs, YouTube categories/playlists/regions, LinkedIn mentions, Instagram locations, Google Business categories, TikTok trending music. Each entry has a `method` id and the params it accepts. Use these to discover values the API needs (flair ids, category ids, mention URNs, \u2026).",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>s({tools:Dt()})),l(e,"trigger_integration_tool",{title:"Call an integration helper tool",description:'Call one of the platform helper tools (see list_integration_tools), e.g. method "reddit:flairs" with params {"subreddit":"r/test"}. Returns the raw result.',inputSchema:{method:M.string().min(1).describe('Tool method id, e.g. "reddit:flairs", "youtube:categories", "linkedin:mentions" (call list_integration_tools first).'),params:M.record(M.string(),M.unknown()).optional().describe('Parameters for the tool as a JSON object, e.g. {"subreddit":"r/test"}.'),teamId:ne},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({method:o,params:n,teamId:i})=>{let a=await f(t,i);return s(await _t(t.client,a,o,n??{}))})}import{z as _}from"zod";function vt(e,t){l(e,"list_teams",{title:"List teams",description:"List the teams in the organization (paginated). Use this to discover team ids for the optional `teamId` argument on other tools.",inputSchema:{limit:_.number().int().positive().max(100).optional().describe("Max number of teams to return."),offset:_.number().int().nonnegative().optional().describe("Number of teams to skip (for pagination)."),search:_.string().optional().describe("Free-text search over team names.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({limit:o,offset:n,search:i})=>s(await t.client.team.teamGetList({limit:o??null,offset:n??null,search:i??null}))),l(e,"get_team",{title:"Get a team by id",description:"Fetch a single team by id, including its connected social accounts/integrations.",inputSchema:{id:_.string().min(1).describe("Team id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.team.teamGetTeam({id:o}))),l(e,"create_team",{title:"Create a team",description:"Create a new team in the organization. Optionally copy the connected social accounts from an existing team via `copyTeamId`.",inputSchema:{name:_.string().min(1).describe("Team name."),avatarUrl:_.string().optional().describe("Optional avatar image URL."),copyTeamId:_.string().optional().describe("Optional id of an existing team to copy social accounts from.")},annotations:{openWorldHint:!0}},async({name:o,avatarUrl:n,copyTeamId:i})=>s(await t.client.team.teamCreateTeam({requestBody:{name:o,avatarUrl:n??null,copyTeamId:i??null}}))),l(e,"update_team",{title:"Update a team",description:"Update a team's name and/or avatar. Only the fields you pass are changed.",inputSchema:{id:_.string().min(1).describe("Team id."),name:_.string().optional().describe("New team name."),avatarUrl:_.string().nullable().optional().describe("New avatar image URL, or null to clear it.")},annotations:{openWorldHint:!0}},async({id:o,name:n,avatarUrl:i})=>{let a={};if(n!==void 0&&(a.name=n),i!==void 0&&(a.avatarUrl=i),Object.keys(a).length===0)throw new u("NOTHING_TO_UPDATE","Nothing to update \u2014 pass at least one of name, avatarUrl.");return s(await t.client.team.teamUpdateTeam({id:o,requestBody:a}))}),l(e,"delete_team",{title:"Delete a team",description:"Delete a team by id. This is destructive and cannot be undone \u2014 it removes the team and its scheduled content.",inputSchema:{id:_.string().min(1).describe("Team id.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({id:o})=>s(await t.client.team.teamDeleteTeam({id:o})))}import{z as H}from"zod";var ie=H.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.");function Rt(e,t){l(e,"get_organization",{title:"Get the organization",description:"Fetch the current organization \u2014 its id, name, API-access flag, plan limits and the list of teams.",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>s(await t.client.organization.organizationGetOrganization())),l(e,"get_usage",{title:"Get usage quotas",description:"Organization usage quotas: posts, comments and uploads (used/limit/remaining), plus a paginated per-social-account breakdown of post-history import usage. Use the pagination/filter args for the imports breakdown.",inputSchema:{teamId:ie,platform:H.string().optional().describe("Filter the imports breakdown to one platform name/alias (e.g. instagram, tiktok)."),socialAccountId:H.string().optional().describe("Filter the imports breakdown to one social-account id."),page:H.number().int().positive().optional().describe("Page of the imports breakdown (1-based)."),pageSize:H.number().int().positive().max(100).optional().describe("Page size of the imports breakdown.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,platform:n,socialAccountId:i,page:a,pageSize:r})=>{let d=o??t.defaultTeamId??await f(t,o).catch(()=>{}),[m,h,y,I]=await Promise.all([t.client.organization.organizationGetPostsUsage().catch(b=>({error:C(b)})),t.client.organization.organizationGetCommentsUsage().catch(b=>({error:C(b)})),t.client.organization.organizationGetUploadsUsage().catch(b=>({error:C(b)})),t.client.organization.organizationGetImportsUsage({page:a,pageSize:r,teamId:d,socialAccountType:n?S(n):void 0,socialAccountId:i}).catch(b=>({error:C(b)}))]);return s({posts:m,comments:h,uploads:y,imports:I})})}import{z as A}from"zod";var Lt=A.string().min(1).describe("Platform name/alias. Post-history import is available on FACEBOOK, INSTAGRAM, THREADS, TIKTOK, YOUTUBE, LINKEDIN, PINTEREST, REDDIT, MASTODON, BLUESKY.");function Ut(e,t){l(e,"create_post_import",{title:"Import post history",description:"Start an async import of a connected account's recent posts (optionally with analytics) for one platform. Poll list_post_imports / get_post_import for status and list_imported_posts for the imported posts.",inputSchema:{platform:Lt,count:A.number().int().positive().describe("How many recent posts to import."),withAnalytics:A.boolean().optional().describe("Also fetch analytics for the imported posts."),importCarousels:A.boolean().optional().describe("Include carousel/album posts (Instagram)."),surface:A.enum(["PROFILE_GRID","NON_GRID","STORY","ALL"]).optional().describe("Which surface to import from (Instagram)."),mediaType:A.enum(["VIDEO","IMAGE"]).optional().describe("Restrict to one media type."),teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{openWorldHint:!0}},async({platform:o,count:n,withAnalytics:i,importCarousels:a,surface:r,mediaType:c,teamId:d})=>{let m=await f(t,d);return s(await t.client.postImport.postImportCreate({requestBody:{teamId:m,socialAccountType:S(o),count:n,...i!==void 0?{withAnalytics:i}:{},...a!==void 0?{importCarousels:a}:{},...r?{surface:r}:{},...c?{mediaType:c}:{}}}))}),l(e,"list_post_imports",{title:"List post-history imports",description:"List post-history import jobs for a team, optionally filtered by platform.",inputSchema:{teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),platform:A.string().optional().describe("Filter by platform name/alias.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({teamId:o,platform:n})=>{let i=await f(t,o);return s(await t.client.postImport.postImportGetStatus({teamId:i,socialAccountType:n?S(n):void 0}))}),l(e,"get_post_import",{title:"Get a post-history import by id",description:"Fetch a single post-history import job by its id, including its status and counts.",inputSchema:{importId:A.string().min(1).describe("Post import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.postImport.postImportGetById({importId:o}))),l(e,"list_imported_posts",{title:"List imported posts for a platform",description:"List the posts imported (with analytics, when available) for a connected account on the given platform.",inputSchema:{platform:Lt,teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured."),limit:A.number().int().positive().max(100).optional(),offset:A.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({platform:o,teamId:n,limit:i,offset:a})=>{let r=await f(t,n);return s(await t.client.postImport.postImportGetImportedPosts({teamId:r,socialAccountType:S(o),limit:i,offset:a??null}))}),l(e,"delete_imported_posts",{title:"Delete imported posts",description:"Bulk-delete imported posts (and their analytics) by id. Destructive.",inputSchema:{postIds:A.array(A.string().min(1)).min(1).describe("Imported-post ids to delete."),teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{destructiveHint:!0,openWorldHint:!0}},async({postIds:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.postImport.postImportDeleteImportedPosts({requestBody:{teamId:i,postIds:o}}))}),l(e,"retry_post_import",{title:"Retry a post-history import",description:"Retry a post-history import job that ended in FAILED / RATE_LIMITED.",inputSchema:{importId:A.string().min(1).describe("Post import id."),teamId:A.string().min(1).optional().describe("bundle.social team id. Optional when the organization has a single team or BUNDLESOCIAL_TEAM_ID is configured.")},annotations:{openWorldHint:!0}},async({importId:o,teamId:n})=>{let i=await f(t,n);return s(await t.client.postImport.postImportRetryImport({importId:o,requestBody:{teamId:i}}))})}import ae from"fs/promises";import dt from"path";import{z as R}from"zod";function re(e){return/^https?:\/\//i.test(e.trim())}async function se(e){if(re(e)){let n=await fetch(e.trim());if(!n.ok)throw new u("CSV_FETCH_FAILED",`Could not download the CSV from "${e}" (HTTP ${n.status}).`,{status:n.status});let i=Buffer.from(await n.arrayBuffer()),a=dt.basename(new URL(e).pathname)||"import.csv";return new File([i],a,{type:"text/csv"})}let t=dt.resolve(e),o;try{o=await ae.readFile(t)}catch{throw new u("CSV_NOT_FOUND",`Could not read CSV "${e}". Provide a public https:// URL, or a local file path that exists on the machine running this MCP server (stdio mode only).`,{path:t})}return new File([o],dt.basename(t),{type:"text/csv"})}function Nt(e,t){l(e,"create_post_csv_import",{title:"Bulk-import posts from a CSV",description:"Upload a CSV for async bulk post import. Accepts a public https:// URL to the CSV, or a local file path when this server runs in stdio mode. Poll get_post_csv_import_status / get_post_csv_import_rows for progress and per-row results.",inputSchema:{source:R.string().min(1).describe("Public https:// URL of the CSV, or a local file path (stdio mode only).")},annotations:{openWorldHint:!0}},async({source:o})=>{let n=await se(o);return s(await t.client.postCsv.postCsvCreate({formData:{file:n}}))}),l(e,"list_post_csv_imports",{title:"List CSV imports",description:"List the post-CSV import history (paginated).",inputSchema:{limit:R.number().int().positive().max(100).optional(),offset:R.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({limit:o,offset:n})=>s(await t.client.postCsv.postCsvGetList({limit:o??null,offset:n??null}))),l(e,"get_post_csv_import",{title:"Get a CSV import by id",description:"Fetch a single post-CSV import by its id, including counts and status.",inputSchema:{importId:R.string().min(1).describe("CSV import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.postCsv.postCsvGetById({importId:o}))),l(e,"get_post_csv_import_status",{title:"Get a CSV import's processing status",description:"Fetch the processing status of a post-CSV import (rows processed/succeeded/failed).",inputSchema:{importId:R.string().min(1).describe("CSV import id.")},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o})=>s(await t.client.postCsv.postCsvGetStatus({importId:o}))),l(e,"get_post_csv_import_rows",{title:"Get a CSV import's row results",description:"List per-row results of a post-CSV import (the raw row, normalized payload, created post id or error), optionally filtered by SUCCESS/FAILED.",inputSchema:{importId:R.string().min(1).describe("CSV import id."),status:R.enum(["SUCCESS","FAILED"]).optional().describe("Filter rows by outcome."),limit:R.number().int().positive().max(100).optional(),offset:R.number().int().nonnegative().optional()},annotations:{readOnlyHint:!0,openWorldHint:!0}},async({importId:o,status:n,limit:i,offset:a})=>s(await t.client.postCsv.postCsvGetRows({importId:o,status:n,limit:i??null,offset:a??null})))}var le=z.version;function kt(e,t){l(e,"check_setup",{title:"Check the bundle.social setup",description:"Diagnose this MCP server's setup: API key present, API reachable, API key valid, organization API access, team resolution, connected integrations and posts quota. Always returns a structured diagnostic object ({ ok, checks: [...] }).",annotations:{readOnlyHint:!0,openWorldHint:!0}},async()=>{let o=[],n=(d,m,h,y={})=>o.push({name:d,status:m,message:h,...y}),i=()=>s({ok:o.every(d=>d.status!=="fail"),mcpVersion:le,node:process.version,checks:o});n("api_key","ok","API key configured");try{let d=await t.client.app.appGetHealth();n("api_reachable","ok","API reachable",{health:d})}catch(d){return n("api_reachable","fail","Could not reach the bundle.social API",{error:C(d)}),i()}let a=[],r;try{let d=await t.client.organization.organizationGetOrganization();a=(d.teams??[]).map(m=>({id:m.id,name:m.name})),r=d.apiAccess,n("authentication","ok","API key is valid",{organizationId:d.id,organizationName:d.name??null})}catch(d){return n("authentication","fail","API key was rejected by the API",{error:C(d)}),i()}n("api_access",r?"ok":"fail",r?"Organization has API access enabled":"Organization does not have API access enabled \u2014 upgrade your plan or contact bundle.social support");let c;if(t.defaultTeamId?(c=t.defaultTeamId,n("team","ok","Using team from BUNDLESOCIAL_TEAM_ID / --team-id",{teamId:c})):a.length===1?(c=a[0].id,n("team","ok","Using the organization's only team",{teamId:c,teamName:a[0].name})):a.length===0?n("team","fail","Organization has no teams \u2014 create one in the dashboard"):n("team","warn",`Organization has ${a.length} teams; tools need a teamId argument (or set BUNDLESOCIAL_TEAM_ID)`,{teams:a}),c)try{let m=(await t.client.team.teamGetTeam({id:c})).socialAccounts??[];n("integrations",m.length>0?"ok":"warn",m.length>0?`${m.length} connected integration(s)`:"No integrations connected \u2014 connect one in the dashboard before posting",{count:m.length,platforms:m.map(h=>h.type),connectUrl:gt})}catch(d){n("integrations","fail","Could not load the team's integrations",{teamId:c,error:C(d)})}try{let d=await t.client.organization.organizationGetPostsUsage();n("posts_quota",d.remaining>0?"ok":"warn",`Posts quota: ${d.used}/${d.limit} used, ${d.remaining} remaining`,{used:d.used,limit:d.limit,remaining:d.remaining})}catch(d){n("posts_quota","warn","Could not read posts quota",{error:C(d)})}return i()})}function Bt(e,t){Rt(e,t),vt(e,t),bt(e,t),wt(e,t),At(e,t),Et(e,t),Ct(e,t),Ut(e,t),Nt(e,t),Pt(e,t),kt(e,t)}var j=z.version;function Gt(e){let t=new de({name:"bundlesocial",version:j},{capabilities:{tools:{}},instructions:"Tools for the bundle.social API: posting/scheduling to 14+ social platforms, comments, media uploads, analytics, team & integration management, and bulk/history imports (post-history, comment, CSV). Run check_setup first to verify the API key, org access and team. Use list_integrations to see connected accounts and their ids. create_post / schedule_post target platforms by name (x, tiktok, instagram, youtube, facebook, threads, linkedin, pinterest, reddit, mastodon, discord, slack, gbp) or by integration id; put platform-required fields (Reddit `sr`, Pinterest `boardName`, TikTok `privacy`, YouTube `madeForKids`/`privacyStatus`) under `platformSettings` keyed by platform \u2014 per-platform fields are documented at https://docs.bundle.social/api-reference/platform-parameters. Team-scoped tools take an optional `teamId` (resolved automatically when the org has one team or BUNDLESOCIAL_TEAM_ID is set). Errors come back as { error: { code, message, details } } with isError: true."}),o={client:ht(e.apiKey,e.apiUrl??x),defaultTeamId:e.defaultTeamId};return Bt(t,o),t}function ct(e){let t=process.argv.indexOf(`--${e}`);if(t!==-1&&t+1<process.argv.length)return process.argv[t+1];let o=process.argv.find(n=>n.startsWith(`--${e}=`));return o?o.slice(`--${e}=`.length):void 0}function mt(e){process.stderr.write(`bundlesocial-mcp: ${e}
|
|
4
|
+
`)}async function me(){if(process.argv.includes("--version")||process.argv.includes("-v")){process.stdout.write(`${j}
|
|
5
5
|
`);return}if(process.argv.includes("--help")||process.argv.includes("-h")){process.stdout.write(`bundlesocial-mcp ${j} \u2014 Model Context Protocol server for the bundle.social API.
|
|
6
6
|
|
|
7
7
|
Usage: bundlesocial-mcp [--api-key <key>] [--api-url <url>] [--team-id <id>]
|
|
8
8
|
|
|
9
9
|
Reads BUNDLESOCIAL_API_KEY (required), BUNDLESOCIAL_API_URL and BUNDLESOCIAL_TEAM_ID from the environment;
|
|
10
10
|
the flags above override them. Communicates over stdio (MCP). Create an API key at ${Y}
|
|
11
|
-
`);return}let e=
|
|
11
|
+
`);return}let e=ct("api-key")??process.env.BUNDLESOCIAL_API_KEY;e||(mt(`missing API key. Set BUNDLESOCIAL_API_KEY (or pass --api-key). Create one at ${Y}`),process.exit(1));let t=Gt({apiKey:e,apiUrl:ct("api-url")??process.env.BUNDLESOCIAL_API_URL,defaultTeamId:ct("team-id")??process.env.BUNDLESOCIAL_TEAM_ID}),o=new ce;await t.connect(o),mt("running on stdio");let n=()=>{t.close().finally(()=>process.exit(0))};process.on("SIGINT",n),process.on("SIGTERM",n)}me().catch(e=>{mt(`fatal: ${e?.stack??e}`),process.exit(1)});
|
|
12
12
|
//# sourceMappingURL=index.js.map
|