search_text

[semantic]

Searches for a literal string or regex pattern across solution documents (non-semantic).

Try this tool in Playground.

Parameters

NameTypeRequiredDescription
querystringNoSearch query (literal string by default). Preferred argument name.
patternstringNoBackward-compatible alias for query.
useRegexbooleanNoTreat pattern as a .NET regex. Default is false.
caseSensitivebooleanNoCase-sensitive match. Default is false.
scopejsonNoOptional search scope.
skipnumberNoPagination offset. Default is 0.
takenumberNoPagination size. Default is 200.
maxLineTextCharsnumberNoMax characters for lineText. Use 0 for unlimited. Default is 200.
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root).
timeout_msnumberNoTimeout in milliseconds (5 minutes). Use 0 to disable. Default is 300000.

Examples

Find TODO comments

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search_text",
    "arguments": {
      "query": "TODO"
    }
  }
}
Response
{
  "success": true,
  "data": {
    "pattern": "TODO",
    "useRegex": false,
    "caseSensitive": false,
    "scopeUsed": {
      "mode": "solution"
    },
    "matchCount": 2,
    "projectsSearched": 2,
    "totalProjectsInWorkspace": 2,
    "documentsMatchedScope": 120,
    "documentsSearched": 120,
    "documentsWithMatches": 1,
    "documentsUnreadable": 0,
    "totalDocumentsInWorkspace": 120,
    "paging": {
      "skip": 0,
      "take": 200,
      "returned": 2,
      "total": 2
    },
    "matches": [
      {
        "filePath": "/path/to/Program.cs",
        "lineNumber": 12,
        "column": 1,
        "lineText": "// TODO: refactor this",
        "projectName": "MyProject"
      }
    ],
    "hints": {
      "nextSteps": [
        "Use get_symbol_at_position if the match is an identifier and you want a symbolKey",
        "Use search_symbols for semantic discovery once you know a symbol name"
      ],
      "scopeNote": null,
      "noMatchNote": null,
      "unreadableNote": null
    }
  },
  "meta": {
    "durationMs": 123,
    "cancelled": false,
    "timedOut": false,
    "timeoutMs": 300000
  },
  "error": null
}

Response Notes

Returns matching text occurrences (with paging)