import{createRequire as f}from"node:module";var d=Object.defineProperty;var c=(e)=>e;function p(e,r){this[e]=c.bind(null,r)}var h=(e,r)=>{for(var t in r)d(e,t,{get:r[t],enumerable:!0,configurable:!0,set:p.bind(r,t)})};var a=(e,r)=>()=>(e&&(r=e(e=0)),r);var v=f(import.meta.url);import{Experimental_StdioMCPTransport as u}from"@ai-sdk/mcp/mcp-stdio";function P(e){let r=l(e);if(r==="stdio"){let i=g(e);return new u(i)}let t=e,n=m(t),o={type:r,url:s(t.url,"url",e.name)};if(n)o.headers=n;if(t.authProvider)o.authProvider=t.authProvider;return o}function S(e,r){let t=e.toolPrefix?.trim();if(!t)return r;let n={};for(let[o,i]of Object.entries(r))n[`${t}_${o}`]=i;return n}function x(e){if(e instanceof Error)return e.message;return String(e)}function l(e){return e.transport??"stdio"}function g(e){let r=e;return{command:s(r.command,"command",e.name),args:r.args,env:r.env,cwd:r.cwd}}function m(e){let r={...e.headers??{}},t=e.accessToken??C(e.accessTokenEnvVar);if(t&&r.Authorization===void 0)r.Authorization=`Bearer ${t}`;return Object.keys(r).length>0?r:void 0}function C(e){if(!e)return;let r=process.env[e];if(!r)return;let t=r.trim();return t.length>0?t:void 0}function s(e,r,t){if(!e)throw Error(`MCP server "${t}" is missing required "${r}".`);let n=e.trim();if(n.length===0)throw Error(`MCP server "${t}" has an empty "${r}".`);return n}var T=()=>{};T();export{S as prefixToolNames,x as getErrorMessage,P as buildMcpTransport};
