11<!-- Autogenerated by weave; DO NOT EDIT -->
2- # MCP Go SDK v0.3 .0
2+ # MCP Go SDK v0.4 .0
33
44[ ![ Open in GitHub Codespaces] ( https://github.com/codespaces/badge.svg )] ( https://codespaces.new/modelcontextprotocol/go-sdk )
55
66*** BREAKING CHANGES***
77
88This version contains breaking changes.
99See the [ release notes] (
10- https://github.com/modelcontextprotocol/go-sdk/releases/tag/v0.3 .0 ) for details.
10+ https://github.com/modelcontextprotocol/go-sdk/releases/tag/v0.4 .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
@@ -19,18 +19,6 @@ software development kit (SDK) for the Model Context Protocol (MCP).
1919> changes. We aim to tag v1.0.0 in September, 2025. See
2020> https://github.com/modelcontextprotocol/go-sdk/issues/328 for details.
2121
22- ## Design
23-
24- The design doc for this SDK is at [ design.md] ( ./design/design.md ) , which was
25- initially reviewed at
26- [ modelcontextprotocol/discussions/364] ( https://github.com/orgs/modelcontextprotocol/discussions/364 ) .
27-
28- Further design discussion should occur in
29- [ issues] ( https://github.com/modelcontextprotocol/go-sdk/issues ) (for concrete
30- proposals) or
31- [ discussions] ( https://github.com/modelcontextprotocol/go-sdk/discussions ) for
32- open-ended discussion. See [ CONTRIBUTING.md] ( /CONTRIBUTING.md ) for details.
33-
3422## Package documentation
3523
3624The SDK consists of three importable packages:
@@ -39,19 +27,56 @@ The SDK consists of three importable packages:
3927 [ ` github.com/modelcontextprotocol/go-sdk/mcp ` ] ( https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp )
4028 package defines the primary APIs for constructing and using MCP clients and
4129 servers.
42- - The
43- [ ` github.com/modelcontextprotocol/go-sdk/jsonschema ` ] ( https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/jsonschema )
44- package provides an implementation of [ JSON
45- Schema] ( https://json-schema.org/ ) , used for MCP tool input and output schema.
4630- The
4731 [ ` github.com/modelcontextprotocol/go-sdk/jsonrpc ` ] ( https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/jsonrpc ) package is for users implementing
4832 their own transports.
49-
33+ - The
34+ [ ` github.com/modelcontextprotocol/go-sdk/auth ` ] ( https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/auth )
35+ package provides some primitives for supporting oauth.
5036
51- ## Example
37+ ## Getting started
5238
53- In this example, an MCP client communicates with an MCP server running in a
54- sidecar process:
39+ To get started creating an MCP server, create an ` mcp.Server ` instance, add
40+ features to it, and then run it over an ` mcp.Transport ` . For example, this
41+ server adds a single simple tool, and then connects it to clients over
42+ stdin/stdout:
43+
44+ ``` go
45+ package main
46+
47+ import (
48+ " context"
49+ " log"
50+
51+ " github.com/modelcontextprotocol/go-sdk/mcp"
52+ )
53+
54+ type Input struct {
55+ Name string ` json:"name" jsonschema:"the name of the person to greet"`
56+ }
57+
58+ type Output struct {
59+ Greeting string ` json:"greeting" jsonschema:"the greeting to tell to the user"`
60+ }
61+
62+ func SayHi (ctx context .Context , req *mcp .CallToolRequest , input Input ) (*mcp .CallToolResult , Output , error ) {
63+ return nil , Output{Greeting: " Hi " + input.Name }, nil
64+ }
65+
66+ func main () {
67+ // Create a server with a single tool.
68+ server := mcp.NewServer (&mcp.Implementation {Name: " greeter" , Version: " v1.0.0" }, nil )
69+ mcp.AddTool (server, &mcp.Tool {Name: " greet" , Description: " say hi" }, SayHi)
70+ // Run the server over stdin/stdout, until the client disconnects
71+ if err := server.Run (context.Background (), &mcp.StdioTransport {}); err != nil {
72+ log.Fatal (err)
73+ }
74+ }
75+ ```
76+
77+ To communicate with that server, we can similarly create an ` mcp.Client ` and
78+ connect it to the corresponding server, by running the server command and
79+ communicating over its stdin/stdout:
5580
5681``` go
5782package main
@@ -96,42 +121,20 @@ func main() {
96121}
97122```
98123
99- Here's an example of the corresponding server component, which communicates
100- with its client over stdin/stdout:
101-
102- ``` go
103- package main
104-
105- import (
106- " context"
107- " log"
108-
109- " github.com/modelcontextprotocol/go-sdk/mcp"
110- )
111-
112- type HiParams struct {
113- Name string ` json:"name" jsonschema:"the name of the person to greet"`
114- }
115-
116- func SayHi (ctx context .Context , req *mcp .CallToolRequest , args HiParams ) (*mcp .CallToolResult , any , error ) {
117- return &mcp.CallToolResult {
118- Content: []mcp.Content {&mcp.TextContent {Text: " Hi " + args.Name }},
119- }, nil , nil
120- }
124+ The [ ` examples/ ` ] ( /examples/ ) directory contains more example clients and
125+ servers.
121126
122- func main () {
123- // Create a server with a single tool.
124- server := mcp.NewServer (&mcp.Implementation {Name: " greeter" , Version: " v1.0.0" }, nil )
127+ ## Design
125128
126- mcp.AddTool (server, &mcp.Tool {Name: " greet" , Description: " say hi" }, SayHi)
127- // Run the server over stdin/stdout, until the client disconnects
128- if err := server.Run (context.Background (), &mcp.StdioTransport {}); err != nil {
129- log.Fatal (err)
130- }
131- }
132- ```
129+ The design doc for this SDK is at [ design.md] ( ./design/design.md ) , which was
130+ initially reviewed at
131+ [ modelcontextprotocol/discussions/364] ( https://github.com/orgs/modelcontextprotocol/discussions/364 ) .
133132
134- The [ ` examples/ ` ] ( /examples/ ) directory contains more example clients and servers.
133+ Further design discussion should occur in
134+ [ issues] ( https://github.com/modelcontextprotocol/go-sdk/issues ) (for concrete
135+ proposals) or
136+ [ discussions] ( https://github.com/modelcontextprotocol/go-sdk/discussions ) for
137+ open-ended discussion. See [ CONTRIBUTING.md] ( /CONTRIBUTING.md ) for details.
135138
136139## Acknowledgements
137140
0 commit comments