Skip to content

Commit e1a1a34

Browse files
committed
docs: improve documentation clarity and client integration steps
- Fix typo in "TroubleShooting" heading, changing it to "Troubleshooting" - Improve CLI usage instructions by formatting commands as code blocks and marking them with "bash" - Change "Start the Server" to a third-level heading for clarity - Add additional code examples for real-world client testing and interaction steps - Clarify and condense instructions for adding the tool to a popular MCP client Signed-off-by: appleboy <[email protected]>
1 parent 770dbdf commit e1a1a34

File tree

4 files changed

+88
-85
lines changed

4 files changed

+88
-85
lines changed

README.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -40,36 +40,36 @@ stdin/stdout:
4040
package main
4141

4242
import (
43-
"context"
44-
"log"
43+
"context"
44+
"log"
4545

46-
"github.com/modelcontextprotocol/go-sdk/mcp"
46+
"github.com/modelcontextprotocol/go-sdk/mcp"
4747
)
4848

4949
type Input struct {
50-
Name string `json:"name" jsonschema:"the name of the person to greet"`
50+
Name string `json:"name" jsonschema:"the name of the person to greet"`
5151
}
5252

5353
type Output struct {
54-
Greeting string `json:"greeting" jsonschema:"the greeting to tell to the user"`
54+
Greeting string `json:"greeting" jsonschema:"the greeting to tell to the user"`
5555
}
5656

5757
func SayHi(ctx context.Context, req *mcp.CallToolRequest, input Input) (
58-
*mcp.CallToolResult,
59-
Output,
60-
error,
58+
*mcp.CallToolResult,
59+
Output,
60+
error,
6161
) {
62-
return nil, Output{Greeting: "Hi " + input.Name}, nil
62+
return nil, Output{Greeting: "Hi " + input.Name}, nil
6363
}
6464

6565
func main() {
66-
// Create a server with a single tool.
67-
server := mcp.NewServer(&mcp.Implementation{Name: "greeter", Version: "v1.0.0"}, nil)
68-
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, SayHi)
69-
// Run the server over stdin/stdout, until the client disconnects.
70-
if err := server.Run(context.Background(), &mcp.StdioTransport{}); err != nil {
71-
log.Fatal(err)
72-
}
66+
// Create a server with a single tool.
67+
server := mcp.NewServer(&mcp.Implementation{Name: "greeter", Version: "v1.0.0"}, nil)
68+
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, SayHi)
69+
// Run the server over stdin/stdout, until the client disconnects.
70+
if err := server.Run(context.Background(), &mcp.StdioTransport{}); err != nil {
71+
log.Fatal(err)
72+
}
7373
}
7474
```
7575

@@ -81,42 +81,42 @@ stdin/stdout:
8181
package main
8282

8383
import (
84-
"context"
85-
"log"
86-
"os/exec"
84+
"context"
85+
"log"
86+
"os/exec"
8787

88-
"github.com/modelcontextprotocol/go-sdk/mcp"
88+
"github.com/modelcontextprotocol/go-sdk/mcp"
8989
)
9090

9191
func main() {
92-
ctx := context.Background()
93-
94-
// Create a new client, with no features.
95-
client := mcp.NewClient(&mcp.Implementation{Name: "mcp-client", Version: "v1.0.0"}, nil)
96-
97-
// Connect to a server over stdin/stdout.
98-
transport := &mcp.CommandTransport{Command: exec.Command("myserver")}
99-
session, err := client.Connect(ctx, transport, nil)
100-
if err != nil {
101-
log.Fatal(err)
102-
}
103-
defer session.Close()
104-
105-
// Call a tool on the server.
106-
params := &mcp.CallToolParams{
107-
Name: "greet",
108-
Arguments: map[string]any{"name": "you"},
109-
}
110-
res, err := session.CallTool(ctx, params)
111-
if err != nil {
112-
log.Fatalf("CallTool failed: %v", err)
113-
}
114-
if res.IsError {
115-
log.Fatal("tool failed")
116-
}
117-
for _, c := range res.Content {
118-
log.Print(c.(*mcp.TextContent).Text)
119-
}
92+
ctx := context.Background()
93+
94+
// Create a new client, with no features.
95+
client := mcp.NewClient(&mcp.Implementation{Name: "mcp-client", Version: "v1.0.0"}, nil)
96+
97+
// Connect to a server over stdin/stdout.
98+
transport := &mcp.CommandTransport{Command: exec.Command("myserver")}
99+
session, err := client.Connect(ctx, transport, nil)
100+
if err != nil {
101+
log.Fatal(err)
102+
}
103+
defer session.Close()
104+
105+
// Call a tool on the server.
106+
params := &mcp.CallToolParams{
107+
Name: "greet",
108+
Arguments: map[string]any{"name": "you"},
109+
}
110+
res, err := session.CallTool(ctx, params)
111+
if err != nil {
112+
log.Fatalf("CallTool failed: %v", err)
113+
}
114+
if res.IsError {
115+
log.Fatal("tool failed")
116+
}
117+
for _, c := range res.Content {
118+
log.Print(c.(*mcp.TextContent).Text)
119+
}
120120
}
121121
```
122122

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ protocol.
3535
1. [Logging](server.md#logging)
3636
1. [Pagination](server.md#pagination)
3737

38-
# TroubleShooting
38+
# Troubleshooting
3939

4040
See [troubleshooting.md](troubleshooting.md) for a troubleshooting guide.

examples/http/README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The example implements:
1010

1111
## Usage
1212

13-
Start the Server
13+
### Start the Server
1414

1515
```bash
1616
go run main.go server
@@ -31,36 +31,39 @@ The client will:
3131

3232
At any given time you can pass a custom URL to the program to run it on a custom host/port:
3333

34-
```
34+
```bash
3535
go run main.go -host 0.0.0.0 -port 9000 server
3636
```
3737

3838
## Testing with real-world MCP Clients
3939

40-
Once the server is started, assuming it's the default
41-
localhost:8080, you can try to add it to a popular MCP client:
40+
Once the server is started, assuming it's the default localhost:8080, you can try to add it to a popular MCP client:
4241

43-
claude mcp add -t http timezone http://localhost:8080
42+
```bash
43+
claude mcp add -t http timezone http://localhost:8080
44+
```
4445

4546
Once added, Claude Code will be able to discover and use the `cityTime` tool provided by this server.
4647

4748
In Claude Code:
4849

49-
> what's the timezone
50+
```
51+
> what's the timezone
5052
51-
⏺ I'll get the current time in a major US city for you.
53+
⏺ I'll get the current time in a major US city for you.
5254
53-
⏺ timezone - cityTime (MCP)(city: "nyc")
54-
⎿ The current time in New York City is 7:30:16 PM EDT on Wedn
55-
esday, July 23, 2025
55+
⏺ timezone - cityTime (MCP)(city: "nyc")
56+
⎿ The current time in New York City is 7:30:16 PM EDT on Wedn
57+
esday, July 23, 2025
5658
5759
58-
⏺ The current timezone is EDT (Eastern Daylight Time), and it's
59-
7:30 PM on Wednesday, July 23, 2025.
60+
⏺ The current timezone is EDT (Eastern Daylight Time), and it's
61+
7:30 PM on Wednesday, July 23, 2025.
6062
61-
> what timezones do you support?
63+
> what timezones do you support?
6264
63-
⏺ The timezone tool supports three US cities:
64-
- NYC (Eastern Time)
65-
- SF (Pacific Time)
66-
- Boston (Eastern Time)
65+
⏺ The timezone tool supports three US cities:
66+
- NYC (Eastern Time)
67+
- SF (Pacific Time)
68+
- Boston (Eastern Time)
69+
```

examples/server/auth-middleware/README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ server := mcp.NewServer(&mcp.Implementation{Name: "authenticated-mcp-server"}, n
154154

155155
// Create authentication middleware
156156
authMiddleware := auth.RequireBearerToken(verifier, &auth.RequireBearerTokenOptions{
157-
Scopes: []string{"read", "write"},
157+
Scopes: []string{"read", "write"},
158158
})
159159

160160
// Create MCP handler
161161
handler := mcp.NewStreamableHTTPHandler(func(r *http.Request) *mcp.Server {
162-
return server
162+
return server
163163
}, nil)
164164

165165
// Apply authentication middleware to MCP handler
@@ -185,9 +185,9 @@ authenticatedHandler := authMiddleware(customMiddleware(handler))
185185

186186
```go
187187
func jwtVerifier(ctx context.Context, tokenString string) (*auth.TokenInfo, error) {
188-
// JWT token verification logic
189-
// On success: Return TokenInfo
190-
// On failure: Return auth.ErrInvalidToken
188+
// JWT token verification logic
189+
// On success: Return TokenInfo
190+
// On failure: Return auth.ErrInvalidToken
191191
}
192192
```
193193

@@ -196,20 +196,20 @@ func jwtVerifier(ctx context.Context, tokenString string) (*auth.TokenInfo, erro
196196
```go
197197
// Get authentication information in MCP tool
198198
func MyTool(ctx context.Context, req *mcp.CallToolRequest, args MyArgs) (*mcp.CallToolResult, any, error) {
199-
// Extract authentication info from request
200-
userInfo := req.Extra.TokenInfo
201-
202-
// Check scopes
203-
if !slices.Contains(userInfo.Scopes, "read") {
204-
return nil, nil, fmt.Errorf("insufficient permissions: read scope required")
205-
}
206-
207-
// Execute tool logic
208-
return &mcp.CallToolResult{
209-
Content: []mcp.Content{
210-
&mcp.TextContent{Text: "Tool executed successfully"},
211-
},
212-
}, nil, nil
199+
// Extract authentication info from request
200+
userInfo := req.Extra.TokenInfo
201+
202+
// Check scopes
203+
if !slices.Contains(userInfo.Scopes, "read") {
204+
return nil, nil, fmt.Errorf("insufficient permissions: read scope required")
205+
}
206+
207+
// Execute tool logic
208+
return &mcp.CallToolResult{
209+
Content: []mcp.Content{
210+
&mcp.TextContent{Text: "Tool executed successfully"},
211+
},
212+
}, nil, nil
213213
}
214214
```
215215

0 commit comments

Comments
 (0)