Skip to content

Commit e4e04fa

Browse files
committed
fix: replaced Prompt.ask() with prompt_toolkit's prompt() to have full featured and bug free cli prompt session
1 parent 6906efa commit e4e04fa

File tree

4 files changed

+64
-7
lines changed

4 files changed

+64
-7
lines changed

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,49 @@ wheels/
1111

1212
logs/
1313
logs
14+
15+
16+
target/
17+
!.mvn/wrapper/maven-wrapper.jar
18+
!**/src/main/**/target/
19+
!**/src/test/**/target/
20+
21+
### IntelliJ IDEA ###
22+
.idea/modules.xml
23+
.idea/jarRepositories.xml
24+
.idea/compiler.xml
25+
.idea/libraries/
26+
*.iws
27+
*.iml
28+
*.ipr
29+
30+
### Eclipse ###
31+
.apt_generated
32+
.classpath
33+
.factorypath
34+
.project
35+
.settings
36+
.springBeans
37+
.sts4-cache
38+
39+
### NetBeans ###
40+
/nbproject/private/
41+
/nbbuild/
42+
/dist/
43+
/nbdist/
44+
/.nb-gradle/
45+
build/
46+
!**/src/main/**/build/
47+
!**/src/test/**/build/
48+
49+
### VS Code ###
50+
.vscode/
51+
52+
### Mac OS ###
53+
.DS_Store
54+
55+
### RELEASE ###
56+
target/
57+
58+
### dependecy ###
59+
lib/

mcp_config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
"run",
2727
"browser_bruter_mcp_server.py"
2828
]
29+
},
30+
"ghidra": {
31+
"command": "python",
32+
"args": [
33+
"/home/zinjacoder/softwares/tools/RE-Malware/GhidraMCP/bridge_mcp_ghidra.py",
34+
"--ghidra-server",
35+
"http://127.0.0.1:8080/"
36+
]
2937
}
3038
}
3139
}

src/interactive_cli.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
"""
55

66
import logging
7-
import platform
87

98
from rich.console import Console
109
from rich.panel import Panel
1110
from rich.prompt import Prompt
11+
from prompt_toolkit import PromptSession
12+
13+
1214
from rich.table import Table
1315

1416
from src.mcp_tools_client import MCPToolsClient
1517

16-
if platform.system() != "Windows":
17-
import readline
18+
19+
session = PromptSession()
1820

1921
# This class is used for handling the interative cli session
2022
class InteractiveCLI:
@@ -40,7 +42,7 @@ async def interactive_cli(self):
4042

4143
while True:
4244
try:
43-
command = Prompt.ask("\n[bold blue]︻デ═一××>[/bold blue] ")
45+
command = await session.prompt_async("\n>>> ")#Prompt.ask("\n[bold blue]>>>[/bold blue] ")#prompt("\n>>> ")
4446
self.log.debug(f"Command Received: {command}")
4547

4648
if command.lower() in ('/exit', '/quit'):
@@ -114,4 +116,4 @@ async def interactive_cli(self):
114116
self.console.print("[blue]Closing Connections...[/blue]")
115117
self.log.debug("Closing client connections")
116118
await self.client.close()
117-
self.console.print("[green]Closed[/green]")
119+
self.console.print("[green]Closed[/green]")

zin_mcp_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# "langgraph",
88
# "langchain_ollama",
99
# "rich",
10-
# "typer"
10+
# "typer",
11+
# "prompt_toolkit"
1112
# ]
1213
# ///
1314

@@ -90,4 +91,4 @@ async def _run():
9091

9192
if __name__ == "__main__":
9293
app()
93-
94+

0 commit comments

Comments
 (0)