You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/mcp_github/issues_pr_analyser.py
+33-42Lines changed: 33 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ class PRIssueAnalyser:
36
36
Methods
37
37
-------
38
38
__init__():
39
-
Initializes the PRIssueAnalyser instance by setting up GitHub integration, IP processing, and the MCP server. Registers all MCP tools for PR and issue management.
39
+
Initialises the PRIssueAnalyser instance by setting up GitHub integration, IP processing, and the MCP server. Registers all MCP tools for PR and issue management.
40
40
Any exceptions during initialization are not explicitly handled and will propagate.
41
41
_register_tools():
42
42
Registers a set of asynchronous MCP tools for:
@@ -52,9 +52,9 @@ class PRIssueAnalyser:
52
52
"""
53
53
def__init__(self):
54
54
"""
55
-
Initializes the main components required for the Issue and PR Analyser.
55
+
Initialises the main components required for the Issue and PR Analyser.
56
56
This constructor performs the following actions:
57
-
- Initializes the GitHub integration and issue processing components.
57
+
- Initialises the GitHub integration and issue processing components.
58
58
- Sets up the MCP (Multi-Component Platform) server for handling PR analysis, issue creation, and updates.
59
59
- Registers the necessary MCP tools for further processing.
60
60
- Logs the successful initialization of the MCP server.
@@ -66,8 +66,8 @@ def __init__(self):
66
66
67
67
# Initialize MCP Server
68
68
self.mcp=FastMCP(
69
-
name="GitHub PR Analyse, Issue Create and Update",
70
-
instruction="Use the tools to analyze GitHub PRs, create and update issues, and manage tags and releases.",
69
+
name="GitHub PR and Issue Analyser",
70
+
instruction="You are a GitHub PR and Issue Analyser. You can fetch PR diffs, update PR descriptions, create and update issues, create tags and releases, and fetch IP information.",
Updates the title and description of a GitHub pull request.
144
-
142
+
Updates the description of a GitHub pull request with a new title and description.
145
143
Args:
146
-
repo_owner (str): The owner of the repository.
147
-
repo_name (str): The name of the repository.
144
+
repo_owner (str): The owner of the GitHub repository.
145
+
repo_name (str): The name of the GitHub repository.
148
146
pr_number (int): The pull request number to update.
149
147
new_title (str): The new title for the pull request.
150
148
new_description (str): The new description for the pull request.
151
-
152
149
Returns:
153
150
str: A message indicating the result of the update operation. Returns a success message if the update is successful, or an error message if an exception occurs.
154
-
155
151
Error Handling:
156
152
Catches and logs any exceptions that occur during the update process. If an error is encountered, the error message is logged and returned.
Adds an inline review comment to a specific line in a GitHub pull request file.
173
-
Only comment if there is an issue with the code, otherwise do not comment.
168
+
Adds an inline review comment to a specific line in a pull request on GitHub.
169
+
Only comment if there are issues with the code, otherwise do not comment.
174
170
Args:
175
-
repo_owner (str): The owner of the repository.
176
-
repo_name (str): The name of the repository.
171
+
repo_owner (str): The owner of the GitHub repository.
172
+
repo_name (str): The name of the GitHub repository.
177
173
pr_number (int): The pull request number to add the comment to.
178
-
path (str): The relative path to the file (e.g., 'src/main.py').
179
-
line (int): The line number in the file to comment on.
180
-
comment_body (str): The content of the review comment.
181
-
174
+
path (str): The file path in the pull request where the comment should be added.
175
+
line (int): The line number in the file where the comment should be added.
176
+
comment_body (str): The content of the comment to be added.
182
177
Returns:
183
-
str: A message indicating the result of the comment addition. Returns a success message if the comment is added successfully, or an error message if an exception occurs.
184
-
178
+
str: A message indicating the result of the inline comment addition. Returns a success message if the comment is added successfully, or an error message if an exception occurs.
185
179
Error Handling:
186
-
Catches and logs any exceptions that occur during the comment addition process. If an error is encountered, the error message is logged and returned.
180
+
Catches and logs any exceptions that occur during the inline comment addition process. If an error is encountered, the error message is logged and returned.
187
181
"""
188
182
logging.info(f"Adding inline review comment to PR #{pr_number}")
repo_owner (str): The owner of the GitHub repository.
199
+
repo_name (str): The name of the GitHub repository.
207
200
pr_number (int): The pull request number to add the comment to.
208
-
comment (str): The comment text to be added.
209
-
201
+
comment (str): The content of the comment to be added.
210
202
Returns:
211
203
str: A message indicating the result of the comment addition. Returns a success message if the comment is added successfully, or an error message if an exception occurs.
212
-
213
204
Error Handling:
214
205
Catches and logs any exceptions that occur during the comment addition process. If an error is encountered, the error message is logged and returned.
Lists all open pull requests for a given repository owner.
221
+
Lists all open pull requests for a given GitHub repository owner.
231
222
Args:
232
-
repo_owner (str): The owner of the repository.
223
+
repo_owner (str): The owner of the GitHub repository.
233
224
Returns:
234
-
Dict[str, Any]: A dictionary containing the list of open pull requests.
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.
235
226
Error Handling:
236
-
Catches and logs any exceptions that occur during the fetch operation. If an error is encountered, the error message is logged and an empty dictionary is returned.
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.
237
228
"""
238
229
logging.info(f"Listing open PRs for {repo_owner}")
239
230
try:
@@ -410,7 +401,7 @@ def run(self):
410
401
defmain():
411
402
"""
412
403
Main entry point for the PR and Issue Analyzer.
413
-
This function initializes the PRIssueAnalyser and executes its main logic.
404
+
This function Initialises the PRIssueAnalyser and executes its main logic.
414
405
If an exception occurs during execution, it logs the error, prints the traceback,
415
406
and exits the program with a non-zero status code.
0 commit comments