Skip to content

Commit 609efda

Browse files
authored
Switch to mcp-go (#15)
1 parent 8d33ddb commit 609efda

File tree

5 files changed

+259
-143
lines changed

5 files changed

+259
-143
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Each tool supports various options for customizing output, such as including lin
4343

4444
This codebase makes use of edited code from [gopls](https://go.googlesource.com/tools/+/refs/heads/master/gopls/internal/protocol) to handle LSP communication. See ATTRIBUTION for details.
4545

46-
[mcp-golang](https://github.com/metoro-io/mcp-golang) is used for MCP communication.
46+
[mcp-go](https://github.com/mark3labs/mcp-go) is used for MCP communication.
4747

4848
## Prerequisites
4949

@@ -161,7 +161,6 @@ Include
161161
```
162162
env: {
163163
"LOG_LEVEL": "DEBUG",
164-
"LOG_COMPONENT_LEVELS": "wire:DEBUG"
165164
}
166165
```
167166

@@ -180,4 +179,3 @@ The following features are on my radar:
180179
- [ ] Add LSP server configuration options and presets for common languages
181180
- [ ] Make a more consistent and scalable API for tools (pagination, etc.)
182181
- [ ] Create tools at a higher level of abstraction, combining diagnostics, code lens, hover, and code actions when reading definitions or references.
183-

go.mod

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.0
44

55
require (
66
github.com/fsnotify/fsnotify v1.9.0
7-
github.com/metoro-io/mcp-golang v0.6.0
7+
github.com/mark3labs/mcp-go v0.21.1
88
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
99
github.com/stretchr/testify v1.10.0
1010
golang.org/x/text v0.24.0
@@ -14,22 +14,14 @@ replace github.com/metoro-io/mcp-golang => github.com/isaacphi/mcp-golang v0.0.0
1414

1515
require (
1616
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
17-
github.com/bahlo/generic-list-go v0.2.0 // indirect
18-
github.com/buger/jsonparser v1.1.1 // indirect
1917
github.com/davecgh/go-spew v1.1.1 // indirect
2018
github.com/google/go-cmp v0.7.0 // indirect
21-
github.com/invopop/jsonschema v0.13.0 // indirect
19+
github.com/google/uuid v1.6.0 // indirect
2220
github.com/kisielk/errcheck v1.9.0 // indirect
2321
github.com/kr/pretty v0.3.1 // indirect
24-
github.com/mailru/easyjson v0.9.0 // indirect
25-
github.com/pkg/errors v0.9.1 // indirect
2622
github.com/pmezard/go-difflib v1.0.0 // indirect
2723
github.com/rogpeppe/go-internal v1.14.1 // indirect
28-
github.com/tidwall/gjson v1.18.0 // indirect
29-
github.com/tidwall/match v1.1.1 // indirect
30-
github.com/tidwall/pretty v1.2.1 // indirect
31-
github.com/tidwall/sjson v1.2.5 // indirect
32-
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
24+
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
3325
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
3426
golang.org/x/mod v0.24.0 // indirect
3527
golang.org/x/sync v0.13.0 // indirect

go.sum

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
22
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
3-
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
4-
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
5-
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
6-
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
73
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
84
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
95
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -16,10 +12,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
1612
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
1713
github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=
1814
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
19-
github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E=
20-
github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
21-
github.com/isaacphi/mcp-golang v0.0.0-20250314121746-948e874f9887 h1:mwj41iKcwcR67wBt/fszrEJtGwuGSmSHcjC6u4ZEHdE=
22-
github.com/isaacphi/mcp-golang v0.0.0-20250314121746-948e874f9887/go.mod h1:ifLP9ZzKpN1UqFWNTpAHOqSvNkMK6b7d1FSZ5Lu0lN0=
15+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
16+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
2317
github.com/kisielk/errcheck v1.9.0 h1:9xt1zI9EBfcYBvdU1nVrzMzzUPUtPKs9bVSIM3TAb3M=
2418
github.com/kisielk/errcheck v1.9.0/go.mod h1:kQxWMMVZgIkDq7U8xtG/n2juOjbLgZtedi0D+/VL/i8=
2519
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
@@ -29,11 +23,9 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
2923
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
3024
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
3125
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
32-
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
33-
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
26+
github.com/mark3labs/mcp-go v0.21.1 h1:7Ek6KPIIbMhEYHRiRIg6K6UAgNZCJaHKQp926MNr6V0=
27+
github.com/mark3labs/mcp-go v0.21.1/go.mod h1:KmJndYv7GIgcPVwEKJjNcbhVQ+hJGJhrCCB/9xITzpE=
3428
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
35-
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
36-
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
3729
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3830
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3931
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
@@ -45,18 +37,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
4537
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
4638
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
4739
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
48-
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
49-
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
50-
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
51-
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
52-
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
53-
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
54-
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
55-
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
56-
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
57-
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
58-
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
59-
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
40+
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
41+
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
6042
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac h1:TSSpLIG4v+p0rPv1pNOQtl1I8knsO4S9trOxNMOLVP4=
6143
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
6244
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=

main.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import (
1414
"github.com/isaacphi/mcp-language-server/internal/logging"
1515
"github.com/isaacphi/mcp-language-server/internal/lsp"
1616
"github.com/isaacphi/mcp-language-server/internal/watcher"
17-
"github.com/metoro-io/mcp-golang"
18-
"github.com/metoro-io/mcp-golang/transport/stdio"
17+
"github.com/mark3labs/mcp-go/server"
1918
)
2019

2120
// Create a logger for the core component
@@ -27,10 +26,10 @@ type config struct {
2726
lspArgs []string
2827
}
2928

30-
type server struct {
29+
type mcpServer struct {
3130
config config
3231
lspClient *lsp.Client
33-
mcpServer *mcp_golang.Server
32+
mcpServer *server.MCPServer
3433
ctx context.Context
3534
cancelFunc context.CancelFunc
3635
workspaceWatcher *watcher.WorkspaceWatcher
@@ -72,16 +71,16 @@ func parseConfig() (*config, error) {
7271
return cfg, nil
7372
}
7473

75-
func newServer(config *config) (*server, error) {
74+
func newServer(config *config) (*mcpServer, error) {
7675
ctx, cancel := context.WithCancel(context.Background())
77-
return &server{
76+
return &mcpServer{
7877
config: *config,
7978
ctx: ctx,
8079
cancelFunc: cancel,
8180
}, nil
8281
}
8382

84-
func (s *server) initializeLSP() error {
83+
func (s *mcpServer) initializeLSP() error {
8584
if err := os.Chdir(s.config.workspaceDir); err != nil {
8685
return fmt.Errorf("failed to change to workspace directory: %v", err)
8786
}
@@ -104,18 +103,24 @@ func (s *server) initializeLSP() error {
104103
return client.WaitForServerReady(s.ctx)
105104
}
106105

107-
func (s *server) start() error {
106+
func (s *mcpServer) start() error {
108107
if err := s.initializeLSP(); err != nil {
109108
return err
110109
}
111110

112-
s.mcpServer = mcp_golang.NewServer(stdio.NewStdioServerTransport())
111+
s.mcpServer = server.NewMCPServer(
112+
"MCP Language Server",
113+
"v0.0.2",
114+
server.WithLogging(),
115+
server.WithRecovery(),
116+
)
117+
113118
err := s.registerTools()
114119
if err != nil {
115120
return fmt.Errorf("tool registration failed: %v", err)
116121
}
117122

118-
return s.mcpServer.Serve()
123+
return server.ServeStdio(s.mcpServer)
119124
}
120125

121126
func main() {
@@ -185,7 +190,7 @@ func main() {
185190
os.Exit(0)
186191
}
187192

188-
func cleanup(s *server, done chan struct{}) {
193+
func cleanup(s *mcpServer, done chan struct{}) {
189194
coreLogger.Info("Cleanup initiated for PID: %d", os.Getpid())
190195

191196
// Create a context with timeout for shutdown operations

0 commit comments

Comments
 (0)