Skip to content

Commit 1d7dbb1

Browse files
committed
feat: add Go LSP configuration and code navigation documentation
Change-Id: I994c8ee8fa2c246808a9f68a86e83a6a3db6f8ac Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 10db833 commit 1d7dbb1

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed

.mcp.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"mcpServers": {
3+
"go-language-server": {
4+
"type": "stdio",
5+
"command": "go",
6+
"args": [
7+
"run",
8+
"github.com/isaacphi/mcp-language-server@latest",
9+
"-workspace",
10+
"./",
11+
"-lsp",
12+
"go",
13+
"--",
14+
"run",
15+
"golang.org/x/tools/gopls@latest"
16+
],
17+
"env": {}
18+
},
19+
"typescript-language-server": {
20+
"type": "stdio",
21+
"command": "go",
22+
"args": [
23+
"run",
24+
"github.com/isaacphi/mcp-language-server@latest",
25+
"-workspace",
26+
"./site/",
27+
"-lsp",
28+
"pnpx",
29+
"--",
30+
"typescript-language-server",
31+
"--stdio"
32+
],
33+
"env": {}
34+
}
35+
}
36+
}

CLAUDE.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,114 @@ if errors.Is(err, errInvalidPKCE) {
270270
- Test both positive and negative cases
271271
- Use `testutil.WaitLong` for timeouts in tests
272272

273+
## Code Navigation and Investigation
274+
275+
### Using Go LSP Tools (STRONGLY RECOMMENDED)
276+
277+
**IMPORTANT**: Always use Go LSP tools for code navigation and understanding. These tools provide accurate, real-time analysis of the codebase and should be your first choice for code investigation.
278+
279+
When working with the Coder codebase, leverage Go Language Server Protocol tools for efficient code navigation:
280+
281+
1. **Find function definitions** (USE THIS FREQUENTLY):
282+
283+
```none
284+
mcp__go-language-server__definition symbolName
285+
```
286+
287+
- Example: `mcp__go-language-server__definition getOAuth2ProviderAppAuthorize`
288+
- Example: `mcp__go-language-server__definition ExtractAPIKeyMW`
289+
- Quickly jump to function implementations across packages
290+
- **Use this when**: You see a function call and want to understand its implementation
291+
- **Tip**: Include package prefix if symbol is ambiguous (e.g., `httpmw.ExtractAPIKeyMW`)
292+
293+
2. **Find symbol references** (ESSENTIAL FOR UNDERSTANDING IMPACT):
294+
295+
```none
296+
mcp__go-language-server__references symbolName
297+
```
298+
299+
- Example: `mcp__go-language-server__references APITokenFromRequest`
300+
- Locate all usages of functions, types, or variables
301+
- Understand code dependencies and call patterns
302+
- **Use this when**: Making changes to understand what code might be affected
303+
- **Critical for**: Refactoring, deprecating functions, or understanding data flow
304+
305+
3. **Get symbol information** (HELPFUL FOR TYPE INFO):
306+
307+
```none
308+
mcp__go-language-server__hover filePath line column
309+
```
310+
311+
- Example: `mcp__go-language-server__hover /Users/thomask33/Projects/coder/coderd/httpmw/apikey.go 560 25`
312+
- Get type information and documentation at specific positions
313+
- **Use this when**: You need to understand the type of a variable or return value
314+
315+
4. **Edit files using LSP** (WHEN MAKING TARGETED CHANGES):
316+
317+
```none
318+
mcp__go-language-server__edit_file filePath edits
319+
```
320+
321+
- Make precise edits using line numbers
322+
- **Use this when**: You need to make small, targeted changes to specific lines
323+
324+
5. **Get diagnostics** (ALWAYS CHECK AFTER CHANGES):
325+
326+
```none
327+
mcp__go-language-server__diagnostics filePath
328+
```
329+
330+
- Check for compilation errors, unused imports, etc.
331+
- **Use this when**: After making changes to ensure code is still valid
332+
333+
### LSP Tool Usage Priority
334+
335+
**ALWAYS USE THESE TOOLS FIRST**:
336+
337+
- **Use LSP `definition`** instead of manual searching for function implementations
338+
- **Use LSP `references`** instead of grep when looking for function/type usage
339+
- **Use LSP `hover`** to understand types and signatures
340+
- **Use LSP `diagnostics`** after making changes to check for errors
341+
342+
**When to use other tools**:
343+
344+
- **Use Grep for**: Text-based searches, finding patterns across files, searching comments
345+
- **Use Bash for**: Running tests, git commands, build operations
346+
- **Use Read tool for**: Reading configuration files, documentation, non-Go files
347+
348+
### Investigation Strategy (LSP-First Approach)
349+
350+
1. **Start with route registration** in `coderd/coderd.go` to understand API endpoints
351+
2. **Use LSP `definition` lookup** to trace from route handlers to actual implementations
352+
3. **Use LSP `references`** to understand how functions are called throughout the codebase
353+
4. **Follow the middleware chain** using LSP tools to understand request processing flow
354+
5. **Check test files** for expected behavior and error patterns
355+
6. **Use LSP `diagnostics`** to ensure your changes don't break compilation
356+
357+
### Common LSP Workflows
358+
359+
**Understanding a new feature**:
360+
361+
1. Use `grep` to find the main entry point (e.g., route registration)
362+
2. Use LSP `definition` to jump to handler implementation
363+
3. Use LSP `references` to see how the handler is used
364+
4. Use LSP `definition` on each function call within the handler
365+
366+
**Making changes to existing code**:
367+
368+
1. Use LSP `references` to understand the impact of your changes
369+
2. Use LSP `definition` to understand the current implementation
370+
3. Make your changes using `Edit` or LSP `edit_file`
371+
4. Use LSP `diagnostics` to verify your changes compile correctly
372+
5. Run tests to ensure functionality still works
373+
374+
**Debugging issues**:
375+
376+
1. Use LSP `definition` to find the problematic function
377+
2. Use LSP `references` to trace how the function is called
378+
3. Use LSP `hover` to understand parameter types and return values
379+
4. Use `Read` to examine the full context around the issue
380+
273381
## Testing Scripts
274382
275383
### OAuth2 Test Scripts

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy