## Create MCP Server

### cURL

```bash
curl --request POST \
  --url https://your-org.platform.barndoor.ai/api/servers \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "My Salesforce Instance",
  "mcp_server_directory_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "slug": "<string>",
  "client_id": "<string>",
  "client_secret": "<string>",
  "meta": {}
}
'
```

### Python

```python
import requests

url = "https://your-org.platform.barndoor.ai/api/servers"

payload = {
    "name": "My Salesforce Instance",
    "mcp_server_directory_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "slug": "<string>",
    "client_id": "<string>",
    "client_secret": "<string>",
    "meta": {}
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)
```

### JavaScript (Fetch)

```javascript
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    name: 'My Salesforce Instance',
    mcp_server_directory_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
    slug: '<string>',
    client_id: '<string>',
    client_secret: '<string>',
    meta: {}
  })
};

fetch('https://your-org.platform.barndoor.ai/api/servers', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### PHP

```php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://your-org.platform.barndoor.ai/api/servers",
  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([
    'name' => 'My Salesforce Instance',
    'mcp_server_directory_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
    'slug' => '<string>',
    'client_id' => '<string>',
    'client_secret' => '<string>',
    'meta' => []
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

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

curl_close($curl);

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

### Go

```go
package main

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

func main() {

url := "https://your-org.platform.barndoor.ai/api/servers"

payload := strings.NewReader("{\n  \"name\": \"My Salesforce Instance\",\n  \"mcp_server_directory_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n  \"slug\": \"<string>\",\n  \"client_id\": \"<string>\",\n  \"client_secret\": \"<string>\",\n  \"meta\": {}\n}")

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

req.Header.Add("Authorization", "Bearer <token>")
	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))
}
```

### Response Examples

#### Success Response
```json
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "connection_id": "<string>",
  "auth_url": "<string>"
}
```

#### Error Response
```json
{
  "error": "ServerNotFound",
  "message": "Server with ID '123' not found",
  "details": {}
}
```

### Authorizations
- **Authorization**: required JWT token obtained through Barndoor's OAuth 2.0 authorization-code flow with PKCE. The token should be included in the Authorization header, e.g., `Authorization: Bearer <your-jwt-token>`.
