<?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: Hoang Le</title>
    <description>The latest articles on DEV Community by Hoang Le (@ivermin1123).</description>
    <link>https://dev.to/ivermin1123</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%2F554617%2Fc9e41127-c73b-419a-8360-c68d38e05e44.jpeg</url>
      <title>DEV Community: Hoang Le</title>
      <link>https://dev.to/ivermin1123</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ivermin1123"/>
    <language>en</language>
    <item>
      <title>Testing MCP agents offline: the recording is the server 📼</title>
      <dc:creator>Hoang Le</dc:creator>
      <pubDate>Sun, 11 Oct 2026 08:55:27 +0000</pubDate>
      <link>https://dev.to/ivermin1123/testing-mcp-agents-offline-the-recording-is-the-server-47kp</link>
      <guid>https://dev.to/ivermin1123/testing-mcp-agents-offline-the-recording-is-the-server-47kp</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; 📼 &lt;code&gt;mcp-cassette&lt;/code&gt; records one real MCP session into a JSONL file, then serves that file &lt;strong&gt;as an MCP server&lt;/strong&gt;. Any client, in any language, runs its tests against the recording offline: no credentials, no rate limits, no network.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fivermin1123%2Fmcp-cassette%2Fmain%2F.github%2Fdemo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fivermin1123%2Fmcp-cassette%2Fmain%2F.github%2Fdemo.gif" alt="Terminal demo: check a live server, record, replay offline, lint, and fail on a breaking contract change" width="760" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🤔 The problem
&lt;/h2&gt;

&lt;p&gt;If your agent calls tools over the Model Context Protocol, its tests depend on something they do not control: a live MCP server, with its credentials, its rate limits and its network.&lt;/p&gt;

&lt;p&gt;The usual fixes both hurt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🧪 &lt;strong&gt;Mock the MCP client library&lt;/strong&gt;, and every test is tied to one SDK.&lt;/li&gt;
&lt;li&gt;🛠️ &lt;strong&gt;Write your own recorder&lt;/strong&gt;, which several projects I came across had each done for themselves.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;mcp-cassette&lt;/code&gt; takes a third route: &lt;strong&gt;the recording is the server.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🎙️ Record once
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx mcp-cassette record &lt;span class="nt"&gt;-o&lt;/span&gt; session.cassette.jsonl &lt;span class="nt"&gt;--&lt;/span&gt; npx &lt;span class="nt"&gt;-y&lt;/span&gt; @modelcontextprotocol/server-github
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The recorder sits between your client and the real server as a transparent proxy and writes every frame, in both directions, to an open JSONL cassette. Secrets it recognizes are redacted before they reach the file, by default.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Pattern matching cannot catch every secret, so give a cassette a quick look before you commit it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  🔁 Replay forever
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx mcp-cassette check &lt;span class="nt"&gt;--stdio&lt;/span&gt; &lt;span class="s2"&gt;"npx mcp-cassette replay session.cassette.jsonl"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;check&lt;/code&gt; is an ordinary MCP client, and it cannot tell the recording from the live server. &lt;strong&gt;Neither can yours.&lt;/strong&gt; The replay speaks MCP over stdio or Streamable HTTP, so any client in any language connects to it unchanged.&lt;/p&gt;

&lt;p&gt;It is a server, not a stub:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📣 Notifications the server pushed on its own are replayed at the point in the session where they arrived.&lt;/li&gt;
&lt;li&gt;🧭 Both the 2025-11-25 revision and the stateless 2026-07-28 revision are supported.&lt;/li&gt;
&lt;li&gt;🔌 A client that probes on one connection and runs its session on a second records both into one file with &lt;code&gt;--mode append&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  🧪 Inside your test runner
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;it&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vitest&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useCassette&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mcp-cassette/vitest&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;recorded call&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tape&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCassette&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;tests/cassettes/weather.http.jsonl&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;is answered from the cassette&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// point your MCP client at tape.url instead of the live server&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;There is a &lt;code&gt;mcp-cassette/jest&lt;/code&gt; twin. A request the recording does not hold fails the test that made it, and says why.&lt;/p&gt;
&lt;h2&gt;
  
  
  🚦 Gate your tool contract
&lt;/h2&gt;

&lt;p&gt;A tool contract is an API. &lt;code&gt;snapshot&lt;/code&gt; writes it to a file you commit, and &lt;code&gt;snapshot --check&lt;/code&gt; fails CI when it breaks:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx mcp-cassette snapshot &lt;span class="nt"&gt;--check&lt;/span&gt; &lt;span class="nt"&gt;--stdio&lt;/span&gt; &lt;span class="s2"&gt;"node dist/my-server.js"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[BREAKING] slugify: tool removed (tool-removed)
[BREAKING] add: parameter "precision" is now required (input-property-became-required)
[DANGEROUS] add: parameter "mode" added (input-property-added-optional)
result: FAIL (2 breaking, 1 dangerous, 0 minor, 0 info; gate: breaking)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  🛡️ Lint what the model reads
&lt;/h2&gt;

&lt;p&gt;Tool poisoning hides in text your agent reads and nobody shows a human: tool descriptions, input schemas, prompts, resources. &lt;code&gt;check&lt;/code&gt; runs sixteen deterministic rules over all of it, each citing the OWASP MCP Top 10 risk it covers, and &lt;code&gt;lint&lt;/code&gt; runs the ones that make sense over what a recorded server &lt;em&gt;returned&lt;/em&gt;, which is where indirect prompt injection arrives.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx mcp-cassette check &lt;span class="nt"&gt;--stdio&lt;/span&gt; &lt;span class="s2"&gt;"node dist/my-server.js"&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt; sarif &lt;span class="nt"&gt;--sarif-location&lt;/span&gt; mcp-contract.snapshot.json &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; mcp-cassette.sarif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Findings come out as text, JSON, or SARIF for GitHub code scanning.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ These are heuristics, not a model. They are a fast tripwire in CI, and the README says plainly what they miss.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  🤖 CI in three lines
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ivermin1123/mcp-cassette@v0.10&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;server-command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;node dist/my-server.js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;That runs the safety check &lt;strong&gt;and&lt;/strong&gt; the contract gate against the snapshot you committed, then leaves one comment on the pull request, updated in place on every push.&lt;/p&gt;
&lt;h2&gt;
  
  
  🚀 Try it in ten seconds
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx mcp-cassette check &lt;span class="nt"&gt;--stdio&lt;/span&gt; &lt;span class="s2"&gt;"npx -y @modelcontextprotocol/server-everything stdio"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;surface: 13 tools, 7 resources, 4 prompts

[OK] no findings

result: PASS (0 error(s), 0 warning(s), gate: error)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/ivermin1123" rel="noopener noreferrer"&gt;
        ivermin1123
      &lt;/a&gt; / &lt;a href="https://github.com/ivermin1123/mcp-cassette" rel="noopener noreferrer"&gt;
        mcp-cassette
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Record a real MCP session once, replay it forever. VCR-style record/replay, contract snapshots, and safety checks for Model Context Protocol servers.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;p&gt;&lt;a href="https://github.com/ivermin1123/mcp-cassette/actions/workflows/ci.yml" rel="noopener noreferrer"&gt;&lt;img src="https://github.com/ivermin1123/mcp-cassette/actions/workflows/ci.yml/badge.svg" alt="CI"&gt;&lt;/a&gt;
&lt;a href="https://www.npmjs.com/package/mcp-cassette" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/214320b86500be182ea605521f975f530a41d06768e86619d96a4a15b5317e5b/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f6d63702d63617373657474652e737667" alt="npm version"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/ivermin1123/mcp-cassette/.github/demo.gif"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fivermin1123%2Fmcp-cassette%2FHEAD%2F.github%2Fdemo.gif" alt="Terminal demo: check a live MCP server, record the session, replay it offline to identical output, lint every surface the server publishes and what a recorded one returned, then fail on breaking contract changes"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;mcp-cassette&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The cassette is itself an MCP server, so any client in any language connects to it exactly as it connects to the live one: no library to import, no product code to change, no transport to wrap.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Record one session against a real &lt;a href="https://modelcontextprotocol.io" rel="nofollow noopener noreferrer"&gt;Model Context Protocol&lt;/a&gt; server, then run your agent tests against the recording: no credentials, no rate limits, no network. The replay is a server, not a stub: it hands back the notifications the recorded server pushed on its own, at the position the recording put them, and it serves a whole &lt;code&gt;io.modelcontextprotocol/tasks&lt;/code&gt; poll sequence. One file covers both protocol eras, the classic lifecycle and 2026-07-28.&lt;/p&gt;

&lt;p&gt;The same binary gates your tool contract against breaking changes, lints every text a server publishes to the model for poisoning, and lints what a recorded server handed &lt;em&gt;back&lt;/em&gt;, which is where indirect prompt injection arrives.&lt;/p&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;npx mcp-cassette check --stdio &lt;/pre&gt;…
&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/ivermin1123/mcp-cassette" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;Apache-2.0 · TypeScript · Node 22 or later&lt;/p&gt;

&lt;h2&gt;
  
  
  💬 Over to you
&lt;/h2&gt;

&lt;p&gt;If you test MCP agents today, how do you do it? And where would a recording &lt;strong&gt;not&lt;/strong&gt; fit? Tell me in the comments 👇&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>testing</category>
      <category>ai</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
