Skip to main content
POST
/
mcp
/
MCP Post
curl --request POST \
  --url https://api.example.com/mcp/ \
  --header 'Accept: <accept>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "initialize",
  "params": {
    "clientInfo": {
      "name": "test_client",
      "version": "1.0.0"
    },
    "protocolVersion": "2024-11-05",
    "capabilities": {}
  }
}
'
import requests

url = "https://api.example.com/mcp/"

payload = {
    "jsonrpc": "2.0",
    "id": "1",
    "method": "initialize",
    "params": {
        "clientInfo": {
            "name": "test_client",
            "version": "1.0.0"
        },
        "protocolVersion": "2024-11-05",
        "capabilities": {}
    }
}
headers = {
    "Accept": "<accept>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Accept: '<accept>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: '1',
    method: 'initialize',
    params: {
      clientInfo: {name: 'test_client', version: '1.0.0'},
      protocolVersion: '2024-11-05',
      capabilities: {}
    }
  })
};

fetch('https://api.example.com/mcp/', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.example.com/mcp/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'jsonrpc' => '2.0',
    'id' => '1',
    'method' => 'initialize',
    'params' => [
        'clientInfo' => [
                'name' => 'test_client',
                'version' => '1.0.0'
        ],
        'protocolVersion' => '2024-11-05',
        'capabilities' => [
                
        ]
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Accept: <accept>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/mcp/"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": \"1\",\n  \"method\": \"initialize\",\n  \"params\": {\n    \"clientInfo\": {\n      \"name\": \"test_client\",\n      \"version\": \"1.0.0\"\n    },\n    \"protocolVersion\": \"2024-11-05\",\n    \"capabilities\": {}\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Accept", "<accept>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.example.com/mcp/")
  .header("Accept", "<accept>")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": \"1\",\n  \"method\": \"initialize\",\n  \"params\": {\n    \"clientInfo\": {\n      \"name\": \"test_client\",\n      \"version\": \"1.0.0\"\n    },\n    \"protocolVersion\": \"2024-11-05\",\n    \"capabilities\": {}\n  }\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/mcp/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = '<accept>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"jsonrpc\": \"2.0\",\n  \"id\": \"1\",\n  \"method\": \"initialize\",\n  \"params\": {\n    \"clientInfo\": {\n      \"name\": \"test_client\",\n      \"version\": \"1.0.0\"\n    },\n    \"protocolVersion\": \"2024-11-05\",\n    \"capabilities\": {}\n  }\n}"

response = http.request(request)
puts response.read_body
{}

Headers

Accept
enum<string>
required

Accept header must include both 'application/json' and 'text/event-stream' media types.

Available options:
application/json, text/event-stream

Body

application/json

A JSON-RPC 2.0 request, notification, or response object.

Response

Successful JSON-RPC response.

The response is of type object.