internal/mcp: add more package documentation, examples
Add more documentation for the mcp package, explaining how to create and use Clients and Servers. Also add an example of using the SSEHandler to crete an MCP server. Change-Id: Ib327826b2cdb1e3418482551c65569ec6f01af33 Reviewed-on: https://go-review.googlesource.com/c/tools/+/668715 Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Neal Patel <nealpatel@google.com> Auto-Submit: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
56ed3872f3
commit
ffa7599a10
1 changed files with 117 additions and 16 deletions
10
mcp/sse.go
10
mcp/sse.go
|
|
@ -277,14 +277,16 @@ type SSEClientTransport struct {
|
|||
|
||||
// NewSSEClientTransport returns a new client transport that connects to the
|
||||
// SSE server at the provided URL.
|
||||
func NewSSEClientTransport(rawURL string) (*SSEClientTransport, error) {
|
||||
url, err := url.Parse(rawURL)
|
||||
//
|
||||
// NewSSEClientTransport panics if the given URL is invalid.
|
||||
func NewSSEClientTransport(baseURL string) *SSEClientTransport {
|
||||
url, err := url.Parse(baseURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
panic(fmt.Sprintf("invalid base url: %v", err))
|
||||
}
|
||||
return &SSEClientTransport{
|
||||
sseEndpoint: url,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Connect connects through the client endpoint.
|
||||
|
|
|
|||
Loading…
Reference in a new issue