mishrabp commited on
Commit
7f7b279
·
verified ·
1 Parent(s): 64c809f

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. src/mcp-github/server.py +26 -0
src/mcp-github/server.py CHANGED
@@ -34,6 +34,32 @@ def get_client():
34
  auth = Auth.Token(token)
35
  return Github(auth=auth)
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  @mcp.tool()
38
  def list_issues(owner: str, repo_name: str, state: str = "open") -> List[Dict[str, Any]]:
39
  """
 
34
  auth = Auth.Token(token)
35
  return Github(auth=auth)
36
 
37
+ @mcp.tool()
38
+ def list_repositories() -> List[Dict[str, Any]]:
39
+ """
40
+ List all repositories for the authenticated user/owner.
41
+ """
42
+ log_usage("mcp-github", "list_repositories")
43
+ try:
44
+ g = get_client()
45
+ # Get repos for the owner/authenticated user
46
+ repos = g.get_user().get_repos(sort="updated", direction="desc")
47
+
48
+ results = []
49
+ for repo in repos[:20]: # Limit to 20 most recent
50
+ results.append({
51
+ "name": repo.name,
52
+ "full_name": repo.full_name,
53
+ "description": repo.description,
54
+ "stars": repo.stargazers_count,
55
+ "forks": repo.forks_count,
56
+ "updated_at": str(repo.updated_at),
57
+ "language": repo.language
58
+ })
59
+ return results
60
+ except Exception as e:
61
+ return [{"error": str(e)}]
62
+
63
  @mcp.tool()
64
  def list_issues(owner: str, repo_name: str, state: str = "open") -> List[Dict[str, Any]]:
65
  """