atxtechbro / atxtechbro/dotfiles
GitHub MCP server crashes with nil pointer dereference when accessing tool annotations
- Dominant language
- Shell
- Stars
- 27
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
## Bug Description
The GitHub MCP server is crashing with a nil pointer dereference error when trying to access `tool.Tool.Annotations.ReadOnlyHint`.
## Error Details
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x870a02]
goroutine 1 [running]:
github.com/github/github-mcp-server/pkg/toolsets.(*Toolset).AddReadTools(0xaafa75?, {0xc0001b85b8?, 0xac883d?, 0x2c?})
/home/linuxmint-lp/ppv/pillars/dotfiles/mcp/github-mcp-server/pkg/toolsets/toolsets.go:207 +0x62
```
## Location
The error occurs at line 207 in `mcp/github-mcp-server/pkg/toolsets/toolsets.go`:
```go
func (t *Toolset) AddReadTools(tools ...server.ServerTool) *Toolset {
for _, tool := range tools {
if !*tool.Tool.Annotations.ReadOnlyHint { // <- Line 207: crashes here
panic(fmt.Sprintf("tool (%s) must be annotated as read-only", tool.Tool.Name))
}
}
t.readTools = append(t.readTools, tools...)
return t
}
```
## Root Cause
The code assumes that `tool.Tool.Annotations` and `ReadOnlyHint` are never nil, but it appears one or both can be nil in certain cases.
## Suggested Fix
Add nil checks before dereferencing:
```go
func (t *Toolset) AddReadTools(tools ...server.ServerTool) *Toolset {
for _, tool := range tools {
if tool.Tool.Annotations == nil || tool.Tool.Annotations.ReadOnlyHint == nil {
panic(fmt.Sprintf("tool (%s) must have annotations with ReadOnlyHint", tool.Tool.Name))
}
if !*tool.Tool.Annotations.ReadOnlyHint {
panic(fmt.Sprintf("tool (%s) must be annotated as read-only", tool.Tool.Name))
}
}
t.readTools = append(t.readTools, tools...)
return t
}
```
## Impact
- GitHub MCP server fails to start
- All GitHub-related MCP functionality is unavailable
- Affects both github-read and github-write servers
## Environment
- OS: Linux 6.8.0-60-generic
- Go version: go1.22.2 linux/amd64
- MCP server location: /home/linuxmint-lp/ppv/pillars/dotfiles/mcp/github-mcp-server
## Reproduction Steps
1. Build the GitHub MCP server from source
2. Configure it in Claude Code or other MCP client
3. The server crashes immediately on startup with the nil pointer error
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in mcp/github-mcp-server/pkg/toolsets/toolsets.go around line 207 and build the GitHub MCP server to reproduce the startup panic. Ensure AddReadTools handles missing annotations or ReadOnlyHint without a nil dereference while preserving the read-only validation, then verify that both github-read and github-write servers start successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100