<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zebu Data</title>
    <description>The latest articles on DEV Community by Zebu Data (@zebudata).</description>
    <link>https://dev.to/zebudata</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4157425%2F95e1b06e-6f59-4f46-8ecd-1c938681e79d.jpg</url>
      <title>DEV Community: Zebu Data</title>
      <link>https://dev.to/zebudata</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zebudata"/>
    <language>en</language>
    <item>
      <title>Our 43 MCP tools cost 202k tokens before a single call</title>
      <dc:creator>Zebu Data</dc:creator>
      <pubDate>Sat, 21 Nov 2026 13:54:35 +0000</pubDate>
      <link>https://dev.to/zebudata/our-43-mcp-tools-cost-202k-tokens-before-a-single-call-13k3</link>
      <guid>https://dev.to/zebudata/our-43-mcp-tools-cost-202k-tokens-before-a-single-call-13k3</guid>
      <description>&lt;p&gt;We build and run 43 public scrapers, and every one of them can be exposed to an agent as an MCP tool through a single endpoint. We had split them into seven themed bundles early on, mostly on instinct. Last week we finally measured what that decision was worth.&lt;/p&gt;

&lt;p&gt;Listing all 43 tools returns 809,618 characters of JSON. At roughly four characters per token, that is about 202,000 tokens of tool definitions, sitting in the context before the agent reads the user's first message. One themed bundle of seven tools returns 107,657 characters, about 27,000 tokens.&lt;/p&gt;

&lt;p&gt;The number that surprised us was not the total. It was the per-tool cost: about 19,500 characters, or 4,900 tokens, for every scraper we added to the list.&lt;/p&gt;

&lt;h2&gt;
  
  
  How we measured it
&lt;/h2&gt;

&lt;p&gt;An MCP server over streamable HTTP takes three requests: &lt;code&gt;initialize&lt;/code&gt;, an &lt;code&gt;initialized&lt;/code&gt; notification carrying the session id the server handed back, then &lt;code&gt;tools/list&lt;/code&gt;. Responses come back as SSE frames, so the JSON sits behind a &lt;code&gt;data:&lt;/code&gt; prefix.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;

&lt;span class="no"&gt;TOKEN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"APIFY_TOKEN"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;want_headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;hdr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Authorization: Bearer {TOKEN}\n"&lt;/span&gt;
           &lt;span class="s2"&gt;"Content-Type: application/json\n"&lt;/span&gt;
           &lt;span class="s2"&gt;"Accept: application/json, text/event-stream\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;hdr&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"mcp-session-id: {sid}\n"&lt;/span&gt;
    &lt;span class="n"&gt;cmd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"curl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-sS"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-X"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-H"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"@-"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="s2"&gt;"--data-binary"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;want_headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-D"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/dev/stderr"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;hdr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;capture_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tools_of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;init&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"jsonrpc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"method"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"initialize"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"params"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"protocolVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2025-06-18"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"capabilities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"clientInfo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"probe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;want_headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;sid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"(?i)^mcp-session-id:\s*(\S+)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;M&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"jsonrpc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"method"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"notifications/initialized"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"jsonrpc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"method"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"tools/list"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splitlines&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"data: "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"result"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"tools"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;tools&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;tools_of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://mcp.apify.com/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;blob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;separators&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;","&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The endpoint we tested is &lt;code&gt;mcp.apify.com&lt;/code&gt;, which takes a &lt;code&gt;?tools=&lt;/code&gt; query parameter naming which scrapers to expose. Any MCP server will answer &lt;code&gt;tools/list&lt;/code&gt; the same way, so the same probe works elsewhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  What came back
&lt;/h2&gt;

&lt;p&gt;Three runs on 2026-11-21, same endpoint, same account:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What we asked for&lt;/th&gt;
&lt;th&gt;Tools returned&lt;/th&gt;
&lt;th&gt;Characters&lt;/th&gt;
&lt;th&gt;Approx. tokens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;No &lt;code&gt;tools&lt;/code&gt; parameter&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;td&gt;71,789&lt;/td&gt;
&lt;td&gt;17,900&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;One themed bundle (7 scrapers)&lt;/td&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;td&gt;107,657&lt;/td&gt;
&lt;td&gt;26,900&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;All 43 scrapers&lt;/td&gt;
&lt;td&gt;47&lt;/td&gt;
&lt;td&gt;809,618&lt;/td&gt;
&lt;td&gt;202,400&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two things in that table need explaining before the numbers mean anything.&lt;/p&gt;

&lt;p&gt;The tool counts do not match the scraper counts. With no &lt;code&gt;tools&lt;/code&gt; parameter the server returns its own 15 generic helpers, none of which are our scrapers. Once you name specific tools, that generic set shrinks to four, so the bundle row is 7 scrapers plus 4 helpers, and the full row is 43 plus 4. We only noticed because the arithmetic refused to work.&lt;/p&gt;

&lt;p&gt;That also means the first row is not a baseline for the other two. It is a different tool set, not a smaller one, which is why it has more tools and fewer characters than the bundle row. The comparison that holds is between rows two and three, where the generic helpers are identical and the only difference is 36 more scrapers. That difference is 701,961 characters, or 19,499 per scraper.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a schema costs that much
&lt;/h2&gt;

&lt;p&gt;A scraper's tool definition is its input schema. Ours carry a search term, a country, a result limit, date filters, sort order, and for the larger ones a dozen optional fields with enums and per-field descriptions written for humans. That is a few hundred lines of JSON Schema each, and it is all useful when the agent is choosing arguments.&lt;/p&gt;

&lt;p&gt;It is only waste when the agent was never going to call that tool. An agent asked to pull reviews for one product carries the full argument surface of 42 scrapers it will not touch, and on a model with a 200,000-token context window, the tool list alone no longer fits.&lt;/p&gt;

&lt;h2&gt;
  
  
  How we split them
&lt;/h2&gt;

&lt;p&gt;Seven bundles, 2 to 8 tools each, covering 36 of the 43 scrapers. The seven that are in no bundle are ones we have not found a coherent home for yet.&lt;/p&gt;

&lt;p&gt;What we got wrong at first was the axis. The obvious split is by data source: one bundle per site. The split that works is by the job the user is doing. Our reviews bundle reaches across seven different sites, because someone comparing customer sentiment wants reviews, and does not care that they live on seven platforms. Our local-business bundle mixes a maps scraper with three directory scrapers for the same reason.&lt;/p&gt;

&lt;p&gt;Splitting by site would have produced a dozen bundles of one or two tools each, and an agent would need three of them to answer most real questions. Splitting by job keeps the common case inside one bundle.&lt;/p&gt;

&lt;p&gt;Two rules fell out of that:&lt;/p&gt;

&lt;p&gt;Keep a bundle under about ten tools. Past that the schemas add up to something the model has to read on every turn, and the bundle starts covering more than one job anyway.&lt;/p&gt;

&lt;p&gt;Let tools appear in more than one bundle. Our review scrapers for two marketplaces sit in both the reviews bundle and their regional commerce bundle. Duplication across bundles costs nothing at runtime, because no agent loads two bundles at once, and it keeps each bundle self-sufficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we would check on any MCP server
&lt;/h2&gt;

&lt;p&gt;Measure the &lt;code&gt;tools/list&lt;/code&gt; response rather than counting tools. Two tools with the same name can differ by an order of magnitude in schema size.&lt;/p&gt;

&lt;p&gt;Compare like with like. Servers add their own helpers, and those helpers change depending on what you ask for.&lt;/p&gt;

&lt;p&gt;Work out the marginal cost of one more tool. On our server it is about 4,900 tokens, which makes the question of whether a tool belongs in a bundle answerable rather than aesthetic.&lt;/p&gt;

&lt;p&gt;Group by the user's task, not by your data sources. Your internal structure is rarely the structure of the question being asked.&lt;/p&gt;

&lt;p&gt;One caveat on the numbers above: we estimated tokens at four characters each rather than running a tokenizer, so treat them as the right order of magnitude and not as exact. The character counts are measured. We also have not tested whether a shorter tool list makes an agent pick the right tool more often. That seems likely, but we have not measured it, so we are not claiming it.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Drafted with AI assistance; the numbers and traces come from our own runs and were checked by us.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>ai</category>
      <category>agents</category>
    </item>
    <item>
      <title>Our scraper stored 20 links per page and kept every page in memory</title>
      <dc:creator>Zebu Data</dc:creator>
      <pubDate>Sun, 08 Nov 2026 13:10:27 +0000</pubDate>
      <link>https://dev.to/zebudata/our-scraper-stored-20-links-per-page-and-kept-every-page-in-memory-325c</link>
      <guid>https://dev.to/zebudata/our-scraper-stored-20-links-per-page-and-kept-every-page-in-memory-325c</guid>
      <description>&lt;p&gt;We build and maintain web scrapers that run for hours at a time. In October one of them ran out of memory, and the cause was a detail of lxml that we had skimmed past in its docs.&lt;/p&gt;

&lt;p&gt;The crawler walked the listing pages of a large online store, about 4 MB of HTML each. On every page it ran a few &lt;code&gt;xpath()&lt;/code&gt; queries, pushed the item links into a queue, and dropped the parsed tree. On a store with about 46,000 listings, memory went from about 100 MB to 3,010 MB, and runs with a 1 GB limit were killed.&lt;/p&gt;

&lt;p&gt;The links were the problem. &lt;code&gt;xpath()&lt;/code&gt; returns "smart strings" that hold a reference to the element they came from, so every queued link kept its whole page tree alive, at about 12.6 MB per page. Adding &lt;code&gt;smart_strings=False&lt;/code&gt; to those calls kept the same crawl at about 100 MB from start to finish.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does xpath() actually return?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;lxml&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;

&lt;span class="n"&gt;tree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromstring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;a href=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/item/1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;gt;Item&amp;lt;/a&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//a/@href&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# _ElementUnicodeResult
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getparent&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;     &lt;span class="c1"&gt;# &amp;lt;Element a at 0x...&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;_ElementUnicodeResult&lt;/code&gt; is a subclass of &lt;code&gt;str&lt;/code&gt;. It prints, compares and hashes like a normal string, so nothing in a crawler looks wrong. It also has &lt;code&gt;getparent()&lt;/code&gt;, which means it holds a reference to its element, and the element keeps its document alive. The lxml docs are direct about the cost: "the tree will be kept alive by the string" (&lt;a href="https://lxml.de/xpathxslt.html#xpath-return-values" rel="noopener noreferrer"&gt;XPath return values&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;While you are still working on the page, that costs nothing extra. It turns into a leak once the string goes somewhere that outlives the page: a crawl queue, a set of seen URLs, a dict of results.&lt;/p&gt;

&lt;h2&gt;
  
  
  How much memory does one kept string cost?
&lt;/h2&gt;

&lt;p&gt;To check this away from our crawler, we wrote a short benchmark script. Each page is a synthetic HTML document of 0.93 MB with 2,000 product cards. The script parses it with &lt;code&gt;lxml.html&lt;/code&gt;, keeps the first 20 links, deletes the tree and moves on to the next page. Each mode runs in its own process, and at the end the script reads the process's memory with macOS &lt;code&gt;footprint&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;kept&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromstring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;make_page&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  &lt;span class="c1"&gt;# about 0.93 MB of HTML
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;smart&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//a/@href&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# lxml default
&lt;/span&gt;    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;str&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//a/@href&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//a/@href&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;smart_strings&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;kept&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;  &lt;span class="c1"&gt;# keep 20 links per page
&lt;/span&gt;    &lt;span class="k"&gt;del&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;links&lt;/span&gt;
&lt;span class="n"&gt;gc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Results from 2026-11-08 (macOS, Python 3.13.0, lxml 6.1.1, libxml2 2.14.6):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;How links were stored&lt;/th&gt;
&lt;th&gt;Pages&lt;/th&gt;
&lt;th&gt;Links kept&lt;/th&gt;
&lt;th&gt;Pages still in memory&lt;/th&gt;
&lt;th&gt;phys_footprint&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;default &lt;code&gt;xpath()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;td&gt;1,000&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;td&gt;221 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;default &lt;code&gt;xpath()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;2,000&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;422 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;str(x)&lt;/code&gt; before storing&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;2,000&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;33 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;smart_strings=False&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;2,000&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;27 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We counted "pages still in memory" by following every kept link back with &lt;code&gt;getparent()&lt;/code&gt; and reading its page title. With the default, every page the script had parsed was still there, at about 4 MB per page. Storing 2,000 short links took 422 MB instead of 27 MB, 15.6 times as much.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why didn't our local test catch it?
&lt;/h2&gt;

&lt;p&gt;We did run the crawler locally before shipping it, and memory looked fine. The number we watched was RSS from &lt;code&gt;ps&lt;/code&gt;, and on macOS that number can sit far below what a process really holds. macOS compresses memory pages that have not been touched for a while. Compressed pages still belong to the process, but they no longer count toward RSS. During the leak, &lt;code&gt;ps&lt;/code&gt; showed 176 MB while the process held about 3 GB.&lt;/p&gt;

&lt;p&gt;We now read &lt;code&gt;phys_footprint&lt;/code&gt; from &lt;code&gt;footprint&lt;/code&gt;. Its man page describes it as the kernel ledger that tracks the dirty memory a process owns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;footprint &lt;span class="nt"&gt;-p&lt;/span&gt; &amp;lt;pid&amp;gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;phys_footprint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the benchmark above, RSS and phys_footprint stayed close (429 MB against 422 MB at 100 pages). Each run took under a second, so most likely nothing had time to be compressed. The gap opens up in long runs, and long runs are where a leak like this one shows up.&lt;/p&gt;

&lt;h2&gt;
  
  
  What did we change?
&lt;/h2&gt;

&lt;p&gt;Every &lt;code&gt;xpath()&lt;/code&gt; call whose results are stored past the current page now passes &lt;code&gt;smart_strings=False&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//a/@href&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;smart_strings&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# compiled expressions take the same argument
&lt;/span&gt;&lt;span class="n"&gt;find_links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;etree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;XPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//a/@href&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;smart_strings&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Code that cleans a value up before storing it was already fine. We checked what the common string operations return:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Expression&lt;/th&gt;
&lt;th&gt;Returns&lt;/th&gt;
&lt;th&gt;Points back to the page&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tree.xpath("//a/@href")[0]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;_ElementUnicodeResult&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tree.xpath("//title/text()")[0]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;_ElementUnicodeResult&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tree.xpath("string(//title)")&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;_ElementUnicodeResult&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;no, &lt;code&gt;getparent()&lt;/code&gt; returns &lt;code&gt;None&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;value.strip()&lt;/code&gt;, &lt;code&gt;"".join(...)&lt;/code&gt;, &lt;code&gt;re.search(...).group()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;str&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;str(value)&lt;/code&gt;, &lt;code&gt;f"{value}"&lt;/code&gt;, &lt;code&gt;value + ""&lt;/code&gt;, &lt;code&gt;value[:]&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;str&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So the leak only bites code that stores the raw result, such as a link or an attribute pushed straight into a queue with no cleanup in between. For a crawler, that is the most common thing to do with a link.&lt;/p&gt;

&lt;p&gt;If you use parsel, the selector library behind Scrapy, this is already handled: its &lt;code&gt;Selector&lt;/code&gt; passes &lt;code&gt;smart_strings=False&lt;/code&gt; to lxml by default (&lt;code&gt;_lxml_smart_strings = False&lt;/code&gt; in parsel 1.11.0). We only ran into the problem because this crawler called lxml directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we took away
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Treat an &lt;code&gt;xpath()&lt;/code&gt; result as a reference to its page until you convert it.&lt;/li&gt;
&lt;li&gt;Convert where values move into longer-lived structures. The line that adds to a queue, a set or a results dict is where &lt;code&gt;smart_strings=False&lt;/code&gt; or &lt;code&gt;str()&lt;/code&gt; belongs.&lt;/li&gt;
&lt;li&gt;When memory grows with the number of pages, count how many documents are still reachable. Following stored strings back with &lt;code&gt;getparent()&lt;/code&gt; answered that for us in a few lines.&lt;/li&gt;
&lt;li&gt;On macOS, watch phys_footprint during long runs. RSS from &lt;code&gt;ps&lt;/code&gt; showed 176 MB while we were holding about 3 GB.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Drafted with AI assistance; the numbers and traces come from our own runs and were checked by us.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>performance</category>
      <category>webscraping</category>
      <category>debugging</category>
    </item>
    <item>
      <title>What we learned publishing 7 MCP servers to the official registry</title>
      <dc:creator>Zebu Data</dc:creator>
      <pubDate>Sat, 10 Oct 2026 15:19:05 +0000</pubDate>
      <link>https://dev.to/zebudata/what-we-learned-publishing-7-mcp-servers-to-the-official-registry-1f7i</link>
      <guid>https://dev.to/zebudata/what-we-learned-publishing-7-mcp-servers-to-the-official-registry-1f7i</guid>
      <description>&lt;p&gt;The official MCP Registry is where MCP clients and directories look up servers, so if you build one, you want it listed there. We build web scrapers on Apify and wrap groups of them as remote MCP servers, and over the last two weeks we published 7 of them: 4 on Oct 1, then 3 more on Oct 7, when we also updated 3 of the first 4. Here's what we ran into, with the real limits and errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Decide what one server should hold
&lt;/h2&gt;

&lt;p&gt;Our first instinct was one big server with every tool. We split them by use case instead: local business leads, customer reviews, YouTube data and so on. Each one holds between 2 and 7 tools.&lt;/p&gt;

&lt;p&gt;Two reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Models pick the wrong tool less often&lt;/strong&gt; when they only see a handful of similar ones.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your gateway may add tools of its own.&lt;/strong&gt; Ours adds 4 helper tools to every server, for checking a job, paging through results, reading a file and stopping a job. A 7-tool server shows up as 11 tools in &lt;code&gt;tools/list&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There's a side benefit: each server gets its own listing, so someone searching a directory for "reviews" or "YouTube" finds the one that matches.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. server.json has hard limits
&lt;/h2&gt;

&lt;p&gt;A minimal remote entry looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"$schema"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"io.github.your-user/your-server"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Your Server"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"One sentence about what the tools do."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"websiteUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"remotes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"streamable-http"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://mcp.example.com/mcp"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 2025-12-11 schema caps &lt;code&gt;title&lt;/code&gt; and &lt;code&gt;description&lt;/code&gt; at 100 characters each, and &lt;code&gt;name&lt;/code&gt; must look like &lt;code&gt;namespace/server&lt;/code&gt;: letters, digits, dots and dashes, plus underscores after the slash. Our first description was 106 characters. We caught it with a length check in our build script, but &lt;code&gt;mcp-publisher validate server.json&lt;/code&gt; catches it too, and it checks against the live registry.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Your namespace comes from your GitHub login
&lt;/h2&gt;

&lt;p&gt;For &lt;code&gt;io.github.&amp;lt;user&amp;gt;/...&lt;/code&gt; names, the publisher authenticates you through GitHub with a device code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mcp-publisher login github      &lt;span class="c"&gt;# shows a code to enter at github.com/login/device&lt;/span&gt;
mcp-publisher validate server.json
mcp-publisher publish server.json
mcp-publisher &lt;span class="nb"&gt;logout&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Approve the code while signed in as the account that owns the namespace. One login covers as many publishes as you need. If you're on a shared machine, log out when you're done so the token doesn't stay on disk. We also checked the binary's SHA-256 against the release's checksums file before running it, since it handles a GitHub token.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. An update is a new version, and the old one stays
&lt;/h2&gt;

&lt;p&gt;To change a server you publish it again with a higher &lt;code&gt;version&lt;/code&gt;. The registry keeps both: after our update, &lt;code&gt;local-business-leads&lt;/code&gt; showed 1.0.0 with &lt;code&gt;isLatest: false&lt;/code&gt; and 1.1.0 with &lt;code&gt;isLatest: true&lt;/code&gt;, both still &lt;code&gt;active&lt;/code&gt;. Clients that read the registry should take the latest, but don't assume an old version disappears.&lt;/p&gt;

&lt;p&gt;The public API can also be slow. A search that returns two entries took about 23 seconds for us, so give scripts a generous timeout.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Keep tool names under 64 characters
&lt;/h2&gt;

&lt;p&gt;Our gateway names each tool &lt;code&gt;owner--tool-name&lt;/code&gt;. One of ours came out at 66 characters, so it was cut to 64 and given a short hash suffix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...--ebay-product-reviews-scraper-with-advanced--60e9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The cut isn't arbitrary: model APIs such as OpenAI's and Anthropic's only accept tool names up to 64 characters. The model still gets the tool, but with a name that's harder to match to a user's request. If you control the underlying names, keep them short.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Directories list you automatically, and may call you unhealthy
&lt;/h2&gt;

&lt;p&gt;We never submitted anything to Glama, but it picked up all our servers from the registry within about a day, and later picked up our updated descriptions too.&lt;/p&gt;

&lt;p&gt;Every one of them is marked &lt;strong&gt;Unhealthy&lt;/strong&gt;. Glama's checker connects without credentials, and our servers require the user to sign in (OAuth), so the check can't get past the start. The fix is to claim the listing and add a test profile that Glama uses only for health checks. If you do that, give it a limited credential, not your main one.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Awesome lists have rules, and a queue
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/punkpeye/awesome-remote-mcp-servers" rel="noopener noreferrer"&gt;awesome-remote-mcp-servers&lt;/a&gt; is the main curated list for remote servers. Its CONTRIBUTING.md asks for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;an endpoint that answers an MCP &lt;code&gt;initialize&lt;/code&gt; request, which CI checks on every PR,&lt;/li&gt;
&lt;li&gt;a Glama connector badge, which CI also checks,&lt;/li&gt;
&lt;li&gt;a star on the repo from the account opening the PR,&lt;/li&gt;
&lt;li&gt;one server per PR, in alphabetical order, with a description of up to 120 characters ending in a period,&lt;/li&gt;
&lt;li&gt;a marker for the auth type: none, API key or OAuth.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What surprised us was the queue. For almost a week after we opened our PR, nothing in the repo was merged at all. Then the maintainer merged almost 400 PRs in a few days, and ours wasn't one of them: other entries had landed next to ours in the same section, so it now had a merge conflict. A comment on the PR asked us to rebase or merge the latest &lt;code&gt;main&lt;/code&gt; first. If you submit, watch your PR and fix conflicts fast, because merges come in batches.&lt;/p&gt;

&lt;p&gt;One more trap: the badge check calls Glama. When Glama was briefly down, our PR failed with "no such connector". Editing the PR description re-ran the checks once it was back.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. A checklist before you publish
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;One server per use case, with a tool count your model can handle.&lt;/li&gt;
&lt;li&gt;Call &lt;code&gt;initialize&lt;/code&gt; and &lt;code&gt;tools/list&lt;/code&gt; on the real URL, with and without credentials, and read the tool names.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;title&lt;/code&gt; and &lt;code&gt;description&lt;/code&gt; within 100 characters, then &lt;code&gt;mcp-publisher validate&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Bump &lt;code&gt;version&lt;/code&gt; on every change.&lt;/li&gt;
&lt;li&gt;Log out of the publisher on shared machines.&lt;/li&gt;
&lt;li&gt;A day later, check how directories show your server, health status included.&lt;/li&gt;
&lt;li&gt;For curated lists: one PR per server, then keep an eye on it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Are you publishing MCP servers too? We'd like to know which directories your users actually find you through.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Written with AI assistance.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>ai</category>
      <category>agents</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Remote MCP tools that run long: what your agent actually gets back</title>
      <dc:creator>Zebu Data</dc:creator>
      <pubDate>Fri, 02 Oct 2026 17:22:01 +0000</pubDate>
      <link>https://dev.to/zebudata/remote-mcp-tools-that-run-long-what-your-agent-actually-gets-back-4gf6</link>
      <guid>https://dev.to/zebudata/remote-mcp-tools-that-run-long-what-your-agent-actually-gets-back-4gf6</guid>
      <description>&lt;p&gt;Most MCP demos show a tool that answers in a second. Real tools often don't: a scraper, a crawl or a report job can take minutes. We build web scrapers on Apify, so this is a problem we run into daily. We wanted to know what an agent actually receives when a remote MCP tool runs longer than one call, so we traced the raw JSON-RPC traffic against Apify's hosted MCP server (&lt;code&gt;mcp.apify.com&lt;/code&gt;, version 0.17.1 at the time) on Oct 2, 2026. The job: a YellowPages scraper reading one results page, which takes about 35 seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Discovery: one tool per job, plus helpers
&lt;/h2&gt;

&lt;p&gt;After &lt;code&gt;initialize&lt;/code&gt;, &lt;code&gt;tools/list&lt;/code&gt; returned one tool per scraper we had allowed through the server URL, plus four helper tools that only make sense for long-running work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;get-actor-run&lt;/code&gt; checks a run's status and can wait for it,&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;get-dataset-items&lt;/code&gt; reads the results in pages,&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;get-key-value-store-record&lt;/code&gt; reads a stored file or record,&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;abort-actor-run&lt;/code&gt; stops a run.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The helpers are the first hint: the server expects the agent to come back for results.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The call returns early
&lt;/h2&gt;

&lt;p&gt;The agent calls the scraper tool with ordinary arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"searchKeyword"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"plumbers"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"location"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Austin, TX"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"maxPages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response arrived after about 30 seconds, while the job was still running. It had two content parts. The first is structured:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"runId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"RUNNING"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"storages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"datasets"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"itemCount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second is plain text written for the model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RUNNING for 30s. In progress. 23 results so far.
Use get-actor-run with runId=… and waitSecs=30 to poll for completion.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That second part is the interesting design choice. The server returns machine-readable state and also tells the model, in plain English, what to do next. An agent that only parses the JSON still works. An agent that only reads text also knows to poll.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Polling has a ceiling
&lt;/h2&gt;

&lt;p&gt;We first asked &lt;code&gt;get-actor-run&lt;/code&gt; to wait 60 seconds and then 120. Both came back as a JSON-RPC error, not a tool result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MCP error -32602: Invalid arguments for tool "get-actor-run".
Validation errors: /waitSecs: must be &amp;lt;= 45.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;waitSecs: 30&lt;/code&gt; the call returned &lt;code&gt;SUCCEEDED&lt;/code&gt;, the run time (about 35 seconds) and the dataset item count (37). The result also carried a &lt;code&gt;_meta&lt;/code&gt; block with the run's platform usage, which a client can show the user before it starts anything bigger.&lt;/p&gt;

&lt;p&gt;Two things to handle here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Validation problems arrive as protocol errors (&lt;code&gt;-32602&lt;/code&gt;), not as tool results with &lt;code&gt;isError&lt;/code&gt;. If your client only checks &lt;code&gt;isError&lt;/code&gt;, it will miss them.&lt;/li&gt;
&lt;li&gt;The wait is capped, so a five-minute job means several polls. Your loop needs a total deadline, not just a per-call wait.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Reading results in pages
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;get-dataset-items&lt;/code&gt; takes the dataset ID plus &lt;code&gt;offset&lt;/code&gt; and &lt;code&gt;limit&lt;/code&gt;, and returns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"datasetId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"items"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;…&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"itemCount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;37&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"totalItemCount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;37&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"offset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a big job, page through with &lt;code&gt;offset&lt;/code&gt; instead of pulling everything into the model's context at once.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. The trap: SUCCEEDED with zero items
&lt;/h2&gt;

&lt;p&gt;The same evening a second test job, a Google Maps scraper, ran for about 157 seconds and finished with status &lt;code&gt;SUCCEEDED&lt;/code&gt;, but &lt;code&gt;get-dataset-items&lt;/code&gt; came back empty:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"items"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"itemCount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"totalItemCount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"offset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An upstream dependency was failing, and the job ended cleanly with nothing to show. If your agent treats &lt;code&gt;SUCCEEDED&lt;/code&gt; as "done, report success", it will tell the user everything worked. Check the item count, and treat "succeeded but empty" as a result the user needs to hear about.&lt;/p&gt;

&lt;h2&gt;
  
  
  A checklist for long-running MCP tools
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Expect an early return.&lt;/strong&gt; Store the run ID the first response gives you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Poll within the server's limits&lt;/strong&gt; (45 seconds per wait here), with an overall deadline and a clear message if it runs out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check protocol errors and &lt;code&gt;isError&lt;/code&gt;.&lt;/strong&gt; They come back in different places.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read results in pages&lt;/strong&gt; to protect the context window.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treat "succeeded, zero items" as a warning&lt;/strong&gt;, not a success.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Abort what you no longer need.&lt;/strong&gt; If the user changes the question halfway, &lt;code&gt;abort-actor-run&lt;/code&gt; saves the rest of the job's cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expose fewer tools.&lt;/strong&gt; A server-side allow list keeps the model from picking the wrong tool and limits what it can touch.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How does your MCP client deal with tools that outlive one call: polling, progress notifications, or something else? We're curious what holds up in production.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Written with AI assistance. Every request and response above comes from real calls we made on Oct 2, 2026.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>ai</category>
      <category>agents</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
