Skip to main content
Glama

Open Search MCP

by flyanima

test_jsonplaceholder

Validate JSON data by testing JSONPlaceholder API endpoints, such as posts, users, and comments, to ensure accurate and reliable data retrieval for research or development purposes.

Instructions

Test JSONPlaceholder API for JSON data validation

Input Schema

NameRequiredDescriptionDefault
endpointNoJSONPlaceholder endpoint to testposts
idNoSpecific resource ID to fetch (optional)

Input Schema (JSON Schema)

{ "properties": { "endpoint": { "default": "posts", "description": "JSONPlaceholder endpoint to test", "enum": [ "posts", "users", "comments", "albums", "photos", "todos" ], "type": "string" }, "id": { "description": "Specific resource ID to fetch (optional)", "type": "number" } }, "required": [], "type": "object" }

Implementation Reference

  • The execute handler function for the test_jsonplaceholder tool, which simulates API calls to JSONPlaceholder endpoints using mock data and returns formatted ToolOutput.
    execute: async (args: ToolInput): Promise<ToolOutput> => { try { const { endpoint = 'posts', id } = args; const baseUrl = 'https://jsonplaceholder.typicode.com'; const url = id ? `${baseUrl}/${endpoint}/${id}` : `${baseUrl}/${endpoint}`; // Simulate API response const mockData = { posts: [{ id: 1, title: 'Test Post', body: 'Test content', userId: 1 }], users: [{ id: 1, name: 'Test User', email: 'test@example.com' }], comments: [{ id: 1, postId: 1, name: 'Test Comment', email: 'test@example.com', body: 'Test comment body' }] }; return { success: true, data: { endpoint, url, response: mockData[endpoint as keyof typeof mockData] || [], status: 'success' }, metadata: { tool: 'test_jsonplaceholder', timestamp: new Date().toISOString() } }; } catch (error) { return { success: false, error: `JSONPlaceholder test failed: ${error instanceof Error ? error.message : String(error)}`, data: null }; } }
  • The inputSchema defining parameters for the test_jsonplaceholder tool: endpoint (enum of JSONPlaceholder resources) and optional id.
    inputSchema: { type: 'object', properties: { endpoint: { type: 'string', enum: ['posts', 'users', 'comments', 'albums', 'photos', 'todos'], description: 'JSONPlaceholder endpoint to test', default: 'posts' }, id: { type: 'number', description: 'Specific resource ID to fetch (optional)' } }, required: [] },
  • The registry.registerTool call that defines and registers the test_jsonplaceholder tool, including name, description, schema, and handler.
    registry.registerTool({ name: 'test_jsonplaceholder', description: 'Test JSONPlaceholder API for JSON data validation', category: 'testing', source: 'JSONPlaceholder', inputSchema: { type: 'object', properties: { endpoint: { type: 'string', enum: ['posts', 'users', 'comments', 'albums', 'photos', 'todos'], description: 'JSONPlaceholder endpoint to test', default: 'posts' }, id: { type: 'number', description: 'Specific resource ID to fetch (optional)' } }, required: [] }, execute: async (args: ToolInput): Promise<ToolOutput> => { try { const { endpoint = 'posts', id } = args; const baseUrl = 'https://jsonplaceholder.typicode.com'; const url = id ? `${baseUrl}/${endpoint}/${id}` : `${baseUrl}/${endpoint}`; // Simulate API response const mockData = { posts: [{ id: 1, title: 'Test Post', body: 'Test content', userId: 1 }], users: [{ id: 1, name: 'Test User', email: 'test@example.com' }], comments: [{ id: 1, postId: 1, name: 'Test Comment', email: 'test@example.com', body: 'Test comment body' }] }; return { success: true, data: { endpoint, url, response: mockData[endpoint as keyof typeof mockData] || [], status: 'success' }, metadata: { tool: 'test_jsonplaceholder', timestamp: new Date().toISOString() } }; } catch (error) { return { success: false, error: `JSONPlaceholder test failed: ${error instanceof Error ? error.message : String(error)}`, data: null }; } } });
  • src/index.ts:245-245 (registration)
    Top-level call to registerJSONPlaceholderTools in the MCP server initialization, which registers the test_jsonplaceholder tool.
    registerJSONPlaceholderTools(this.toolRegistry); // 2 tools: test_jsonplaceholder, test_httpbin

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