Skip to main content
Glama

get-post

Retrieve a specific WordPress post by ID using site URL, credentials, and optional parameters like post password or context (view, embed, edit).

Instructions

Get a specific post by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoScope under which the request is madeview
passwordYesWordPress application password
postIdYesID of the post to retrieve
postPasswordNoThe password for the post if it is password protected
siteUrlYesWordPress site URL
usernameYesWordPress username

Implementation Reference

  • The handler function that executes the 'get-post' tool logic. It makes an authenticated API request to retrieve a specific WordPress post by ID, handles optional parameters like context and postPassword, formats the post details into a text response, and catches any errors.
    async ({ siteUrl, username, password, postId, context, postPassword }) => {
      try {
        const params: Record<string, any> = { context };
        if (postPassword) params.password = postPassword;
    
        const post = await makeWPRequest<WPPost>({
          siteUrl,
          endpoint: `posts/${postId}`,
          auth: { username, password },
          params
        });
        
        return {
          content: [
            {
              type: "text",
              text: `Post Details:\nID: ${post.id}\nTitle: ${post.title?.rendered || "No title"}\nDate: ${post.date || "No date"}\nStatus: ${post.status || "unknown"}\nAuthor: ${post.author || "Unknown"}\nContent: ${post.content?.rendered || "No content"}\nExcerpt: ${post.excerpt?.rendered || "No excerpt"}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error retrieving post: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • Zod input schema defining the parameters for the 'get-post' tool: required siteUrl, username, password, postId; optional context and postPassword.
    {
      siteUrl: z.string().url().describe("WordPress site URL"),
      username: z.string().describe("WordPress username"),
      password: z.string().describe("WordPress application password"),
      postId: z.number().describe("ID of the post to retrieve"),
      context: z.enum(["view", "embed", "edit"]).optional().default("view").describe("Scope under which the request is made"),
      postPassword: z.string().optional().describe("The password for the post if it is password protected"),
    },
  • src/index.ts:704-745 (registration)
    Registration of the 'get-post' tool on the MCP server using server.tool(), specifying name, description, input schema, and handler function.
      "get-post",
      "Get a specific post by ID",
      {
        siteUrl: z.string().url().describe("WordPress site URL"),
        username: z.string().describe("WordPress username"),
        password: z.string().describe("WordPress application password"),
        postId: z.number().describe("ID of the post to retrieve"),
        context: z.enum(["view", "embed", "edit"]).optional().default("view").describe("Scope under which the request is made"),
        postPassword: z.string().optional().describe("The password for the post if it is password protected"),
      },
      async ({ siteUrl, username, password, postId, context, postPassword }) => {
        try {
          const params: Record<string, any> = { context };
          if (postPassword) params.password = postPassword;
    
          const post = await makeWPRequest<WPPost>({
            siteUrl,
            endpoint: `posts/${postId}`,
            auth: { username, password },
            params
          });
          
          return {
            content: [
              {
                type: "text",
                text: `Post Details:\nID: ${post.id}\nTitle: ${post.title?.rendered || "No title"}\nDate: ${post.date || "No date"}\nStatus: ${post.status || "unknown"}\nAuthor: ${post.author || "Unknown"}\nContent: ${post.content?.rendered || "No content"}\nExcerpt: ${post.excerpt?.rendered || "No excerpt"}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error retrieving post: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • TypeScript interface WPPost defining the structure of WordPress post objects used in the get-post tool response typing.
    interface WPPost {
      id: number;
      date?: string;
      date_gmt?: string;
      guid?: {
        rendered: string;
      };
      modified?: string;
      modified_gmt?: string;
      slug?: string;
      status?: 'publish' | 'future' | 'draft' | 'pending' | 'private';
      type?: string;
      link?: string;
      title?: {
        rendered: string;
      };
      content?: {
        rendered: string;
        protected?: boolean;
      };
      excerpt?: {
        rendered: string;
        protected?: boolean;
      };
      author?: number;
      featured_media?: number;
      comment_status?: 'open' | 'closed';
      ping_status?: 'open' | 'closed';
      sticky?: boolean;
      template?: string;
      format?: 'standard' | 'aside' | 'chat' | 'gallery' | 'link' | 'image' | 'quote' | 'status' | 'video' | 'audio';
      meta?: Record<string, any>;
      _links?: {
        self?: Array<{ href: string }>;
        collection?: Array<{ href: string }>;
        about?: Array<{ href: string }>;
        author?: Array<{ href: string; embeddable: boolean }>;
        replies?: Array<{ href: string; embeddable: boolean }>;
        'version-history'?: Array<{ href: string }>;
        'predecessor-version'?: Array<{ href: string; id: number }>;
        'wp:featuredmedia'?: Array<{ href: string; embeddable: boolean }>;
        'wp:attachment'?: Array<{ href: string }>;
        'wp:term'?: Array<{ href: string; taxonomy: string; embeddable: boolean }>;
        curies?: Array<{ name: string; href: string; templated: boolean }>;
      };
      categories?: number[];
      tags?: number[];
    }
  • Shared helper function makeWPRequest that performs authenticated HTTP requests to the WordPress REST API, used by the get-post handler.
    async function makeWPRequest<T>({
      siteUrl, 
      endpoint,
      method = 'GET',
      auth,
      data = null,
      params = null
    }: {
      siteUrl: string;
      endpoint: string;
      method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
      auth: { username: string; password: string };
      data?: any;
      params?: any;
    }): Promise<T> {
      const authString = Buffer.from(`${auth.username}:${auth.password}`).toString('base64');
      
      try {
        const response = await axios({
          method,
          url: `${siteUrl}/wp-json/wp/v2/${endpoint}`,
          headers: {
            'Authorization': `Basic ${authString}`,
            'Content-Type': 'application/json',
          },
          data: data,
          params: params
        });
        
        return response.data as T;
      } catch (error) {
        if (axios.isAxiosError(error) && error.response) {
          throw new Error(`WordPress API error: ${error.response.data?.message || error.message}`);
        }
        throw error;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states it's a read operation ('Get'), which is helpful, but lacks details on authentication needs (implied by parameters), rate limits, error handling, or what the return format looks like (no output schema). For a tool with 6 parameters including authentication, this is insufficient.

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, clear sentence with zero wasted words. It's front-loaded with the core purpose and efficiently communicates the essential action without unnecessary elaboration.

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

Completeness2/5

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

For a tool with 6 parameters (including authentication), no annotations, and no output schema, the description is incomplete. It doesn't address authentication requirements, return format, error conditions, or how it differs from sibling tools. The high parameter count and lack of structured metadata mean the description should provide more contextual guidance.

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?

Schema description coverage is 100%, so the schema fully documents all 6 parameters. The description adds no additional parameter information beyond implying 'postId' is required, which is already in the schema. This meets the baseline of 3 when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Get') and resource ('a specific post by ID'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get-post-stats' or 'get-top-posts', which also retrieve post-related information but with different scopes or aggregations.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'get-post-stats' (for statistics) or 'list-posts' (for multiple posts). It also doesn't mention prerequisites such as authentication requirements, which are implied by the required parameters but not explicitly stated in the description.

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/prathammanocha/wordpress-mcp-server'

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