Skip to content

Fix context variable shadowing in server_sdk.go #22

@NP-compete

Description

@NP-compete

Summary

In `server_sdk.go`, a variable named `context` shadows the `context` package, which can cause confusion.

Current State

```go
// internal/mcp/server_sdk.go:155-157
if context, ok := req.Params.Arguments["context"]; ok {
args.Context = context
}
```

Problem

Using `context` as a variable name shadows the `context` package. While this doesn't cause a bug in this specific case (the package isn't used in this scope), it's a code smell that can lead to confusion and bugs in the future.

Expected Outcome

Rename the variable to avoid shadowing:

```go
if ctxArg, ok := req.Params.Arguments["context"]; ok {
args.Context = ctxArg
}
```

Or use a more descriptive name:

```go
if contextValue, ok := req.Params.Arguments["context"]; ok {
args.Context = contextValue
}
```

Acceptance Criteria

  • Variable renamed to not shadow `context` package
  • `go vet` passes without warnings
  • All tests pass
  • Consider enabling `shadow` check in golangci-lint (currently disabled)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions