Skip to main content
Glama

Get Article

get_article

Retrieve a specific article by its unique ID within Emlog blog systems, including handling password-protected content.

Instructions

Get a specific article by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the article to retrieve
passwordNoPassword for protected articles

Implementation Reference

  • The handler function for the "get_article" MCP tool. It fetches the article details using emlogClient and returns formatted text output.
    async ({ id, password }) => {
      try {
        const article = await emlogClient.getArticleDetail(id, password);
        return {
          content: [{
            type: "text",
            text: `Article: ${article.title}\n\nContent: ${article.content}\n\nExcerpt: ${article.excerpt || 'N/A'}\nCategory: ${article.sort_id}\nTags: ${article.tags || 'N/A'}\nViews: ${article.views}\nComments: ${article.comnum}`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Error: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    }
  • Input schema for the get_article tool using Zod validation.
    inputSchema: {
      id: z.number().describe("The ID of the article to retrieve"),
      password: z.string().optional().describe("Password for protected articles")
    }
  • src/index.ts:280-281 (registration)
    Registration of the "get_article" tool with the MCP server.
    server.registerTool(
      "get_article",
  • Helper method in EmlogClient that performs the actual API call to retrieve article details.
    async getArticleDetail(id: number, password?: string): Promise<EmlogPost> {
      const params: { id: number; password?: string } = { id };
      if (password) params.password = password;
      const queryParams = this.buildParams(params);
      const response = await this.api.get(`/?rest-api=article_detail&${queryParams.toString()}`);
      return response.data.data.article;
    }
  • TypeScript interface defining the structure of an EmlogPost, used for typing the article data.
    export interface EmlogPost {
      id: number;
      title: string;
      content: string;
      content_raw?: string;
      excerpt?: string;
      excerpt_raw?: string;
      description?: string;
      description_raw?: string;
      cover?: string;
      url?: string;
      author_id: number;
      author_name: string;
      author_avatar?: string;
      sort_id: number;
      sort_name: string;
      views: number;
      comnum: number;
      like_count: number;
      date: string;
      tags: Array<{ name: string; url: string }>;
      top: 'y' | 'n';
      sortop: 'y' | 'n';
      need_pwd: 'y' | 'n';
      allow_remark?: 'y' | 'n';
      password?: string;
      link?: string;
      fields?: Record<string, any>;
      type?: string;
    }

Tool Definition Quality

Score is being calculated. Check back soon.

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/eraincc/emlog-mcp'

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