Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/awmg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/githubnext/gh-aw/pkg/cli"
"github.com/githubnext/gh-aw/pkg/awmg"
"github.com/githubnext/gh-aw/pkg/console"
)

Expand All @@ -15,10 +15,10 @@ var (

func main() {
// Set version info
cli.SetVersionInfo(version)
awmg.SetVersionInfo(version)

// Create the mcp-gateway command
cmd := cli.NewMCPGatewayCommand()
cmd := awmg.NewMCPGatewayCommand()

// Update command usage to reflect standalone binary
cmd.Use = "awmg"
Expand Down
2 changes: 1 addition & 1 deletion docs/awmg.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ sandbox:
- ✅ **Protocol Support**: Supports initialize, list_tools, call_tool, list_resources, list_prompts
- ✅ **Comprehensive Logging**: Per-server log files with detailed operation logs
- ✅ **Command Transport**: Subprocess-based MCP servers via stdio
- **HTTP Transport**: HTTP/SSE transport (planned)
- **Streamable HTTP Transport**: HTTP transport using go-sdk StreamableClientTransport
- ⏳ **Docker Support**: Container-based MCP servers (planned)

## Development
Expand Down
52 changes: 46 additions & 6 deletions pkg/cli/mcp_gateway_command.go → pkg/awmg/gateway.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cli
package awmg

import (
"context"
Expand All @@ -18,7 +18,20 @@ import (
"github.com/spf13/cobra"
)

var gatewayLog = logger.New("cli:mcp_gateway")
var gatewayLog = logger.New("awmg:gateway")

// version is set by the main package
var version = "dev"

// SetVersionInfo sets the version information for the awmg package
func SetVersionInfo(v string) {
version = v
}

// GetVersion returns the current version
func GetVersion() string {
return version
}

// MCPGatewayConfig represents the configuration for the MCP gateway
type MCPGatewayConfig struct {
Expand Down Expand Up @@ -504,10 +517,37 @@ func (g *MCPGatewayServer) createMCPSession(serverName string, config MCPServerC

// Handle different server types
if config.URL != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot move current file to awmg package

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the gateway code to pkg/awmg package in commit 7a7d8d7. The package now contains:

  • gateway.go - main gateway implementation with streamable HTTP support
  • gateway_test.go - unit tests
  • gateway_rewrite_test.go - config rewrite tests
  • gateway_integration_test.go - integration tests
  • gateway_inspect_integration_test.go - inspect integration tests

Updated cmd/awmg/main.go to import from github.com/githubnext/gh-aw/pkg/awmg.

// HTTP transport (not yet fully supported in go-sdk for SSE)
gatewayLog.Printf("Attempting HTTP client for %s at %s", serverName, config.URL)
fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("HTTP transport not yet supported for %s", serverName)))
return nil, fmt.Errorf("HTTP transport not yet fully implemented in MCP gateway")
// Streamable HTTP transport using the go-sdk StreamableClientTransport
gatewayLog.Printf("Creating streamable HTTP client for %s at %s", serverName, config.URL)
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Using streamable HTTP transport: %s", config.URL)))

// Create streamable client transport
transport := &mcp.StreamableClientTransport{
Endpoint: config.URL,
}

gatewayLog.Printf("Creating MCP client for %s", serverName)
client := mcp.NewClient(&mcp.Implementation{
Name: fmt.Sprintf("gateway-client-%s", serverName),
Version: GetVersion(),
}, nil)

gatewayLog.Printf("Connecting to MCP server %s with 30s timeout", serverName)
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Connecting to %s...", serverName)))

ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

session, err := client.Connect(ctx, transport, nil)
if err != nil {
gatewayLog.Printf("Failed to connect to HTTP server %s: %v", serverName, err)
fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Connection failed for %s: %v", serverName, err)))
return nil, fmt.Errorf("failed to connect to HTTP server: %w", err)
}

gatewayLog.Printf("Successfully connected to MCP server %s via streamable HTTP", serverName)
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage(fmt.Sprintf("Connected to %s successfully via streamable HTTP", serverName)))
return session, nil
} else if config.Command != "" {
// Command transport (subprocess with stdio)
gatewayLog.Printf("Creating command client for %s with command: %s %v", serverName, config.Command, config.Args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build integration

package cli
package awmg

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build integration

package cli
package awmg

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cli
package awmg

import (
"encoding/json"
Expand Down
Loading