import{s as Ne,o as Pe,n as gt}from"../chunks/scheduler.008aaf19.js";import{S as Ge,i as Ze,e as h,s as u,c as y,h as De,a as m,d as e,b as c,f as Me,g as T,j as f,k as ue,l as Ut,m as s,n as w,t as J,o as $,p as d}from"../chunks/index.7c7f75b2.js";import{C as E}from"../chunks/CodeBlock.027569b9.js";import{H as P,E as He}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.4f0ca956.js";import{H as he,a as dt}from"../chunks/HfOption.b44a1114.js";function Re(C){let a,M="For JavaScript, we need to install the <code>tiny-agents</code> package.",o,r,l;return r=new E({props:{code:"bnBtJTIwaW5zdGFsbCUyMCU0MGh1Z2dpbmdmYWNlJTJGdGlueS1hZ2VudHM=",highlighted:"npm install @huggingface/tiny-agents",wrap:!1}}),{c(){a=h("p"),a.innerHTML=M,o=u(),y(r.$$.fragment)},l(p){a=m(p,"P",{"data-svelte-h":!0}),f(a)!=="svelte-ge4g1p"&&(a.innerHTML=M),o=c(p),T(r.$$.fragment,p)},m(p,g){s(p,a,g),s(p,o,g),w(r,p,g),l=!0},p:gt,i(p){l||(J(r.$$.fragment,p),l=!0)},o(p){$(r.$$.fragment,p),l=!1},d(p){p&&(e(a),e(o)),d(r,p)}}}function Le(C){let a,M="For Python, you need to install the latest version of <code>huggingface_hub</code> with the <code>mcp</code> extra to get all the necessary components.",o,r,l;return r=new E({props:{code:"cGlwJTIwaW5zdGFsbCUyMCUyMmh1Z2dpbmdmYWNlX2h1YiU1Qm1jcCU1RCUzRSUzRDAuMzIuMCUyMg==",highlighted:'pip install <span class="hljs-string">&quot;huggingface_hub[mcp]&gt;=0.32.0&quot;</span>',wrap:!1}}),{c(){a=h("p"),a.innerHTML=M,o=u(),y(r.$$.fragment)},l(p){a=m(p,"P",{"data-svelte-h":!0}),f(a)!=="svelte-17v2whs"&&(a.innerHTML=M),o=c(p),T(r.$$.fragment,p)},m(p,g){s(p,a,g),s(p,o,g),w(r,p,g),l=!0},p:gt,i(p){l||(J(r.$$.fragment,p),l=!0)},o(p){$(r.$$.fragment,p),l=!1},d(p){p&&(e(a),e(o)),d(r,p)}}}function ze(C){let a,M,o,r;return a=new dt({props:{id:"tiny-agents",option:"typescript",$$slots:{default:[Re]},$$scope:{ctx:C}}}),o=new dt({props:{id:"tiny-agents",option:"python",$$slots:{default:[Le]},$$scope:{ctx:C}}}),{c(){y(a.$$.fragment),M=u(),y(o.$$.fragment)},l(l){T(a.$$.fragment,l),M=c(l),T(o.$$.fragment,l)},m(l,p){w(a,l,p),s(l,M,p),w(o,l,p),r=!0},p(l,p){const g={};p&2&&(g.$$scope={dirty:p,ctx:l}),a.$set(g);const U={};p&2&&(U.$$scope={dirty:p,ctx:l}),o.$set(U)},i(l){r||(J(a.$$.fragment,l),J(o.$$.fragment,l),r=!0)},o(l){$(a.$$.fragment,l),$(o.$$.fragment,l),r=!1},d(l){l&&e(M),d(a,l),d(o,l)}}}function Ye(C){let a,M="Let’s setup a project with a basic Tiny Agent.",o,r,l,p,g="The JSON file will look like this:",U,I,k,b,_="We can then run the agent with the following command:",A,v,q;return r=new E({props:{code:"bWtkaXIlMjBteS1hZ2VudCUwQXRvdWNoJTIwbXktYWdlbnQlMkZhZ2VudC5qc29uJTBBY2QlMjBteS1hZ2VudA==",highlighted:`<span class="hljs-built_in">mkdir</span> my-agent
<span class="hljs-built_in">touch</span> my-agent/agent.json
<span class="hljs-built_in">cd</span> my-agent`,wrap:!1}}),I=new E({props:{code:"JTdCJTBBJTA5JTIybW9kZWwlMjIlM0ElMjAlMjJRd2VuJTJGUXdlbjIuNS03MkItSW5zdHJ1Y3QlMjIlMkMlMEElMDklMjJwcm92aWRlciUyMiUzQSUyMCUyMm5lYml1cyUyMiUyQyUwQSUwOSUyMnNlcnZlcnMlMjIlM0ElMjAlNUIlMEElMDklMDklN0IlMEElMDklMDklMDklMjJ0eXBlJTIyJTNBJTIwJTIyc3RkaW8lMjIlMkMlMEElMDklMDklMDklMjJjb21tYW5kJTIyJTNBJTIwJTIybnB4JTIyJTJDJTBBJTA5JTA5JTA5JTIyYXJncyUyMiUzQSUyMCU1QiUwQSUwOSUwOSUwOSUwOSUyMm1jcC1yZW1vdGUlMjIlMkMlMEElMDklMDklMDklMDklMjJodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBNzg2MCUyRmdyYWRpb19hcGklMkZtY3AlMkZzc2UlMjIlMEElMDklMDklMDklNUQlMEElMDklMDklN0QlMEElMDklNUQlMEElN0Q=",highlighted:`<span class="hljs-punctuation">{</span>
	<span class="hljs-attr">&quot;model&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Qwen/Qwen2.5-72B-Instruct&quot;</span><span class="hljs-punctuation">,</span>
	<span class="hljs-attr">&quot;provider&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;nebius&quot;</span><span class="hljs-punctuation">,</span>
	<span class="hljs-attr">&quot;servers&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
		<span class="hljs-punctuation">{</span>
			<span class="hljs-attr">&quot;type&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;stdio&quot;</span><span class="hljs-punctuation">,</span>
			<span class="hljs-attr">&quot;command&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;npx&quot;</span><span class="hljs-punctuation">,</span>
			<span class="hljs-attr">&quot;args&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
				<span class="hljs-string">&quot;mcp-remote&quot;</span><span class="hljs-punctuation">,</span>
				<span class="hljs-string">&quot;http://localhost:7860/gradio_api/mcp/sse&quot;</span>
			<span class="hljs-punctuation">]</span>
		<span class="hljs-punctuation">}</span>
	<span class="hljs-punctuation">]</span>
<span class="hljs-punctuation">}</span>`,wrap:!1}}),v=new E({props:{code:"bnB4JTIwJTQwaHVnZ2luZ2ZhY2UlMkZ0aW55LWFnZW50cyUyMHJ1biUyMGFnZW50Lmpzb24=",highlighted:"npx @huggingface/tiny-agents run agent.json",wrap:!1}}),{c(){a=h("p"),a.textContent=M,o=u(),y(r.$$.fragment),l=u(),p=h("p"),p.textContent=g,U=u(),y(I.$$.fragment),k=u(),b=h("p"),b.textContent=_,A=u(),y(v.$$.fragment)},l(i){a=m(i,"P",{"data-svelte-h":!0}),f(a)!=="svelte-u3birs"&&(a.textContent=M),o=c(i),T(r.$$.fragment,i),l=c(i),p=m(i,"P",{"data-svelte-h":!0}),f(p)!=="svelte-17fg1qf"&&(p.textContent=g),U=c(i),T(I.$$.fragment,i),k=c(i),b=m(i,"P",{"data-svelte-h":!0}),f(b)!=="svelte-yk7odv"&&(b.textContent=_),A=c(i),T(v.$$.fragment,i)},m(i,j){s(i,a,j),s(i,o,j),w(r,i,j),s(i,l,j),s(i,p,j),s(i,U,j),w(I,i,j),s(i,k,j),s(i,b,j),s(i,A,j),w(v,i,j),q=!0},p:gt,i(i){q||(J(r.$$.fragment,i),J(I.$$.fragment,i),J(v.$$.fragment,i),q=!0)},o(i){$(r.$$.fragment,i),$(I.$$.fragment,i),$(v.$$.fragment,i),q=!1},d(i){i&&(e(a),e(o),e(l),e(p),e(U),e(k),e(b),e(A)),d(r,i),d(I,i),d(v,i)}}}function Oe(C){let a,M="Let’s setup a project with a basic Tiny Agent.",o,r,l,p,g="The JSON file will look like this:",U,I,k,b,_="We can then run the agent with the following command:",A,v,q;return r=new E({props:{code:"bWtkaXIlMjBteS1hZ2VudCUwQXRvdWNoJTIwbXktYWdlbnQlMkZhZ2VudC5qc29uJTBBY2QlMjBteS1hZ2VudA==",highlighted:`<span class="hljs-built_in">mkdir</span> my-agent
<span class="hljs-built_in">touch</span> my-agent/agent.json
<span class="hljs-built_in">cd</span> my-agent`,wrap:!1}}),I=new E({props:{code:"JTdCJTBBJTA5JTIybW9kZWwlMjIlM0ElMjAlMjJRd2VuJTJGUXdlbjIuNS03MkItSW5zdHJ1Y3QlMjIlMkMlMEElMDklMjJwcm92aWRlciUyMiUzQSUyMCUyMm5lYml1cyUyMiUyQyUwQSUwOSUyMnNlcnZlcnMlMjIlM0ElMjAlNUIlMEElMDklMDklN0IlMEElMDklMDklMDklMjJ0eXBlJTIyJTNBJTIwJTIyc3RkaW8lMjIlMkMlMEElMDklMDklMDklMjJjb21tYW5kJTIyJTNBJTIwJTIybnB4JTIyJTJDJTBBJTA5JTA5JTA5JTIyYXJncyUyMiUzQSUyMCU1QiUwQSUwOSUwOSUwOSUwOSUyMm1jcC1yZW1vdGUlMjIlMkMlMjAlMEElMDklMDklMDklMDklMjJodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBNzg2MCUyRmdyYWRpb19hcGklMkZtY3AlMkZzc2UlMjIlMEElMDklMDklMDklNUQlMEElMDklMDklN0QlMEElMDklNUQlMEElN0Q=",highlighted:`<span class="hljs-punctuation">{</span>
	<span class="hljs-attr">&quot;model&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Qwen/Qwen2.5-72B-Instruct&quot;</span><span class="hljs-punctuation">,</span>
	<span class="hljs-attr">&quot;provider&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;nebius&quot;</span><span class="hljs-punctuation">,</span>
	<span class="hljs-attr">&quot;servers&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
		<span class="hljs-punctuation">{</span>
			<span class="hljs-attr">&quot;type&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;stdio&quot;</span><span class="hljs-punctuation">,</span>
			<span class="hljs-attr">&quot;command&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;npx&quot;</span><span class="hljs-punctuation">,</span>
			<span class="hljs-attr">&quot;args&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
				<span class="hljs-string">&quot;mcp-remote&quot;</span><span class="hljs-punctuation">,</span> 
				<span class="hljs-string">&quot;http://localhost:7860/gradio_api/mcp/sse&quot;</span>
			<span class="hljs-punctuation">]</span>
		<span class="hljs-punctuation">}</span>
	<span class="hljs-punctuation">]</span>
<span class="hljs-punctuation">}</span>`,wrap:!1}}),v=new E({props:{code:"dGlueS1hZ2VudHMlMjBydW4lMjBhZ2VudC5qc29u",highlighted:"tiny-agents run agent.json",wrap:!1}}),{c(){a=h("p"),a.textContent=M,o=u(),y(r.$$.fragment),l=u(),p=h("p"),p.textContent=g,U=u(),y(I.$$.fragment),k=u(),b=h("p"),b.textContent=_,A=u(),y(v.$$.fragment)},l(i){a=m(i,"P",{"data-svelte-h":!0}),f(a)!=="svelte-u3birs"&&(a.textContent=M),o=c(i),T(r.$$.fragment,i),l=c(i),p=m(i,"P",{"data-svelte-h":!0}),f(p)!=="svelte-17fg1qf"&&(p.textContent=g),U=c(i),T(I.$$.fragment,i),k=c(i),b=m(i,"P",{"data-svelte-h":!0}),f(b)!=="svelte-yk7odv"&&(b.textContent=_),A=c(i),T(v.$$.fragment,i)},m(i,j){s(i,a,j),s(i,o,j),w(r,i,j),s(i,l,j),s(i,p,j),s(i,U,j),w(I,i,j),s(i,k,j),s(i,b,j),s(i,A,j),w(v,i,j),q=!0},p:gt,i(i){q||(J(r.$$.fragment,i),J(I.$$.fragment,i),J(v.$$.fragment,i),q=!0)},o(i){$(r.$$.fragment,i),$(I.$$.fragment,i),$(v.$$.fragment,i),q=!1},d(i){i&&(e(a),e(o),e(l),e(p),e(U),e(k),e(b),e(A)),d(r,i),d(I,i),d(v,i)}}}function Ve(C){let a,M,o,r;return a=new dt({props:{id:"tiny-agents",option:"typescript",$$slots:{default:[Ye]},$$scope:{ctx:C}}}),o=new dt({props:{id:"tiny-agents",option:"python",$$slots:{default:[Oe]},$$scope:{ctx:C}}}),{c(){y(a.$$.fragment),M=u(),y(o.$$.fragment)},l(l){T(a.$$.fragment,l),M=c(l),T(o.$$.fragment,l)},m(l,p){w(a,l,p),s(l,M,p),w(o,l,p),r=!0},p(l,p){const g={};p&2&&(g.$$scope={dirty:p,ctx:l}),a.$set(g);const U={};p&2&&(U.$$scope={dirty:p,ctx:l}),o.$set(U)},i(l){r||(J(a.$$.fragment,l),J(o.$$.fragment,l),r=!0)},o(l){$(a.$$.fragment,l),$(o.$$.fragment,l),r=!1},d(l){l&&e(M),d(a,l),d(o,l)}}}function Fe(C){let a,M;return a=new E({props:{code:"Y29uc3QlMjBhZ2VudCUyMCUzRCUyMG5ldyUyMEFnZW50KCU3QiUwQSUyMCUyMCUyMCUyMHByb3ZpZGVyJTNBJTIwcHJvY2Vzcy5lbnYuUFJPVklERVIlMjAlM0YlM0YlMjAlMjJuZWJpdXMlMjIlMkMlMEElMjAlMjAlMjAlMjBtb2RlbCUzQSUyMHByb2Nlc3MuZW52Lk1PREVMX0lEJTIwJTNGJTNGJTIwJTIyUXdlbiUyRlF3ZW4yLjUtNzJCLUluc3RydWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwYXBpS2V5JTNBJTIwcHJvY2Vzcy5lbnYuSEZfVE9LRU4lMkMlMEElMjAlMjAlMjAlMjBzZXJ2ZXJzJTNBJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTJGJTJGJTIwLi4uJTIwZXhpc3RpbmclMjBzZXJ2ZXJzJTIwLi4uJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwY29tbWFuZCUzQSUyMCUyMm5weCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGFyZ3MlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJtY3AtcmVtb3RlJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyaHR0cCUzQSUyRiUyRmxvY2FsaG9zdCUzQTc4NjAlMkZncmFkaW9fYXBpJTJGbWNwJTJGc3NlJTIyJTIwJTIwJTJGJTJGJTIwWW91ciUyMEdyYWRpbyUyME1DUCUyMHNlcnZlciUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSU3RCklM0I=",highlighted:`<span class="hljs-keyword">const</span> agent = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Agent</span>({
    <span class="hljs-attr">provider</span>: process.<span class="hljs-property">env</span>.<span class="hljs-property">PROVIDER</span> ?? <span class="hljs-string">&quot;nebius&quot;</span>,
    <span class="hljs-attr">model</span>: process.<span class="hljs-property">env</span>.<span class="hljs-property">MODEL_ID</span> ?? <span class="hljs-string">&quot;Qwen/Qwen2.5-72B-Instruct&quot;</span>,
    <span class="hljs-attr">apiKey</span>: process.<span class="hljs-property">env</span>.<span class="hljs-property">HF_TOKEN</span>,
    <span class="hljs-attr">servers</span>: [
        <span class="hljs-comment">// ... existing servers ...</span>
        {
            <span class="hljs-attr">command</span>: <span class="hljs-string">&quot;npx&quot;</span>,
            <span class="hljs-attr">args</span>: [
                <span class="hljs-string">&quot;mcp-remote&quot;</span>,
                <span class="hljs-string">&quot;http://localhost:7860/gradio_api/mcp/sse&quot;</span>  <span class="hljs-comment">// Your Gradio MCP server</span>
            ]
        }
    ],
});`,wrap:!1}}),{c(){y(a.$$.fragment)},l(o){T(a.$$.fragment,o)},m(o,r){w(a,o,r),M=!0},p:gt,i(o){M||(J(a.$$.fragment,o),M=!0)},o(o){$(a.$$.fragment,o),M=!1},d(o){d(a,o)}}}function Xe(C){let a,M;return a=new E({props:{code:"aW1wb3J0JTIwb3MlMEElMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwQWdlbnQlMEElMEFhZ2VudCUyMCUzRCUyMEFnZW50KCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIyUXdlbiUyRlF3ZW4yLjUtNzJCLUluc3RydWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwcHJvdmlkZXIlM0QlMjJuZWJpdXMlMjIlMkMlMEElMjAlMjAlMjAlMjBzZXJ2ZXJzJTNEJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY29tbWFuZCUyMiUzQSUyMCUyMm5weCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmFyZ3MlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJtY3AtcmVtb3RlJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyaHR0cCUzQSUyRiUyRmxvY2FsaG9zdCUzQTc4NjAlMkZncmFkaW9fYXBpJTJGbWNwJTJGc3NlJTIyJTIwJTIwJTIzJTIwWW91ciUyMEdyYWRpbyUyME1DUCUyMHNlcnZlciUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSk=",highlighted:`<span class="hljs-keyword">import</span> os

<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> Agent

agent = Agent(
    model=<span class="hljs-string">&quot;Qwen/Qwen2.5-72B-Instruct&quot;</span>,
    provider=<span class="hljs-string">&quot;nebius&quot;</span>,
    servers=[
        {
            <span class="hljs-string">&quot;command&quot;</span>: <span class="hljs-string">&quot;npx&quot;</span>,
            <span class="hljs-string">&quot;args&quot;</span>: [
                <span class="hljs-string">&quot;mcp-remote&quot;</span>,
                <span class="hljs-string">&quot;http://localhost:7860/gradio_api/mcp/sse&quot;</span>  <span class="hljs-comment"># Your Gradio MCP server</span>
            ]
        }
    ],
)`,wrap:!1}}),{c(){y(a.$$.fragment)},l(o){T(a.$$.fragment,o)},m(o,r){w(a,o,r),M=!0},p:gt,i(o){M||(J(a.$$.fragment,o),M=!0)},o(o){$(a.$$.fragment,o),M=!1},d(o){d(a,o)}}}function Ke(C){let a,M,o,r;return a=new dt({props:{id:"tiny-agents",option:"typescript",$$slots:{default:[Fe]},$$scope:{ctx:C}}}),o=new dt({props:{id:"tiny-agents",option:"python",$$slots:{default:[Xe]},$$scope:{ctx:C}}}),{c(){y(a.$$.fragment),M=u(),y(o.$$.fragment)},l(l){T(a.$$.fragment,l),M=c(l),T(o.$$.fragment,l)},m(l,p){w(a,l,p),s(l,M,p),w(o,l,p),r=!0},p(l,p){const g={};p&2&&(g.$$scope={dirty:p,ctx:l}),a.$set(g);const U={};p&2&&(U.$$scope={dirty:p,ctx:l}),o.$set(U)},i(l){r||(J(a.$$.fragment,l),J(o.$$.fragment,l),r=!0)},o(l){$(a.$$.fragment,l),$(o.$$.fragment,l),r=!1},d(l){l&&e(M),d(a,l),d(o,l)}}}function tn(C){let a,M,o,r,l,p,g,U='Now that we’ve built MCP servers in Gradio and learned about creating MCP clients, let’s complete our end-to-end application by building an agent that can seamlessly interact with our sentiment analysis tool. This section builds on the project <a href="https://huggingface.co/blog/tiny-agents" rel="nofollow">Tiny Agents</a>, which demonstrates a super simple way of deploying MCP clients that can connect to services like our Gradio sentiment analysis server.',I,k,b="In this final exercise of Unit 2, we will walk you through how to implement both TypeScript (JS) and Python MCP clients that can communicate with any MCP server, including the Gradio-based sentiment analysis server we built in the previous sections. This completes our end-to-end MCP application flow: from building a Gradio MCP server exposing a sentiment analysis tool, to creating a flexible agent that can use this tool alongside other capabilities.",_,A,v='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/tiny-agents/thumbnail.jpg" alt="meme"/>',q,i,j="Image credit https://x.com/adamdotdev",Ct,G,It,Z,me="Let’s install the necessary packages to build our Tiny Agents.",bt,S,fe='<p>Some MCP Clients, notably Claude Desktop, do not yet support SSE-based MCP Servers. In those cases, you can use a tool such as <a href="https://github.com/geelen/mcp-remote" rel="nofollow">mcp-remote</a>. First install Node.js. Then, add the following to your own MCP Client config:</p>',vt,D,ye="Tiny Agent can run MCP servers with a command line environment. To do this, we will need to install <code>npm</code> and run the server with <code>npx</code>. <strong>We’ll need these for both Python and JavaScript.</strong>",kt,H,Te='Let’s install <code>npx</code> with <code>npm</code>. If you don’t have <code>npm</code> installed, check out the <a href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm" rel="nofollow">npm documentation</a>.',At,R,qt,L,we="Then, we need to install the <code>mcp-remote</code> package.",Et,z,xt,Q,_t,Y,Bt,O,Je='Let’s repeat the example from <a href="https://huggingface.co/learn/mcp-course/unit1/mcp-clients#tiny-agents-clients" rel="nofollow">Unit 1</a> to create a basic Tiny Agent. Tiny Agents can create MCP clients from the command line based on JSON configuration files.',St,W,Qt,V,$e="Here we have a basic Tiny Agent that can connect to our Gradio MCP server. It includes a model, provider, and a server configuration.",Wt,F,de="<thead><tr><th>Field</th> <th>Description</th></tr></thead> <tbody><tr><td><code>model</code></td> <td>The open source model to use for the agent</td></tr> <tr><td><code>provider</code></td> <td>The inference provider to use for the agent</td></tr> <tr><td><code>servers</code></td> <td>The servers to use for the agent. We’ll use the <code>mcp-remote</code> server for our Gradio MCP server.</td></tr></tbody>",Nt,x,Jt,ge="We could also use an open source model running locally with Tiny Agents. If we start a local inference server with",ce,X,re,$t,je="Here we have a Tiny Agent that can connect to a local model. It includes a model, endpoint URL (<code>http://localhost:1234/v1</code>), and a server configuration. The endpoint should be an OpenAI-compatible endpoint.",Pt,K,Gt,tt,Ue="Now that we understand both Tiny Agents and Gradio MCP servers, let’s see how they work together! The beauty of MCP is that it provides a standardized way for agents to interact with any MCP-compatible server, including our Gradio-based sentiment analysis server from earlier sections.",Zt,et,Dt,nt,Ce="To connect our Tiny Agent to the Gradio sentiment analysis server we built earlier in this unit, we just need to add it to our list of servers. Here’s how we can modify our agent configuration:",Ht,N,Rt,st,Ie="Now our agent can use the sentiment analysis tool alongside other tools! For example, it could:",Lt,lt,be="<li>Read text from a file using the filesystem server</li> <li>Analyze its sentiment using our Gradio server</li> <li>Write the results back to a file</li>",zt,at,Yt,it,ve="When deploying your Gradio MCP server to Hugging Face Spaces, you’ll need to update the server URL in your agent configuration to point to your deployed space:",Ot,pt,Vt,ot,ke="This allows your agent to use the sentiment analysis tool from anywhere, not just locally!",Ft,ut,Xt,ct,Ae="In this unit, we’ve gone from understanding MCP basics to building a complete end-to-end application:",Kt,rt,qe="<li>We created a Gradio MCP server that exposes a sentiment analysis tool</li> <li>We learned how to connect to this server using MCP clients</li> <li>We built a tiny agent in TypeScript and Python that can interact with our tool</li>",te,Mt,Ee="This demonstrates the power of the Model Context Protocol - we can create specialized tools using frameworks we’re familiar with (like Gradio), expose them through a standardized interface (MCP), and then have agents seamlessly use these tools alongside other capabilities.",ee,ht,xe="The complete flow we’ve built allows an agent to:",ne,mt,_e="<li>Connect to multiple tool providers</li> <li>Dynamically discover available tools</li> <li>Use our custom sentiment analysis tool</li> <li>Combine it with other capabilities like file system access and web browsing</li>",se,ft,Be="This modular approach is what makes MCP so powerful for building flexible AI applications.",le,yt,ae,Tt,Se='<li>Check out the Tiny Agents blog posts in <a href="https://huggingface.co/blog/python-tiny-agents" rel="nofollow">Python</a> and <a href="https://huggingface.co/blog/tiny-agents" rel="nofollow">TypeScript</a></li> <li>Review the <a href="https://huggingface.co/docs/huggingface.js/main/en/tiny-agents/README" rel="nofollow">Tiny Agents documentation</a></li> <li>Build something with Tiny Agents!</li>',ie,wt,pe,jt,oe;return l=new P({props:{title:"Building Tiny Agents with MCP and the Hugging Face Hub",local:"building-tiny-agents-with-mcp-and-the-hugging-face-hub",headingTag:"h1"}}),G=new P({props:{title:"Installation",local:"installation",headingTag:"h2"}}),R=new E({props:{code:"JTIzJTIwaW5zdGFsbCUyMG5weCUwQW5wbSUyMGluc3RhbGwlMjAtZyUyMG5weA==",highlighted:`<span class="hljs-comment"># install npx</span>
npm install -g npx`,wrap:!1}}),z=new E({props:{code:"bnBtJTIwaSUyMG1jcC1yZW1vdGU=",highlighted:"npm i mcp-remote",wrap:!1}}),Q=new he({props:{id:"tiny-agents",options:["typescript","python"],$$slots:{default:[ze]},$$scope:{ctx:C}}}),Y=new P({props:{title:"Tiny Agents MCP Client in the Command Line",local:"tiny-agents-mcp-client-in-the-command-line",headingTag:"h2"}}),W=new he({props:{id:"tiny-agents",options:["typescript","python"],$$slots:{default:[Ve]},$$scope:{ctx:C}}}),X=new E({props:{code:"JTdCJTBBJTA5JTIybW9kZWwlMjIlM0ElMjAlMjJRd2VuJTJGUXdlbjMtMzJCJTIyJTJDJTBBJTA5JTIyZW5kcG9pbnRVcmwlMjIlM0ElMjAlMjJodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBMTIzNCUyRnYxJTIyJTJDJTBBJTA5JTIyc2VydmVycyUyMiUzQSUyMCU1QiUwQSUwOSUwOSU3QiUwQSUwOSUwOSUwOSUyMnR5cGUlMjIlM0ElMjAlMjJzdGRpbyUyMiUyQyUwQSUwOSUwOSUwOSUyMmNvbW1hbmQlMjIlM0ElMjAlMjJucHglMjIlMkMlMEElMDklMDklMDklMjJhcmdzJTIyJTNBJTIwJTVCJTBBJTA5JTA5JTA5JTA5JTIybWNwLXJlbW90ZSUyMiUyQyUwQSUwOSUwOSUwOSUwOSUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0ExMjM0JTJGdjElMkZtY3AlMkZzc2UlMjIlMEElMDklMDklMDklNUQlMEElMDklMDklN0QlMEElMDklNUQlMEElN0Q=",highlighted:`<span class="hljs-punctuation">{</span>
	<span class="hljs-attr">&quot;model&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Qwen/Qwen3-32B&quot;</span><span class="hljs-punctuation">,</span>
	<span class="hljs-attr">&quot;endpointUrl&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;http://localhost:1234/v1&quot;</span><span class="hljs-punctuation">,</span>
	<span class="hljs-attr">&quot;servers&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
		<span class="hljs-punctuation">{</span>
			<span class="hljs-attr">&quot;type&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;stdio&quot;</span><span class="hljs-punctuation">,</span>
			<span class="hljs-attr">&quot;command&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;npx&quot;</span><span class="hljs-punctuation">,</span>
			<span class="hljs-attr">&quot;args&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
				<span class="hljs-string">&quot;mcp-remote&quot;</span><span class="hljs-punctuation">,</span>
				<span class="hljs-string">&quot;http://localhost:1234/v1/mcp/sse&quot;</span>
			<span class="hljs-punctuation">]</span>
		<span class="hljs-punctuation">}</span>
	<span class="hljs-punctuation">]</span>
<span class="hljs-punctuation">}</span>`,wrap:!1}}),K=new P({props:{title:"Custom Tiny Agents MCP Client",local:"custom-tiny-agents-mcp-client",headingTag:"h2"}}),et=new P({props:{title:"Using the Gradio Server with Tiny Agents",local:"using-the-gradio-server-with-tiny-agents",headingTag:"h3"}}),N=new he({props:{id:"tiny-agents",options:["typescript","python"],$$slots:{default:[Ke]},$$scope:{ctx:C}}}),at=new P({props:{title:"Deployment Considerations",local:"deployment-considerations",headingTag:"h3"}}),pt=new E({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwY29tbWFuZCUzQSUyMCUyMm5weCUyMiUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJtY3AtcmVtb3RlJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZZT1VSX1VTRVJOQU1FLW1jcC1zZW50aW1lbnQuaGYuc3BhY2UlMkZncmFkaW9fYXBpJTJGbWNwJTJGc3NlJTIyJTBBJTIwJTIwJTIwJTIwJTVEJTBBJTdE",highlighted:`<span class="hljs-punctuation">{</span>
    command<span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;npx&quot;</span><span class="hljs-punctuation">,</span>
    args<span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
        <span class="hljs-string">&quot;mcp-remote&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-string">&quot;https://YOUR_USERNAME-mcp-sentiment.hf.space/gradio_api/mcp/sse&quot;</span>
    <span class="hljs-punctuation">]</span>
<span class="hljs-punctuation">}</span>`,wrap:!1}}),ut=new P({props:{title:"Conclusion: Our Complete End-to-End MCP Application",local:"conclusion-our-complete-end-to-end-mcp-application",headingTag:"h2"}}),yt=new P({props:{title:"Next Steps",local:"next-steps",headingTag:"h2"}}),wt=new He({props:{source:"https://github.com/huggingface/mcp-course/blob/main/units/en/unit2/tiny-agents.mdx"}}),{c(){a=h("meta"),M=u(),o=h("p"),r=u(),y(l.$$.fragment),p=u(),g=h("p"),g.innerHTML=U,I=u(),k=h("p"),k.textContent=b,_=u(),A=h("p"),A.innerHTML=v,q=u(),i=h("figcaption"),i.textContent=j,Ct=u(),y(G.$$.fragment),It=u(),Z=h("p"),Z.textContent=me,bt=u(),S=h("blockquote"),S.innerHTML=fe,vt=u(),D=h("p"),D.innerHTML=ye,kt=u(),H=h("p"),H.innerHTML=Te,At=u(),y(R.$$.fragment),qt=u(),L=h("p"),L.innerHTML=we,Et=u(),y(z.$$.fragment),xt=u(),y(Q.$$.fragment),_t=u(),y(Y.$$.fragment),Bt=u(),O=h("p"),O.innerHTML=Je,St=u(),y(W.$$.fragment),Qt=u(),V=h("p"),V.textContent=$e,Wt=u(),F=h("table"),F.innerHTML=de,Nt=u(),x=h("blockquote"),Jt=h("p"),Jt.textContent=ge,ce=u(),y(X.$$.fragment),re=u(),$t=h("p"),$t.innerHTML=je,Pt=u(),y(K.$$.fragment),Gt=u(),tt=h("p"),tt.textContent=Ue,Zt=u(),y(et.$$.fragment),Dt=u(),nt=h("p"),nt.textContent=Ce,Ht=u(),y(N.$$.fragment),Rt=u(),st=h("p"),st.textContent=Ie,Lt=u(),lt=h("ol"),lt.innerHTML=be,zt=u(),y(at.$$.fragment),Yt=u(),it=h("p"),it.textContent=ve,Ot=u(),y(pt.$$.fragment),Vt=u(),ot=h("p"),ot.textContent=ke,Ft=u(),y(ut.$$.fragment),Xt=u(),ct=h("p"),ct.textContent=Ae,Kt=u(),rt=h("ol"),rt.innerHTML=qe,te=u(),Mt=h("p"),Mt.textContent=Ee,ee=u(),ht=h("p"),ht.textContent=xe,ne=u(),mt=h("ul"),mt.innerHTML=_e,se=u(),ft=h("p"),ft.textContent=Be,le=u(),y(yt.$$.fragment),ae=u(),Tt=h("ul"),Tt.innerHTML=Se,ie=u(),y(wt.$$.fragment),pe=u(),jt=h("p"),this.h()},l(t){const n=De("svelte-u9bgzb",document.head);a=m(n,"META",{name:!0,content:!0}),n.forEach(e),M=c(t),o=m(t,"P",{}),Me(o).forEach(e),r=c(t),T(l.$$.fragment,t),p=c(t),g=m(t,"P",{"data-svelte-h":!0}),f(g)!=="svelte-1i2mofa"&&(g.innerHTML=U),I=c(t),k=m(t,"P",{"data-svelte-h":!0}),f(k)!=="svelte-17erzb7"&&(k.textContent=b),_=c(t),A=m(t,"P",{"data-svelte-h":!0}),f(A)!=="svelte-1c6ln2u"&&(A.innerHTML=v),q=c(t),i=m(t,"FIGCAPTION",{"data-svelte-h":!0}),f(i)!=="svelte-1m426zi"&&(i.textContent=j),Ct=c(t),T(G.$$.fragment,t),It=c(t),Z=m(t,"P",{"data-svelte-h":!0}),f(Z)!=="svelte-zbqr5w"&&(Z.textContent=me),bt=c(t),S=m(t,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(S)!=="svelte-13s9ono"&&(S.innerHTML=fe),vt=c(t),D=m(t,"P",{"data-svelte-h":!0}),f(D)!=="svelte-cm95y3"&&(D.innerHTML=ye),kt=c(t),H=m(t,"P",{"data-svelte-h":!0}),f(H)!=="svelte-fmiuqb"&&(H.innerHTML=Te),At=c(t),T(R.$$.fragment,t),qt=c(t),L=m(t,"P",{"data-svelte-h":!0}),f(L)!=="svelte-1my26py"&&(L.innerHTML=we),Et=c(t),T(z.$$.fragment,t),xt=c(t),T(Q.$$.fragment,t),_t=c(t),T(Y.$$.fragment,t),Bt=c(t),O=m(t,"P",{"data-svelte-h":!0}),f(O)!=="svelte-1kp4tvd"&&(O.innerHTML=Je),St=c(t),T(W.$$.fragment,t),Qt=c(t),V=m(t,"P",{"data-svelte-h":!0}),f(V)!=="svelte-1rwqp6x"&&(V.textContent=$e),Wt=c(t),F=m(t,"TABLE",{"data-svelte-h":!0}),f(F)!=="svelte-1t9o7a9"&&(F.innerHTML=de),Nt=c(t),x=m(t,"BLOCKQUOTE",{class:!0});var B=Me(x);Jt=m(B,"P",{"data-svelte-h":!0}),f(Jt)!=="svelte-zc6kf8"&&(Jt.textContent=ge),ce=c(B),T(X.$$.fragment,B),re=c(B),$t=m(B,"P",{"data-svelte-h":!0}),f($t)!=="svelte-wmyadc"&&($t.innerHTML=je),B.forEach(e),Pt=c(t),T(K.$$.fragment,t),Gt=c(t),tt=m(t,"P",{"data-svelte-h":!0}),f(tt)!=="svelte-199v3jp"&&(tt.textContent=Ue),Zt=c(t),T(et.$$.fragment,t),Dt=c(t),nt=m(t,"P",{"data-svelte-h":!0}),f(nt)!=="svelte-j3rusv"&&(nt.textContent=Ce),Ht=c(t),T(N.$$.fragment,t),Rt=c(t),st=m(t,"P",{"data-svelte-h":!0}),f(st)!=="svelte-1yuwy1b"&&(st.textContent=Ie),Lt=c(t),lt=m(t,"OL",{"data-svelte-h":!0}),f(lt)!=="svelte-1bb9kd9"&&(lt.innerHTML=be),zt=c(t),T(at.$$.fragment,t),Yt=c(t),it=m(t,"P",{"data-svelte-h":!0}),f(it)!=="svelte-1s79p96"&&(it.textContent=ve),Ot=c(t),T(pt.$$.fragment,t),Vt=c(t),ot=m(t,"P",{"data-svelte-h":!0}),f(ot)!=="svelte-7f5u21"&&(ot.textContent=ke),Ft=c(t),T(ut.$$.fragment,t),Xt=c(t),ct=m(t,"P",{"data-svelte-h":!0}),f(ct)!=="svelte-1nbw8nf"&&(ct.textContent=Ae),Kt=c(t),rt=m(t,"OL",{"data-svelte-h":!0}),f(rt)!=="svelte-z5piv3"&&(rt.innerHTML=qe),te=c(t),Mt=m(t,"P",{"data-svelte-h":!0}),f(Mt)!=="svelte-1oh8l42"&&(Mt.textContent=Ee),ee=c(t),ht=m(t,"P",{"data-svelte-h":!0}),f(ht)!=="svelte-abb6o5"&&(ht.textContent=xe),ne=c(t),mt=m(t,"UL",{"data-svelte-h":!0}),f(mt)!=="svelte-vpq8ia"&&(mt.innerHTML=_e),se=c(t),ft=m(t,"P",{"data-svelte-h":!0}),f(ft)!=="svelte-wtf0dm"&&(ft.textContent=Be),le=c(t),T(yt.$$.fragment,t),ae=c(t),Tt=m(t,"UL",{"data-svelte-h":!0}),f(Tt)!=="svelte-hdhkgk"&&(Tt.innerHTML=Se),ie=c(t),T(wt.$$.fragment,t),pe=c(t),jt=m(t,"P",{}),Me(jt).forEach(e),this.h()},h(){ue(a,"name","hf:doc:metadata"),ue(a,"content",en),ue(S,"class","tip"),ue(x,"class","tip")},m(t,n){Ut(document.head,a),s(t,M,n),s(t,o,n),s(t,r,n),w(l,t,n),s(t,p,n),s(t,g,n),s(t,I,n),s(t,k,n),s(t,_,n),s(t,A,n),s(t,q,n),s(t,i,n),s(t,Ct,n),w(G,t,n),s(t,It,n),s(t,Z,n),s(t,bt,n),s(t,S,n),s(t,vt,n),s(t,D,n),s(t,kt,n),s(t,H,n),s(t,At,n),w(R,t,n),s(t,qt,n),s(t,L,n),s(t,Et,n),w(z,t,n),s(t,xt,n),w(Q,t,n),s(t,_t,n),w(Y,t,n),s(t,Bt,n),s(t,O,n),s(t,St,n),w(W,t,n),s(t,Qt,n),s(t,V,n),s(t,Wt,n),s(t,F,n),s(t,Nt,n),s(t,x,n),Ut(x,Jt),Ut(x,ce),w(X,x,null),Ut(x,re),Ut(x,$t),s(t,Pt,n),w(K,t,n),s(t,Gt,n),s(t,tt,n),s(t,Zt,n),w(et,t,n),s(t,Dt,n),s(t,nt,n),s(t,Ht,n),w(N,t,n),s(t,Rt,n),s(t,st,n),s(t,Lt,n),s(t,lt,n),s(t,zt,n),w(at,t,n),s(t,Yt,n),s(t,it,n),s(t,Ot,n),w(pt,t,n),s(t,Vt,n),s(t,ot,n),s(t,Ft,n),w(ut,t,n),s(t,Xt,n),s(t,ct,n),s(t,Kt,n),s(t,rt,n),s(t,te,n),s(t,Mt,n),s(t,ee,n),s(t,ht,n),s(t,ne,n),s(t,mt,n),s(t,se,n),s(t,ft,n),s(t,le,n),w(yt,t,n),s(t,ae,n),s(t,Tt,n),s(t,ie,n),w(wt,t,n),s(t,pe,n),s(t,jt,n),oe=!0},p(t,[n]){const B={};n&2&&(B.$$scope={dirty:n,ctx:t}),Q.$set(B);const Qe={};n&2&&(Qe.$$scope={dirty:n,ctx:t}),W.$set(Qe);const We={};n&2&&(We.$$scope={dirty:n,ctx:t}),N.$set(We)},i(t){oe||(J(l.$$.fragment,t),J(G.$$.fragment,t),J(R.$$.fragment,t),J(z.$$.fragment,t),J(Q.$$.fragment,t),J(Y.$$.fragment,t),J(W.$$.fragment,t),J(X.$$.fragment,t),J(K.$$.fragment,t),J(et.$$.fragment,t),J(N.$$.fragment,t),J(at.$$.fragment,t),J(pt.$$.fragment,t),J(ut.$$.fragment,t),J(yt.$$.fragment,t),J(wt.$$.fragment,t),oe=!0)},o(t){$(l.$$.fragment,t),$(G.$$.fragment,t),$(R.$$.fragment,t),$(z.$$.fragment,t),$(Q.$$.fragment,t),$(Y.$$.fragment,t),$(W.$$.fragment,t),$(X.$$.fragment,t),$(K.$$.fragment,t),$(et.$$.fragment,t),$(N.$$.fragment,t),$(at.$$.fragment,t),$(pt.$$.fragment,t),$(ut.$$.fragment,t),$(yt.$$.fragment,t),$(wt.$$.fragment,t),oe=!1},d(t){t&&(e(M),e(o),e(r),e(p),e(g),e(I),e(k),e(_),e(A),e(q),e(i),e(Ct),e(It),e(Z),e(bt),e(S),e(vt),e(D),e(kt),e(H),e(At),e(qt),e(L),e(Et),e(xt),e(_t),e(Bt),e(O),e(St),e(Qt),e(V),e(Wt),e(F),e(Nt),e(x),e(Pt),e(Gt),e(tt),e(Zt),e(Dt),e(nt),e(Ht),e(Rt),e(st),e(Lt),e(lt),e(zt),e(Yt),e(it),e(Ot),e(Vt),e(ot),e(Ft),e(Xt),e(ct),e(Kt),e(rt),e(te),e(Mt),e(ee),e(ht),e(ne),e(mt),e(se),e(ft),e(le),e(ae),e(Tt),e(ie),e(pe),e(jt)),e(a),d(l,t),d(G,t),d(R,t),d(z,t),d(Q,t),d(Y,t),d(W,t),d(X),d(K,t),d(et,t),d(N,t),d(at,t),d(pt,t),d(ut,t),d(yt,t),d(wt,t)}}}const en='{"title":"Building Tiny Agents with MCP and the Hugging Face Hub","local":"building-tiny-agents-with-mcp-and-the-hugging-face-hub","sections":[{"title":"Installation","local":"installation","sections":[],"depth":2},{"title":"Tiny Agents MCP Client in the Command Line","local":"tiny-agents-mcp-client-in-the-command-line","sections":[],"depth":2},{"title":"Custom Tiny Agents MCP Client","local":"custom-tiny-agents-mcp-client","sections":[{"title":"Using the Gradio Server with Tiny Agents","local":"using-the-gradio-server-with-tiny-agents","sections":[],"depth":3},{"title":"Deployment Considerations","local":"deployment-considerations","sections":[],"depth":3}],"depth":2},{"title":"Conclusion: Our Complete End-to-End MCP Application","local":"conclusion-our-complete-end-to-end-mcp-application","sections":[],"depth":2},{"title":"Next Steps","local":"next-steps","sections":[],"depth":2}],"depth":1}';function nn(C){return Pe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class un extends Ge{constructor(a){super(),Ze(this,a,nn,tn,Ne,{})}}export{un as component};
