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: groundwork for multi-user to server#195

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 intomainfrommulti-user-groundwork
Apr 9, 2025

Conversation

SamMorrowDrums
Copy link
Collaborator

In order to facilitate multi-user (MCP Host) to server communication, we need to support new*github.Client clients per request, rather than globally.

This change is a NOOP that makes it possible.

@CopilotCopilotAI review requested due to automatic review settingsApril 9, 2025 13:47
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 lays the groundwork for multi‐user support by updating all GitHub client calls to accept a function returning a per-request GitHub client instead of a global client. Key changes include modifying tool/resource handler function signatures, updating tests to wrap the client in a closure, and propagating these changes across resources, pull requests, issues, and code scanning tools.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

FileDescription
pkg/github/server_test.goUpdated GetMe call to use a client-returning lambda.
pkg/github/server.goIntroduced a getClient function to extract authToken from context and used it for all GitHub client invocations.
pkg/github/search*.go, repositories*.go, pullrequests*.go, issues*.go, code_scanning*.goUpdated function signatures and calls to pass a getClient closure, ensuring per-request client configuration.
Comments suppressed due to low confidence (1)

pkg/github/server.go:21

  • [nitpick] Consider extracting the string literal "authToken" into a named constant to improve clarity and maintainability in contexts where it's used.
authToken, ok := ctx.Value("authToken").(string)

@SamMorrowDrumsSamMorrowDrumsforce-pushed themulti-user-groundwork branch 3 times, most recently fromdbf1375 tob4ca6a9CompareApril 9, 2025 14:30
@@ -13,7 +13,7 @@ import (
"github.com/mark3labs/mcp-go/server"
)

func GetCodeScanningAlert(client*github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
func GetCodeScanningAlert(getClient func(ctx context.Context) (*github.Client, error), t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we create a type with this function signature?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

Yeah, I knew I should really - not hard to fix.

juruen reacted with heart emoji
williammartin
williammartin previously approved these changesApr 9, 2025
Copy link
Collaborator

@williammartinwilliammartin left a comment

Choose a reason for hiding this comment

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

Approved but minor request. Happy for you to bypass under the assumption you just address this if you make any changes!

SamMorrowDrums reacted with heart emoji
@@ -18,7 +18,7 @@ import (
func Test_GetMe(t *testing.T) {
// Verify tool definition
mockClient := github.NewClient(nil)
tool, _ := GetMe(mockClient, translations.NullTranslationHelper)
tool, _ := GetMe(func(_ context.Context) (*github.Client, error) { returnmockClient, nil }, translations.NullTranslationHelper)
Copy link
Collaborator

@williammartinwilliammartinApr 9, 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 wouldn't mind I think a lot of noise could go away with:

funcstubGetClientFn(client*github.Client)GetClientFn {returnfunc(_ context.Context) (*github.Client,error) {returnclient,nil}}funcTest_GetMe(t*testing.T) {// Verify tool definitionmockClient:=github.NewClient(nil)tool,_:=GetMe(stubGetClientFn(mockClient),translations.NullTranslationHelper)...

Or perhaps:

funcstubbedGetClientFn()GetClientFn {returnfunc(_ context.Context) (*github.Client,error) {returngithub.NewClient(nil),nil}}funcTest_GetMe(t*testing.T) {// Verify tool definitiontool,_:=GetMe(stubbedGetClientFn(),translations.NullTranslationHelper)...

Slight preference for the former because it's clearer how the client is being injected.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Made minor edit to names above, just in case you'd already read it.

SamMorrowDrums reacted with heart emoji
@SamMorrowDrumsSamMorrowDrums merged commit3ec8699 intomainApr 9, 2025
16 checks passed
@SamMorrowDrumsSamMorrowDrums deleted the multi-user-groundwork branchApril 9, 2025 23:59
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@williammartinwilliammartinwilliammartin left review comments

Copilot code reviewCopilotCopilot left review comments

@juruenjuruenAwaiting requested review from juruen

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

Successfully merging this pull request may close these issues.

3 participants
@SamMorrowDrums@juruen@williammartin

[8]ページ先頭

©2009-2025 Movatter.jp