Skip to content

Commit e788759

Browse files
authored
Merge branch 'modelcontextprotocol:main' into add-sequentialthinking-example
2 parents 4c5ac51 + aa9d4b2 commit e788759

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2723
-953
lines changed

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<!-- Autogenerated by weave; DO NOT EDIT -->
2-
# MCP Go SDK
2+
# MCP Go SDK v0.2.0
3+
4+
***BREAKING CHANGES***
5+
6+
This version contains breaking changes.
7+
See the [release notes](
8+
https://github.com/modelcontextprotocol/go-sdk/releases/tag/v0.2.0) for details.
39

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

@@ -26,7 +32,7 @@ open-ended discussion. See CONTRIBUTING.md for details.
2632

2733
## Package documentation
2834

29-
The SDK consists of two importable packages:
35+
The SDK consists of three importable packages:
3036

3137
- The
3238
[`github.com/modelcontextprotocol/go-sdk/mcp`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp)
@@ -36,6 +42,10 @@ The SDK consists of two importable packages:
3642
[`github.com/modelcontextprotocol/go-sdk/jsonschema`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/jsonschema)
3743
package provides an implementation of [JSON
3844
Schema](https://json-schema.org/), used for MCP tool input and output schema.
45+
- The
46+
[`github.com/modelcontextprotocol/jsonrpc`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/jsonschema) package is for users implementing
47+
their own transports.
48+
3949

4050
## Example
4151

@@ -57,7 +67,7 @@ func main() {
5767
ctx := context.Background()
5868

5969
// Create a new client, with no features.
60-
client := mcp.NewClient("mcp-client", "v1.0.0", nil)
70+
client := mcp.NewClient(&mcp.Implementation{Name: "mcp-client", Version: "v1.0.0"}, nil)
6171

6272
// Connect to a server over stdin/stdout
6373
transport := mcp.NewCommandTransport(exec.Command("myserver"))
@@ -99,7 +109,7 @@ import (
99109
)
100110

101111
type HiParams struct {
102-
Name string `json:"name"`
112+
Name string `json:"name", mcp:"the name of the person to greet"`
103113
}
104114

105115
func SayHi(ctx context.Context, cc *mcp.ServerSession, params *mcp.CallToolParamsFor[HiParams]) (*mcp.CallToolResultFor[any], error) {
@@ -110,12 +120,9 @@ func SayHi(ctx context.Context, cc *mcp.ServerSession, params *mcp.CallToolParam
110120

111121
func main() {
112122
// Create a server with a single tool.
113-
server := mcp.NewServer("greeter", "v1.0.0", nil)
114-
server.AddTools(
115-
mcp.NewServerTool("greet", "say hi", SayHi, mcp.Input(
116-
mcp.Property("name", mcp.Description("the name of the person to greet")),
117-
)),
118-
)
123+
server := mcp.NewServer(&mcp.Implementation{Name: "greeter", Version: "v1.0.0"}, nil)
124+
125+
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, SayHi)
119126
// Run the server over stdin/stdout, until the client disconnects
120127
if err := server.Run(context.Background(), mcp.NewStdioTransport()); err != nil {
121128
log.Fatal(err)

design/design.md

Lines changed: 57 additions & 116 deletions
Large diffs are not rendered by default.

examples/completion/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func main() {
4040

4141
// Create the MCP Server instance and assign the handler.
4242
// No server running, just showing the configuration.
43-
_ = mcp.NewServer("myServer", "v1.0.0", &mcp.ServerOptions{
43+
_ = mcp.NewServer(&mcp.Implementation{Name: "server"}, &mcp.ServerOptions{
4444
CompletionHandler: myCompletionHandler,
4545
})
4646

examples/hello/main.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
var httpAddr = flag.String("http", "", "if set, use streamable HTTP at this address, instead of stdin/stdout")
2020

2121
type HiArgs struct {
22-
Name string `json:"name"`
22+
Name string `json:"name" mcp:"the name to say hi to"`
2323
}
2424

2525
func SayHi(ctx context.Context, ss *mcp.ServerSession, params *mcp.CallToolParamsFor[HiArgs]) (*mcp.CallToolResultFor[struct{}], error) {
@@ -42,22 +42,14 @@ func PromptHi(ctx context.Context, ss *mcp.ServerSession, params *mcp.GetPromptP
4242
func main() {
4343
flag.Parse()
4444

45-
server := mcp.NewServer("greeter", "v0.0.1", nil)
46-
server.AddTools(mcp.NewServerTool("greet", "say hi", SayHi, mcp.Input(
47-
mcp.Property("name", mcp.Description("the name to say hi to")),
48-
)))
49-
server.AddPrompts(&mcp.ServerPrompt{
50-
Prompt: &mcp.Prompt{Name: "greet"},
51-
Handler: PromptHi,
52-
})
53-
server.AddResources(&mcp.ServerResource{
54-
Resource: &mcp.Resource{
55-
Name: "info",
56-
MIMEType: "text/plain",
57-
URI: "embedded:info",
58-
},
59-
Handler: handleEmbeddedResource,
60-
})
45+
server := mcp.NewServer(&mcp.Implementation{Name: "greeter"}, nil)
46+
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, SayHi)
47+
server.AddPrompt(&mcp.Prompt{Name: "greet"}, PromptHi)
48+
server.AddResource(&mcp.Resource{
49+
Name: "info",
50+
MIMEType: "text/plain",
51+
URI: "embedded:info",
52+
}, handleEmbeddedResource)
6153

6254
if *httpAddr != "" {
6355
handler := mcp.NewStreamableHTTPHandler(func(*http.Request) *mcp.Server {

0 commit comments

Comments
 (0)