mcp_http_request
Send HTTP requests (GET, POST, PUT, DELETE, PATCH) with customizable headers, body data, and URL parameters. Retrieve responses for seamless integration with Ontology MCP server workflows.
Instructions
HTTP 요청을 보내고 응답을 반환합니다. GET, POST, PUT, DELETE 등 다양한 HTTP 메소드를 사용할 수 있으며, 헤더와 데이터를 설정할 수 있습니다.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | 요청 바디 데이터 | |
| headers | No | 요청 헤더 (예: {"Content-Type": "application/json", "Authorization": "Bearer token"}) | |
| method | No | HTTP 메소드 (기본값: GET) | |
| params | No | URL 파라미터 (예: ?key=value) | |
| timeout | No | 타임아웃(밀리초 단위, 기본값: 30000) | |
| url | Yes | 요청할 URL |
Input Schema (JSON Schema)
{
"properties": {
"data": {
"description": "요청 바디 데이터",
"type": "object"
},
"headers": {
"description": "요청 헤더 (예: {\"Content-Type\": \"application/json\", \"Authorization\": \"Bearer token\"})",
"type": "object"
},
"method": {
"description": "HTTP 메소드 (기본값: GET)",
"enum": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH"
],
"type": "string"
},
"params": {
"description": "URL 파라미터 (예: ?key=value)",
"type": "object"
},
"timeout": {
"description": "타임아웃(밀리초 단위, 기본값: 30000)",
"type": "number"
},
"url": {
"description": "요청할 URL",
"type": "string"
}
},
"required": [
"url"
],
"type": "object"
}
Implementation Reference
- src/tools/index.ts:519-536 (handler)MCP tool handler function for 'mcp_http_request' that invokes httpService.request and formats the response.async handler(args: any): Promise<ToolResponse> { try { const result = await httpService.request(args); return { content: [{ type: 'text', text: result }] }; } catch (error) { return { content: [{ type: 'text', text: `HTTP 요청 오류: ${error instanceof Error ? error.message : String(error)}` }] }; } }
- src/tools/index.ts:488-518 (schema)Input schema definition for the mcp_http_request tool parameters.inputSchema: { type: 'object', properties: { url: { type: 'string', description: '요청할 URL' }, method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'], description: 'HTTP 메소드 (기본값: GET)' }, headers: { type: 'object', description: '요청 헤더 (예: {"Content-Type": "application/json", "Authorization": "Bearer token"})' }, data: { type: 'object', description: '요청 바디 데이터' }, params: { type: 'object', description: 'URL 파라미터 (예: ?key=value)' }, timeout: { type: 'number', description: '타임아웃(밀리초 단위, 기본값: 30000)' } }, required: ['url'] },
- src/services/http-service.ts:25-75 (helper)Core HTTP request implementation using axios, handling config, response formatting, and errors.async request(args: HttpRequestArgs): Promise<string> { try { const config: AxiosRequestConfig = { url: args.url, method: args.method || 'GET', timeout: args.timeout || 30000, }; if (args.headers) { config.headers = args.headers; } if (args.params) { config.params = args.params; } if (args.data) { config.data = args.data; } const response = await axios(config); // 응답 데이터 처리 let responseData = response.data; // 객체인 경우 JSON 문자열로 변환 if (typeof responseData === 'object') { responseData = JSON.stringify(responseData, null, 2); } return responseData; } catch (error) { if (axios.isAxiosError(error)) { const statusCode = error.response?.status; const responseData = error.response?.data; throw new McpError( ErrorCode.InternalError, `HTTP 요청 오류 (${statusCode}): ${ typeof responseData === 'object' ? JSON.stringify(responseData, null, 2) : responseData || error.message }` ); } throw new McpError( ErrorCode.InternalError, `HTTP 요청 실패: ${formatError(error)}` ); }
- src/tools/index.ts:485-537 (registration)Tool object definition and registration in the tools export array used by the MCP server.{ name: 'mcp_http_request', description: 'HTTP 요청을 보내고 응답을 반환합니다. GET, POST, PUT, DELETE 등 다양한 HTTP 메소드를 사용할 수 있으며, 헤더와 데이터를 설정할 수 있습니다.', inputSchema: { type: 'object', properties: { url: { type: 'string', description: '요청할 URL' }, method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'], description: 'HTTP 메소드 (기본값: GET)' }, headers: { type: 'object', description: '요청 헤더 (예: {"Content-Type": "application/json", "Authorization": "Bearer token"})' }, data: { type: 'object', description: '요청 바디 데이터' }, params: { type: 'object', description: 'URL 파라미터 (예: ?key=value)' }, timeout: { type: 'number', description: '타임아웃(밀리초 단위, 기본값: 30000)' } }, required: ['url'] }, async handler(args: any): Promise<ToolResponse> { try { const result = await httpService.request(args); return { content: [{ type: 'text', text: result }] }; } catch (error) { return { content: [{ type: 'text', text: `HTTP 요청 오류: ${error instanceof Error ? error.message : String(error)}` }] }; } } },
- src/index.ts:24-53 (registration)MCP server capabilities registration declaring support for mcp_http_request tool.capabilities: { tools: { mcp_sparql_execute_query: true, mcp_sparql_update: true, mcp_sparql_list_repositories: true, mcp_sparql_list_graphs: true, mcp_sparql_get_resource_info: true, mcp_ollama_run: true, mcp_ollama_show: true, mcp_ollama_pull: true, mcp_ollama_list: true, mcp_ollama_rm: true, mcp_ollama_chat_completion: true, mcp_ollama_status: true, mcp_http_request: true, mcp_openai_chat: true, mcp_openai_image: true, mcp_openai_tts: true, mcp_openai_transcribe: true, mcp_openai_embedding: true, mcp_gemini_generate_text: true, mcp_gemini_chat_completion: true, mcp_gemini_list_models: true, mcp_gemini_generate_images: false, mcp_gemini_generate_image: false, mcp_gemini_generate_videos: false, mcp_gemini_generate_multimodal_content: false, mcp_imagen_generate: false, mcp_gemini_create_image: false, mcp_gemini_edit_image: false