Skip to main content
Glama
aguaitech

Elementor MCP Server

by aguaitech

get_page_id_by_slug

Retrieve the WordPress page ID using its slug for targeted Elementor data management. Input the slug to identify the specific page within your WordPress site.

Instructions

Retrieves the ID of a specific WordPress page by its slug.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
slugYesThe slug (URL-friendly name) of the page to find.

Implementation Reference

  • The handler function for the MCP tool 'get_page_id_by_slug'. It takes the input slug, calls the getPageIdBySlug helper, and returns the page ID formatted as MCP text content.
    async (input) => {
      // Handler
      const pageId = await getPageIdBySlug(input.slug);
      return {
        content: [
          {
            type: "text",
            text: `${pageId}`,
          },
        ],
      };
    }
  • Zod schema defining the input parameters for the tool: a required 'slug' string.
    {
      // Input Schema
      slug: z
        .string()
        .describe("The slug (URL-friendly name) of the page to find."),
    },
  • src/index.js:258-279 (registration)
    Registration of the 'get_page_id_by_slug' tool using server.tool(), including name, description, schema, and inline handler.
    server.tool(
      "get_page_id_by_slug",
      "Retrieves the ID of a specific WordPress page by its slug.",
      {
        // Input Schema
        slug: z
          .string()
          .describe("The slug (URL-friendly name) of the page to find."),
      },
      async (input) => {
        // Handler
        const pageId = await getPageIdBySlug(input.slug);
        return {
          content: [
            {
              type: "text",
              text: `${pageId}`,
            },
          ],
        };
      }
    );
  • Supporting helper function that queries the WordPress REST API for pages matching the slug, returns the first ID found, or throws if none.
    async function getPageIdBySlug(slug) {
        const client = getApiClient();
        let pageId = null;
    
        try {
            const response = await client.get(`/wp-json/wp/v2/pages`, {
                params: {
                    slug: slug,
                    _fields: 'id', // Only need the ID
                }
            });
    
            if (response.data && response.data.length > 0) {
                pageId = response.data[0].id;
                return pageId; // Return the ID directly
            } else {
                // Throw an error if not found, to be caught by the caller
                throw new Error(`Page with slug '${slug}' not found.`);
            }
        } catch (error) {
            // Re-throw the error for the caller to handle
            throw error; // Propagate the error (could be Axios error or the 'not found' error)
        }
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the tool's read-only nature ('Retrieves') and specific lookup behavior, but does not mention potential errors (e.g., if the slug doesn't exist), performance aspects, or authentication needs. It adds basic behavioral context but lacks depth for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Retrieves the ID') with no wasted words. Every part of the sentence earns its place by specifying the resource and lookup method.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (single parameter, no output schema, no annotations), the description is adequate but minimal. It covers the basic purpose and parameter context, but lacks details on return values, error handling, or integration with siblings, leaving some gaps for an agent to infer behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the schema already documenting the 'slug' parameter as 'The slug (URL-friendly name) of the page to find.' The description adds no additional parameter details beyond what the schema provides, so it meets the baseline of 3 without compensating or detracting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Retrieves') and target resource ('the ID of a specific WordPress page by its slug'), distinguishing it from siblings like get_page (which likely returns full page data) and other CRUD operations. It precisely communicates the tool's function without redundancy.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you need a page ID from a slug, but does not explicitly state when to use this tool versus alternatives like get_page (which might return more data) or when not to use it (e.g., if you already have the ID). It provides clear context but lacks explicit exclusions or named alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/aguaitech/Elementor-MCP'

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