Skip to content

Commit 9c946c8

Browse files
authored
Merge pull request #18 from zinja-coder/fix_them_all
Fixed following issue zinja-coder/jadx-ai-mcp#33 and following issues: - fix: fixed the following error -> "HTTP error 400: {"error":"Missing required parameter 'class'"}." in following mcp tools -> get_fields_of_class, get_methods_of_class - fix: fixed the following error -> Unexpected error: Expecting value: line 1 column 1 (char 0). - fix: added dict as a return type in mcp tools to keep up to date with fastmcp
2 parents b5ef0ef + 5df8f29 commit 9c946c8

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

jadx_mcp_server.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ async def get_from_jadx(endpoint: str, params: dict = {}) -> Union[str, dict]:
207207
resp.raise_for_status()
208208
response = resp.text
209209
if isinstance(response, str):
210-
return json.loads(response)
210+
try:
211+
return json.loads(response)
212+
except Exception as e: # fix the `Unexpected error: Expecting value: line 1 column 1 (char 0).` error
213+
response = {"response":resp.text}
211214
return response
212215
except httpx.HTTPStatusError as e:
213216
error_message = f"HTTP error {e.response.status_code}: {e.response.text}"
@@ -320,7 +323,7 @@ async def get_methods_of_class(class_name: str) -> dict:
320323
A list of all methods in the class.
321324
"""
322325

323-
response = await get_from_jadx("methods-of-class", {"method": class_name})
326+
response = await get_from_jadx("methods-of-class", {"class_name": class_name})
324327
if isinstance(response, str):
325328
return json.loads(response)
326329
return response
@@ -336,7 +339,7 @@ async def get_fields_of_class(class_name: str) -> dict:
336339
A list of all fields in the class.
337340
"""
338341

339-
response = await get_from_jadx("fields-of-class", {"method": class_name})
342+
response = await get_from_jadx("fields-of-class", {"class_name": class_name})
340343
if isinstance(response, str):
341344
return json.loads(response)
342345
return response

test.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ call_tool "get_methods_of_class" '{"class_name":"com.zin.dvac.AuthActivity"}' 18
123123

124124
# 12) get_fields_of_class
125125
echo "--- get_fields_of_class ---"
126-
call_tool "get_fields_of_class" '{"class_name":"com.zin.dvac.AuthActivity"}' 19 | jq -r '.result[]? // .'
126+
call_tool "get_fields_of_class" '{"class_name":"com.zin.dvac.DatabaseHelper"}' 19 | jq -r '.result[]? // .'
127127

128128
# 13) get_smali_of_class
129129
echo "--- get_smali_of_class ---"
@@ -152,11 +152,11 @@ echo "--- get_main_application_classes_code (offset=0,count=3) ---"
152152
call_tool "get_main_application_classes_code" '{"offset":0,"count":3}' 25 | jq -r '.result.items[]?.name, .result.items[]?.content'
153153

154154
# 19) rename operations (use with care; examples commented)
155-
echo "--- rename_class ---"
156-
call_tool "rename_class" '{"class_name":"com.zin.dvac.AuthActivity","new_name":"WebViewActivity"}' 26 | jq
157-
echo "--- rename_method ---"
158-
call_tool "rename_method" '{"method_name":"com.zin.dvac.AuthActivity.onCreate","new_name":"initializeWebView"}' 27 | jq
159-
echo "--- rename_field ---"
160-
call_tool "rename_field" '{"class_name":"com.zin.dvac.LoginActivity","field_name":"editTextLoginPassword","new_name":"passwordInputField"}' 28 | jq
155+
#echo "--- rename_class ---"
156+
#call_tool "rename_class" '{"class_name":"com.zin.dvac.AuthActivity","new_name":"WebViewActivity"}' 26 | jq
157+
#echo "--- rename_method ---"
158+
#call_tool "rename_method" '{"method_name":"com.zin.dvac.AuthActivity.onCreate","new_name":"initializeWebView"}' 27 | jq
159+
#echo "--- rename_field ---"
160+
#call_tool "rename_field" '{"class_name":"com.zin.dvac.LoginActivity","field_name":"editTextLoginPassword","new_name":"passwordInputField"}' 28 | jq
161161

162162
echo "== done =="

0 commit comments

Comments
 (0)