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

# Replace MCP connection settings

PUT https://api.v2.rasen.ai/v1/mcp-servers/{server_id}
Content-Type: application/json

Full replacement. Discovery resets to not\_discovered only when url, transport, auth or header\_name changes. A credential-only change (for example adopting a rotated version) keeps the current discovery. Does not change frozen published connections; rediscover/select/publish to adopt changes. To adopt a rotated credential, supply the new \{secret\_id, version}; each agent adopts it only when published. conflict with details.reason=name\_taken: the server name, or the secret name of an inline credential, is taken. resource\_key\_conflict: the resource\_key of the server (create only) or of an inline credential is taken; details.resource\_type says which. Inline credential material also requires secrets.manage, because it creates a secret; a \{secret\_id, version} reference also requires secrets.read.

Reference: https://docs.v2.rasen.ai/api-reference/mcp-servers/replace

## Authentication

- `Authorization` header (bearer token, required) — Create and manage workspace-owned keys through the existing app session routes, outside this public API. Creator and manager identities are audit actors only. Key validity follows workspace policy, expiry and explicit revocation, independently of creator membership. Do not include a workspace-selection header.

## Request

### Path parameters

- `server_id` (string, required) — Resource identity within the authenticated workspace.

### Headers

- `If-Match` (string, required) — Strong ETag from the resource being changed. Draft/tool/variable/publication operations use the complete agent draft ETag; number operations use the number ETag; MCP update uses its own ETag. Never retry a stale edit by blindly using a fresh ETag. Agent identity edits use the identity ETag; knowledge-source reingest uses the source ETag. A stale revision returns 409: draft_conflict for agent, draft, variable, tool, MCP server and publication-token checks; conflict with details.reason=stale_revision for phone numbers and knowledge sources. A missing header returns 428 revision_required. Same-intent replay uses the original If-Match and returns its receipt before checking current revision.
- `Idempotency-Key` (string, required) — Stable key per logical intent, 1–255 printable characters. Persist it before sending. Retry the same key/body after an uncertain result for 24 hours. A changed body conflicts. Beyond retention, reconcile the resource before retrying; this is not permanent deduplication. Current authorization is rechecked on replay. Evaluation order: authenticate and check current authorization; look up intent; replay its stored receipt before checking the current revision; only a new intent evaluates If-Match and executes. Fingerprint includes method, path, body and original If-Match. A changed request returns idempotency_key_reused. The server stores only a keyed (HMAC) fingerprint, and no error or response ever returns a fingerprint or hash of a request. In-flight intent returns 409 idempotency_in_progress with Retry-After; retry the same intent after reconciliation. Receipts describe that attempt, not current resource state. A replay returns the original status code and body, with the response header Idempotent-Replayed: true.

### Body (application/json)

This endpoint expects a McpServerWrite.

- `name` (string, required)
- `url` (string, required)
- `transport` (enum, required)
  - Allowed values: `streamable_http`, `sse`
- `auth` (enum, required)
  - Allowed values: `none`, `bearer`, `secret_header`
- `credential` (CredentialInput, optional) — Exactly one of: an existing reference \{secret\_id, version} to an active version of a secret with the matching purpose, or new write-only inline material. No mixed shape. A reference to a revoked, deleted or wrong-purpose version refuses with credential\_unavailable. References pin the exact version and never follow rotation.
- `header_name` (string, optional)
- `connect_timeout_ms` (integer, optional, default: 3000)
- `resource_key` (string, optional) — Optional caller-chosen resource key: an opaque external identifier that matches your own record (for example a CRM ID, a configuration-file ID or a UUID) to this resource. Rasen still generates the canonical id; use id in paths and references. Case-sensitive, compared exactly, never normalized or parsed. 1-128 characters from A-Z a-z 0-9 . _ : ~ - and starting with a letter or digit; UUIDs and ULIDs are valid. Unique per resource type within one workspace; separate environment workspaces can reuse the same key. Set only at creation and immutable afterwards. A create with a key that already exists returns 409 resource_key_conflict with details.existing_id; it never updates or returns the existing resource. Not an Idempotency-Key: that header identifies one request intent for 24 hours, and a same-intent replay returns its original receipt before the resource-key check runs. Uniqueness includes archived resources. A key becomes free again only after its resource is permanently deleted or erased (a deleted secret or a deleted knowledge source); archive never frees it. On replaceMcpServer an omitted resource_key keeps the stored key, and a different value, including any value on a server that was created without a key, returns 409 conflict with details.reason=resource_key_immutable. Keys are set at create only.

## Response

### 200

Replace MCP connection settings.

- `id` (string, required) — Opaque mcp identifier. Do not parse its contents.
- `revision` (string, required)
- `name` (string, required)
- `url` (string, required)
- `transport` (string, required) — Open response vocabulary. Preserve unknown values; never assume they mean success.
- `has_credential` (boolean, required)
- `discovery_state` (string, required) — Open response vocabulary. Preserve unknown values; never assume they mean success.
- `discovery_id` (string, required, nullable)
- `created_at` (datetime, required)
- `auth` (string, required) — Open response vocabulary. Preserve unknown values; never assume they mean success.
- `header_name` (string, required, nullable)
- `credential` (SecretReferenceRead, required, nullable) — Exact pinned credential reference; null for auth=none. Never contains secret material.
- `connect_timeout_ms` (integer, required)
- `discovery_sha256` (string, required, nullable)
- `resource_key` (string, required, nullable) — Optional caller-chosen resource key: an opaque external identifier that matches your own record (for example a CRM ID, a configuration-file ID or a UUID) to this resource. Rasen still generates the canonical id; use id in paths and references. Case-sensitive, compared exactly, never normalized or parsed. 1-128 characters from A-Z a-z 0-9 . _ : ~ - and starting with a letter or digit; UUIDs and ULIDs are valid. Unique per resource type within one workspace; separate environment workspaces can reuse the same key. Set only at creation and immutable afterwards. A create with a key that already exists returns 409 resource_key_conflict with details.existing_id; it never updates or returns the existing resource. Not an Idempotency-Key: that header identifies one request intent for 24 hours, and a same-intent replay returns its original receipt before the resource-key check runs. Uniqueness includes archived resources. A key becomes free again only after its resource is permanently deleted or erased (a deleted secret or a deleted knowledge source); archive never frees it.

## Errors

### 400 Bad Request Error

Invalid input or cursor. Correct the request.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 401 Unauthorized Error

Invalid, expired or revoked API key. Creator departure or membership changes do not invalidate a workspace key.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 403 Forbidden Error

Operation not allowed by current credential or workspace access.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 404 Not Found Error

Resource absent or not visible in this workspace.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 409 Conflict Error

Conflict. Not retryable: read the current state, fix the request and send a new request. The one exception is idempotency_in_progress, which carries Retry-After: wait, then resend the identical request with the same Idempotency-Key. The operation lists its codes in x-error-codes; branch on error.code and, for conflict, error.details.reason.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 413 Content Too Large Error

Body or upload exceeds its allowed limit.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 422 Unprocessable Entity Error

The request is well formed but refused, for example a destination that is not a permitted public address.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 428 Precondition Error

Required If-Match revision is absent.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 429 Too Many Requests Error

Rate limited. Respect Retry-After and retry the same intent where permitted.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 500 Internal Server Error

Internal error. The effect may have happened. Retry the same request with the same Idempotency-Key; read the resource before creating a new intent. For an operation that takes an Idempotency-Key, a client retry with the same key is safe: the server replays the stored outcome if the first attempt took effect; if the first attempt had no effect, the retry performs the operation once. Never retry with a new key.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 503 Service Unavailable Error

Service unavailable. Respect Retry-After where present. For an operation that takes an Idempotency-Key, a client retry with the same key is safe: the server replays the stored outcome if the first attempt took effect; if the first attempt had no effect, the retry performs the operation once. Never retry with a new key.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

## Types

### CredentialInput

Exactly one of: an existing reference \{secret\_id, version} to an active version of a secret with the matching purpose, or new write-only inline material. No mixed shape. A reference to a revoked, deleted or wrong-purpose version refuses with credential\_unavailable. References pin the exact version and never follow rotation.

### SecretReferenceRead

Pinned reference to one exact credential version. Never follows rotation: to adopt a new version, replace the tool or MCP server with the new version, then publish each affected agent. No secret material in responses.

- `secret_id` (string, required) — Opaque sec identifier. Do not parse its contents.
- `version` (integer, required)

### ErrorResponseError

Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

- `code` (string, required) — Stable code. Branch on code (and details.reason for conflict), never on message. Each code has one HTTP status; see components.x-error-catalog.
- `message` (string, required) — Safe description; no provider payload or submitted secrets.
- `details` (map from string to any, optional) — Safe code-specific details. The public fields for each code are listed in components.x-error-catalog. Details never contain a request fingerprint, a hash of a request, secret material or another tenant's data. forbidden may include required_capabilities (a list).
- `request_id` (string, optional) — Same value as the X-Request-Id header. Quote it to support.
- `retry` (string, optional) — Retry class of this code: no (fix the request or state first), yes (retry the same request and the same Idempotency-Key), retry_after (wait for Retry-After, then retry the same request). Open response vocabulary. Preserve unknown values; never assume they mean success.

### SecretReference

Pinned reference to one exact credential version. Never follows rotation: to adopt a new version, replace the tool or MCP server with the new version, then publish each affected agent. No secret material in responses.

- `secret_id` (string, required) — Opaque sec identifier. Do not parse its contents.
- `version` (integer, required)

### InlineCredential

Write-only credential material for one-off setup. Never returned, logged or included in diffs. It creates a new secret at version 1 (purpose from the consumer) and binds that exact version; the secret then appears in GET /secrets. For declarative or repeated setup, do not re-send inline material: look up or create the secret with POST /secrets and a resource\_key, then send a \{secret\_id, version} reference. Each inline apply creates another secret; with a resource\_key that exists it returns 409 resource\_key\_conflict with details.existing\_id instead.

- `value` (string, required)
- `material_kind` (enum, required) — A descriptive label that does not change how the value is sent. Rasen sends the stored value unchanged as the header value for a webhook secret header, or as "Bearer \<value>" for an MCP server with auth=bearer, or as the header value for auth=secret\_header. For basic\_auth, store the complete header value, for example "Basic \<base64 of user:password>", and use a secret header named Authorization. No kind and auth-mode pair is refused.
  - Allowed values: `api_key`, `bearer_token`, `basic_auth`
- `name` (string, optional) — Optional secret handle for the created secret.
- `resource_key` (string, optional) — Optional caller-chosen resource key: an opaque external identifier that matches your own record (for example a CRM ID, a configuration-file ID or a UUID) to this resource. Rasen still generates the canonical id; use id in paths and references. Case-sensitive, compared exactly, never normalized or parsed. 1-128 characters from A-Z a-z 0-9 . _ : ~ - and starting with a letter or digit; UUIDs and ULIDs are valid. Unique per resource type within one workspace; separate environment workspaces can reuse the same key. Set only at creation and immutable afterwards. A create with a key that already exists returns 409 resource_key_conflict with details.existing_id; it never updates or returns the existing resource. Not an Idempotency-Key: that header identifies one request intent for 24 hours, and a same-intent replay returns its original receipt before the resource-key check runs. Uniqueness includes archived resources. A key becomes free again only after its resource is permanently deleted or erased (a deleted secret or a deleted knowledge source); archive never frees it.

## Examples

**Request**

```json
{
  "name": "Order system",
  "url": "https://mcp.example.com/mcp",
  "transport": "streamable_http",
  "auth": "bearer",
  "credential": {
    "secret_id": "sec_01j00000000000000000000000",
    "version": 1
  }
}
```

**Response**

```json
{
  "id": "mcp_01j00000000000000000000000",
  "revision": "example",
  "name": "example",
  "url": "https://api.example.com/resource",
  "transport": "streamable_http",
  "has_credential": true,
  "discovery_state": "not_discovered",
  "discovery_id": "discovery_01j00000000000000000000000",
  "created_at": "2026-09-25T10:00:00Z",
  "auth": "none",
  "header_name": "example",
  "credential": {
    "secret_id": "sec_01j00000000000000000000000",
    "version": 1
  },
  "connect_timeout_ms": 100,
  "discovery_sha256": "9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c",
  "resource_key": "3f8e5a0c-9d1b-4c7e-a2f4-6b0d9e1c7a55"
}
```

**SDK Code**

```python mcpServers_replace_example
import requests

url = "https://api.v2.rasen.ai/v1/mcp-servers/server_id"

payload = {
    "name": "Order system",
    "url": "https://mcp.example.com/mcp",
    "transport": "streamable_http",
    "auth": "bearer",
    "credential": {
        "secret_id": "sec_01j00000000000000000000000",
        "version": 1
    }
}
headers = {
    "Idempotency-Key": "intent-appointment-001",
    "If-Match": "\"draft-17\"",
    "Authorization": "Bearer <api_key>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript mcpServers_replace_example
const url = 'https://api.v2.rasen.ai/v1/mcp-servers/server_id';
const options = {
  method: 'PUT',
  headers: {
    'Idempotency-Key': 'intent-appointment-001',
    'If-Match': '"draft-17"',
    Authorization: 'Bearer <api_key>',
    'Content-Type': 'application/json'
  },
  body: '{"name":"Order system","url":"https://mcp.example.com/mcp","transport":"streamable_http","auth":"bearer","credential":{"secret_id":"sec_01j00000000000000000000000","version":1}}'
};

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

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

url = URI("https://api.v2.rasen.ai/v1/mcp-servers/server_id")

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

request = Net::HTTP::Put.new(url)
request["Idempotency-Key"] = 'intent-appointment-001'
request["If-Match"] = '"draft-17"'
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Order system\",\n  \"url\": \"https://mcp.example.com/mcp\",\n  \"transport\": \"streamable_http\",\n  \"auth\": \"bearer\",\n  \"credential\": {\n    \"secret_id\": \"sec_01j00000000000000000000000\",\n    \"version\": 1\n  }\n}"

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

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

HttpResponse<String> response = Unirest.put("https://api.v2.rasen.ai/v1/mcp-servers/server_id")
  .header("Idempotency-Key", "intent-appointment-001")
  .header("If-Match", "\"draft-17\"")
  .header("Authorization", "Bearer <api_key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Order system\",\n  \"url\": \"https://mcp.example.com/mcp\",\n  \"transport\": \"streamable_http\",\n  \"auth\": \"bearer\",\n  \"credential\": {\n    \"secret_id\": \"sec_01j00000000000000000000000\",\n    \"version\": 1\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.v2.rasen.ai/v1/mcp-servers/server_id', [
  'body' => '{
  "name": "Order system",
  "url": "https://mcp.example.com/mcp",
  "transport": "streamable_http",
  "auth": "bearer",
  "credential": {
    "secret_id": "sec_01j00000000000000000000000",
    "version": 1
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <api_key>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => 'intent-appointment-001',
    'If-Match' => '"draft-17"',
  ],
]);

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

```csharp mcpServers_replace_example
using RestSharp;

var client = new RestClient("https://api.v2.rasen.ai/v1/mcp-servers/server_id");
var request = new RestRequest(Method.PUT);
request.AddHeader("Idempotency-Key", "intent-appointment-001");
request.AddHeader("If-Match", "\"draft-17\"");
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Order system\",\n  \"url\": \"https://mcp.example.com/mcp\",\n  \"transport\": \"streamable_http\",\n  \"auth\": \"bearer\",\n  \"credential\": {\n    \"secret_id\": \"sec_01j00000000000000000000000\",\n    \"version\": 1\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift mcpServers_replace_example
import Foundation

let headers = [
  "Idempotency-Key": "intent-appointment-001",
  "If-Match": "\"draft-17\"",
  "Authorization": "Bearer <api_key>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Order system",
  "url": "https://mcp.example.com/mcp",
  "transport": "streamable_http",
  "auth": "bearer",
  "credential": [
    "secret_id": "sec_01j00000000000000000000000",
    "version": 1
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.v2.rasen.ai/v1/mcp-servers/server_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```