Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: extend user agent#237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SamMorrowDrums merged 1 commit intomainfromextend-user-agent
Apr 12, 2025
Merged

chore: extend user agent#237

SamMorrowDrums merged 1 commit intomainfromextend-user-agent
Apr 12, 2025

Conversation

SamMorrowDrums
Copy link
Collaborator

This gets you things like:github-mcp-server/<version> (Visual Studio Code - Insiders/<version>) if provided by the host.

digitarald reacted with heart emoji
@CopilotCopilotAI review requested due to automatic review settingsApril 12, 2025 09:25
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends the user agent string by integrating host-supplied client details into the server initialization process.

  • Introduces a new hook function, beforeInit, that modifies the user agent with client information.
  • Updates the server initialization to include hooks.
  • Adds a new package import required for the extended functionality.

@@ -137,11 +138,19 @@ func runStdioServer(cfg runConfig) error {

t, dumpTranslations := translations.TranslationHelper()

beforeInit := func(_ context.Context, _ any, message *mcp.InitializeRequest) {
ghClient.UserAgent = fmt.Sprintf("github-mcp-server/%s (%s/%s)", version, message.Params.ClientInfo.Name, message.Params.ClientInfo.Version)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Haven't looked into how hooks work in depth, so bear with me, one question that I have is whether we need to protect this with a mutex.

Copy link
Collaborator

@juruenjuruenApr 12, 2025
edited
Loading

Choose a reason for hiding this comment

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

Disregard my comment. Even we wanted to protect it with a mutex, we couldn't because this is in the github.Client.

Copy link
Collaborator

@juruenjuruenApr 12, 2025
edited
Loading

Choose a reason for hiding this comment

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

So, if I understand this correctly. This is going to be OK from a race condition standpoint if host/client always initializes the server before doing anything else.

The only way to cause a race here is by calling a tool and initializing at the same time.

SamMorrowDrums reacted with thumbs up emoji
Copy link
Collaborator

@juruenjuruenApr 12, 2025
edited
Loading

Choose a reason for hiding this comment

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

If you wanted to completely remove the possibility of a race, you could make things slightly more complex and set the client info into a different variable protected by a mutex. And then, you could set the client agent accordingly.

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

Yeah, that's a good shout. I was thinking about this too, but it is only a one-shot event, and if it happens a second time it can also update the info, that's fine.

Copy link
Collaborator

@juruenjuruen left a comment
edited
Loading

Choose a reason for hiding this comment

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

LGTM! I added a comment re: races as Ithink there might be a chance to trigger one. However, if the server behaves correctly, it shouldn't happen.

@SamMorrowDrumsSamMorrowDrums merged commit9dacf70 intomainApr 12, 2025
16 checks passed
@SamMorrowDrumsSamMorrowDrums deleted the extend-user-agent branchApril 12, 2025 10:24
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@juruenjuruenjuruen approved these changes

Copilot code reviewCopilotCopilot left review comments

@williammartinwilliammartinAwaiting requested review from williammartin

@tobytobyAwaiting requested review from toby

@digitaralddigitaraldAwaiting requested review from digitarald

@timrogerstimrogersAwaiting requested review from timrogers

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@SamMorrowDrums@juruen

[8]ページ先頭

©2009-2025 Movatter.jp