How to call mcp server with curl?

Updated October 2026 · How we answer

Short answerOnly servers that use the HTTP transport can be called with curl. Send a JSON-RPC initialize request with POST, save the session ID from the response, then send tools/list or tools/call requests with that session ID.

Why curl only works with HTTP servers

MCP messages are JSON-RPC 2.0 objects. Servers that use the stdio transport talk through standard input and output, so curl has no way to reach them.

Servers that use the Streamable HTTP transport accept POST requests at one endpoint, and that is what you can call with curl.

Send the requests in order

Start with an initialize POST that includes a protocol version, client details and an Accept header that lists both application/json and text/event-stream. If the response includes an Mcp-Session-Id header, copy it and send it on every later request.

After the server accepts initialization, send the initialized notification. Then send your tools/list or tools/call request with a unique id.

  • POST an initialize request to the endpoint
  • Save the Mcp-Session-Id response header
  • POST the initialized notification
  • POST tools/list to see available tools
  • POST tools/call with a tool name and arguments

Read the response

The server may reply with plain JSON or with an event stream, so check the Content-Type header before you parse the body. Each reply carries the same id you sent, which lets you match it to your request.

A JSON-RPC error object tells you what went wrong, such as a missing session or bad parameters.

Common mistakes

  • Leaving out the Accept header, which some servers reject.
  • Reusing the same JSON-RPC id for two different requests.
  • Skipping initialize and expecting tools/call to work.
From our shopsCASEONYX: Dark-luxe tough phone cases.