Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ https://github.com/user-attachments/assets/52980f32-64d6-4b78-9cbf-18d6ae120cdd
- [`find_references`](#find_references)
- [`rename_symbol`](#rename_symbol)
- [`get_diagnostics`](#get_diagnostics)
- [`get_class_members`](#get_class_members)
- [`get_method_signature`](#get_method_signature)
- [💡 Real-world Examples](#-real-world-examples)
- [Finding Function Definitions](#finding-function-definitions)
- [Finding All References](#finding-all-references)
Expand All @@ -55,6 +57,9 @@ When using AI-powered coding assistants like Claude, you often need to navigate

- **Go to Definition**: Find where symbols are defined
- **Find References**: Locate all references to a symbol
- **Class Exploration**: List all members of a class with their types
- **Method Signatures**: Get full method signatures with parameters and return types
- **Code Diagnostics**: Get errors, warnings, and hints for your code
- **Multi-language Support**: Configurable LSP servers for different file types
- **TypeScript**: Built-in support via typescript-language-server
- **Python**: Support via python-lsp-server (pylsp)
Expand Down Expand Up @@ -389,6 +394,35 @@ Get language diagnostics (errors, warnings, hints) for a file. Supports both pul
**Parameters:**
- `file_path`: The path to the file

### `get_class_members`

List all properties and methods of a class. Returns members with their types and signatures using LSP hover information, including namespace/package information and detailed parameter types.

**Parameters:**
- `file_path`: The path to the file containing the class
- `class_name`: The name of the class

**Enhanced Response Includes:**
- Full type signatures with documentation
- Namespace and package information for imported types
- Parameter details including names, types, optional flags, and default values
- Return type information for methods

### `get_method_signature`

Show full method definition with parameters and return type using LSP hover information. Particularly useful for understanding API methods and their expected parameters.

**Parameters:**
- `file_path`: The path to the file containing the method
- `method_name`: The name of the method
- `class_name`: Optional - The name of the class containing the method (helps narrow results)

**Enhanced Response Includes:**
- Complete method signature with all type information
- Parsed parameter details with types and default values
- Namespace/package information for complex types
- Documentation comments when available

## 💡 Real-world Examples

### Finding Function Definitions
Expand Down Expand Up @@ -443,6 +477,56 @@ Results: Found 3 diagnostics:
- Hint: Consider using const instead of let (Line 30, Column 1)
```

### Exploring Class Structure

When understanding API architecture:

```
Claude: Let me explore the ApiService class structure
> Using cclsp.get_class_members for class "ApiService"

Results: Found 8 members in class "ApiService":
• constructor (constructor) at src/services/api.ts:10:3
• baseUrl (property) at src/services/api.ts:12:3
private baseUrl: string
Type: string
• request (method) at src/services/api.ts:20:3
async request<T>(endpoint: string, options?: RequestOptions): Promise<T>
Parameters:
- endpoint: string
- options?: RequestOptions
Returns: Promise<T>
• get (method) at src/services/api.ts:35:3
async get<T>(endpoint: string): Promise<T>
Parameters:
- endpoint: string
Returns: Promise<T>
• post (method) at src/services/api.ts:40:3
async post<T>(endpoint: string, data: unknown): Promise<T>
Parameters:
- endpoint: string
- data: unknown
Returns: Promise<T>
```

### Getting Method Signatures

When understanding function APIs:

```
Claude: I need to understand the formatDate method signature
> Using cclsp.get_method_signature for method "formatDate"

Method: formatDate at src/utils/date.ts:15:10
formatDate(date: Date | string, format?: string): string

Type Details:
Parameters:
- date: Date | string
- format?: string = "YYYY-MM-DD"
Returns: string
```

## 🔍 Troubleshooting

### Known Issues
Expand Down
4 changes: 4 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

184 changes: 184 additions & 0 deletions docs/USAGE_PATTERNS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# Common CCLSP Usage Patterns

This document outlines common usage patterns for the CCLSP MCP server in development workflows.

## Table of Contents
1. [Basic Symbol Navigation](#basic-symbol-navigation)
2. [Code Exploration](#code-exploration)
3. [Refactoring](#refactoring)
4. [Debugging and Diagnostics](#debugging-and-diagnostics)
5. [API Documentation](#api-documentation)

## Basic Symbol Navigation

### Finding Symbol Definitions

Find where a function, class, or variable is defined:

```
find_definition:
file_path: "src/index.ts"
symbol_name: "processRequest"
symbol_kind: "function" # optional, helps narrow results
```

### Finding All References

Locate all places where a symbol is used:

```
find_references:
file_path: "src/models/user.ts"
symbol_name: "User"
symbol_kind: "class"
include_declaration: true # include the definition location
```

## Code Exploration

### Exploring Class Structure

Get all members (properties and methods) of a class:

```
get_class_members:
file_path: "src/services/api.ts"
class_name: "ApiService"
```

This returns:
- All properties with their types
- All methods with their signatures
- Member visibility (public/private/protected)
- Location information for each member

### Understanding Method Signatures

Get detailed method signature information including parameters and return types:

```
get_method_signature:
file_path: "src/utils/helpers.ts"
method_name: "formatDate"
class_name: "DateFormatter" # optional, for class methods
```

Returns:
- Full method signature with parameter types
- Return type information
- JSDoc comments if available
- Overload signatures if applicable

## Refactoring

### Safe Symbol Renaming

Rename symbols across the entire codebase:

```
# For unique symbols
rename_symbol:
file_path: "src/config.ts"
symbol_name: "oldConfigName"
new_name: "newConfigName"

# For ambiguous symbols (multiple matches)
rename_symbol_strict:
file_path: "src/config.ts"
line: 42
character: 10
new_name: "newConfigName"
```

## Debugging and Diagnostics

### Getting File Diagnostics

Check for errors, warnings, and hints in a file:

```
get_diagnostics:
file_path: "src/components/button.tsx"
```

Returns:
- Syntax errors
- Type errors
- Linting warnings
- Code hints and suggestions
- Exact location of each issue

## API Documentation

### Complete Workflow Example

Here's a complete workflow for exploring and understanding an API:

1. **Find the main API class**:
```
find_definition:
file_path: "src/index.ts"
symbol_name: "ApiClient"
symbol_kind: "class"
```

2. **Explore its structure**:
```
get_class_members:
file_path: "src/api/client.ts"
class_name: "ApiClient"
```

3. **Get method details**:
```
get_method_signature:
file_path: "src/api/client.ts"
method_name: "request"
class_name: "ApiClient"
```

4. **Find usage examples**:
```
find_references:
file_path: "src/api/client.ts"
symbol_name: "request"
symbol_kind: "method"
```

## Best Practices

1. **Use symbol_kind when available**: This helps narrow down results and improves accuracy.

2. **Check diagnostics before refactoring**: Run `get_diagnostics` to ensure the file is error-free before making changes.

3. **Use strict mode for ambiguous renames**: If `rename_symbol` returns multiple candidates, use `rename_symbol_strict` with specific coordinates.

4. **Combine tools for comprehensive understanding**: Use `get_class_members` followed by `get_method_signature` for complete API documentation.

5. **Verify LSP server configuration**: Ensure the appropriate language server is configured for your file types in `cclsp.json`.

## Troubleshooting

If tools return no results:
1. Verify the file path is correct and absolute
2. Check that the appropriate LSP server is configured for the file type
3. Ensure the symbol name is spelled correctly
4. Try without `symbol_kind` parameter for broader search
5. Check server logs for any LSP errors

## Language-Specific Notes

### TypeScript/JavaScript
- Supports JSDoc comments in hover information
- Handles type aliases and interfaces
- Works with both `.ts` and `.tsx` files

### Python
- Returns type hints when available
- Supports docstring information
- Works with virtual environments when configured

### Go
- Provides interface implementation information
- Includes package documentation
- Supports workspace modules
Loading