• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

valksor / go-assern / 26285265118

22 May 2026 11:31AM UTC coverage: 51.35% (+5.7%) from 45.617%
26285265118

push

github

k0d3r1s
Ignores local Claude memory files

The local memory server creates files that are not meant for version control. These rules ensure they stay out of the repository.

2909 of 5665 relevant lines covered (51.35%)

75.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.23
/internal/instance/session.go
1
package instance
2

3
import (
4
        "fmt"
5
        "sync"
6
        "sync/atomic"
7

8
        "github.com/mark3labs/mcp-go/mcp"
9
        "github.com/mark3labs/mcp-go/server"
10
)
11

12
// sessionCounter provides unique session IDs.
13
var sessionCounter atomic.Uint64
14

15
// socketSession implements server.ClientSession for socket connections.
16
// Each socket connection gets its own unique session to avoid conflicts
17
// with the stdio session used by the primary instance.
18
//
19
// It also implements server.SessionWithTools so that runtime tool discovery
20
// can scope loaded tools to a single client, keeping one client's discovery
21
// state from leaking to others sharing the same instance.
22
type socketSession struct {
23
        id                 string
24
        notifications      chan mcp.JSONRPCNotification
25
        initialized        atomic.Bool
26
        loggingLevel       atomic.Value
27
        clientInfo         atomic.Value
28
        clientCapabilities atomic.Value
29

30
        toolsMu      sync.RWMutex
31
        sessionTools map[string]server.ServerTool
32
}
33

34
// newSocketSession creates a new session with a unique ID for a socket connection.
35
func newSocketSession() *socketSession {
37✔
36
        return &socketSession{
37✔
37
                id:            fmt.Sprintf("socket-%d", sessionCounter.Add(1)),
37✔
38
                notifications: make(chan mcp.JSONRPCNotification, 100),
37✔
39
                sessionTools:  make(map[string]server.ServerTool),
37✔
40
        }
37✔
41
}
37✔
42

43
// GetSessionTools returns the per-session tools loaded for this connection.
44
func (s *socketSession) GetSessionTools() map[string]server.ServerTool {
6✔
45
        s.toolsMu.RLock()
6✔
46
        defer s.toolsMu.RUnlock()
6✔
47

6✔
48
        return s.sessionTools
6✔
49
}
6✔
50

51
// SetSessionTools replaces the per-session tools for this connection.
52
func (s *socketSession) SetSessionTools(tools map[string]server.ServerTool) {
×
53
        s.toolsMu.Lock()
×
54
        defer s.toolsMu.Unlock()
×
55

×
56
        s.sessionTools = tools
×
57
}
×
58

59
func (s *socketSession) SessionID() string {
85✔
60
        return s.id
85✔
61
}
85✔
62

63
func (s *socketSession) NotificationChannel() chan<- mcp.JSONRPCNotification {
1✔
64
        return s.notifications
1✔
65
}
1✔
66

67
func (s *socketSession) Initialize() {
13✔
68
        s.loggingLevel.Store(mcp.LoggingLevelError)
13✔
69
        s.initialized.Store(true)
13✔
70
}
13✔
71

72
func (s *socketSession) Initialized() bool {
2✔
73
        return s.initialized.Load()
2✔
74
}
2✔
75

76
func (s *socketSession) GetClientInfo() mcp.Implementation {
2✔
77
        if value := s.clientInfo.Load(); value != nil {
3✔
78
                if clientInfo, ok := value.(mcp.Implementation); ok {
2✔
79
                        return clientInfo
1✔
80
                }
1✔
81
        }
82

83
        return mcp.Implementation{}
1✔
84
}
85

86
func (s *socketSession) SetClientInfo(clientInfo mcp.Implementation) {
13✔
87
        s.clientInfo.Store(clientInfo)
13✔
88
}
13✔
89

90
func (s *socketSession) GetClientCapabilities() mcp.ClientCapabilities {
2✔
91
        if value := s.clientCapabilities.Load(); value != nil {
3✔
92
                if clientCapabilities, ok := value.(mcp.ClientCapabilities); ok {
2✔
93
                        return clientCapabilities
1✔
94
                }
1✔
95
        }
96

97
        return mcp.ClientCapabilities{}
1✔
98
}
99

100
func (s *socketSession) SetClientCapabilities(clientCapabilities mcp.ClientCapabilities) {
13✔
101
        s.clientCapabilities.Store(clientCapabilities)
13✔
102
}
13✔
103

104
func (s *socketSession) SetLogLevel(level mcp.LoggingLevel) {
4✔
105
        s.loggingLevel.Store(level)
4✔
106
}
4✔
107

108
func (s *socketSession) GetLogLevel() mcp.LoggingLevel {
6✔
109
        level := s.loggingLevel.Load()
6✔
110
        if level == nil {
7✔
111
                return mcp.LoggingLevelError
1✔
112
        }
1✔
113

114
        if l, ok := level.(mcp.LoggingLevel); ok {
10✔
115
                return l
5✔
116
        }
5✔
117

118
        return mcp.LoggingLevelError
×
119
}
120

121
// close closes the notification channel.
122
func (s *socketSession) close() {
20✔
123
        close(s.notifications)
20✔
124
}
20✔
125

126
// Compile-time guarantee that socketSession supports per-session tools.
127
var _ server.SessionWithTools = (*socketSession)(nil)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc