// @bun
var d=Object.defineProperty;var c=(e)=>e;function p(e,r){this[e]=c.bind(null,r)}var T=(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 h=import.meta.require;import{Experimental_StdioMCPTransport as f}from"@ai-sdk/mcp/mcp-stdio";function R(e){let r=u(e);if(r==="stdio"){let i=l(e);return new f(i)}let t=e,n=g(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 y(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 P(e){if(e instanceof Error)return e.message;return String(e)}function u(e){return e.transport??"stdio"}function l(e){let r=e;return{command:s(r.command,"command",e.name),args:r.args,env:r.env,cwd:r.cwd}}function g(e){let r={...e.headers??{}},t=e.accessToken??m(e.accessTokenEnvVar);if(t&&r.Authorization===void 0)r.Authorization=`Bearer ${t}`;return Object.keys(r).length>0?r:void 0}function m(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 C=()=>{};C();export{y as prefixToolNames,P as getErrorMessage,R as buildMcpTransport};
