Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/mcp_github/github_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,3 +665,28 @@ def create_release(self, repo_owner: str, repo_name: str, tag_name: str, release
logging.error(f"Error creating release: {str(e)}")
traceback.print_exc()
return {"status": "error", "message": str(e)}

def user_activity_query(self, variables: dict[str, Any], query: str) -> Dict[str, Any]:
"""
Performs a user activity query using GitHub's GraphQL API across all repositories and organisations.
Args:
variables (dict[str, Any]): The variables to include in the query i.e. {"login": "username", "from": "2023-01-01", "to": "2023-12-31"}.
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring example shows variables with date parameters ("from", "to") but these are Python reserved keywords. The example should use different parameter names or clarify that these are within a dictionary context. Consider updating the example to use valid parameter names like {"login": "username", "from_date": "2023-01-01", "to_date": "2023-12-31"} or wrap the reserved words in quotes to make it clear they're dictionary keys.

Suggested change
variables (dict[str, Any]): The variables to include in the query i.e. {"login": "username", "from": "2023-01-01", "to": "2023-12-31"}.
variables (dict[str, Any]): The variables to include in the query i.e. {"login": "username", "from_date": "2023-01-01", "to_date": "2023-12-31"}.

Copilot uses AI. Check for mistakes.
query (str): The search query string. GitHub GraphQL query summary collection that includes all activity across all orgs, public and private.
Returns:
Dict[str, Any]: The JSON response from the GitHub API containing search results if successful.
"""
logging.info("Performing user query on GitHub")

try:
response = requests.post('https://api.github.com/graphql', json={'query': query, 'variables': variables}, headers=self._get_headers(), timeout=TIMEOUT)
response.raise_for_status()
query_data = response.json()
return query_data
except requests.exceptions.RequestException as req_err:
logging.error(f"Request error during user activity query: {str(req_err)}")
traceback.print_exc()
return {"status": "error", "message": str(req_err)}
except Exception as e:
logging.error(f"Error performing user activity query: {str(e)}")
traceback.print_exc()
return {"status": "error", "message": str(e)}