Skip to content

Commit e028081

Browse files
authored
docs: use helper functions and return error as result (#322)
Signed-off-by: Navendu Pottekkat <[email protected]>
1 parent 17af676 commit e028081

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ func main() {
5858
}
5959

6060
func helloHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
61-
name, ok := request.GetArguments()["name"].(string)
62-
if !ok {
63-
return nil, errors.New("name must be a string")
61+
name, err := request.RequireString("name")
62+
if err != nil {
63+
return mcp.NewToolResultError(err.Error()), nil
6464
}
6565

6666
return mcp.NewToolResultText(fmt.Sprintf("Hello, %s!", name)), nil
@@ -94,11 +94,15 @@ MCP Go handles all the complex protocol details and server management, so you ca
9494
- [Prompts](#prompts)
9595
- [Examples](#examples)
9696
- [Extras](#extras)
97+
- [Transports](#transports)
9798
- [Session Management](#session-management)
99+
- [Basic Session Handling](#basic-session-handling)
100+
- [Per-Session Tools](#per-session-tools)
101+
- [Tool Filtering](#tool-filtering)
102+
- [Working with Context](#working-with-context)
98103
- [Request Hooks](#request-hooks)
99104
- [Tool Handler Middleware](#tool-handler-middleware)
100105
- [Regenerating Server Code](#regenerating-server-code)
101-
- [Contributing](/CONTRIBUTING.md)
102106

103107
## Installation
104108

0 commit comments

Comments
 (0)