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

# Register an MCP tool source

POST https://api.rasen.ai/v1/mcp-servers
Content-Type: application/json

Register a customer endpoint using inline write-only credentials or an authorized reference. No secret readback. Discovery is separate and does not execute a tool. 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.rasen.ai/enterprise/api-reference/mcp-servers/create

## Authentication

- `Authorization` header (bearer token, required) — An organisation-owned key whose secret starts ra_org_. The Owner or an Admin of an organisation that Rasen has invited makes it in the app; no API operation makes, changes, rotates or revokes a key. On a workspace operation send the workspace ID in the Rasen-Workspace header; without it the answer is 400 invalid_request with details.field Rasen-Workspace. A workspace outside the organisation or outside the key's workspace list is 404 not_found. An organisation that is not invited gets 403 organisation_api_not_enabled.

## Request

### Headers

- `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.
- `Rasen-Workspace` (string, required) — The ID of the workspace that this operation acts in. It must be a workspace of the key's organisation and in the key's workspace list. A missing, empty or malformed value is 400 invalid_request with details.field Rasen-Workspace; a workspace outside the organisation or the key's workspace list is the hidden 404 not_found.

### 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

### 201

Register an MCP tool source.

- `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.

### 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.

### 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.

- SecretReference: SecretReference
- InlineCredential: InlineCredential

### 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
  },
  "resource_key": "crm:mcp-orders"
}
```

**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_create_example
import requests

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

payload = {
    "name": "Order system",
    "url": "https://mcp.example.com/mcp",
    "transport": "streamable_http",
    "auth": "bearer",
    "credential": {
        "secret_id": "sec_01j00000000000000000000000",
        "version": 1
    },
    "resource_key": "crm:mcp-orders"
}
headers = {
    "Idempotency-Key": "intent-appointment-001",
    "Rasen-Workspace": "ws_01j00000000000000000000000",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript mcpServers_create_example
const url = 'https://api.rasen.ai/v1/mcp-servers';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': 'intent-appointment-001',
    'Rasen-Workspace': 'ws_01j00000000000000000000000',
    Authorization: 'Bearer <token>',
    '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},"resource_key":"crm:mcp-orders"}'
};

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

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

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

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

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = 'intent-appointment-001'
request["Rasen-Workspace"] = 'ws_01j00000000000000000000000'
request["Authorization"] = 'Bearer <token>'
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  \"resource_key\": \"crm:mcp-orders\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.rasen.ai/v1/mcp-servers")
  .header("Idempotency-Key", "intent-appointment-001")
  .header("Rasen-Workspace", "ws_01j00000000000000000000000")
  .header("Authorization", "Bearer <token>")
  .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  \"resource_key\": \"crm:mcp-orders\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.rasen.ai/v1/mcp-servers', [
  'body' => '{
  "name": "Order system",
  "url": "https://mcp.example.com/mcp",
  "transport": "streamable_http",
  "auth": "bearer",
  "credential": {
    "secret_id": "sec_01j00000000000000000000000",
    "version": 1
  },
  "resource_key": "crm:mcp-orders"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => 'intent-appointment-001',
    'Rasen-Workspace' => 'ws_01j00000000000000000000000',
  ],
]);

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

```csharp mcpServers_create_example
using RestSharp;

var client = new RestClient("https://api.rasen.ai/v1/mcp-servers");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "intent-appointment-001");
request.AddHeader("Rasen-Workspace", "ws_01j00000000000000000000000");
request.AddHeader("Authorization", "Bearer <token>");
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  \"resource_key\": \"crm:mcp-orders\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift mcpServers_create_example
import Foundation

let headers = [
  "Idempotency-Key": "intent-appointment-001",
  "Rasen-Workspace": "ws_01j00000000000000000000000",
  "Authorization": "Bearer <token>",
  "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
  ],
  "resource_key": "crm:mcp-orders"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.rasen.ai/v1/mcp-servers")! 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()
```