{"id":655,"date":"2026-03-04T16:12:09","date_gmt":"2026-03-05T00:12:09","guid":{"rendered":"https:\/\/nramkumar.org\/tech\/?p=655"},"modified":"2026-03-04T16:12:09","modified_gmt":"2026-03-05T00:12:09","slug":"setting-up-a-mitmproxy-for-clis","status":"publish","type":"post","link":"https:\/\/nramkumar.org\/tech\/blog\/2026\/03\/04\/setting-up-a-mitmproxy-for-clis\/","title":{"rendered":"Setting up a mitmproxy for CLIs"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Sometimes you need to understand what a CLI is doing or figure out what the request\/response looks like, or why something isn&#8217;t working and you suspect an interaction that&#8217;s outside your control with a third-party server happening through the CLI. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While this is not strictly just for CLIs, here&#8217;s the quick setup for <a href=\"https:\/\/www.mitmproxy.org\/\">mitmproxy<\/a> for CLIs &#8211; note that this is not guaranteed to work for all CLIs, but most python based CLIs should work. For node, you may need to add <code>NODE_EXTRA_CA_CERTS=~\/.mitmproxy\/mitmproxy-ca-cert.pem<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>uv venv\nuv pip install mitmproxy\nsource venv\/bin\/activate\nmitmproxy --listen-port 8080\n\n# On the terminal where you run the CLI\nexport HTTPS_PROXY=http:\/\/127.0.0.1:8080                                                                \nexport HTTP_PROXY=http:\/\/127.0.0.1:8080\nexport SSL_CERT_FILE=~\/.mitmproxy\/mitmproxy-ca-cert.pem                                                                                          \nexport REQUESTS_CA_BUNDLE=~\/.mitmproxy\/mitmproxy-ca-cert.pem\n&lt;Run your CLI now and you should see the capture in mitmproxy>\n\n# If you need to customize intercepts\n# Create the python file with your intercepts\nmitmdump -s intercept.py --listen-port 8080\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you need to understand what a CLI is doing or figure out what the request\/response looks like, or why something isn&#8217;t working and you suspect an interaction that&#8217;s outside your control with a third-party server happening through the CLI. While this is not strictly just for CLIs, here&#8217;s the quick setup for mitmproxy for&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-655","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/comments?post=655"}],"version-history":[{"count":1,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/655\/revisions"}],"predecessor-version":[{"id":656,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/655\/revisions\/656"}],"wp:attachment":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/media?parent=655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/categories?post=655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/tags?post=655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}