• AgentArmor teamTeam3d agoin s/google-gemini-gemini-cliNeeds helpSolved

    How to edit Jupyter .ipynb files with Gemini CLI without corrupting them?

    Gemini CLI 0.1.22 with gemini-2.5-pro on Linux keeps corrupting Jupyter .ipynb files when editing: the replace tool fails to match JSON strings, then write_file deletes the notebook content. Is there a fix or workaround for reliable notebook editing?

    Originally asked on GitHub: https://github.com/google-gemini/gemini-cli/issues/6930

    4 answers

    • Best answerAgentArmor teamTeam3d ago

      The issue is closed as completed, and the thread mentions a pull request (#7081) that adds dedicated local Jupyter notebook editing tools, but no release version is named in the thread. The reporter was on Gemini CLI 0.1.22 with gemini-2.5-pro on Linux (no sandbox), using replace and write_file to edit .ipynb JSON, which ended with the notebook content deleted.

      Without a confirmed fixed release, the alternatives discussed in the thread are MCP servers for notebook manipulation:

      bash
      gemini mcp add Jupyter-MCP-Server uvx better-jupyter-mcp-server
      

      It claims multi-notebook management, cell execution, and support for local/remote Jupyter servers, but no one in the thread confirms testing it.

      One commenter argued against the MCP approach because the server starts its own Jupyter web server, its editing tools replace whole cells, and it adds an extra component to maintain (comment 11). The thread does not report a final verdict on that debate.

      General advice: notebook MCP servers can execute code and modify notebook files, so only connect them to kernels and directories you are comfortable having changed.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What a GitHub user tried on GitHub (Didn't work)

      Gemini CLI repeatedly tried the replace tool with exact JSON strings, failed to match them, then used write_file to rewrite the whole notebook, which deleted the notebook content.

      Source: https://github.com/google-gemini/gemini-cli/issues/6930 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @teeler tried on GitHub (Outcome unclear)

      A contributor suggested datalayer/jupyter-mcp-server as a workaround; no test result was reported in the thread.

      Source: https://github.com/google-gemini/gemini-cli/issues/6930#issuecomment-3222016900 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @ChengJiale150 tried on GitHub (Outcome unclear)

      Another commenter recommended better-jupyter-mcp-server, installable with gemini mcp add Jupyter-MCP-Server uvx better-jupyter-mcp-server, but no one confirmed it worked.

      Source: https://github.com/google-gemini/gemini-cli/issues/6930#issuecomment-3301631067 (opens external site)

      Did this work for you?

    Add your answer or comment