Skip to content

Commit 6b09469

Browse files
Merge branch 'modelcontextprotocol:main' into issue/170
2 parents 1228679 + ef2fc60 commit 6b09469

File tree

20 files changed

+877
-129
lines changed

20 files changed

+877
-129
lines changed

README.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
<!-- Autogenerated by weave; DO NOT EDIT -->
2-
# MCP Go SDK v0.5.0
2+
# MCP Go SDK v0.6.0
33

44
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/modelcontextprotocol/go-sdk)
55

66
***BREAKING CHANGES***
77

8-
This version contains breaking changes.
8+
This version contains minor breaking changes.
99
See the [release notes](
10-
https://github.com/modelcontextprotocol/go-sdk/releases/tag/v0.5.0) for details.
10+
https://github.com/modelcontextprotocol/go-sdk/releases/tag/v0.6.0) for details.
1111

1212
[![PkgGoDev](https://pkg.go.dev/badge/github.com/modelcontextprotocol/go-sdk)](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk)
1313

14-
This repository contains an unreleased implementation of the official Go
15-
software development kit (SDK) for the Model Context Protocol (MCP).
14+
This repository contains an implementation of the official Go software
15+
development kit (SDK) for the Model Context Protocol (MCP).
1616

17-
> [!WARNING]
18-
> The SDK is not yet at v1.0.0 and may still be subject to incompatible API
19-
> changes. We aim to tag v1.0.0 in September, 2025. See
20-
> https://github.com/modelcontextprotocol/go-sdk/issues/328 for details.
17+
> [!IMPORTANT]
18+
> The SDK is in release-candidate state, and is going to be tagged v1.0.0
19+
> soon (see https://github.com/modelcontextprotocol/go-sdk/issues/328).
20+
> We do not anticipate significant API changes or instability. Please use it
21+
> and [file issues](https://github.com/modelcontextprotocol/go-sdk/issues/new/choose).
2122
22-
## Package documentation
23+
## Package / Feature documentation
2324

2425
The SDK consists of several importable packages:
2526

@@ -33,11 +34,13 @@ The SDK consists of several importable packages:
3334
- The
3435
[`github.com/modelcontextprotocol/go-sdk/auth`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/auth)
3536
package provides some primitives for supporting oauth.
36-
3737
- The
3838
[`github.com/modelcontextprotocol/go-sdk/oauthex`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/oauthex)
3939
package provides extensions to the OAuth protocol, such as ProtectedResourceMetadata.
4040

41+
The SDK endeavors to implement the full MCP spec. The [`docs/`](/docs/) directory
42+
contains feature documentation, mapping the MCP spec to the packages above.
43+
4144
## Getting started
4245

4346
To get started creating an MCP server, create an `mcp.Server` instance, add
@@ -63,7 +66,11 @@ type Output struct {
6366
Greeting string `json:"greeting" jsonschema:"the greeting to tell to the user"`
6467
}
6568

66-
func SayHi(ctx context.Context, req *mcp.CallToolRequest, input Input) (*mcp.CallToolResult, Output, error) {
69+
func SayHi(ctx context.Context, req *mcp.CallToolRequest, input Input) (
70+
*mcp.CallToolResult,
71+
Output,
72+
error,
73+
) {
6774
return nil, Output{Greeting: "Hi " + input.Name}, nil
6875
}
6976

@@ -78,9 +85,9 @@ func main() {
7885
}
7986
```
8087

81-
To communicate with that server, we can similarly create an `mcp.Client` and
82-
connect it to the corresponding server, by running the server command and
83-
communicating over its stdin/stdout:
88+
To communicate with that server, create an `mcp.Client` and connect it to the
89+
corresponding server, by running the server command and communicating over its
90+
stdin/stdout:
8491

8592
```go
8693
package main
@@ -128,24 +135,18 @@ func main() {
128135
The [`examples/`](/examples/) directory contains more example clients and
129136
servers.
130137

131-
## Design
132-
133-
The design doc for this SDK is at [design.md](./design/design.md), which was
134-
initially reviewed at
135-
[modelcontextprotocol/discussions/364](https://github.com/orgs/modelcontextprotocol/discussions/364).
138+
## Contributing
136139

137-
Further design discussion should occur in
138-
[issues](https://github.com/modelcontextprotocol/go-sdk/issues) (for concrete
139-
proposals) or
140-
[discussions](https://github.com/modelcontextprotocol/go-sdk/discussions) for
141-
open-ended discussion. See [CONTRIBUTING.md](/CONTRIBUTING.md) for details.
140+
We welcome contributions to the SDK! Please see See
141+
[CONTRIBUTING.md](/CONTRIBUTING.md) for details of how to contribute.
142142

143-
## Acknowledgements
143+
## Acknowledgements / Alternatives
144144

145-
Several existing Go MCP SDKs inspired the development and design of this
146-
official SDK, notably [mcp-go](https://github.com/mark3labs/mcp-go), authored
147-
by Ed Zynda. We are grateful to Ed as well as the other contributors to mcp-go,
148-
and to authors and contributors of other SDKs such as
145+
Several third party Go MCP SDKs inspired the development and design of this
146+
official SDK, and continue to be viable alternatives, notably
147+
[mcp-go](https://github.com/mark3labs/mcp-go), originally authored by Ed Zynda.
148+
We are grateful to Ed as well as the other contributors to mcp-go, and to
149+
authors and contributors of other SDKs such as
149150
[mcp-golang](https://github.com/metoro-io/mcp-golang) and
150151
[go-mcp](https://github.com/ThinkInAIXYZ/go-mcp). Thanks to their work, there
151152
is a thriving ecosystem of Go MCP clients and servers.

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<!-- Autogenerated by weave; DO NOT EDIT -->
2-
These docs are a work-in-progress.
3-
42
# Features
53

64
These docs mirror the [official MCP spec](https://modelcontextprotocol.io/specification/2025-06-18).
5+
Use the index below to learn how the SDK implements a particular aspect of the
6+
protocol.
77

88
## Base Protocol
99

docs/client.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ func Example_roots() {
5656
if _, err := s.Connect(ctx, t1, nil); err != nil {
5757
log.Fatal(err)
5858
}
59-
if _, err := c.Connect(ctx, t2, nil); err != nil {
59+
60+
clientSession, err := c.Connect(ctx, t2, nil)
61+
if err != nil {
6062
log.Fatal(err)
6163
}
64+
defer clientSession.Close()
6265

6366
// ...and add a root. The server is notified about the change.
6467
c.AddRoots(&mcp.Root{URI: "file://b"})

docs/protocol.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ If [`RequireBearerTokenOptions.ResourceMetadataURL`](https://pkg.go.dev/github.c
254254
the middleware function sets the WWW-Authenticate header as required by the [Protected Resource
255255
Metadata spec](https://datatracker.ietf.org/doc/html/rfc9728).
256256

257+
Server handlers, such as tool handlers, can obtain the `TokenInfo` returned by the `TokenVerifier`
258+
from `req.Extra.TokenInfo`, where `req` is the handler's request. (For example, a
259+
[`CallToolRequest`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#CallToolRequest).)
260+
HTTP handlers wrapped by the `RequireBearerToken` middleware can obtain the `TokenInfo` from the context
261+
with [`auth.TokenInfoFromContext`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/auth#TokenInfoFromContext).
262+
263+
257264
The [_auth middleware example_](https://github.com/modelcontextprotocol/go-sdk/tree/main/examples/server/auth-middleware) shows how to implement authorization for both JWT tokens and API keys.
258265

259266
### Client

0 commit comments

Comments
 (0)