Skip to main content
Glama

search_articles

Find articles on Emlog blogs by keyword, tag, or category. Filter and sort results by views or comment counts for precise content discovery.

Instructions

Search articles by keyword, tag, or category

Input Schema

NameRequiredDescriptionDefault
countNoNumber of articles per page
keywordNoSearch keyword for article titles
orderNoSort order: views (by view count) or comnum (by comment count)
pageNoPage number (default: 1)
sort_idNoFilter by category ID
tagNoFilter by tag

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "count": { "description": "Number of articles per page", "type": "number" }, "keyword": { "description": "Search keyword for article titles", "type": "string" }, "order": { "description": "Sort order: views (by view count) or comnum (by comment count)", "enum": [ "views", "comnum" ], "type": "string" }, "page": { "description": "Page number (default: 1)", "type": "number" }, "sort_id": { "description": "Filter by category ID", "type": "number" }, "tag": { "description": "Filter by tag", "type": "string" } }, "type": "object" }

Implementation Reference

  • Handler function for the 'search_articles' tool. It calls emlogClient.getArticleList with the provided search parameters and formats the returned articles into a readable text list with pagination info.
    async ({ keyword, tag, sort_id, page, count, order }) => { try { const result = await emlogClient.getArticleList({ keyword, tag, sort_id, page, count, order }); const articles = result.articles; const articleList = articles.map((article: any) => `- ${article.title} (ID: ${article.id}) - Views: ${article.views}, Comments: ${article.comnum}` ).join('\n'); return { content: [{ type: "text", text: `Found ${articles.length} articles (Page ${result.page}/${result.total_pages}):\n\n${articleList || 'No articles found'}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
  • Input schema using Zod for validating parameters to the search_articles tool: keyword, tag, category (sort_id), pagination (page, count), and sorting (order).
    inputSchema: { keyword: z.string().optional().describe("Search keyword for article titles"), tag: z.string().optional().describe("Filter by tag"), sort_id: z.number().optional().describe("Filter by category ID"), page: z.number().optional().describe("Page number (default: 1)"), count: z.number().optional().describe("Number of articles per page"), order: z.enum(["views", "comnum"]).optional().describe("Sort order: views (by view count) or comnum (by comment count)") } },
  • src/index.ts:311-355 (registration)
    Registers the search_articles tool with the MCP server using server.registerTool, including title, description, inputSchema, and the handler function.
    server.registerTool( "search_articles", { title: "Search Articles", description: "Search articles by keyword, tag, or category", inputSchema: { keyword: z.string().optional().describe("Search keyword for article titles"), tag: z.string().optional().describe("Filter by tag"), sort_id: z.number().optional().describe("Filter by category ID"), page: z.number().optional().describe("Page number (default: 1)"), count: z.number().optional().describe("Number of articles per page"), order: z.enum(["views", "comnum"]).optional().describe("Sort order: views (by view count) or comnum (by comment count)") } }, async ({ keyword, tag, sort_id, page, count, order }) => { try { const result = await emlogClient.getArticleList({ keyword, tag, sort_id, page, count, order }); const articles = result.articles; const articleList = articles.map((article: any) => `- ${article.title} (ID: ${article.id}) - Views: ${article.views}, Comments: ${article.comnum}` ).join('\n'); return { content: [{ type: "text", text: `Found ${articles.length} articles (Page ${result.page}/${result.total_pages}):\n\n${articleList || 'No articles found'}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
  • Supporting method in EmlogClient that makes the HTTP GET request to the Emlog API endpoint '/?rest-api=article_list' with search parameters to retrieve the list of matching articles.
    async getArticleList(params: { page?: number; count?: number; sort_id?: number; keyword?: string; tag?: string; order?: 'views' | 'comnum'; } = {}): Promise<{ articles: EmlogPost[]; page: number; total_pages: number; has_more: boolean }> { const queryParams = this.buildParams(params); const response = await this.api.get(`/?rest-api=article_list&${queryParams.toString()}`); return response.data.data; }

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