Read Theme File


Returns a theme file's contents — functions.php, style.css, a template, theme.json, a script. By default this is the draft copy when one exists, so edits build on each other; pass source "live" for what visitors get now. Long files come back in line ranges. Read-only.

Property Value
Ability slug mosmcp/theme-file-read
Wire tool name mosmcp__theme-file-read
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
path string Yes — Path inside the theme, for example "functions.php" or "templates/single.html".
source string (one of draft, live) draft "draft" (the default: the draft copy when theme files have been changed there) or "live".
start_line integer (min 1) — First line to return.
line_count integer (min 1) — How many lines to return, up to 2000.

 

Output schema

Field Type Required
path string Yes
source string
size integer
lines integer
start_line integer
end_line integer
truncated boolean
pending string
content string Yes
notes string[]

 

Example

Sample prompt
Show me what's in my theme's functions.php.

Example request (json)

{
  "jsonrpc": "2.0",
  "id": 305,
  "method": "tools/call",
  "params": {
    "name": "mosmcp__theme-file-read",
    "arguments": {
      "input": {
        "path": "functions.php"
      }
    }
  }
}

Example response (json)

{
  "jsonrpc": "2.0",
  "id": 305,
  "result": {
    "isError": false,
    "structuredContent": {
      "path": "functions.php",
      "source": "live",
      "size": 1834,
      "lines": 62,
      "start_line": 1,
      "end_line": 62,
      "truncated": false,
      "pending": "",
      "content": "<?php
/**
* Theme functions.
*/
add_action( 'wp_enqueue_scripts', 'mytheme_styles' );
...", "notes": [] } } }

 

Edge cases / errors

  • Binary or unsupported file type (images, fonts, files with no extension) → refused with mosmcp_theme_file_type_unreadable.
  • File is deleted in the draft → refused with mosmcp_theme_file_pending_delete; pass source "live" to read the current version.
  • Files longer than 2000 lines come back in chunks → truncated is true and a note says to pass start_line to read more.
  • Missing file → mosmcp_theme_file_not_found.

 


<< Previous Next >>
Outline Theme File Search Theme Files

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.