@sequenzy/mcp 0.0.42 → 0.0.43

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.
@@ -0,0 +1,2 @@
1
+ var y=Object.create;var{getPrototypeOf:C,defineProperty:f,getOwnPropertyNames:x}=Object;var w=Object.prototype.hasOwnProperty;function U(t){return this[t]}var _,R,b=(t,e,n)=>{var r=t!=null&&typeof t==="object";if(r){var o=e?_??=new WeakMap:R??=new WeakMap,a=o.get(t);if(a)return a}n=t!=null?y(C(t)):{};let c=e||!t||!t.__esModule?f(n,"default",{value:t,enumerable:!0}):n;for(let i of x(t))if(!w.call(c,i))f(c,i,{get:U.bind(t,i),enumerable:!0});if(r)o.set(t,c);return c};var I=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var E=(t)=>t;function T(t,e){this[t]=E.bind(null,e)}var k=(t,e)=>{for(var n in e)f(t,n,{get:e[n],enumerable:!0,configurable:!0,set:T.bind(e,n)})};import{AsyncLocalStorage as M}from"node:async_hooks";class d extends Error{statusCode;rawDetails;code;context;constructor(t,e,n,r,o){super(t);this.statusCode=e;this.rawDetails=n;this.code=r;this.context=o;this.name="McpApiError"}}function P(t){if(t instanceof d)return{message:t.message,statusCode:t.statusCode,code:t.code,rawDetails:t.rawDetails,context:t.context};if(t instanceof Error)return{message:t.message};return{message:String(t)}}function S(t){let e=P(t),n=e.message.trim()||"Unknown error",r=n.toLowerCase(),o=e.rawDetails?.trim()||n;if(e.context?.title||e.context?.description||e.context?.howToFix||e.context?.docsUrl)return{title:e.context.title??(e.statusCode===409?"Request conflict":"API request failed"),description:e.context.description??n,howToFix:e.context.howToFix??"Review the details below, adjust the tool input, and retry.",docsUrl:e.context.docsUrl??"https://docs.sequenzy.com/concepts/mcp",details:o};if(e.code==="MCP_AUTH_REQUIRED"||r.includes("sequenzy_api_key environment variable is required"))return{title:"Missing MCP API key",description:"The MCP server started without a Sequenzy API key, so it cannot authenticate any tool or resource request.",howToFix:"Add `SEQUENZY_API_KEY` to the MCP server environment, or run `npx @sequenzy/setup` to configure the integration automatically.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:o};if(e.statusCode===401||e.code==="UNAUTHORIZED")return{title:"Authentication failed",description:"The MCP server reached Sequenzy, but the current API key was rejected.",howToFix:"Replace `SEQUENZY_API_KEY` with a valid personal API key, then restart the MCP client so it reconnects with fresh credentials.",docsUrl:"https://docs.sequenzy.com/authentication",details:o};if(e.statusCode===403||r.includes("access denied"))return{title:"Access denied",description:"The current API key is valid, but it does not have permission to access the requested company or action.",howToFix:"Use an API key that belongs to the right account, or select a company the key can access before retrying the tool call.",docsUrl:"https://docs.sequenzy.com/authentication",details:o};if(r.includes("no company available")||r.includes("company not found"))return{title:"Company selection required",description:"The MCP server could not resolve a company for this request.",howToFix:"Call `get_account` to inspect available companies, then call `select_company`, or pass `companyId` explicitly in the next tool call.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:o};if(e.statusCode===404||r.includes("not found"))return{title:"Requested resource not found",description:"Sequenzy could not find the requested campaign, template, sequence, company, or subscriber.",howToFix:"List or fetch the resource collection first, then retry the tool with a confirmed ID or email value.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:o};if(e.statusCode===409||r.includes("already exists"))return{title:"Resource already exists",description:"Sequenzy rejected this MCP request because it would create a duplicate resource.",howToFix:"List the existing resources first, reuse the matching resource when appropriate, or retry with a unique name or domain.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:o};if(e.statusCode===429||r.includes("rate limit"))return{title:"Rate limited",description:"Sequenzy temporarily slowed this MCP request because too many requests were sent too quickly.",howToFix:"Wait briefly before retrying. If the client is looping, reduce retries or add backoff before the next tool call.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:o};if(e.code==="NETWORK_ERROR"||r.includes("fetch failed"))return{title:"Network or configuration error",description:"The MCP server could not reach the Sequenzy API from this environment.",howToFix:"Check connectivity and verify `SEQUENZY_API_URL` if you override it in the MCP environment.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:o};if(r.includes("unknown tool")||r.includes("unknown resource"))return{title:"Unsupported MCP request",description:"The client asked for a tool or resource name that this Sequenzy MCP server does not expose.",howToFix:"Refresh the client's tool list and call only the names returned by `list_tools` or `list_resources`.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:o};if(r.includes("is required")||r.includes("invalid"))return{title:"Invalid MCP input",description:"The tool call was missing a required field or included an invalid value.",howToFix:"Review the tool schema, supply the missing argument, and retry the request with corrected input.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:o};if(e.statusCode&&e.statusCode>=500)return{title:"Sequenzy server error",description:"The request reached Sequenzy, but the server could not complete it successfully.",howToFix:"Retry once. If it still fails, keep the details below and consult the docs before escalating.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:o};return{title:"Tool execution failed",description:"The MCP server could not complete the requested operation.",howToFix:"Review the details below, adjust the tool input or credentials, and retry.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:o}}function h(t){let e=S(t);return[`Sequenzy MCP error: ${e.title}`,`Description: ${e.description}`,`How to fix: ${e.howToFix}`,`Docs: ${e.docsUrl}`,`Details: ${e.details}`].join(`
2
+ `)}var q="https://api.sequenzy.com",l=new M,g=null;function A(){let t=l.getStore();if(t)return t.selectedCompanyId??null;return g}function K(t){let e=l.getStore();if(e){e.selectedCompanyId=t;return}g=t}function Y(t,e){return l.run(t,e)}function v(){return l.getStore()?.apiUrl??process.env.SEQUENZY_API_URL??q}function m(){return l.getStore()?.apiKey??process.env.SEQUENZY_API_KEY}function j(){if(m())return;console.error(h(new d("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED"))),process.exit(1)}function s(t,e){let n=t[e];return typeof n==="string"&&n.trim()!==""?n.trim():void 0}function D(t){if(t===void 0)return;if(typeof t==="string")return t.trim()||void 0;return JSON.stringify(t)}function O(t){if(!t.trim())return{message:"Request failed"};try{let e=JSON.parse(t);if(typeof e==="string")return{message:e};let n=typeof e.error==="object"&&e.error!==null?e.error:void 0,r=s(e,"code")??(n?s(n,"code"):void 0),o=(typeof e.error==="string"?e.error:void 0)??(n?s(n,"message"):void 0)??s(e,"message")??s(e,"error")??t,a=s(e,"howToFix")??s(e,"resolution"),c={...s(e,"title")?{title:s(e,"title")}:{},...s(e,"description")?{description:s(e,"description")}:{},...a?{howToFix:a}:{},...s(e,"docsUrl")?{docsUrl:s(e,"docsUrl")}:{}},i=D(e.details);if(Object.keys(c).length>0||i)return{message:o,...r?{code:r}:{},...i?{details:i}:{},...Object.keys(c).length>0?{context:c}:{}};if(typeof e.error==="string")return{message:e.error,...r?{code:r}:{}};if(n)return{message:o,...r?{code:r}:{}};return{message:o,...r?{code:r}:{}}}catch{return{message:t}}}async function Q(t,e,n,r){let o=m();if(!o)throw new d("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED");let a={"Content-Type":"application/json",Authorization:`Bearer ${o}`},c=r??A();if(c)a["x-company-id"]=c;let i;try{i=await fetch(`${v()}${e}`,{method:t,headers:a,body:n?JSON.stringify(n):void 0})}catch(u){throw new d(u instanceof Error?u.message:"Failed to reach Sequenzy API",0,void 0,"NETWORK_ERROR")}if(!i.ok){let u=await i.text(),p=O(u);throw new d(p.message,i.status,p.details??u,p.code,p.context)}return i.json()}export{Y as withMcpRequestContext,K as setSelectedCompanyId,A as getSelectedCompanyId,j as assertConfiguredApiKey,Q as apiRequest};