fix(observability): include MCP session ID in access logs
Some checks failed
CI / build-and-test (push) Failing after -32m50s
Some checks failed
CI / build-and-test (push) Failing after -32m50s
* Add function to extract MCP session ID from request headers and query parameters * Update access log to include MCP session ID fix(cli): simplify project lookup logic * Refactor project retrieval to prefer GUID lookup when input is a valid UUID * Introduce separate functions for fetching projects by GUID and name
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -132,11 +131,10 @@ func connectRemote(ctx context.Context) (*mcp.ClientSession, error) {
|
||||
verboseLogf("connecting to %s", endpointURL())
|
||||
client := mcp.NewClient(&mcp.Implementation{Name: "amcs-cli", Version: "0.0.1"}, nil)
|
||||
transport := &mcp.StreamableClientTransport{
|
||||
Endpoint: endpointURL(),
|
||||
HTTPClient: newHTTPClient(),
|
||||
Endpoint: endpointURL(),
|
||||
HTTPClient: newHTTPClient(),
|
||||
DisableStandaloneSSE: true,
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
|
||||
defer cancel()
|
||||
session, err := client.Connect(ctx, transport, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("connect to AMCS server: %w", err)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -26,11 +25,8 @@ var sseCmd = &cobra.Command{
|
||||
HTTPClient: newHTTPClient(),
|
||||
}
|
||||
|
||||
connectCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
verboseLogf("connecting to SSE endpoint %s", sseEndpointURL())
|
||||
remote, err := client.Connect(connectCtx, transport, nil)
|
||||
remote, err := client.Connect(ctx, transport, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("connect to AMCS SSE endpoint: %w", err)
|
||||
}
|
||||
@@ -79,6 +75,9 @@ var sseCmd = &cobra.Command{
|
||||
|
||||
func sseEndpointURL() string {
|
||||
base := strings.TrimRight(strings.TrimSpace(cfg.Server), "/")
|
||||
if strings.HasSuffix(base, "/mcp") {
|
||||
base = strings.TrimSuffix(base, "/mcp")
|
||||
}
|
||||
if strings.HasSuffix(base, "/sse") {
|
||||
return base
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user