Skip to content

Commit d5f2540

Browse files
saidsefCopilot
andauthored
chore: update PR/issue listing and documentation (#66)
* chore: update list pr to include issues Also, updated documentation features section * chore: update log message Co-authored-by: Copilot <[email protected]> * chore: update log message Co-authored-by: Copilot <[email protected]> * chore: update function description Co-authored-by: Copilot <[email protected]> * chore: update function description Co-authored-by: Copilot <[email protected]> * chore: update function description Co-authored-by: Copilot <[email protected]> * chore: package version bump to v2.4.0 --------- Co-authored-by: Copilot <[email protected]>
1 parent 24862ca commit d5f2540

File tree

5 files changed

+228
-228
lines changed

5 files changed

+228
-228
lines changed

README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ The toolset enables automated PR analysis, issue tracking, tagging and release m
1212

1313
## Features
1414

15-
| Feature | Function Name | Description |
16-
|----------------------------|--------------------------------|-----------------------------------------------------------------------------------------------|
17-
| PR Content Retrieval | `get_github_pr_content` | Fetch PR metadata including title, description, author, and state. |
18-
| PR Diff Analysis | `get_github_pr_diff` | Retrieve the diff/patch content showing file changes in the PR. |
19-
| PR Description Updates | `update_github_pr_description` | Update PR titles and descriptions with What/Why/How sections and file changes. |
20-
| PR General Comments | `add_github_pr_comment` | Add general discussion comments to pull requests. |
21-
| PR Inline Code Comments | `add_github_pr_inline_comment` | Add inline review comments to specific lines in PR files for code review. |
22-
| Issue Creation | `create_github_issue` | Create new issues with conventional commit prefixes (feat/fix/chore) and MCP label. |
23-
| Issue Updates | `update_github_issue` | Modify existing issues with new title, body, and state (open/closed). |
24-
| Tag Management | `create_github_tag` | Create new git tags with associated messages for versioning. |
25-
| Release Management | `create_github_release` | Generate GitHub releases with automatic release notes and tag references. |
26-
| Network Information | `get_ipv4_ipv6_info` | Fetch IPv4 and IPv6 network information for the system. |
27-
| MCP Tool Registration | `_register_tools` | Tools are registered and exposed via the MCP server for easy integration. |
15+
| Function | Description |
16+
|------------------------------------------|---------------------------------------------------------------------------------------------------|
17+
| Analyse GitHub Pull Requests and fetch diffs | Retrieve the diff/patch for any PR in a repository. |
18+
| Fetch content and metadata for specific PRs | Get PR title, description, author, timestamps, and state. |
19+
| Update PR title and description | Change the title and body of any PR. |
20+
| Add comments to PRs | Post general comments to a PR thread. |
21+
| Add inline review comments to PRs | Comment on specific lines in PR files for code review. |
22+
| Create and update GitHub Issues | Open new issues or update existing ones with title, body, labels, and state. |
23+
| Create tags and releases | Tag repository commits and publish releases with changelogs. |
24+
| Retrieve IPv4 and IPv6 information | Get public IP address details for both IPv4 and IPv6. |
25+
| List all open Issues or Pull Requests | View all open PRs or issues for any user or organisation. |
2826

2927
## Requirements
3028

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.3.2"
3+
version = "2.4.0"
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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import requests
2222
import traceback
2323
from os import getenv
24-
from typing import Dict, Any, Optional
24+
from typing import Dict, Any, Optional, Literal
2525

2626
GITHUB_TOKEN = getenv('GITHUB_TOKEN')
2727

@@ -270,21 +270,22 @@ def update_pr_description(self, repo_owner: str, repo_name: str, pr_number: int,
270270
traceback.print_exc()
271271
return None
272272

273-
def list_open_prs(self, repo_owner: str) -> Dict[str, Any]:
273+
def list_open_issues_prs(self, repo_owner: str, issue: Literal['pr', 'issue'] = 'pr') -> Dict[str, Any]:
274274
"""
275-
Lists all open pull requests for a given repository owner.
275+
Lists all open Issues or Pull Requests for a given repository owner.
276276
Args:
277277
repo_owner (str): The owner of the repository.
278+
issue (Literal['pr', 'issue']): The type of items to list, either 'pr' for pull requests or 'issue' for issues. Defaults to 'pr'.
278279
Returns:
279-
Dict[str, Any]: A dictionary containing the list of open pull requests.
280+
Dict[str, Any]: A dictionary containing the list of open pull requests or issues, depending on the value of the `issue` parameter.
280281
None: If an error occurs during the request.
281282
Error Handling:
282283
Logs an error message and prints the traceback if the request fails or an exception is raised.
283284
"""
284-
logging.info(f"Listing open PRs for {repo_owner}")
285+
logging.info(f"Listing open {issue}s for {repo_owner}")
285286

286287
# Construct the search URL
287-
search_url = f"https://api.github.com/search/issues?q=is:pr+is:open+user:{repo_owner}"
288+
search_url = f"https://api.github.com/search/issues?q=is:{issue}+is:open+user:{repo_owner}"
288289

289290
try:
290291
response = requests.get(search_url, headers=self._get_headers())

src/mcp_github/issues_pr_analyser.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,23 @@ async def add_github_pr_comment(repo_owner: str, repo_name: str, pr_number: int,
216216
return error_msg
217217

218218
@self.mcp.tool()
219-
async def list_github_prs(repo_owner: str) -> str:
219+
async def list_github_issues_prs(repo_owner: str, issue: str) -> str:
220220
"""
221-
Lists all open pull requests for a given GitHub repository owner.
221+
Lists all open pull requests or issues for a given GitHub repository owner.
222222
Args:
223223
repo_owner (str): The owner of the GitHub repository.
224+
issue (str): The type of items to list, either 'pr' for pull requests or 'issue' for issues.
224225
Returns:
225-
str: A message indicating the result of the PR listing. Returns a success message with the list of open PRs if successful, or an error message if an exception occurs.
226+
str: A message indicating the result of the listing. Returns a success message with the list of open pull requests or issues if successful, or an error message if an exception occurs.
226227
Error Handling:
227-
Catches and logs any exceptions that occur during the PR listing process. If an error is encountered, the error message is logged and returned.
228+
Catches and logs any exceptions that occur during the listing process. If an error is encountered, the error message is logged and returned.
228229
"""
229-
logging.info(f"Listing open PRs for {repo_owner}")
230+
logging.info(f"Listing open {issue} for {repo_owner}")
230231
try:
231-
open_prs = self.gi.list_open_prs(repo_owner)
232-
return f"Successfully listed open PRs for {repo_owner}: {open_prs}"
232+
open_issues_prs = self.gi.list_open_issues_prs(repo_owner, issue)
233+
return f"Successfully listed open {issue} for {repo_owner}: {open_issues_prs}"
233234
except Exception as e:
234-
error_msg = f"Error adding comment to PR: {str(e)}"
235+
error_msg = f"Error listing {issue} for {repo_owner}: {str(e)}"
235236
logging.error(error_msg)
236237
traceback.print_exc(file=sys.stderr)
237238
return error_msg

0 commit comments

Comments
 (0)