import{s as Re,n as Ze,o as Ee}from"../chunks/scheduler.9cda857a.js";import{S as We,i as Xe,e as i,s as a,c as p,h as Qe,a as o,d as l,b as n,f as qe,g as c,j as r,k as Q,l as Ve,m as s,n as u,t as d,o as M,p as m}from"../chunks/index.003612b0.js";import{C as ze}from"../chunks/CopyLLMTxtMenu.44d08a39.js";import{C as Ge}from"../chunks/CodeBlock.a90632f1.js";import{H as E,E as Fe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.e5cfda8c.js";function Ye(Te){let f,V,W,z,w,F,C,Y,T,be="You can <strong>expose any public Space that has a visible <code>MCP</code> badge into a callable tool</strong> that will be available in any MCP-compatible client, you can add as many Spaces as you want and without writing a single line of code.",O,b,N,U,Ue='From your <a href="https://huggingface.co/settings/mcp" rel="nofollow">Hub MCP settings</a>, select your MCP client (VSCode, Cursor, Claude Code, etc.) then follow the setup instructions.',K,v,ve='<img src="https://cdn-uploads.huggingface.co/production/uploads/5f17f0a0925b9863e28ad517/wWm_GeuWF17OrMyJT4tMx.png" alt="image/png"/>',D,g,Je='<p>You need a valid Hugging Face token with <strong>READ</strong> permissions to use MCP tools. If you don’t have one, <a href="https://huggingface.co/settings/tokens/new?tokenType=read" target="_blank">create a new “Read” access token here</a>.</p>',ee,J,te,$,$e='<img src="https://cdn-uploads.huggingface.co/production/uploads/5f17f0a0925b9863e28ad517/ex9KRpvamn84ZaOlSp_Bj.png" alt="image/png"/>',le,I,Ie='<li>Browse compatible <a href="https://huggingface.co/spaces?filter=mcp-server" rel="nofollow">Spaces</a> to find Spaces that are usable via MCP. You can also look for the grey <strong>MCP</strong> badge on any Spaces card.</li> <li>Click the badge and choose <strong>Add to MCP tools</strong> then confirm when asked.</li> <li>The Space should be listed in your MCP Server settings in the Spaces Tools section.</li>',se,j,je='<img src="https://cdn-uploads.huggingface.co/production/uploads/5f17f0a0925b9863e28ad517/uI4PsneUZoWn_TExhNJyt.png" alt="image/png"/>',ae,x,ne,P,xe="If your MCP client is configured correctly, the Spaces you added will be available instantly without changing anything (if it doesn’t restart your client and it should appear). Most MCP clients will list what tools are currently loaded so you can make sure the Space is available.",ie,y,Pe='<p>For ZeroGPU Spaces, your quota will be used when the tool is called, if you run out of quota you can <a href="https://huggingface.co/subscribe/pro?from=ZeroGPU" target="_blank">subscribe to PRO</a> to get 25 minutes of daily quota (x8 more quota than free users). For example your PRO account lets you generate up to 600 images per day using FLUX.1-schnell.</p>',oe,S,re,B,Se='To create your own MCP-enabled Space, you need to <a href="https://huggingface.co/new-space?sdk=gradio" rel="nofollow">Create a new Gradio Space</a> then make sure to enable MCP support in the code. Get started with <a href="https://huggingface.co/docs/hub/en/spaces-sdks-gradio" rel="nofollow">Gradio Spaces</a> and make sure to check the <a href="https://www.gradio.app/guides/building-mcp-server-with-gradio" rel="nofollow">detailed MCP guide</a> for more details.',pe,_,Be="First, install Gradio with MCP support:",ce,k,ue,H,_e="Then create your app with clear type hints and docstrings:",de,L,Me,A,ke="Push the app to a <strong>Gradio Space</strong> and it will automatically receive the <strong>MCP</strong> badge. Anyone can then add it as a tool with a single click.",me,h,He='<p>It’s also quite easy to convert an existing Gradio Space to MCP server. Duplicate it from the context menu then just add the <code>mcp_server=True</code> parameter to your <code>launch()</code> method, and ensure your functions have clear type hints and docstrings - you can use AI tools to automate this quite easily (<a href="https://huggingface.co/spaces/Lightricks/ltx-video-distilled/discussions/22/files" target="_blank">example</a> of AI generated docstrings).</p>',fe,q,ge,G,Le="As Hugging Face Spaces is the largest directory of AI apps, you can find many creative tools that can be used as MCP tools. Mixing and matching different Spaces can lead to powerful and creative workflows.",ye,R,Ae=`<video controls=""><source src="https://cdn-uploads.huggingface.co/production/uploads/5f17f0a0925b9863e28ad517/jmYCdqYh32iwCgxM9p0Ig.mp4" type="video/mp4"/></video> <figcaption>This video demonstrates the use of
    <a href="https://huggingface.co/spaces/Lightricks/ltx-video-distilled">Lightricks/ltx-video-distilled</a> and
    <a href="https://huggingface.co/spaces/ResembleAI/Chatterbox">ResembleAI/Chatterbox</a> in Claude Code to generate a video with audio.</figcaption>`,he,Z,we,X,Ce;return w=new ze({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),C=new E({props:{title:"Spaces as MCP servers",local:"spaces-as-mcp-servers",headingTag:"h1"}}),b=new E({props:{title:"Setup your MCP Client",local:"setup-your-mcp-client",headingTag:"h2"}}),J=new E({props:{title:"Add an existing Space to your MCP tools",local:"add-an-existing-space-to-your-mcp-tools",headingTag:"h2"}}),x=new E({props:{title:"Use Spaces from your MCP client",local:"use-spaces-from-your-mcp-client",headingTag:"h2"}}),S=new E({props:{title:"Build your own MCP-compatible Gradio Space",local:"build-your-own-mcp-compatible-gradio-space",headingTag:"h2"}}),k=new Ge({props:{code:"cGlwJTIwaW5zdGFsbCUyMCUyMmdyYWRpbyU1Qm1jcCU1RCUyMg==",highlighted:'pip install <span class="hljs-string">&quot;gradio[mcp]&quot;</span>',wrap:!1}}),L=new Ge({props:{code:"aW1wb3J0JTIwZ3JhZGlvJTIwYXMlMjBnciUwQSUwQWRlZiUyMGxldHRlcl9jb3VudGVyKHdvcmQlM0ElMjBzdHIlMkMlMjBsZXR0ZXIlM0ElMjBzdHIpJTIwLSUzRSUyMGludCUzQSUwQSUyMCUyMCUyMCUyMCUyMiUyMiUyMkNvdW50JTIwb2NjdXJyZW5jZXMlMjBvZiUyMGElMjBsZXR0ZXIlMjBpbiUyMGElMjB3b3JkLiUwQSUyMCUyMCUyMCUyMCUwQSUyMCUyMCUyMCUyMEFyZ3MlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB3b3JkJTNBJTIwVGhlJTIwd29yZCUyMHRvJTIwc2VhcmNoJTIwaW4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsZXR0ZXIlM0ElMjBUaGUlMjBsZXR0ZXIlMjB0byUyMGNvdW50JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTBBJTIwJTIwJTIwJTIwUmV0dXJucyUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyME51bWJlciUyMG9mJTIwdGltZXMlMjB0aGUlMjBsZXR0ZXIlMjBhcHBlYXJzJTIwaW4lMjB0aGUlMjB3b3JkJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwd29yZC5sb3dlcigpLmNvdW50KGxldHRlci5sb3dlcigpKSUwQSUwQWRlbW8lMjAlM0QlMjBnci5JbnRlcmZhY2UoZm4lM0RsZXR0ZXJfY291bnRlciUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGlucHV0cyUzRCU1QiUyMnRleHQlMjIlMkMlMjAlMjJ0ZXh0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwb3V0cHV0cyUzRCUyMm51bWJlciUyMiklMEFkZW1vLmxhdW5jaChtY3Bfc2VydmVyJTNEVHJ1ZSklMjAlMjAlMjAlMjMlMjBleHBvc2VzJTIwYW4lMjBNQ1AlMjBzY2hlbWElMjBhdXRvbWF0aWNhbGx5",highlighted:`<span class="hljs-keyword">import</span> gradio <span class="hljs-keyword">as</span> gr

<span class="hljs-keyword">def</span> <span class="hljs-title function_">letter_counter</span>(<span class="hljs-params">word: <span class="hljs-built_in">str</span>, letter: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">int</span>:
    <span class="hljs-string">&quot;&quot;&quot;Count occurrences of a letter in a word.
    
    Args:
        word: The word to search in
        letter: The letter to count
        
    Returns:
        Number of times the letter appears in the word
    &quot;&quot;&quot;</span>
    <span class="hljs-keyword">return</span> word.lower().count(letter.lower())

demo = gr.Interface(fn=letter_counter,
                    inputs=[<span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>],
                    outputs=<span class="hljs-string">&quot;number&quot;</span>)
demo.launch(mcp_server=<span class="hljs-literal">True</span>)   <span class="hljs-comment"># exposes an MCP schema automatically</span>`,wrap:!1}}),q=new E({props:{title:"Be creative by mixing Spaces!",local:"be-creative-by-mixing-spaces",headingTag:"h2"}}),Z=new Fe({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/spaces-mcp-servers.md"}}),{c(){f=i("meta"),V=a(),W=i("p"),z=a(),p(w.$$.fragment),F=a(),p(C.$$.fragment),Y=a(),T=i("p"),T.innerHTML=be,O=a(),p(b.$$.fragment),N=a(),U=i("p"),U.innerHTML=Ue,K=a(),v=i("p"),v.innerHTML=ve,D=a(),g=i("blockquote"),g.innerHTML=Je,ee=a(),p(J.$$.fragment),te=a(),$=i("p"),$.innerHTML=$e,le=a(),I=i("ol"),I.innerHTML=Ie,se=a(),j=i("p"),j.innerHTML=je,ae=a(),p(x.$$.fragment),ne=a(),P=i("p"),P.textContent=xe,ie=a(),y=i("blockquote"),y.innerHTML=Pe,oe=a(),p(S.$$.fragment),re=a(),B=i("p"),B.innerHTML=Se,pe=a(),_=i("p"),_.textContent=Be,ce=a(),p(k.$$.fragment),ue=a(),H=i("p"),H.textContent=_e,de=a(),p(L.$$.fragment),Me=a(),A=i("p"),A.innerHTML=ke,me=a(),h=i("blockquote"),h.innerHTML=He,fe=a(),p(q.$$.fragment),ge=a(),G=i("p"),G.textContent=Le,ye=a(),R=i("figure"),R.innerHTML=Ae,he=a(),p(Z.$$.fragment),we=a(),X=i("p"),this.h()},l(e){const t=Qe("svelte-u9bgzb",document.head);f=o(t,"META",{name:!0,content:!0}),t.forEach(l),V=n(e),W=o(e,"P",{}),qe(W).forEach(l),z=n(e),c(w.$$.fragment,e),F=n(e),c(C.$$.fragment,e),Y=n(e),T=o(e,"P",{"data-svelte-h":!0}),r(T)!=="svelte-ov3yqv"&&(T.innerHTML=be),O=n(e),c(b.$$.fragment,e),N=n(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1ep3vkx"&&(U.innerHTML=Ue),K=n(e),v=o(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-18h14xl"&&(v.innerHTML=ve),D=n(e),g=o(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),r(g)!=="svelte-1ifygxo"&&(g.innerHTML=Je),ee=n(e),c(J.$$.fragment,e),te=n(e),$=o(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-lvyf92"&&($.innerHTML=$e),le=n(e),I=o(e,"OL",{"data-svelte-h":!0}),r(I)!=="svelte-16crp8c"&&(I.innerHTML=Ie),se=n(e),j=o(e,"P",{"data-svelte-h":!0}),r(j)!=="svelte-f2sou3"&&(j.innerHTML=je),ae=n(e),c(x.$$.fragment,e),ne=n(e),P=o(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-1ifq8g9"&&(P.textContent=xe),ie=n(e),y=o(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),r(y)!=="svelte-17i5n4c"&&(y.innerHTML=Pe),oe=n(e),c(S.$$.fragment,e),re=n(e),B=o(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-isnif0"&&(B.innerHTML=Se),pe=n(e),_=o(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-69969g"&&(_.textContent=Be),ce=n(e),c(k.$$.fragment,e),ue=n(e),H=o(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-jbl32b"&&(H.textContent=_e),de=n(e),c(L.$$.fragment,e),Me=n(e),A=o(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-1qvamjl"&&(A.innerHTML=ke),me=n(e),h=o(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),r(h)!=="svelte-1h4u17z"&&(h.innerHTML=He),fe=n(e),c(q.$$.fragment,e),ge=n(e),G=o(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-14oi344"&&(G.textContent=Le),ye=n(e),R=o(e,"FIGURE",{"data-svelte-h":!0}),r(R)!=="svelte-5r7lvj"&&(R.innerHTML=Ae),he=n(e),c(Z.$$.fragment,e),we=n(e),X=o(e,"P",{}),qe(X).forEach(l),this.h()},h(){Q(f,"name","hf:doc:metadata"),Q(f,"content",Oe),Q(g,"class","warning"),Q(y,"class","tip"),Q(h,"class","tip")},m(e,t){Ve(document.head,f),s(e,V,t),s(e,W,t),s(e,z,t),u(w,e,t),s(e,F,t),u(C,e,t),s(e,Y,t),s(e,T,t),s(e,O,t),u(b,e,t),s(e,N,t),s(e,U,t),s(e,K,t),s(e,v,t),s(e,D,t),s(e,g,t),s(e,ee,t),u(J,e,t),s(e,te,t),s(e,$,t),s(e,le,t),s(e,I,t),s(e,se,t),s(e,j,t),s(e,ae,t),u(x,e,t),s(e,ne,t),s(e,P,t),s(e,ie,t),s(e,y,t),s(e,oe,t),u(S,e,t),s(e,re,t),s(e,B,t),s(e,pe,t),s(e,_,t),s(e,ce,t),u(k,e,t),s(e,ue,t),s(e,H,t),s(e,de,t),u(L,e,t),s(e,Me,t),s(e,A,t),s(e,me,t),s(e,h,t),s(e,fe,t),u(q,e,t),s(e,ge,t),s(e,G,t),s(e,ye,t),s(e,R,t),s(e,he,t),u(Z,e,t),s(e,we,t),s(e,X,t),Ce=!0},p:Ze,i(e){Ce||(d(w.$$.fragment,e),d(C.$$.fragment,e),d(b.$$.fragment,e),d(J.$$.fragment,e),d(x.$$.fragment,e),d(S.$$.fragment,e),d(k.$$.fragment,e),d(L.$$.fragment,e),d(q.$$.fragment,e),d(Z.$$.fragment,e),Ce=!0)},o(e){M(w.$$.fragment,e),M(C.$$.fragment,e),M(b.$$.fragment,e),M(J.$$.fragment,e),M(x.$$.fragment,e),M(S.$$.fragment,e),M(k.$$.fragment,e),M(L.$$.fragment,e),M(q.$$.fragment,e),M(Z.$$.fragment,e),Ce=!1},d(e){e&&(l(V),l(W),l(z),l(F),l(Y),l(T),l(O),l(N),l(U),l(K),l(v),l(D),l(g),l(ee),l(te),l($),l(le),l(I),l(se),l(j),l(ae),l(ne),l(P),l(ie),l(y),l(oe),l(re),l(B),l(pe),l(_),l(ce),l(ue),l(H),l(de),l(Me),l(A),l(me),l(h),l(fe),l(ge),l(G),l(ye),l(R),l(he),l(we),l(X)),l(f),m(w,e),m(C,e),m(b,e),m(J,e),m(x,e),m(S,e),m(k,e),m(L,e),m(q,e),m(Z,e)}}}const Oe='{"title":"Spaces as MCP servers","local":"spaces-as-mcp-servers","sections":[{"title":"Setup your MCP Client","local":"setup-your-mcp-client","sections":[],"depth":2},{"title":"Add an existing Space to your MCP tools","local":"add-an-existing-space-to-your-mcp-tools","sections":[],"depth":2},{"title":"Use Spaces from your MCP client","local":"use-spaces-from-your-mcp-client","sections":[],"depth":2},{"title":"Build your own MCP-compatible Gradio Space","local":"build-your-own-mcp-compatible-gradio-space","sections":[],"depth":2},{"title":"Be creative by mixing Spaces!","local":"be-creative-by-mixing-spaces","sections":[],"depth":2}],"depth":1}';function Ne(Te){return Ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class st extends We{constructor(f){super(),Xe(this,f,Ne,Ye,Re,{})}}export{st as component};
