Skip to main content
Glama
flyanima

Open Search MCP

by flyanima

jsonplaceholder_comments

Retrieve test comments data from JSONPlaceholder for development and testing purposes, with optional filtering by post ID and configurable result limits.

Instructions

Get test comments data from JSONPlaceholder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
postIdNoPost ID to get comments for (1-100, optional)
limitNoMaximum number of comments to return (1-100)

Implementation Reference

  • The main handler function that executes the tool logic. It fetches comments from the JSONPlaceholder API using the client instance and formats the response with success status, data, and error handling.
    execute: async (args: any) => { try { const comments = await client.getComments(args.postId, args.limit || 10); return { success: true, data: { source: 'JSONPlaceholder API', type: 'comments', postId: args.postId, results: comments, count: comments.length, timestamp: Date.now(), apiUsed: true } }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to get test comments' }; } } });
  • Registers the 'jsonplaceholder_comments' tool with the ToolRegistry, including name, description, input schema, and the execute handler.
    registry.registerTool({ name: 'jsonplaceholder_comments', description: 'Get test comments data from JSONPlaceholder', category: 'testing', source: 'jsonplaceholder.typicode.com', inputSchema: { type: 'object', properties: { postId: { type: 'number', description: 'Post ID to get comments for (1-100, optional)' }, limit: { type: 'number', description: 'Maximum number of comments to return (1-100)', default: 10, minimum: 1, maximum: 100 } }, required: [] }, execute: async (args: any) => { try { const comments = await client.getComments(args.postId, args.limit || 10); return { success: true, data: { source: 'JSONPlaceholder API', type: 'comments', postId: args.postId, results: comments, count: comments.length, timestamp: Date.now(), apiUsed: true } }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to get test comments' }; } } });
  • Zod schema definition used for input validation specific to the jsonplaceholder_comments tool in the global input validator.
    'jsonplaceholder_comments': z.object({ postId: z.number().int().min(1).max(100).optional(), limit: z.number().int().min(1).max(100).optional().default(10) }),
  • Helper method in JSONPlaceholderAPIClient class that constructs the API endpoint for comments and fetches/slices the data, used by the tool handler.
    async getComments(postId?: number, limit?: number) { const endpoint = postId ? `/posts/${postId}/comments` : '/comments'; const comments = await this.makeRequest(endpoint); return limit ? comments.slice(0, limit) : comments; }

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/flyanima/open-search-mcp'

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