many: minor cosmetic changes (#529)

This commit is contained in:
Jonathan Amsterdam 2025-09-25 16:06:24 -04:00 • committed by GitHub
commit 5f05f8a43a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 21 additions and 21 deletions

View file

@ -33,7 +33,7 @@ The SDK consists of several importable packages:
their own transports.
- The
[`github.com/modelcontextprotocol/go-sdk/auth`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/auth)
package provides some primitives for supporting oauth.
package provides some primitives for supporting OAuth.
- The
[`github.com/modelcontextprotocol/go-sdk/oauthex`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/oauthex)
package provides extensions to the OAuth protocol, such as ProtectedResourceMetadata.
@ -78,7 +78,7 @@ func main() {
// Create a server with a single tool.
server := mcp.NewServer(&mcp.Implementation{Name: "greeter", Version: "v1.0.0"}, nil)
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, SayHi)
// Run the server over stdin/stdout, until the client disconnects
// Run the server over stdin/stdout, until the client disconnects.
if err := server.Run(context.Background(), &mcp.StdioTransport{}); err != nil {
log.Fatal(err)
}
@ -106,7 +106,7 @@ func main() {
// Create a new client, with no features.
client := mcp.NewClient(&mcp.Implementation{Name: "mcp-client", Version: "v1.0.0"}, nil)
// Connect to a server over stdin/stdout
// Connect to a server over stdin/stdout.
transport := &mcp.CommandTransport{Command: exec.Command("myserver")}
session, err := client.Connect(ctx, transport, nil)
if err != nil {

View file

@ -56,8 +56,6 @@ func TokenInfoFromContext(ctx context.Context) *TokenInfo {
// If verification succeeds, the [TokenInfo] is added to the request's context and the request proceeds.
// If verification fails, the request fails with a 401 Unauthenticated, and the WWW-Authenticate header
// is populated to enable [protected resource metadata].
//
//
// [protected resource metadata]: https://datatracker.ietf.org/doc/rfc9728
func RequireBearerToken(verifier TokenVerifier, opts *RequireBearerTokenOptions) func(http.Handler) http.Handler {

View file

@ -16,8 +16,8 @@ type ID struct {
value any
}
// MakeID coerces the given Go value to an ID. The value is assumed to be the
// default JSON marshaling of a Request identifier -- nil, float64, or string.
// MakeID coerces the given Go value to an ID. The value should be the
// default JSON marshaling of a Request identifier: nil, float64, or string.
//
// Returns an error if the value type was not a valid Request ID type.
//

View file

@ -32,7 +32,7 @@ The SDK consists of several importable packages:
their own transports.
- The
[`github.com/modelcontextprotocol/go-sdk/auth`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/auth)
package provides some primitives for supporting oauth.
package provides some primitives for supporting OAuth.
- The
[`github.com/modelcontextprotocol/go-sdk/oauthex`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/oauthex)
package provides extensions to the OAuth protocol, such as ProtectedResourceMetadata.

View file

@ -19,7 +19,7 @@ func main() {
// Create a new client, with no features.
client := mcp.NewClient(&mcp.Implementation{Name: "mcp-client", Version: "v1.0.0"}, nil)
// Connect to a server over stdin/stdout
// Connect to a server over stdin/stdout.
transport := &mcp.CommandTransport{Command: exec.Command("myserver")}
session, err := client.Connect(ctx, transport, nil)
if err != nil {

View file

@ -32,7 +32,7 @@ func main() {
// Create a server with a single tool.
server := mcp.NewServer(&mcp.Implementation{Name: "greeter", Version: "v1.0.0"}, nil)
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, SayHi)
// Run the server over stdin/stdout, until the client disconnects
// Run the server over stdin/stdout, until the client disconnects.
if err := server.Run(context.Background(), &mcp.StdioTransport{}); err != nil {
log.Fatal(err)
}

View file

@ -19,8 +19,8 @@ type (
Response = jsonrpc2.Response
)
// MakeID coerces the given Go value to an ID. The value is assumed to be the
// default JSON marshaling of a Request identifier -- nil, float64, or string.
// MakeID coerces the given Go value to an ID. The value should be the
// default JSON marshaling of a Request identifier: nil, float64, or string.
//
// Returns an error if the value type was not a valid Request ID type.
func MakeID(v any) (ID, error) {

View file

@ -668,7 +668,7 @@ func (cs *ClientSession) callProgressNotificationHandler(ctx context.Context, pa
// NotifyProgress sends a progress notification from the client to the server
// associated with this session.
// This can be used if the client is performing a long-running task that was
// initiated by the server
// initiated by the server.
func (cs *ClientSession) NotifyProgress(ctx context.Context, params *ProgressNotificationParams) error {
return handleNotify(ctx, notificationProgress, newClientRequest(cs, orZero[Params](params)))
}
@ -701,7 +701,7 @@ func (cs *ClientSession) Resources(ctx context.Context, params *ListResourcesPar
// ResourceTemplates provides an iterator for all resource templates available on the server,
// automatically fetching pages and managing cursors.
// The `params` argument can set the initial cursor.
// The params argument can set the initial cursor.
// Iteration stops at the first encountered error, which will be yielded.
func (cs *ClientSession) ResourceTemplates(ctx context.Context, params *ListResourceTemplatesParams) iter.Seq2[*ResourceTemplate, error] {
if params == nil {

View file

@ -189,7 +189,7 @@ type ResourceContents struct {
Meta Meta `json:"_meta,omitempty"`
}
func (r ResourceContents) MarshalJSON() ([]byte, error) {
func (r *ResourceContents) MarshalJSON() ([]byte, error) {
// If we could assume Go 1.24, we could use omitzero for Blob and avoid this method.
if r.URI == "" {
return nil, errors.New("ResourceContents missing URI")
@ -197,7 +197,7 @@ func (r ResourceContents) MarshalJSON() ([]byte, error) {
if r.Blob == nil {
// Text. Marshal normally.
type wireResourceContents ResourceContents // (lacks MarshalJSON method)
return json.Marshal((wireResourceContents)(r))
return json.Marshal((wireResourceContents)(*r))
}
// Blob.
if r.Text != "" {

View file

@ -176,7 +176,6 @@ type EventStore interface {
// with all of its streams.
// A store cannot rely on this method being called for cleanup. It should institute
// additional mechanisms, such as timeouts, to reclaim storage.
//
SessionClosed(_ context.Context, sessionID string) error
// There is no StreamClosed method. A server doesn't know when a stream is finished, because

View file

@ -18,7 +18,7 @@ import (
)
// Optional annotations for the client. The client can use annotations to inform
// how objects are used or displayed
// how objects are used or displayed.
type Annotations struct {
// Describes who the intended customer of this object or data is.
//

View file

@ -27,6 +27,7 @@ import (
"github.com/yosida95/uritemplate/v3"
)
// DefaultPageSize is the default for [ServerOptions.PageSize].
const DefaultPageSize = 1000
// A Server is an instance of an MCP server.

View file

@ -453,13 +453,13 @@ func clientRequestFor[P Params](s *ClientSession, p P) *ClientRequest[P] {
// Params is a parameter (input) type for an MCP call or notification.
type Params interface {
// isParams discourages implementation of Params outside of this package.
isParams()
// GetMeta returns metadata from a value.
GetMeta() map[string]any
// SetMeta sets the metadata on a value.
SetMeta(map[string]any)
// isParams discourages implementation of Params outside of this package.
isParams()
}
// RequestParams is a parameter (input) type for an MCP request.

View file

@ -7,4 +7,6 @@ package oauthex
import "github.com/modelcontextprotocol/go-sdk/internal/oauthex"
// ProtectedResourceMetadata is the metadata for an OAuth 2.0 protected resource,
// as defined in section 2 of https://www.rfc-editor.org/rfc/rfc9728.html.
type ProtectedResourceMetadata = oauthex.ProtectedResourceMetadata