Skip to main content
Glama
flyanima

Open Search MCP

by flyanima

jsonplaceholder_health_test

Test API connectivity and response times for JSONPlaceholder endpoints to verify service health and performance.

Instructions

Test API connectivity and response times using JSONPlaceholder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endpointsNoEndpoints to test: posts, users, comments, albums, photos, todos

Implementation Reference

  • The execute function implementing the tool's core logic: performs health checks on specified JSONPlaceholder endpoints by fetching limited data samples, calculating response times, tracking success/failure, and returning detailed test summary.
    execute: async (args: any) => {
      try {
        const endpoints = args.endpoints || ['posts', 'users', 'comments'];
        const testResults: any = {
          timestamp: new Date().toISOString(),
          endpoints_tested: endpoints,
          results: {},
          summary: {
            total_tests: endpoints.length,
            successful: 0,
            failed: 0,
            average_response_time: 0
          }
        };
    
        let totalResponseTime = 0;
    
        for (const endpoint of endpoints) {
          const startTime = Date.now();
          try {
            let data;
            switch (endpoint) {
              case 'posts':
                data = await client.getPosts(3);
                break;
              case 'users':
                data = await client.getUsers(3);
                break;
              case 'comments':
                data = await client.getComments(undefined, 3);
                break;
              case 'albums':
                data = await client.getAlbums(undefined, 3);
                break;
              case 'photos':
                data = await client.getPhotos(undefined, 3);
                break;
              case 'todos':
                data = await client.getTodos(undefined, 3);
                break;
              default:
                throw new Error(`Unknown endpoint: ${endpoint}`);
            }
    
            const responseTime = Date.now() - startTime;
            totalResponseTime += responseTime;
    
            testResults.results[endpoint] = {
              status: 'success',
              response_time: responseTime,
              data_count: Array.isArray(data) ? data.length : 1
            };
            testResults.summary.successful++;
    
          } catch (error) {
            const responseTime = Date.now() - startTime;
            testResults.results[endpoint] = {
              status: 'failed',
              response_time: responseTime,
              error: error instanceof Error ? error.message : 'Unknown error'
            };
            testResults.summary.failed++;
          }
        }
    
        testResults.summary.average_response_time = Math.round(totalResponseTime / endpoints.length);
    
        return {
          success: true,
          data: {
            source: 'JSONPlaceholder API',
            health_test: testResults,
            timestamp: Date.now(),
            apiUsed: true
          }
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Failed to run health test'
        };
      }
    }
  • Registers the 'jsonplaceholder_health_test' tool into the ToolRegistry within the registerJSONPlaceholderTools function.
    registry.registerTool({
      name: 'jsonplaceholder_health_test',
      description: 'Test API connectivity and response times using JSONPlaceholder',
      category: 'testing',
      source: 'jsonplaceholder.typicode.com',
      inputSchema: {
        type: 'object',
        properties: {
          endpoints: {
            type: 'array',
            items: { type: 'string' },
            description: 'Endpoints to test: posts, users, comments, albums, photos, todos',
            default: ['posts', 'users', 'comments']
          }
        },
        required: []
      },
      execute: async (args: any) => {
        try {
          const endpoints = args.endpoints || ['posts', 'users', 'comments'];
          const testResults: any = {
            timestamp: new Date().toISOString(),
            endpoints_tested: endpoints,
            results: {},
            summary: {
              total_tests: endpoints.length,
              successful: 0,
              failed: 0,
              average_response_time: 0
            }
          };
    
          let totalResponseTime = 0;
    
          for (const endpoint of endpoints) {
            const startTime = Date.now();
            try {
              let data;
              switch (endpoint) {
                case 'posts':
                  data = await client.getPosts(3);
                  break;
                case 'users':
                  data = await client.getUsers(3);
                  break;
                case 'comments':
                  data = await client.getComments(undefined, 3);
                  break;
                case 'albums':
                  data = await client.getAlbums(undefined, 3);
                  break;
                case 'photos':
                  data = await client.getPhotos(undefined, 3);
                  break;
                case 'todos':
                  data = await client.getTodos(undefined, 3);
                  break;
                default:
                  throw new Error(`Unknown endpoint: ${endpoint}`);
              }
    
              const responseTime = Date.now() - startTime;
              totalResponseTime += responseTime;
    
              testResults.results[endpoint] = {
                status: 'success',
                response_time: responseTime,
                data_count: Array.isArray(data) ? data.length : 1
              };
              testResults.summary.successful++;
    
            } catch (error) {
              const responseTime = Date.now() - startTime;
              testResults.results[endpoint] = {
                status: 'failed',
                response_time: responseTime,
                error: error instanceof Error ? error.message : 'Unknown error'
              };
              testResults.summary.failed++;
            }
          }
    
          testResults.summary.average_response_time = Math.round(totalResponseTime / endpoints.length);
    
          return {
            success: true,
            data: {
              source: 'JSONPlaceholder API',
              health_test: testResults,
              timestamp: Date.now(),
              apiUsed: true
            }
          };
        } catch (error) {
          return {
            success: false,
            error: error instanceof Error ? error.message : 'Failed to run health test'
          };
        }
      }
    });
  • Inline input schema defining the tool's expected parameters (optional endpoints array).
    inputSchema: {
      type: 'object',
      properties: {
        endpoints: {
          type: 'array',
          items: { type: 'string' },
          description: 'Endpoints to test: posts, users, comments, albums, photos, todos',
          default: ['posts', 'users', 'comments']
        }
      },
      required: []
    },
  • Zod schema in global input validator for validating and parsing tool inputs specifically for 'jsonplaceholder_health_test'.
    'jsonplaceholder_health_test': z.object({
      endpoints: z.array(z.enum(['posts', 'users', 'comments', 'albums', 'photos', 'todos'])).optional()
    }),
  • Helper class instantiated and used by the handler to make actual API requests to JSONPlaceholder endpoints.
    class JSONPlaceholderAPIClient {
      private baseURL = 'https://jsonplaceholder.typicode.com';
    
      async makeRequest(endpoint: string, params: Record<string, any> = {}) {
        try {
          const response = await axios.get(`${this.baseURL}${endpoint}`, {
            params,
            timeout: 10000
          });
    
          return response.data;
        } catch (error) {throw error;
        }
      }
    
      async getPosts(limit?: number) {
        const posts = await this.makeRequest('/posts');
        return limit ? posts.slice(0, limit) : posts;
      }
    
      async getUsers(limit?: number) {
        const users = await this.makeRequest('/users');
        return limit ? users.slice(0, limit) : users;
      }
    
      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;
      }
    
      async getAlbums(userId?: number, limit?: number) {
        const endpoint = userId ? `/users/${userId}/albums` : '/albums';
        const albums = await this.makeRequest(endpoint);
        return limit ? albums.slice(0, limit) : albums;
      }
    
      async getPhotos(albumId?: number, limit?: number) {
        const endpoint = albumId ? `/albums/${albumId}/photos` : '/photos';
        const photos = await this.makeRequest(endpoint);
        return limit ? photos.slice(0, limit) : photos;
      }
    
      async getTodos(userId?: number, limit?: number) {
        const endpoint = userId ? `/users/${userId}/todos` : '/todos';
        const todos = await this.makeRequest(endpoint);
        return limit ? todos.slice(0, limit) : todos;
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions testing 'API connectivity and response times', which implies a read-only operation that measures performance, but it doesn't detail what the tool actually does (e.g., whether it makes HTTP requests, how it calculates response times, or what output to expect). This leaves significant gaps in understanding the tool's behavior.

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, efficient sentence: 'Test API connectivity and response times using JSONPlaceholder'. It is front-loaded with the core purpose, has zero wasted words, and is appropriately sized for a simple tool. Every part of the sentence earns its place by conveying essential information.

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?

Given the tool's complexity (a testing tool with no annotations and no output schema), the description is incomplete. It doesn't explain what the tool returns (e.g., success/failure status, response time data), how it handles errors, or the scope of testing. For a tool that likely involves network operations, more context is needed to understand its full behavior and output.

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?

The input schema has 100% description coverage, with the 'endpoints' parameter clearly documented in the schema itself (listing options like 'posts', 'users', etc.). The description adds no additional meaning beyond what the schema provides, such as explaining how endpoints are tested or default behavior. With high schema coverage, the baseline score of 3 is appropriate, as 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 tool's purpose: 'Test API connectivity and response times using JSONPlaceholder'. It specifies the verb ('Test') and the resource ('API connectivity and response times'), making the function understandable. However, it doesn't explicitly differentiate from sibling tools like 'test_jsonplaceholder' or 'test_httpbin', which appear to serve similar testing purposes.

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. It doesn't mention sibling tools like 'test_jsonplaceholder' or 'test_httpbin', nor does it specify scenarios where this tool is preferred over others. Without such context, users must infer usage based on the tool name alone.

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

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