- [x] Add API reference documentation with tool descriptions and examples - [x] Add ERROR_CODES reference with error descriptions and remediation steps - [x] Add PERFORMANCE tuning guide with caching and optimization details - [x] Add GitHub Actions workflows for linting and security scanning - [x] Add golangci-lint configuration with comprehensive linter settings - [x] Add pre-commit hooks configuration for local development - [x] Add API documentation generator tool (cmd/docgen) - [x] Update Go version from 1.24 to 1.25 across workflows - [x] Add static build configuration to goreleaser - [x] Add metrics package with Prometheus-style metric types - [x] Add parser benchmarks for performance testing - [x] Add LSP manager integration tests - [x] Add server integration tests with MCP protocol flow testing - [x] Extract regex cache to shared utility package - [x] Add context cancellation handling in AST queries - [x] Add graceful shutdown with timeout to server - [x] Add configurable max parse size (MaxParseSize) - [x] Add Config.Validate() method with comprehensive checks - [x] Add parser cache statistics tracking - [x] Add file permission preservation in edit operations - [x] Improve line splitting for large files with bufio.Scanner - [x] Add comprehensive config tests for edge cases - [x] Update Makefile with new targets and documentation
14 KiB
MCP Filepuff Error Codes Reference
This document provides a comprehensive reference for all error codes that can be returned by mcp-filepuff, along with descriptions and remediation steps.
Error Code Structure
All errors in mcp-filepuff use structured error handling with the following components:
- Error Code: A numeric identifier (1000-1999) for programmatic handling
- Message: Human-readable description of the error
- Context: Additional key-value pairs providing error context
- Remediation: Suggested steps to resolve the error
- Cause: Underlying error (if wrapping another error)
Error Categories
| Range | Category | Description |
|---|---|---|
| 1000-1099 | Search Errors | File search and ripgrep operations |
| 1100-1199 | Parser Errors | AST parsing and tree-sitter operations |
| 1200-1299 | LSP Errors | Language server protocol operations |
| 1300-1399 | Edit Errors | File editing operations |
| 1400-1499 | Query Errors | AST pattern matching operations |
| 1500-1599 | Config Errors | Configuration and validation |
| 1900-1999 | Internal Errors | Internal server errors |
Search Errors (1000-1099)
1001 - ErrRipgrepNotFound
Description: The ripgrep (rg) binary is not found in the system PATH.
Common Causes:
- ripgrep is not installed
- ripgrep is not in PATH
- PATH environment variable not properly set
Remediation:
# macOS
brew install ripgrep
# Ubuntu/Debian
sudo apt install ripgrep
# Windows (Chocolatey)
choco install ripgrep
# Windows (Scoop)
scoop install ripgrep
1002 - ErrRipgrepTimeout
Description: Search operation exceeded the configured timeout limit.
Context Fields:
pattern: The search pattern that timed outduration: How long the search ran before timing out
Common Causes:
- Search pattern too broad (e.g.,
.matching everything) - Searching a very large directory tree
- Complex regex pattern causing backtracking
Remediation:
- Use more specific search patterns
- Narrow the search scope with
pathsparameter - Increase timeout via
MCP_SEARCH_TIMEOUTenvironment variable:export MCP_SEARCH_TIMEOUT="2m"
1003 - ErrInvalidPattern
Description: The search pattern is invalid or malformed.
Context Fields:
pattern: The invalid patternerror: Specific parsing error
Common Causes:
- Invalid regex syntax
- Unclosed brackets or parentheses
- Invalid escape sequences
Remediation:
- Validate regex syntax at regex101.com
- Escape special characters properly
- Use
regex: falsefor literal string searches
1004 - ErrSearchFailed
Description: General search operation failure.
Context Fields:
error: Underlying error message
Common Causes:
- Permission denied on files/directories
- I/O errors
- ripgrep process crashed
Remediation:
- Check file and directory permissions
- Verify workspace path is accessible
- Check system logs for I/O errors
1005 - ErrNoResults
Description: Search completed but found no matches.
Note: This is an informational code, not necessarily an error.
Parser Errors (1100-1199)
1101 - ErrParserNotFound
Description: No Tree-sitter parser is available for the requested language.
Context Fields:
language: The unsupported language
Supported Languages:
- Go, TypeScript, JavaScript, Python, C, C++, HTML, Vue, Elixir, JSON, YAML
Remediation:
- Use a supported language
- Check file extension is correct
1102 - ErrParseFailed
Description: Tree-sitter failed to parse the file.
Context Fields:
file: Path to the filelanguage: Detected languageerror: Specific parsing error
Common Causes:
- File has syntax errors
- File encoding is not UTF-8
- Binary file detected
Remediation:
- Fix syntax errors in the source file
- Ensure file is valid UTF-8
- Check file is not a binary
1103 - ErrInvalidLanguage
Description: The specified or detected language is not supported.
Context Fields:
language: The unsupported languagefile: File path (if detected from extension)
Remediation:
- Use a file with a supported extension
- Supported:
.go,.ts,.tsx,.js,.jsx,.py,.c,.h,.cpp,.hpp,.html,.vue,.ex,.exs,.json,.yaml,.yml
1104 - ErrFileTooBig
Description: File exceeds the maximum size limit for parsing.
Context Fields:
file: Path to the filesize_bytes: Actual file sizelimit_bytes: Maximum allowed size
Default Limit: 10 MB
Remediation:
- Process smaller files
- Increase limit via configuration:
{ "max_parse_size": 20971520 }
1105 - ErrInvalidSyntax
Description: File contains syntax errors that prevent proper parsing.
Context Fields:
file: Path to the fileerrors: List of syntax errors with locations
Remediation:
- Fix syntax errors in the source file
- Run language-specific linters/compilers to identify issues
LSP Errors (1200-1299)
1201 - ErrLSPServerNotFound
Description: The LSP server for the requested language is not installed or not in PATH.
Context Fields:
language: The language needing LSPserver: The expected server binary name
LSP Servers by Language:
| Language | Server | Installation |
|---|---|---|
| Go | gopls |
go install golang.org/x/tools/gopls@latest |
| TypeScript/JavaScript | typescript-language-server |
npm install -g typescript-language-server typescript |
| Python | pylsp |
pip install python-lsp-server |
| C/C++ | clangd |
Install via system package manager |
Remediation: Install the appropriate language server for your language.
1202 - ErrLSPInitFailed
Description: LSP server failed to initialize.
Context Fields:
language: The languagecommand: The server commanderror: Specific initialization error
Common Causes:
- Workspace configuration issues
- Missing dependencies for the project
- LSP server crashed during startup
Remediation:
- Check LSP server logs
- Verify workspace has proper configuration files (go.mod, package.json, etc.)
- Try running the LSP server manually to see errors
1203 - ErrLSPTimeout
Description: LSP operation exceeded timeout.
Context Fields:
operation: The LSP method that timed outduration: How long the operation ran
Common Causes:
- LSP server indexing large project
- Complex type analysis
- Server deadlock
Remediation:
- Wait for LSP server to complete initial indexing
- Increase timeout via
MCP_LSP_TIMEOUT:export MCP_LSP_TIMEOUT="10m" - Restart the MCP server to restart LSP servers
1204 - ErrLSPCommunication
Description: Communication error with LSP server.
Context Fields:
error: Specific communication error
Common Causes:
- LSP server crashed
- Broken pipe (server terminated)
- Protocol version mismatch
Remediation:
- Restart the MCP server
- Update LSP server to latest version
- Check for known issues with your LSP server version
1205 - ErrNoHoverInfo
Description: No hover information available at the requested position.
Note: Not all positions have hover information (e.g., whitespace, keywords).
1206 - ErrNoDefinition
Description: No definition found for the symbol at the requested position.
Common Causes:
- Position is not on a symbol
- Symbol is a built-in
- External dependency without source
1207 - ErrNoReferences
Description: No references found for the symbol.
Note: A symbol may have no references if unused.
Edit Errors (1300-1399)
1301 - ErrEditFailed
Description: General edit operation failure.
Context Fields:
file: Path to the fileoperation: The edit operation attemptederror: Specific error details
1302 - ErrInvalidEdit
Description: The edit request is malformed or invalid.
Context Fields:
message: Specific validation failure
Common Causes:
- Missing required fields
- Invalid operation type
- Missing
new_contentfor replace/insert
Valid Operations:
replace- Replace selected contentinsert_before- Insert before selectioninsert_after- Insert after selectiondelete- Delete selected content
Remediation: Review the edit request and ensure all required fields are provided.
1303 - ErrFileNotFound
Description: The target file does not exist.
Context Fields:
file: Path that was not found
Remediation:
- Verify the file path is correct
- Check for typos in the path
- Ensure the file exists in the workspace
1304 - ErrFileNotReadable
Description: The file exists but cannot be read.
Context Fields:
file: Path to the fileerror: System error details
Common Causes:
- Permission denied
- File locked by another process
- File is a directory
Remediation:
- Check file permissions
- Close other programs using the file
- On macOS, ensure terminal has disk access
1305 - ErrFileNotWritable
Description: Cannot write to the file.
Context Fields:
file: Path to the fileerror: System error details
Common Causes:
- Permission denied
- Read-only filesystem
- Disk full
- File locked
Remediation:
- Check file and directory permissions
- Verify disk space
- Close other programs using the file
1306 - ErrNodeNotFound
Description: No AST node matches the selector criteria.
Context Fields:
selector: Description of the selector criteria
Common Causes:
- Selector doesn't match any code
- Wrong node kind specified
- Name doesn't exist in file
Remediation:
- Use
file_readwithinclude_ast: trueto see available symbols - Verify selector criteria (kind, name, pattern, line)
- Check spelling of symbol names
1307 - ErrValidationFailed
Description: Edit would produce invalid syntax.
Context Fields:
file: Path to the fileerror: Syntax error details
Common Causes:
new_contenthas syntax errors- Edit breaks surrounding code structure
Remediation:
- Validate
new_contentsyntax independently - Use
edit_previewto see the proposed changes - Ensure the edit maintains valid syntax
1308 - ErrInvalidSelection
Description: Selector matches multiple nodes or is ambiguous.
Context Fields:
message: Details about the ambiguity
Common Causes:
- Text/pattern matches multiple locations
- Multiple functions with same name
Remediation:
- Add
selector_indexto choose specific match - Add more selector criteria (kind, name, line)
- Use line number to narrow selection
Query Errors (1400-1499)
1401 - ErrInvalidQuery
Description: The AST query is malformed.
Context Fields:
query: The invalid queryerror: Specific parsing error
Remediation: Review query syntax. Valid patterns use:
$NAMEfor single captures$$$ARGSfor multiple items$_for wildcards
1402 - ErrQueryTimeout
Description: AST query exceeded timeout.
Context Fields:
query: The query that timed outduration: How long it ran
Remediation:
- Use more specific patterns
- Narrow search paths
- Reduce
max_results
1403 - ErrNoMatches
Description: Query executed successfully but found no matches.
Note: Informational, not necessarily an error.
1404 - ErrQueryCompile
Description: Failed to compile the query pattern.
Context Fields:
pattern: The invalid patternerror: Compilation error
Config Errors (1500-1599)
1501 - ErrInvalidConfig
Description: Configuration file or value is invalid.
Context Fields:
field: The invalid fieldvalue: The invalid valueerror: Specific validation error
Remediation:
Review .mcp-filepuff.json configuration file syntax and values.
1502 - ErrPathNotAllowed
Description: Requested path is outside the workspace root.
Context Fields:
path: The requested pathworkspace: The workspace root
Security Note: This prevents path traversal attacks.
Remediation:
- Ensure all paths are within workspace
- Don't use
..to escape workspace - Configure workspace root appropriately
1503 - ErrWorkspaceNotSet
Description: Workspace root is not configured.
Remediation:
Start the server with -workspace flag:
mcp-filepuff -workspace /path/to/workspace
Internal Errors (1900-1999)
1900 - ErrInternal
Description: Unexpected internal error.
Context Fields:
error: Error detailsstack: Stack trace (in debug mode)
Remediation:
- Check server logs
- Report issue if reproducible
1901 - ErrCacheFailed
Description: Cache operation failed.
Context Fields:
operation: Cache operation that failederror: Specific error
1902 - ErrConcurrency
Description: Concurrency-related error (race condition, deadlock).
Context Fields:
operation: Operation that failederror: Specific error
Common Error Scenarios
Scenario 1: New Project Setup
Symptoms: LSP features not working, errors like "LSP server not found"
Solution:
- Install required language servers
- Initialize project (e.g.,
go mod init,npm init) - Restart MCP server
Scenario 2: Edit Fails with Validation Error
Symptoms: Edit operation rejected with syntax error
Solution:
- Use
edit_previewfirst to see proposed changes - Validate
new_contentis syntactically correct - Check that surrounding code structure is maintained
Scenario 3: Search Returns Too Many Results
Symptoms: Search timeout or truncated results
Solution:
- Use more specific patterns
- Add file type filters:
"file_types": ["go"] - Limit search paths
- Set
max_resultslimit
Scenario 4: File Access Errors
Symptoms: Permission denied, file not readable
Solution:
- Check file permissions:
ls -la <file> - On macOS, grant disk access to terminal
- Close programs locking the file
- Run server with appropriate user permissions
See Also
- API.md - Complete API reference
- PERFORMANCE.md - Performance tuning guide
- README.md - Getting started