-
Notifications
You must be signed in to change notification settings - Fork 135
feat: add proxy stdio subcommand to enable Claude Desktop #1236
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
353c95c
feat: add proxy stdio subcommand
taskbot ec8719b
add bridge for sse
taskbot 3cd7559
update docs
taskbot ab57689
Update pkg/transport/bridge.go
yrobla 78f0cf6
changes from copilot
taskbot f70fb07
add tests
taskbot f7d9a48
fix for stdio proxy
taskbot 0a26e21
update docs
taskbot 4064485
fix stdio proxy
taskbot 14c6ae8
changes from review
taskbot fe9997d
use mcp-go for proxy
taskbot 24594f4
changes from copilot
taskbot eaab468
Merge branch 'main' into issue-1166
yrobla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package app | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os/signal" | ||
| "syscall" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/stacklok/toolhive/pkg/logger" | ||
| "github.com/stacklok/toolhive/pkg/transport" | ||
| "github.com/stacklok/toolhive/pkg/workloads" | ||
| ) | ||
|
|
||
| var proxyStdioCmd = &cobra.Command{ | ||
| Use: "stdio WORKLOAD-NAME SERVER_NAME", | ||
| Short: "Create a stdio-based proxy for an MCP server", | ||
| Long: `Create a stdio-based proxy that connects stdin/stdout to a target MCP server. | ||
|
|
||
| Example: | ||
| thv proxy stdio my-workload my-server-proxy | ||
| `, | ||
| Args: cobra.ExactArgs(2), | ||
| RunE: proxyStdioCmdFunc, | ||
| } | ||
|
|
||
| func proxyStdioCmdFunc(cmd *cobra.Command, args []string) error { | ||
| ctx, cancel := signal.NotifyContext(cmd.Context(), syscall.SIGINT, syscall.SIGTERM) | ||
| defer cancel() | ||
|
|
||
| workloadName := args[0] | ||
| serverName := args[1] | ||
|
|
||
| workloadManager, err := workloads.NewManager(ctx) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to create workload manager: %w", err) | ||
| } | ||
| stdioWorkload, err := workloadManager.GetWorkload(ctx, workloadName) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to get workload %q: %w", workloadName, err) | ||
| } | ||
| logger.Infof("Starting stdio proxy for server=%q -> %s", serverName, workloadName) | ||
|
|
||
yrobla marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| bridge, err := transport.NewStdioBridge(stdioWorkload.URL) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to create stdio bridge: %w", err) | ||
| } | ||
| bridge.InitReady = make(chan struct{}) | ||
| bridge.Start(ctx) | ||
|
|
||
| // Consume until interrupt | ||
| close(bridge.InitReady) | ||
| <-ctx.Done() | ||
| logger.Info("Shutting down bridge") | ||
| bridge.Shutdown() | ||
| return nil | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.