(method, urlStr, data = null, headers = {})
| 6 | |
| 7 | // Helper function to make HTTP requests |
| 8 | async function makeHttpRequest (method, urlStr, data = null, headers = {}) { |
| 9 | try { |
| 10 | const response = await axios({ |
| 11 | method: method.toUpperCase(), |
| 12 | url: urlStr, |
| 13 | data, |
| 14 | headers |
| 15 | }) |
| 16 | return { |
| 17 | status: response.status, |
| 18 | headers: response.headers, |
| 19 | data: response.data |
| 20 | } |
| 21 | } catch (error) { |
| 22 | if (error.response) { |
| 23 | const err = new Error(`Request failed with status ${error.response.status}`) |
| 24 | err.response = { |
| 25 | status: error.response.status, |
| 26 | headers: error.response.headers, |
| 27 | data: error.response.data |
| 28 | } |
| 29 | throw err |
| 30 | } else { |
| 31 | throw error |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | // Helper function to initialize MCP session |
| 37 | async function initSession () { |
no outgoing calls
no test coverage detected