"use strict";exports.id=8124,exports.ids=[8124],exports.modules={88124:(a,b,c)=>{c.d(b,{Jc:()=>p,McpConfigSchema:()=>l,callTool:()=>r,connectAndListTools:()=>q});var d=c(43444),e=c(37567),f=c(1960),g=c(66133),h=c(14126);let i=h.Ik({transport:h.eu("stdio"),command:h.Yj().min(1),args:h.YO(h.Yj()).default([]),env:h.g1(h.Yj(),h.Yj()).default({}),cwd:h.Yj().optional()}),j=h.Ik({transport:h.eu("http"),url:h.Yj().url(),headers:h.g1(h.Yj(),h.Yj()).default({})}),k=h.Ik({transport:h.eu("sse"),url:h.Yj().url(),headers:h.g1(h.Yj(),h.Yj()).default({})}),l=h.gM("transport",[i,j,k]),m={name:"reflex-utility-bridge",version:"0.1.0"};async function n(a){let b=new d.K(m);if("stdio"===a.transport){let c=await p(a.env),d=new e.oQ({command:a.command,args:a.args,env:{...process.env,...c},cwd:a.cwd});return await b.connect(d),{client:b,close:()=>b.close()}}if("http"===a.transport){let c=await p(a.headers),d=new f.j(new URL(a.url),{requestInit:{headers:c}});return await b.connect(d),{client:b,close:()=>b.close()}}let c=await p(a.headers),h=new g.A(new URL(a.url),{requestInit:{headers:c}});return await b.connect(h),{client:b,close:()=>b.close()}}let o=/\$oauth:([a-z][a-z0-9-]*)/g;async function p(a){let b={};for(let[d,e]of Object.entries(a)){if("string"!=typeof e||!e.includes("$oauth:")){b[d]=e;continue}let a=new Set;e.replace(o,(b,c)=>(a.add(c),""));let f=e,{getAccessToken:g}=await c.e(2503).then(c.bind(c,82503)),{isOAuthProviderId:h}=await c.e(3657).then(c.bind(c,63657));for(let b of a){if(!h(b))throw Error(`unknown OAuth provider in placeholder: ${b}`);let a=await g(b);f=f.replace(RegExp(`\\$oauth:${b}\\b`,"g"),a)}b[d]=f}return b}async function q(a){let{client:b,close:c}=await n(a);try{let a=b.getServerVersion(),{tools:c}=await b.listTools();return{name:a?.name,version:a?.version,tools:c.map(a=>({name:a.name,description:a.description,inputSchema:a.inputSchema}))}}finally{await c().catch(()=>{})}}async function r(a,b,c){let{client:d,close:e}=await n(a);try{let a=await d.callTool({name:b,arguments:c});return{isError:"boolean"==typeof a.isError?a.isError:void 0,content:a.content}}finally{await e().catch(()=>{})}}}};