> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.claw-ops.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.claw-ops.com/_mcp/server.

# 외부 MCP 연결 자격증명 교체

POST https://api.claw-ops.com/v1/accounts/{accountId}/mcp-connections/{connectionId}/credential
Content-Type: application/json

자격증명을 교체합니다. 기본 동작은 **검증 후 교체**입니다 — 새 자격증명으로 실제 연결에 성공한 뒤에야 저장하므로, 잘못된 값으로 정상 연결을 덮어써 통화가 망가지는 일이 없습니다.

러너에 접근할 수 없는 등 검증이 불가능한 상황에서는 force=true 로 검증 없이 저장할 수 있습니다. 이 경우 status 가 untested 가 되어 **통화에서는 사용되지 않으며**, 이후 연결 테스트를 통과해야 다시 사용됩니다.

응답에는 자격증명이 포함되지 않습니다.

Reference: https://docs.claw-ops.com/api-레퍼런스/claw-ops-api/agents/rotate-mcp-credential

## Authentication

- `Authorization` header (bearer token, required) — API Key를 Bearer 토큰으로 전달

## Request

### Path parameters

- `accountId` (string, required) — 계정 ID
- `connectionId` (string, required) — MCP 연결 ID

### Body (application/json)

- `authType` (enum, required) — none 으로 바꾸면 저장된 자격증명이 제거됩니다.
  - Allowed values: `none`, `bearer`, `api_key`
- `headerName` (string, optional) — authType=api_key 일 때만 사용합니다.
- `secret` (string, optional) — authType 이 none 이 아닐 때 필수. 저장 후 다시 조회할 수 없습니다.
- `force` (boolean, optional, default: false) — true 면 연결 검증 없이 저장합니다(복구용). status 가 untested 가 되어 통화에서 사용되지 않습니다.

## Response

### 200

교체 성공

- `connectionId` (string, required) — 연결 ID
- `name` (string, required)
- `url` (string, required)
- `host` (string, required) — url 의 호스트. 목록 화면 표시용.
- `transport` (enum, required)
  - Allowed values: `streamable_http`, `sse`
- `authType` (enum, required)
  - Allowed values: `none`, `bearer`, `api_key`
- `authHeaderName` (string, required, nullable) — authType=api_key 일 때의 헤더 이름. bearer 는 Authorization 고정이라 null.
- `hasSecret` (boolean, required) — 자격증명 설정 여부. 값 자체는 조회할 수 없습니다.
- `enabled` (boolean, required)
- `status` (enum, required) — untested 는 연결 테스트를 통과하지 않은 상태입니다. 에이전트에 붙이려면 tested 여야 하며, 통화 중에도 tested 인 연결만 사용됩니다. credential_error 는 마지막 테스트가 인증 실패한 경우입니다.
  - Allowed values: `untested`, `tested`, `credential_error`
- `toolCount` (integer, required)
- `tools` (list of object, required) — 마지막 연결 테스트에서 발견된 도구 목록. 표시·선택용 스냅샷입니다.
  - `name` (string, required)
  - `description` (string, required, nullable)
  - `inputSchema` (map from string to any, required) — 도구 인자의 JSON Schema. 서버가 준 원본입니다.
- `lastTestedAt` (datetime, required, nullable)
- `lastErrorCode` (enum, required, nullable) — 마지막 연결 실패 사유.
  - Allowed values: `URL_BLOCKED`, `AUTH_FAILED`, `TIMEOUT`, `TLS_ERROR`, `PROTOCOL_ERROR`, `TOO_MANY_TOOLS`
- `agentCount` (integer, required) — 이 연결을 사용하는 에이전트 수.
- `dateCreated` (datetime, required)
- `dateUpdated` (datetime, required)

## Examples

**Request**

```json
{
  "authType": "bearer"
}
```

**Response**

```json
{
  "connectionId": "clx0mcp0000000000000001",
  "name": "예약 CRM",
  "url": "https://crm.example.com/mcp",
  "host": "crm.example.com",
  "transport": "streamable_http",
  "authType": "bearer",
  "authHeaderName": null,
  "hasSecret": true,
  "enabled": true,
  "status": "tested",
  "toolCount": 3,
  "tools": [
    {
      "name": "get_reservation",
      "description": "예약 번호로 예약 정보를 조회합니다.",
      "inputSchema": {}
    }
  ],
  "lastTestedAt": "2024-01-15T09:30:00Z",
  "lastErrorCode": null,
  "agentCount": 1,
  "dateCreated": "2024-01-15T09:30:00Z",
  "dateUpdated": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api.claw-ops.com/v1/accounts/accountId/mcp-connections/connectionId/credential"

payload = { "authType": "bearer" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.claw-ops.com/v1/accounts/accountId/mcp-connections/connectionId/credential';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"authType":"bearer"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://api.claw-ops.com/v1/accounts/accountId/mcp-connections/connectionId/credential"

	payload := strings.NewReader("{\n  \"authType\": \"bearer\"\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(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.claw-ops.com/v1/accounts/accountId/mcp-connections/connectionId/credential")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"authType\": \"bearer\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.claw-ops.com/v1/accounts/accountId/mcp-connections/connectionId/credential")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"authType\": \"bearer\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.claw-ops.com/v1/accounts/accountId/mcp-connections/connectionId/credential', [
  'body' => '{
  "authType": "bearer"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.claw-ops.com/v1/accounts/accountId/mcp-connections/connectionId/credential");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"authType\": \"bearer\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["authType": "bearer"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.claw-ops.com/v1/accounts/accountId/mcp-connections/connectionId/credential")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```