Search Theme Files


Searches every text file in the theme for some wording, a function name or a CSS selector, returning each matching line with its file and line number. Read-only.

Also known as: grep theme, find in theme code, where is this defined.

Property Value
Ability slug mosmcp/theme-file-search
Wire tool name mosmcp__theme-file-search
Category Theme: Files (mosmcp-theme-files)
Plan Free

 

Required access

Requirement Value
Capability edit_theme_options
Minimum default role Administrator (Shop manager too when WooCommerce is active)
Annotations readOnly: true · destructive: false · idempotent: true · openWorld: false

 

Input schema

Field Type Required Default Description
text string Yes — Text to find.
source string (one of draft, live) draft "draft" (the default: the draft copy when theme files have been changed there) or "live".
case_sensitive boolean false Match letter case exactly.
types string[] — Optional file extensions to search, for example ["php","css"].

 

Output schema

Field Type Required
searched_for string
source string
files_searched integer
match_count integer Yes
truncated boolean
matches object[] Yes
matches[].path string
matches[].line integer
matches[].text string
notes string[]

 

Example

Sample prompt
Where in my theme is the 'site-header' CSS class used?

Example request (json)

{
  "jsonrpc": "2.0",
  "id": 306,
  "method": "tools/call",
  "params": {
    "name": "mosmcp__theme-file-search",
    "arguments": {
      "input": {
        "text": ".site-header",
        "types": [
          "css",
          "php"
        ]
      }
    }
  }
}

Example response (json)

{
  "jsonrpc": "2.0",
  "id": 306,
  "result": {
    "isError": false,
    "structuredContent": {
      "searched_for": ".site-header",
      "source": "live",
      "files_searched": 18,
      "match_count": 1,
      "truncated": false,
      "matches": [
        {
          "path": "style.css",
          "line": 142,
          "text": ".site-header { padding: 24px 0; }"
        }
      ],
      "notes": []
    }
  }
}

 

Edge cases / errors

  • Blank text → refused with mosmcp_empty_search_text.
  • More than 200 matches → results stop at 200, truncated is true, and a note suggests narrowing with types or a longer phrase.
  • Very large files and folders like node_modules, vendor and .git are skipped; each matching line is cut to 300 characters.

 


<< Previous Next >>
Read Theme File Write Theme File

For more information about the Secure MCP Server for WordPress plugin, explore the following resources:

Product Overview | Pricing | Try for Free | Documentation

If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.