Skip to main content
Glama
Nikhil-Patil-RI

Github-Oauth MCP Server

get_user_repositories

Fetch repositories for authenticated GitHub users to manage and access their code projects through OAuth-secured connections.

Instructions

Fetch the repositories of the authenticated user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get_user_repositories' tool. It is decorated with @mcp.tool() for registration and implements the logic to retrieve and format the user's GitHub repositories using the GitHub API and the stored access token.
    @mcp.tool()
    async def get_user_repositories() -> str:
        """Fetch the repositories of the authenticated user."""
        global access_token
    
        if not access_token:
            return "You are not authorized. Please authorize first."
    
        url = f"{GITHUB_API_BASE}/user/repos"
        headers = {
            "Authorization": f"Bearer {access_token}",
            "User-Agent": USER_AGENT,
            "Accept": "application/vnd.github.v3+json",
        }
        data = await make_request(url, headers)
        if not data:
            return "Unable to fetch repositories."
    
        if isinstance(data, list):
            repos = []
            for repo in data:
                repos.append(f"Name: {repo['name']}, URL: {repo['html_url']}, Language: {repo.get('language', 'Unknown')}")
            return "\n---\n".join(repos)
    
        return "No repositories found."
  • Helper utility function used by get_user_repositories to perform authenticated HTTP requests to the GitHub API.
    async def make_request(url: str, headers: dict[str, str], params: dict[str, str] = None) -> Optional[dict[str, Any]]:
        """Make an HTTP GET request with error handling."""
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(url, headers=headers, params=params, timeout=30.0)
                response.raise_for_status()
                return response.json()
            except Exception as e:
                print(f"Request failed: {e}")
                return None

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Nikhil-Patil-RI/MCP-Github-Oauth'

If you have feedback or need assistance with the MCP directory API, please join our Discord server