# Verify an unsaved MCP setup

Explicitly check a stable MCP setup before saving it.

`POST https://api.smallworld.sh/api/v1/mcp-integrations/verify-setup`

## Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| id | body | UUID | Yes | The integrationId reserved by detection. Omit to allocate an ID during creation. |
| url | body | string | Yes | Remote MCP server URL. Must be public HTTPS, except loopback HTTP in development. |
| authMode | body | "none" \| "oauth2" \| "api_key" | Yes | The sign-in mode detected or selected for this server. |
| scopes | body | string[] \| null | No | OAuth scopes, or null to request the server's advertised scopes. OAuth only. |
| apiKeyHeader | body | string \| null | No | API-key mode only: header name. Null sends Authorization: Bearer <key>. End-user API keys are configured through the connection API. |
| oauthApp | body | object | No | OAuth only: clientId and optional clientSecret. Supplied values are encrypted. Client secrets are write-only; the separate OAuth app endpoint can return the client ID. |
| authorizationServerUrl | body | string | No | OAuth issuer override when the server does not advertise its authorization server. |

## Request examples

### curl

```curl
curl --fail-with-body -X POST 'https://api.smallworld.sh/api/v1/mcp-integrations/verify-setup' \
  -H "Authorization: Bearer $SMALLWORLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "id": "72b98ef7-4750-4521-b11d-82c114aa56f4",
  "url": "https://mcp.example.com/mcp",
  "authMode": "oauth2",
  "oauthApp": {
    "clientId": "your-client-id",
    "clientSecret": "write-only-secret"
  }
}'
```

### typescript

```typescript
const response = await fetch("https://api.smallworld.sh/api/v1/mcp-integrations/verify-setup", {
  method: "POST",
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({
  "id": "72b98ef7-4750-4521-b11d-82c114aa56f4",
  "url": "https://mcp.example.com/mcp",
  "authMode": "oauth2",
  "oauthApp": {
    "clientId": "your-client-id",
    "clientSecret": "write-only-secret"
  }
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const result = await response.json();
```

### python

```python
response = requests.post(
    "https://api.smallworld.sh/api/v1/mcp-integrations/verify-setup",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
  "id": "72b98ef7-4750-4521-b11d-82c114aa56f4",
  "url": "https://mcp.example.com/mcp",
  "authMode": "oauth2",
  "oauthApp": {
    "clientId": "your-client-id",
    "clientSecret": "write-only-secret"
  }
},
    timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Responses

Returns status, message, registration, and optional clientSecretRequired. Status is ready, unverified, needs_setup, credentials_required, provider_restricted, or verification_failed. HTTP 200 can report unsuccessful setup; inspect status. ready and unverified permit activation.

### 200

Returns status, message, registration, and optional clientSecretRequired. Status is ready, unverified, needs_setup, credentials_required, provider_restricted, or verification_failed. HTTP 200 can report unsuccessful setup; inspect status. ready and unverified permit activation.

```json
{
  "status": "unverified",
  "message": "OAuth app configured. Connection not yet tested.",
  "registration": "owner_app",
  "clientSecretRequired": true
}
```

### 400

invalid_request: Invalid body, path, or query. Unknown body fields and query parameters are rejected.

#### invalid_request

Invalid body, path, or query. Unknown body fields and query parameters are rejected.

```json
{
  "statusCode": 400,
  "code": "invalid_request",
  "message": "The request is invalid"
}
```

### 401

authentication_required: The Authorization header is missing or empty. invalid_api_key: The API key is invalid or revoked, or the header doesn't use the Bearer scheme.

#### authentication_required

The Authorization header is missing or empty.

```json
{
  "statusCode": 401,
  "code": "authentication_required",
  "message": "Authentication is required"
}
```

#### invalid_api_key

The API key is invalid or revoked, or the header doesn't use the Bearer scheme.

```json
{
  "statusCode": 401,
  "code": "invalid_api_key",
  "message": "The API key is invalid or revoked"
}
```

### 403

ip_not_allowed: The request came from an address outside the workspace's IP allowlist.

#### ip_not_allowed

The request came from an address outside the workspace's IP allowlist.

```json
{
  "statusCode": 403,
  "code": "ip_not_allowed",
  "message": "The source IP address is not allowed by this account's security settings"
}
```

### 413

request_too_large: The JSON body is larger than 12 MiB. File uploads count toward it, base64 or escaping included.

#### request_too_large

The JSON body is larger than 12 MiB. File uploads count toward it, base64 or escaping included.

```json
{
  "statusCode": 413,
  "code": "request_too_large",
  "message": "The request body is larger than 12 MiB."
}
```

### 415

unsupported_media_type: The request has a body that isn't JSON. Send JSON with Content-Type: application/json, or no body at all.

#### unsupported_media_type

The request has a body that isn't JSON. Send JSON with Content-Type: application/json, or no body at all.

```json
{
  "statusCode": 415,
  "code": "unsupported_media_type",
  "message": "Send the request body as JSON with Content-Type: application/json."
}
```

### 500

internal_error: An unexpected server error.

#### internal_error

An unexpected server error.

```json
{
  "statusCode": 500,
  "code": "internal_error",
  "message": "Internal server error"
}
```

## Notes

- Verification can contact the MCP and OAuth servers and register an OAuth client. Detection only discovers metadata; it never registers a client. Identical setup checks share cached work under the existing retry rules.

- Use the reserved ID from detection with the same URL and sign-in mode. A changed URL requires detection again.
