Skip to content

Commit 4617b1e

Browse files
authored
Merge pull request #3 from leavez/trival
trivial
2 parents ffc5f08 + 4f583a4 commit 4617b1e

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

client/client.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ type Client struct {
2626
// NewClient creates a new MCP client with the given transport.
2727
// Usage:
2828
//
29-
// client, err := NewClient(transport.NewStdio("mcp", nil, "--stdio"))
29+
// stdio := transport.NewStdio("./mcp_server", nil, "xxx")
30+
// client, err := NewClient(stdio)
3031
// if err != nil {
31-
// log.Fatalf("Failed to create client: %v", err)
32+
// log.Fatalf("Failed to create client: %v", err)
3233
// }
3334
func NewClient(transport transport.Interface) *Client {
3435
return &Client{

client/sse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func NewSSEMCPClient(baseURL string, options ...transport.ClientOption) (*Client
3030

3131
// GetEndpoint returns the current endpoint URL for the SSE connection.
3232
//
33-
// Note: This method only works with SSE transport.
33+
// Note: This method only works with SSE transport, or it will panic.
3434
func GetEndpoint(c *Client) *url.URL {
3535
t := c.GetTransport()
3636
sse := t.(*transport.SSE)

client/stdio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewStdioMCPClient(
3232
// GetStderr returns a reader for the stderr output of the subprocess.
3333
// This can be used to capture error messages or logs from the subprocess.
3434
//
35-
// Note: This method only works with stdio transport.
35+
// Note: This method only works with stdio transport, or it will panic.
3636
func GetStderr(c *Client) io.Reader {
3737
t := c.GetTransport()
3838
stdio := t.(*transport.Stdio)

client/transport/sse.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ func (c *SSE) Start(ctx context.Context) error {
9797
req.Header.Set("Cache-Control", "no-cache")
9898
req.Header.Set("Connection", "keep-alive")
9999

100+
// set custom http headers
101+
for k, v := range c.headers {
102+
req.Header.Set(k, v)
103+
}
104+
100105
resp, err := c.httpClient.Do(req)
101106
if err != nil {
102107
return fmt.Errorf("failed to connect to SSE stream: %w", err)

0 commit comments

Comments
 (0)