Skip to content

Commit 5fc50be

Browse files
authored
fix: ipv6 response format (#87)
1 parent 2de6553 commit 5fc50be

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "mcp-github-pr-issue-analyser"
3-
version = "2.6.1"
3+
version = "2.6.2"
44
description = "MCP GitHub Issues Create/Update and PR Analyse"
55
readme = "README.md"
66
requires-python = ">=3.12"

src/mcp_github/github_integration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ def list_open_issues_prs(self, repo_owner: str, issue: Literal['pr', 'issue'] =
290290
response.raise_for_status()
291291
pr_data = response.json()
292292
open_prs = {
293-
"total_open_prs": pr_data['total_count'],
294-
"pull_requests": [
293+
"total": pr_data['total_count'],
294+
f"open_{issue}s": [
295295
{
296296
"url": item['html_url'],
297297
"title": item['title'],
@@ -307,11 +307,11 @@ def list_open_issues_prs(self, repo_owner: str, issue: Literal['pr', 'issue'] =
307307
]
308308
}
309309

310-
logging.info(f"Open PRs listed successfully")
310+
logging.info(f"Open {issue}s listed successfully")
311311
return open_prs
312312

313313
except Exception as e:
314-
logging.error(f"Error listing open PRs: {str(e)}")
314+
logging.error(f"Error listing open {issue}s: {str(e)}")
315315
traceback.print_exc()
316316
return None
317317

src/mcp_github/ip_integration.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def get_info(self, url: str) -> Dict[str, Any]:
6363
return response.json()
6464
except requests.RequestException as e:
6565
logging.error(f"Error fetching IP info: {e}")
66-
logging.debug(traceback.format_exc())
66+
logging.debug(e)
67+
traceback.print_exc()
6768
return {}
6869

6970
def get_ipv4_info(self) -> Dict[str, Any]:
@@ -79,7 +80,8 @@ def get_ipv4_info(self) -> Dict[str, Any]:
7980
return ipv4
8081
except requests.RequestException as e:
8182
logging.error(f"Error fetching IPv4 info: {e}")
82-
logging.debug(traceback.format_exc())
83+
logging.debug(e)
84+
traceback.print_exc()
8385
return {}
8486

8587
def get_ipv6_info(self) -> Dict[str, Any]:
@@ -94,17 +96,15 @@ def get_ipv6_info(self) -> Dict[str, Any]:
9496
Logs an error message and returns an empty dictionary if a `requests.RequestException` is raised during the fetch operation.
9597
Also logs the full traceback at the debug level for troubleshooting.
9698
"""
97-
# Override the allowed_gai_family method to use IPv6
98-
def allowed_gai_family():
99-
return socket.AF_INET6
100-
urllib3_connection.allowed_gai_family = allowed_gai_family
10199
try:
100+
urllib3_connection.allowed_gai_family = lambda: socket.AF_INET6
102101
ipv6 = self.get_info(self.ipv6_api_url)
103102
if not ipv6:
104103
logging.error("No IPv6 information found.")
105-
return {}
104+
return {"error": "No IPv6 information found."}
106105
return ipv6
107106
except requests.RequestException as e:
108107
logging.error(f"Error fetching IPv6 info: {e}")
109-
logging.debug(traceback.format_exc())
110-
return {}
108+
logging.debug(e)
109+
traceback.print_exc()
110+
return {"error": f"Failed to fetch IPv6 information: {str(e)}"}

src/mcp_github/issues_pr_analyser.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,19 @@ async def get_ipv4_ipv6_info() -> dict[str, Any]:
358358
logging.info({"status": "info", "message": "Fetching IPv4 and IPv6 information"})
359359
try:
360360
ipv4_info = self.ip.get_ipv4_info()
361-
ipv6_info = self.ip.get_ipv6_info()
362-
if ipv4_info is None:
361+
try:
362+
ipv6_info = self.ip.get_ipv6_info()
363+
except Exception as e:
364+
logging.error(f"Error fetching IPv6 info: {e}")
365+
ipv6_info = None
366+
if not isinstance(ipv4_info, dict) or ipv4_info is None:
363367
logging.info({"status": "error", "message": "No changes returned from getv4_ip_info"})
364-
return {}
365-
if ipv6_info is None:
368+
return {"status": "No IPv4 information available"}
369+
if not isinstance(ipv6_info, dict) or ipv6_info is None or "ip" not in ipv6_info:
366370
logging.info({"status": "error", "message": "No changes returned from getv6_ip_info"})
367-
return {}
368-
if ipv4_info and ipv6_info:
369-
ipv4_info["ipv6"] = ipv6_info["ip"]
371+
return {"status": "No IPv6 information available"}
372+
else:
373+
ipv4_info["ipv6"] = ipv6_info.get("ip", "No IPv6 address found")
370374
logging.info({"status": "success", "message": "Successfully fetched IPv4 and IPv6 information"})
371375
return ipv4_info
372376
except Exception as e:

0 commit comments

Comments
 (0)