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
Is your feature request related to a problem? Please describe.
If I prompt "Read my blog repo and do a thing", it asks me "What's your Github username?" But, it should know that. It has an access token.
The key issue here is that the MCP server does not currently determine or expose the GitHub username or account associated with the access token (GITHUB_PERSONAL_ACCESS_TOKEN). This causes problems when the LLM tries to execute user-specific queries, such as searching for repositories owned by the authenticated user.
Describe the solution you'd like
Solution: Automatically Determine the GitHub User
To improve accuracy, the MCP server should:
Retrieve the authenticated user's GitHub identity upon startup.
Store this identity for reference in tool executions.
Expose it as an available parameter or auto-fill it in requests when appropriate.
Implementation Plan
Fetch the authenticated GitHub user using the GitHub API's /user endpoint:
asyncfunctiongetAuthenticatedUser(){constresponse=awaitfetch("https://api.github.com/user",{headers: {Authorization: `token ${process.env.GITHUB_PERSONAL_ACCESS_TOKEN}`,"User-Agent": "github-mcp-server",},});if(!response.ok){thrownewError(`Failed to fetch authenticated user: ${response.statusText}`);}returnresponse.json();}
Store the username in the server state on initialization:
letauthenticatedGitHubUser=null;asyncfunctioninitializeServer(){try{constuser=awaitgetAuthenticatedUser();authenticatedGitHubUser=user.login;console.log(`Authenticated as GitHub user: ${authenticatedGitHubUser}`);}catch(error){console.error("Error retrieving GitHub user:",error);process.exit(1);}}
Use this stored username to modify tool behavior:
If a request lacks an explicit username, default to authenticatedGitHubUser.
Example: Modify repository searches:
case"search_repositories": {constargs=repository.SearchRepositoriesSchema.parse(request.params.arguments);constusername=args.owner||authenticatedGitHubUser;// Use stored username if not providedconstresults=awaitrepository.searchRepositories(username,args.query,args.page,args.perPage);return{content: [{type: "text",text: JSON.stringify(results,null,2)}],};}
Expose the GitHub username in the ListToolsRequestSchema response so the LLM can reference it explicitly:
Is your feature request related to a problem? Please describe.
If I prompt "Read my blog repo and do a thing", it asks me "What's your Github username?" But, it should know that. It has an access token.
The key issue here is that the MCP server does not currently determine or expose the GitHub username or account associated with the access token (
GITHUB_PERSONAL_ACCESS_TOKEN
). This causes problems when the LLM tries to execute user-specific queries, such as searching for repositories owned by the authenticated user.Describe the solution you'd like
Solution: Automatically Determine the GitHub User
To improve accuracy, the MCP server should:
Implementation Plan
Fetch the authenticated GitHub user using the GitHub API's
/user
endpoint:Store the username in the server state on initialization:
Use this stored username to modify tool behavior:
authenticatedGitHubUser
.Expose the GitHub username in the
ListToolsRequestSchema
response so the LLM can reference it explicitly:Expected Benefits
The text was updated successfully, but these errors were encountered: