Execute cURL Request
curl_executeExecute HTTP requests with structured cURL parameters, supporting authentication, custom headers, form data, and JSON path filtering for targeted data extraction.
Instructions
Execute an HTTP request using cURL with structured parameters.
This tool provides a safe, structured way to make HTTP requests with common cURL options. It handles URL encoding, header formatting, and response processing automatically.
Args:
url (string, required): The URL to request
method (string): HTTP method - GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
headers (object): HTTP headers as key-value pairs
data (string): Request body for POST/PUT/PATCH requests
form (object): Form data as key-value pairs (multipart/form-data)
follow_redirects (boolean): Follow HTTP redirects (default: true)
max_redirects (number): Maximum redirects to follow (0-50)
insecure (boolean): Skip SSL verification (default: false)
timeout (number): Request timeout in seconds (1-300, default: 30)
user_agent (string): Custom User-Agent header (a browser-like default is sent automatically if not set; empty string disables)
basic_auth (string): Basic auth as "username:password"
bearer_token (string): Bearer token for Authorization header
verbose (boolean): Include verbose request/response details
include_headers (boolean): Include response headers in output
compressed (boolean): Request compressed response (default: true)
include_metadata (boolean): Wrap response in JSON with metadata
jq_filter (string): JSON path filter to extract specific data
max_result_size (number): Max bytes to return inline (default: 500KB, max: 1MB). Auto-saves to file when exceeded
save_to_file (boolean): Force save response to temp file. Returns filepath instead of content
output_dir (string): Custom directory to save files (overrides MCP_CURL_OUTPUT_DIR env var)
jq_filter Syntax:
.key - Object property access
.[n] or .n - Array index (non-negative only, e.g., .results.0)
.[n:m] - Array slice from index n to m
.["key"] - Bracket notation for special characters in keys
.a,.b,.c - Multiple comma-separated paths (returns array of values, max 20)
jq_filter Validation:
Unclosed quotes and brackets throw clear errors
Leading zeros in indices rejected (use .0 not .00)
Negative indices not supported (unlike real jq)
Indices must be within safe integer range
Returns: The HTTP response body, or JSON with metadata if include_metadata is true: { "success": boolean, "exit_code": number, "response": string, "stderr": string (if present), "saved_to_file": boolean (if response was saved), "filepath": string (path to saved file) }
Examples:
Simple GET: { "url": "https://api.example.com/data" }
POST JSON: { "url": "https://api.example.com/users", "method": "POST", "headers": {"Content-Type": "application/json"}, "data": "{"name": "John"}" }
With auth: { "url": "https://api.example.com/secure", "bearer_token": "your-token-here" }
Extract field: { "url": "https://api.github.com/repos/octocat/hello-world", "jq_filter": ".name" }
Multiple fields: { "url": "https://api.example.com/user", "jq_filter": ".name,.email,.id" }
Dot notation: { "url": "https://api.example.com/items", "jq_filter": ".results.0.name" }
Array slice: { "url": "https://api.example.com/items", "jq_filter": ".results[0:10]" }
Custom output: { "url": "https://api.example.com/large", "save_to_file": true, "output_dir": "/path/to/dir" }
Error Handling:
Returns error message if cURL fails or times out
Exit code 0 indicates success
Non-zero exit codes indicate various cURL errors
Invalid JSON with jq_filter returns error with response preview
Temp File Lifecycle: Files saved with save_to_file or auto-save are:
Stored in a secure temp directory (owner-only access: 0o700/0o600)
Deleted on graceful server shutdown (SIGINT/SIGTERM)
Orphaned files from crashed sessions are cleaned on next server start
Check mcp-curl-* in system temp dir if files persist after crash
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL to request (http or https) | |
| method | No | HTTP method (defaults to GET, or POST if data is provided) | |
| headers | No | HTTP headers as key-value pairs (e.g., {"Content-Type": "application/json"}) | |
| data | No | Request body data (for POST/PUT/PATCH). Use JSON string for JSON payloads | |
| form | No | Form data as key-value pairs (uses multipart/form-data) | |
| follow_redirects | No | Follow HTTP redirects (default: true) | |
| max_redirects | No | Maximum number of redirects to follow | |
| insecure | No | Skip SSL certificate verification (default: false) | |
| timeout | No | Request timeout in seconds (default: 30, max: 300) | |
| user_agent | No | Custom User-Agent header. If not set, a browser-like User-Agent is sent automatically. Set to empty string to disable. | |
| basic_auth | No | Basic authentication in format 'username:password' | |
| bearer_token | No | Bearer token for Authorization header | |
| verbose | No | Include verbose output with request/response details | |
| include_headers | No | Include response headers in output | |
| compressed | No | Request compressed response and automatically decompress | |
| include_metadata | No | Wrap response in JSON with metadata (exit code, success status) | |
| jq_filter | No | JSON path filter to extract specific data. Supports: .key, .[n] or .n (non-negative array index), .[n:m] (slice), .["key"] (bracket notation), .a,.b (multiple comma-separated paths return array, max 20). Negative indices not supported. Applied after response, before max_result_size check. | |
| max_result_size | No | Max bytes to return inline (default: 500KB, max: 1MB). Larger responses auto-save to temp file | |
| save_to_file | No | Force save response to temp file. Returns filepath instead of content | |
| output_dir | No | Directory to save response files (must exist and be writable). Overrides MCP_CURL_OUTPUT_DIR env var. Falls back to system temp directory. |