MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / demo_edit_tool

Function demo_edit_tool

examples/01_basic_tools.py:63–87  ·  view source on GitHub ↗

Demo: Edit an existing file.

()

Source from the content-addressed store, hash-verified

61
62
63async def demo_edit_tool():
64 """Demo: Edit an existing file."""
65 print("\n" + "=" * 60)
66 print("Demo 3: EditTool - Edit file content")
67 print("=" * 60)
68
69 with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".txt") as f:
70 f.write("Python is great!\nI love Python programming.")
71 temp_path = f.name
72
73 try:
74 print(f"Original content:\n{Path(temp_path).read_text()}\n")
75
76 tool = EditTool()
77 result = await tool.execute(
78 path=temp_path, old_str="Python", new_str="Agent"
79 )
80
81 if result.success:
82 print(f"✅ File edited successfully")
83 print(f"New content:\n{Path(temp_path).read_text()}")
84 else:
85 print(f"❌ Failed: {result.error}")
86 finally:
87 Path(temp_path).unlink()
88
89
90async def demo_bash_tool():

Callers 1

mainFunction · 0.85

Calls 2

executeMethod · 0.95
EditToolClass · 0.90

Tested by

no test coverage detected