Skip to main content
Glama

wp_search_site

Search across posts, pages, and media on a WordPress site to find specific content with comprehensive results and metadata.

Instructions

Performs a site-wide search for content across posts, pages, and media with comprehensive results and metadata.

Usage Examples: • Search everything: wp_search_site --term="WordPress" • Search posts only: wp_search_site --term="tutorial" --type="posts" • Search pages: wp_search_site --term="about" --type="pages" • Search media: wp_search_site --term="logo" --type="media" • Find specific content: wp_search_site --term="contact form"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
termYesThe search term to look for.
typeNoThe type of content to search.

Implementation Reference

  • The handler function that implements the core logic of wp_search_site. It performs the search using the WordPressClient's search method and formats the results as a markdown list.
    public async handleSearchSite(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      try {
        const { term, type } = params as { term: string; type?: "posts" | "pages" | "media" };
        const results = await client.search(term, type ? [type] : undefined);
        if (results.length === 0) {
          return `No results found for "${term}".`;
        }
        const content =
          `Found ${results.length} results for "${term}":\n\n` +
          results.map((r) => `- [${r.type}] **${r.title}**\n  Link: ${r.url}`).join("\n");
        return content;
      } catch (_error) {
        throw new Error(`Failed to perform search: ${getErrorMessage(_error)}`);
      }
    }
  • The tool definition object within SiteTools.getTools() method, which registers the wp_search_site tool including its name, description, input parameters schema, and reference to the handler function.
    {
      name: "wp_search_site",
      description:
        "Performs a site-wide search for content across posts, pages, and media with comprehensive results and metadata.\n\n" +
        "**Usage Examples:**\n" +
        '• Search everything: `wp_search_site --term="WordPress"`\n' +
        '• Search posts only: `wp_search_site --term="tutorial" --type="posts"`\n' +
        '• Search pages: `wp_search_site --term="about" --type="pages"`\n' +
        '• Search media: `wp_search_site --term="logo" --type="media"`\n' +
        '• Find specific content: `wp_search_site --term="contact form"`',
      parameters: [
        {
          name: "term",
          type: "string",
          required: true,
          description: "The search term to look for.",
        },
        {
          name: "type",
          type: "string",
          description: "The type of content to search.",
          enum: ["posts", "pages", "media"],
        },
      ],
      handler: this.handleSearchSite.bind(this),
    },
  • The input parameters schema defining the 'term' (required string) and optional 'type' (enum: posts, pages, media) for the wp_search_site tool.
    parameters: [
      {
        name: "term",
        type: "string",
        required: true,
        description: "The search term to look for.",
      },
      {
        name: "type",
        type: "string",
        description: "The type of content to search.",
        enum: ["posts", "pages", "media"],
      },
    ],

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/docdyhr/mcp-wordpress'

If you have feedback or need assistance with the MCP directory API, please join our Discord server