mirror of
https://github.com/lukaszraczylo/filepuff-mcp.git
synced 2026-10-11 04:47:58 +00:00
perf(tools): lower default result sizes to cut response tokens
The default limits let broad queries flood the model context. This change sets smaller defaults. An explicit parameter still overrides each one. - file_search: max_results 1000 to 50, context_lines 2 to 0. - ast_query: max_results 100 to 50. - ast_query compact output omits the node type unless verbose is set. On a fixed seven-call suite, response size fell from 198529 to 61960 bytes.
This commit is contained in:
@@ -283,7 +283,7 @@ Search for text patterns in files using ripgrep.
|
||||
- `file_types`: File types to search (e.g., ["go", "ts", "py"])
|
||||
- `ignore_case`: Case insensitive search
|
||||
- `regex`: Treat pattern as regex (default: true)
|
||||
- `context_lines`: Number of context lines around matches (default: 2)
|
||||
- `context_lines`: Number of context lines around matches (default: 0)
|
||||
- `max_results`: Maximum number of results to return
|
||||
|
||||
---
|
||||
@@ -352,7 +352,7 @@ Search for AST patterns in code files using structural pattern matching.
|
||||
- `name_matches`: Regex pattern to filter by name
|
||||
- `name_exact`: Exact name to match
|
||||
- `kind_in`: Node types to match (e.g., function_declaration)
|
||||
- `max_results`: Maximum number of results (default: 100)
|
||||
- `max_results`: Maximum number of results (default: 50)
|
||||
|
||||
**Examples**:
|
||||
```json
|
||||
|
||||
+2
-2
@@ -70,7 +70,7 @@ Search for text patterns in files using ripgrep. Supports regex patterns, file t
|
||||
| `file_types` | `array[string]` | No | File types to search (e.g., ['go', 'ts', 'py']) |
|
||||
| `ignore_case` | `boolean` | No | Case insensitive search |
|
||||
| `regex` | `boolean` | No | Treat pattern as regex (default: true) |
|
||||
| `context_lines` | `number` | No | Number of context lines around matches (default: 2) |
|
||||
| `context_lines` | `number` | No | Number of context lines around matches (default: 0) |
|
||||
| `max_results` | `number` | No | Maximum number of results to return |
|
||||
|
||||
**Examples:**
|
||||
@@ -153,7 +153,7 @@ Search for AST patterns in code files. Use code patterns with $VAR placeholders
|
||||
| `name_matches` | `string` | No | Regex pattern to filter by name |
|
||||
| `name_exact` | `string` | No | Exact name to match |
|
||||
| `kind_in` | `array[string]` | No | Node types to match (e.g., function_declaration, class_declaration) |
|
||||
| `max_results` | `number` | No | Maximum number of results to return (default: 100) |
|
||||
| `max_results` | `number` | No | Maximum number of results to return (default: 50) |
|
||||
|
||||
**Examples:**
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ const (
|
||||
DefaultSearchTimeout = 30 * time.Second
|
||||
DefaultMaxFileSize = 10 * 1024 * 1024 // 10 MB
|
||||
DefaultMaxParseSize = 10 * 1024 * 1024 // 10 MB
|
||||
DefaultMaxSearchResults = 1000
|
||||
DefaultMaxSearchResults = 50
|
||||
DefaultMaxEditSize = 100 * 1024 // 100 KB
|
||||
DefaultResourceLinkThresholdBytes = 64 * 1024 // 64 KiB
|
||||
)
|
||||
|
||||
@@ -509,11 +509,15 @@ func formatResults(results []MatchResult, maxResults int, format string, offset
|
||||
case "compact":
|
||||
for i := 0; i < renderCount; i++ {
|
||||
r := results[i]
|
||||
firstLine := firstLineOf(r.Text, 80)
|
||||
if !verbose {
|
||||
fmt.Fprintf(&sb, "%s:%d %s\n", r.File, r.Location.Line, firstLine)
|
||||
continue
|
||||
}
|
||||
nodeType := "unknown"
|
||||
if r.Node != nil {
|
||||
nodeType = r.Node.Type()
|
||||
}
|
||||
firstLine := firstLineOf(r.Text, 80)
|
||||
fmt.Fprintf(&sb, "%s:%d (%s) %s\n", r.File, r.Location.Line, nodeType, firstLine)
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ func (s *Server) resolveASTQueryParams(request mcp.CallToolRequest) (*astQueryPa
|
||||
prefsMaxResults = sp.DefaultMaxResults
|
||||
prefsFormat = sp.ASTQueryFormat
|
||||
}
|
||||
p.maxResults = effectiveInt(request, "max_results", prefsMaxResults, 100)
|
||||
p.maxResults = effectiveInt(request, "max_results", prefsMaxResults, 50)
|
||||
|
||||
p.format = request.GetString("format", "")
|
||||
if p.format == "" {
|
||||
|
||||
@@ -51,7 +51,7 @@ func (s *Server) handleFileSearch(ctx context.Context, request mcp.CallToolReque
|
||||
fileTypes := request.GetStringSlice("file_types", nil)
|
||||
ignoreCase := request.GetBool("ignore_case", false)
|
||||
regex := request.GetBool("regex", true)
|
||||
contextLines := request.GetInt("context_lines", 2)
|
||||
contextLines := request.GetInt("context_lines", 0)
|
||||
|
||||
// Consult session prefs for max_results and cluster when not explicitly supplied.
|
||||
prefs := s.sessionPrefs.Load()
|
||||
|
||||
@@ -49,7 +49,7 @@ const helpFileSearch = "# file_search — flags and examples\n\n" +
|
||||
"| `cluster=true` | Coalesce consecutive match lines into ranges (`L12-14│ text`). Drops context lines for density. |\n" +
|
||||
"| `cursor` | Opaque pagination token from a previous truncated response — fetches next page. |\n" +
|
||||
"| `max_results` | Page size for pagination. Re-run with `cursor` to get next page. |\n" +
|
||||
"| `context_lines` | Number of context lines around matches (default: 2). |\n" +
|
||||
"| `context_lines` | Number of context lines around matches (default: 0). |\n" +
|
||||
"| `ignore_case` | Case-insensitive search. |\n" +
|
||||
"| `regex` | Treat pattern as regex (default: true). |\n" +
|
||||
"| `file_types` | Restrict to file extensions, e.g. `[\"go\", \"ts\"]`. |\n" +
|
||||
@@ -77,7 +77,7 @@ const helpASTQuery = "# ast_query — flags and examples\n\n" +
|
||||
"| `verbose=true` | Emit `Found N match(es):` preamble (v1 behaviour). Default: false. |\n" +
|
||||
"| `format` | `compact` (default, one line per match) \\| `verbose` (full code+captures) \\| `location` (file:line only) |\n" +
|
||||
"| `cursor` | Opaque pagination token from a previous truncated response — fetches next page. |\n" +
|
||||
"| `max_results` | Page size (default: 100). |\n" +
|
||||
"| `max_results` | Page size (default: 50). |\n" +
|
||||
"| `name_exact` | Exact symbol name to match. |\n" +
|
||||
"| `name_matches` | Regex pattern to filter by name. |\n" +
|
||||
"| `kind_in` | Node types to match (e.g. `function_declaration`, `class_declaration`). |\n" +
|
||||
|
||||
@@ -136,7 +136,7 @@ func (s *Server) registerTools() {
|
||||
mcp.Description("Treat pattern as regex (default: true)"),
|
||||
),
|
||||
mcp.WithNumber("context_lines",
|
||||
mcp.Description("Number of context lines around matches (default: 2)"),
|
||||
mcp.Description("Number of context lines around matches (default: 0)"),
|
||||
),
|
||||
mcp.WithNumber("max_results",
|
||||
mcp.Description("Maximum number of results to return (page size for pagination)"),
|
||||
@@ -252,7 +252,7 @@ func (s *Server) registerTools() {
|
||||
mcp.WithStringItems(),
|
||||
),
|
||||
mcp.WithNumber("max_results",
|
||||
mcp.Description("Maximum number of results to return (default: 100, page size for pagination)"),
|
||||
mcp.Description("Maximum number of results to return (default: 50, page size for pagination)"),
|
||||
),
|
||||
mcp.WithString("format",
|
||||
mcp.Description("Output format: \"compact\" (default, one line per match), \"verbose\" (full code+captures), \"location\" (file:line only)"),
|
||||
|
||||
Reference in New Issue
Block a user