Skip to content

Commit d26d381

Browse files
committed
fix(auth-middleware): update function signatures to use correct MCP types after rebase
1 parent c424ec4 commit d26d381

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

examples/server/auth-middleware/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ go 1.23.0
44

55
require (
66
github.com/golang-jwt/jwt/v5 v5.2.2
7-
github.com/modelcontextprotocol/go-sdk v0.0.0
7+
github.com/modelcontextprotocol/go-sdk v0.3.0
88
)
99

1010
require (
11-
github.com/google/jsonschema-go v0.2.0 // indirect
11+
github.com/google/jsonschema-go v0.2.1-0.20250825175020-748c325cec76 // indirect
1212
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
1313
)
1414

examples/server/auth-middleware/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeD
22
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
33
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
44
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
5-
github.com/google/jsonschema-go v0.2.0 h1:Uh19091iHC56//WOsAd1oRg6yy1P9BpSvpjOL6RcjLQ=
6-
github.com/google/jsonschema-go v0.2.0/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
5+
github.com/google/jsonschema-go v0.2.1-0.20250825175020-748c325cec76 h1:mBlBwtDebdDYr+zdop8N62a44g+Nbv7o2KjWyS1deR4=
6+
github.com/google/jsonschema-go v0.2.1-0.20250825175020-748c325cec76/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
77
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
88
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
99
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=

examples/server/auth-middleware/main.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,19 @@ type CreateResourceArgs struct {
137137
}
138138

139139
// SayHi is a simple MCP tool that requires authentication
140-
func SayHi(ctx context.Context, req *mcp.ServerRequest[*mcp.CallToolParamsFor[struct{}]]) (*mcp.CallToolResultFor[struct{}], error) {
140+
func SayHi(ctx context.Context, req *mcp.CallToolRequest, args struct{}) (*mcp.CallToolResult, any, error) {
141141
// Extract user information from context (set by auth middleware)
142142
userInfo := ctx.Value("user_info").(*auth.TokenInfo)
143143

144-
return &mcp.CallToolResultFor[struct{}]{
144+
return &mcp.CallToolResult{
145145
Content: []mcp.Content{
146146
&mcp.TextContent{Text: fmt.Sprintf("Hello! You have scopes: %v", userInfo.Scopes)},
147147
},
148-
}, nil
148+
}, nil, nil
149149
}
150150

151151
// GetUserInfo is an MCP tool that requires read scope
152-
func GetUserInfo(ctx context.Context, req *mcp.ServerRequest[*mcp.CallToolParamsFor[GetUserInfoArgs]]) (*mcp.CallToolResultFor[struct{}], error) {
152+
func GetUserInfo(ctx context.Context, req *mcp.CallToolRequest, args GetUserInfoArgs) (*mcp.CallToolResult, any, error) {
153153
// Extract user information from context (set by auth middleware)
154154
userInfo := ctx.Value("user_info").(*auth.TokenInfo)
155155

@@ -163,26 +163,26 @@ func GetUserInfo(ctx context.Context, req *mcp.ServerRequest[*mcp.CallToolParams
163163
}
164164

165165
if !hasReadScope {
166-
return nil, fmt.Errorf("insufficient permissions: read scope required")
166+
return nil, nil, fmt.Errorf("insufficient permissions: read scope required")
167167
}
168168

169169
userData := map[string]interface{}{
170-
"requested_user_id": req.Params.Arguments.UserID,
170+
"requested_user_id": args.UserID,
171171
"your_scopes": userInfo.Scopes,
172172
"message": "User information retrieved successfully",
173173
}
174174

175175
userDataJSON, _ := json.Marshal(userData)
176176

177-
return &mcp.CallToolResultFor[struct{}]{
177+
return &mcp.CallToolResult{
178178
Content: []mcp.Content{
179179
&mcp.TextContent{Text: string(userDataJSON)},
180180
},
181-
}, nil
181+
}, nil, nil
182182
}
183183

184184
// CreateResource is an MCP tool that requires write scope
185-
func CreateResource(ctx context.Context, req *mcp.ServerRequest[*mcp.CallToolParamsFor[CreateResourceArgs]]) (*mcp.CallToolResultFor[struct{}], error) {
185+
func CreateResource(ctx context.Context, req *mcp.CallToolRequest, args CreateResourceArgs) (*mcp.CallToolResult, any, error) {
186186
// Extract user information from context (set by auth middleware)
187187
userInfo := ctx.Value("user_info").(*auth.TokenInfo)
188188

@@ -196,24 +196,24 @@ func CreateResource(ctx context.Context, req *mcp.ServerRequest[*mcp.CallToolPar
196196
}
197197

198198
if !hasWriteScope {
199-
return nil, fmt.Errorf("insufficient permissions: write scope required")
199+
return nil, nil, fmt.Errorf("insufficient permissions: write scope required")
200200
}
201201

202202
resourceInfo := map[string]interface{}{
203-
"name": req.Params.Arguments.Name,
204-
"description": req.Params.Arguments.Description,
205-
"content": req.Params.Arguments.Content,
203+
"name": args.Name,
204+
"description": args.Description,
205+
"content": args.Content,
206206
"created_by": "authenticated_user",
207207
"created_at": time.Now().Format(time.RFC3339),
208208
}
209209

210210
resourceInfoJSON, _ := json.Marshal(resourceInfo)
211211

212-
return &mcp.CallToolResultFor[struct{}]{
212+
return &mcp.CallToolResult{
213213
Content: []mcp.Content{
214214
&mcp.TextContent{Text: fmt.Sprintf("Resource created successfully: %s", string(resourceInfoJSON))},
215215
},
216-
}, nil
216+
}, nil, nil
217217
}
218218

219219
// authMiddleware extracts token information and adds it to the context

0 commit comments

Comments
 (0)