Skip to main content
Glama
Nikhil-Patil-RI

Github-Oauth MCP Server

get_access_token_from_code

Exchange an authorization code for an access token to authenticate with GitHub using OAuth protocol.

Instructions

Exchange authorization code for an access token.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • The main handler function for the 'get_access_token_from_code' tool. It is decorated with @mcp.tool() for registration and implements the OAuth token exchange using HTTP POST to GitHub's access_token endpoint.
    @mcp.tool()
    async def get_access_token_from_code(code: str) -> str:
        """Exchange authorization code for an access token."""
        global access_token
    
        url = "https://github.com/login/oauth/access_token"
        headers = {"Accept": "application/json"}
        params = {
            "client_id": CLIENT_ID,
            "client_secret": CLIENT_SECRET,
            "code": code,
            "redirect_uri": REDIRECT_URI,
        }
        async with httpx.AsyncClient() as client:
            try:
                response = await client.post(url, headers=headers, params=params, timeout=30.0)
                response.raise_for_status()
                data = response.json()
                access_token = data.get("access_token", "")
                if access_token:
                    return "Authorization successful! Access token obtained."
                return "Failed to obtain access token."
            except Exception as e:
                print(f"Error fetching access token: {e}")
                return "Failed to fetch access token."
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('exchange') but lacks critical details: it doesn't specify authentication requirements, rate limits, error handling, or the nature of the returned access token (e.g., scope, expiration). This leaves significant gaps for a tool that performs a sensitive OAuth operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence earns its place by conveying essential purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (OAuth token exchange), lack of annotations, no output schema, and poor schema coverage, the description is incomplete. It fails to address authentication needs, response format, error cases, or integration with sibling tools like 'authorize_github'. This leaves the agent under-informed for a security-sensitive operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, with one parameter ('code') undocumented in the schema. The description adds minimal value by implying the parameter is an 'authorization code', but it doesn't explain the code's format, source, or validity constraints. This is inadequate compensation for the schema's lack of documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('exchange') and resource ('authorization code for an access token'). It distinguishes itself from sibling tools like 'authorize_github', 'get_user_profile', and 'get_user_repositories' by focusing on token exchange rather than authorization initiation or data retrieval. However, it doesn't explicitly mention the OAuth context or differentiate from other potential token-related operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an authorization code from a prior step like 'authorize_github'), exclusions, or contextual cues. The agent must infer usage from the purpose alone, which is insufficient for optimal tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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