Skip to main content
Glama
247arjun
by 247arjun

curl_post

Send HTTP POST requests to specified URLs with custom data, JSON payloads, headers, and timeout settings, enabling streamlined API interactions.

Instructions

Make an HTTP POST request using curl

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
content_typeNoContent-Type header (will be added automatically for JSON data)
dataNoData to send in the POST request body
follow_redirectsNoWhether to follow redirects
headersNoOptional HTTP headers in the format 'Header: Value'
json_dataNoJSON object to send as POST data
timeoutNoRequest timeout in seconds
urlYesThe URL to make the POST request to

Implementation Reference

  • The handler function for the 'curl_post' tool. It constructs the curl command line arguments based on the input parameters (URL, data/JSON, headers, etc.), calls the shared executeCurl helper to run the command, and formats the stdout/stderr/output as text content.
    async ({ url, data, json_data, headers, content_type, follow_redirects, timeout }) => {
      const args = ['curl'];
      
      // Add the URL
      args.push(url);
      
      // Add POST method
      args.push('-X', 'POST');
      
      // Handle data
      if (json_data) {
        args.push('-d', JSON.stringify(json_data));
        if (!content_type) {
          content_type = 'application/json';
        }
      } else if (data) {
        args.push('-d', data);
      }
      
      // Add content type header
      if (content_type) {
        args.push('-H', `Content-Type: ${content_type}`);
      }
      
      // Add additional headers if provided
      if (headers && headers.length > 0) {
        headers.forEach(header => {
          args.push('-H', header);
        });
      }
      
      // Add follow redirects option
      if (follow_redirects) {
        args.push('-L');
      }
      
      // Add timeout if provided
      if (timeout) {
        args.push('--max-time', timeout.toString());
      }
      
      // Include response headers in output
      args.push('-i');
      
      try {
        const result = await executeCurl(args);
        
        return {
          content: [
            {
              type: "text",
              text: `Exit Code: ${result.exitCode}\n\nResponse:\n${result.stdout}${result.stderr ? `\n\nErrors:\n${result.stderr}` : ''}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error executing curl: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • Zod input schema defining the parameters accepted by the curl_post tool.
    {
      url: z.string().describe("The URL to make the POST request to"),
      data: z.string().optional().describe("Data to send in the POST request body"),
      json_data: z.record(z.any()).optional().describe("JSON object to send as POST data"),
      headers: z.array(z.string()).optional().describe("Optional HTTP headers in the format 'Header: Value'"),
      content_type: z.string().optional().describe("Content-Type header (will be added automatically for JSON data)"),
      follow_redirects: z.boolean().optional().default(false).describe("Whether to follow redirects"),
      timeout: z.number().optional().describe("Request timeout in seconds"),
    },
  • src/index.ts:131-209 (registration)
    The server.tool call that registers the 'curl_post' tool with name, description, input schema, and handler function.
    server.tool(
      "curl_post",
      "Make an HTTP POST request using curl",
      {
        url: z.string().describe("The URL to make the POST request to"),
        data: z.string().optional().describe("Data to send in the POST request body"),
        json_data: z.record(z.any()).optional().describe("JSON object to send as POST data"),
        headers: z.array(z.string()).optional().describe("Optional HTTP headers in the format 'Header: Value'"),
        content_type: z.string().optional().describe("Content-Type header (will be added automatically for JSON data)"),
        follow_redirects: z.boolean().optional().default(false).describe("Whether to follow redirects"),
        timeout: z.number().optional().describe("Request timeout in seconds"),
      },
      async ({ url, data, json_data, headers, content_type, follow_redirects, timeout }) => {
        const args = ['curl'];
        
        // Add the URL
        args.push(url);
        
        // Add POST method
        args.push('-X', 'POST');
        
        // Handle data
        if (json_data) {
          args.push('-d', JSON.stringify(json_data));
          if (!content_type) {
            content_type = 'application/json';
          }
        } else if (data) {
          args.push('-d', data);
        }
        
        // Add content type header
        if (content_type) {
          args.push('-H', `Content-Type: ${content_type}`);
        }
        
        // Add additional headers if provided
        if (headers && headers.length > 0) {
          headers.forEach(header => {
            args.push('-H', header);
          });
        }
        
        // Add follow redirects option
        if (follow_redirects) {
          args.push('-L');
        }
        
        // Add timeout if provided
        if (timeout) {
          args.push('--max-time', timeout.toString());
        }
        
        // Include response headers in output
        args.push('-i');
        
        try {
          const result = await executeCurl(args);
          
          return {
            content: [
              {
                type: "text",
                text: `Exit Code: ${result.exitCode}\n\nResponse:\n${result.stdout}${result.stderr ? `\n\nErrors:\n${result.stderr}` : ''}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error executing curl: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Shared helper function used by curl_post (and other curl tools) to safely spawn a child curl process, capture output streams, and return stdout, stderr, and exit code.
    async function executeCurl(args: string[]): Promise<{ stdout: string; stderr: string; exitCode: number }> {
      return new Promise((resolve) => {
        // Ensure we're only calling curl with safe arguments
        if (!args.includes('curl')) {
          args.unshift('curl');
        }
        
        const child = spawn('curl', args.slice(1), {
          stdio: ['pipe', 'pipe', 'pipe'],
          shell: false,
        });
    
        let stdout = '';
        let stderr = '';
    
        child.stdout.on('data', (data) => {
          stdout += data.toString();
        });
    
        child.stderr.on('data', (data) => {
          stderr += data.toString();
        });
    
        child.on('close', (code) => {
          resolve({
            stdout,
            stderr,
            exitCode: code || 0,
          });
        });
    
        child.on('error', (error) => {
          resolve({
            stdout: '',
            stderr: error.message,
            exitCode: 1,
          });
        });
      });
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without disclosing behavioral traits. It doesn't mention error handling, authentication needs, rate limits, what happens with redirects (though the parameter hints at this), or response format expectations. For a tool with 7 parameters and no annotation coverage, this is a significant gap in behavioral context.

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 that directly states the tool's purpose with zero wasted words. It's appropriately sized and front-loaded, making it easy for an agent to quickly understand the core functionality without unnecessary elaboration.

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 (7 parameters, no output schema, no annotations), the description is insufficiently complete. It doesn't address what the tool returns (no output schema means the description should hint at response format), error conditions, or practical usage scenarios. For a general-purpose HTTP tool with multiple configuration options, more context is needed to help the agent use it effectively.

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?

Schema description coverage is 100%, providing detailed parameter documentation. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain relationships between parameters like data vs json_data, or provide usage examples). With high schema coverage, the baseline of 3 is appropriate as the description doesn't compensate but doesn't need to given the comprehensive schema.

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 'Make an HTTP POST request using curl' clearly states the action (POST request) and technology (curl), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like curl_put or curl_get, which would require mentioning it's specifically for POST method requests versus other HTTP methods.

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 like curl_put or curl_get. There's no mention of POST-specific use cases (e.g., submitting form data, creating resources) or when other methods might be more appropriate, leaving the agent without contextual usage instructions.

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

Related 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/247arjun/mcp-curl'

If you have feedback or need assistance with the MCP directory API, please join our Discord server