test_httpbin
Test and validate HTTP requests and responses with HTTPBin to ensure proper API functionality and debugging. Adjust methods (GET, POST, etc.) and endpoints for precise testing scenarios.
Instructions
Test HTTP requests and responses using HTTPBin
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endpoint | No | HTTPBin endpoint to test | get |
| method | No | HTTP method to test | GET |
Input Schema (JSON Schema)
{
"properties": {
"endpoint": {
"default": "get",
"description": "HTTPBin endpoint to test",
"type": "string"
},
"method": {
"default": "GET",
"description": "HTTP method to test",
"enum": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH"
],
"type": "string"
}
},
"required": [],
"type": "object"
}
Implementation Reference
- The execute handler function implementing the test_httpbin tool logic. It simulates HTTPBin responses with mock data for testing HTTP methods and endpoints.execute: async (args: ToolInput): Promise<ToolOutput> => { try { const { method = 'GET', endpoint = 'get' } = args; // Simulate HTTPBin response const mockResponse = { args: {}, headers: { 'Accept': 'application/json', 'User-Agent': 'Open-Search-MCP/1.0' }, origin: '127.0.0.1', url: `https://httpbin.org/${endpoint}`, method: method }; return { success: true, data: { method, endpoint, response: mockResponse, status: 'success' }, metadata: { tool: 'test_httpbin', timestamp: new Date().toISOString() } }; } catch (error) { return { success: false, error: `HTTPBin test failed: ${error instanceof Error ? error.message : String(error)}`, data: null }; } }
- Input schema for the test_httpbin tool, defining parameters 'method' (enum of HTTP methods) and 'endpoint' (string).inputSchema: { type: 'object', properties: { method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'], description: 'HTTP method to test', default: 'GET' }, endpoint: { type: 'string', description: 'HTTPBin endpoint to test', default: 'get' } }, required: [] },
- src/tools/testing/jsonplaceholder-tools.ts:126-185 (registration)Direct registration of the test_httpbin tool via registry.registerTool, including name, description, category, source, schema, and handler.registry.registerTool({ name: 'test_httpbin', description: 'Test HTTP requests and responses using HTTPBin', category: 'testing', source: 'HTTPBin', inputSchema: { type: 'object', properties: { method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'], description: 'HTTP method to test', default: 'GET' }, endpoint: { type: 'string', description: 'HTTPBin endpoint to test', default: 'get' } }, required: [] }, execute: async (args: ToolInput): Promise<ToolOutput> => { try { const { method = 'GET', endpoint = 'get' } = args; // Simulate HTTPBin response const mockResponse = { args: {}, headers: { 'Accept': 'application/json', 'User-Agent': 'Open-Search-MCP/1.0' }, origin: '127.0.0.1', url: `https://httpbin.org/${endpoint}`, method: method }; return { success: true, data: { method, endpoint, response: mockResponse, status: 'success' }, metadata: { tool: 'test_httpbin', timestamp: new Date().toISOString() } }; } catch (error) { return { success: false, error: `HTTPBin test failed: ${error instanceof Error ? error.message : String(error)}`, data: null }; } } });
- src/index.ts:245-245 (registration)Main server initialization calls registerJSONPlaceholderTools which registers the test_httpbin tool (along with test_jsonplaceholder).registerJSONPlaceholderTools(this.toolRegistry); // 2 tools: test_jsonplaceholder, test_httpbin