---
title: "createWorkspaceMCPServer"
---

> Documentation Index
> Fetch the complete documentation index at: https://agenthold.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# createWorkspaceMCPServer

Path: agenthold API › tools

`POST /workspaces/{workspaceId}/mcp-servers`

URL: `/api/v1/workspaces/{workspaceId}/mcp-servers`

Workspace admins only.

## Authentication

Requires one of the following:

- `session`, apiKey, in cookie
- `token`, http bearer, header `Authorization`

## Path parameters

- `workspaceId` (`createWorkspaceMCPServer.path.workspaceId`; string, required)

## Request body

_Required._

- `name` (`createWorkspaceMCPServer.name`; string, required) — Letters, digits, dashes and underscores.
- `transport` (`createWorkspaceMCPServer.transport`; string, required)
  - one of `"stdio"`, `"http"`
- `command` (`createWorkspaceMCPServer.command`; string, optional) — stdio only; runs inside the sandbox.
- `args` (`createWorkspaceMCPServer.args`; array of string, optional)
- `env` (`createWorkspaceMCPServer.env`; map of string, optional) — stdio only. Values may reference secrets as {{secret:NAME}}.
- `url` (`createWorkspaceMCPServer.url`; string, optional) — http only.
- `headers` (`createWorkspaceMCPServer.headers`; map of string, optional) — http only. Values may reference secrets as {{secret:NAME}}; the sandbox sees a placeholder and the egress proxy injects the value.

## Example request

```json
{
  "name": "string",
  "transport": "stdio",
  "command": "string",
  "args": [
    "string"
  ],
  "env": {
    "property1": "string",
    "property2": "string"
  },
  "url": "string",
  "headers": {
    "property1": "string",
    "property2": "string"
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/api/v1/workspaces/<workspaceId>/mcp-servers' \
  --header 'Content-Type: application/json' \
  --cookie 'agenthold_session=<agenthold_session>' \
  --data '
{
  "name": "string",
  "transport": "stdio",
  "command": "string",
  "args": [
    "string"
  ],
  "env": {
    "property1": "string",
    "property2": "string"
  },
  "url": "string",
  "headers": {
    "property1": "string",
    "property2": "string"
  }
}
'
```

### TypeScript

```typescript
const url = '<base-url>/api/v1/workspaces/<workspaceId>/mcp-servers';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    cookie: 'agenthold_session=<agenthold_session>'
  },
  body: JSON.stringify({
    name: 'string',
    transport: 'stdio',
    command: 'string',
    args: ['string'],
    env: {property1: 'string', property2: 'string'},
    url: 'string',
    headers: {property1: 'string', property2: 'string'}
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/api/v1/workspaces/<workspaceId>/mcp-servers"

payload = {
    "name": "string",
    "transport": "stdio",
    "command": "string",
    "args": ["string"],
    "env": {
        "property1": "string",
        "property2": "string"
    },
    "url": "string",
    "headers": {
        "property1": "string",
        "property2": "string"
    }
}
headers = {
    "cookie": "agenthold_session=<agenthold_session>",
    "Content-Type": "application/json"
}

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

print(response.text)
```

## Responses

### 201

Created.

#### Example

```json
{
  "name": "string",
  "transport": "stdio",
  "command": "string",
  "args": [
    "string"
  ],
  "env": {
    "property1": "string",
    "property2": "string"
  },
  "url": "string",
  "headers": {
    "property1": "string",
    "property2": "string"
  },
  "id": "string",
  "workspaceId": "string",
  "scope": "workspace",
  "agentId": "string",
  "secretRefs": [
    "string"
  ],
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z"
}
```

- `name` (`createWorkspaceMCPServer.response.201.name`; string, required) — Letters, digits, dashes and underscores.
- `transport` (`createWorkspaceMCPServer.response.201.transport`; string, required)
  - one of `"stdio"`, `"http"`
- `command` (`createWorkspaceMCPServer.response.201.command`; string, required) — stdio only; runs inside the sandbox.
- `args` (`createWorkspaceMCPServer.response.201.args`; array of string, required)
- `env` (`createWorkspaceMCPServer.response.201.env`; map of string, required) — stdio only. Values may reference secrets as {{secret:NAME}}.
- `url` (`createWorkspaceMCPServer.response.201.url`; string, required) — http only.
- `headers` (`createWorkspaceMCPServer.response.201.headers`; map of string, required) — http only. Values may reference secrets as {{secret:NAME}}; the sandbox sees a placeholder and the egress proxy injects the value.
- `id` (`createWorkspaceMCPServer.response.201.id`; string, required)
- `workspaceId` (`createWorkspaceMCPServer.response.201.workspaceId`; string, required)
- `scope` (`createWorkspaceMCPServer.response.201.scope`; string, required)
  - one of `"workspace"`, `"agent"`
- `secretRefs` (`createWorkspaceMCPServer.response.201.secretRefs`; array of string, required)
- `createdAt` (`createWorkspaceMCPServer.response.201.createdAt`; string, required)
  - format: `date-time`
- `updatedAt` (`createWorkspaceMCPServer.response.201.updatedAt`; string, required)
  - format: `date-time`
- `agentId` (`createWorkspaceMCPServer.response.201.agentId`; string, optional)

### 400

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createWorkspaceMCPServer.response.400.error`; string, required)

### 403

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createWorkspaceMCPServer.response.403.error`; string, required)

### 404

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createWorkspaceMCPServer.response.404.error`; string, required)

### 409

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createWorkspaceMCPServer.response.409.error`; string, required)


Source: https://agenthold.dev/api/create-workspace-mcp-server/index.md
