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

# Publish Agent

> Use the publish_agent MCP tool on the DialNexa remote MCP server.

Changes state - verify before retry

Publishes a DRAFT version of an agent, making it live and immutable. Once published, that version can never be edited again; publishing automatically creates the next draft version of the same agent, which is where further changes go. Inbound calls and workflows switch to the newly published version; a batch that is already running keeps the version it was created with. Phone numbers are attached separately with add\_agent\_phone\_number (the agent needs a published version first). Use get\_agent first to find the draft version\_number to publish. Refused if the draft's prompt is over the selected model's size ceiling (prompt\_health.status over\_ceiling from create\_agent/update\_agent) — shorten the prompt or choose a model with a larger limit first.

## Parameters

| Name | Type | Required | Description |
| - | - | - | - |
| `agent_id` | `string` | Yes | The agent ID, e.g. agent\_abc123 |
| `version_number` | `string` | Yes | The draft version number to publish, e.g. 0 — from get\_agent |

## Complete input schema

```json theme={null}
{
  "type": "object",
  "properties": {
    "agent_id": {
      "type": "string",
      "description": "The agent ID, e.g. agent_abc123"
    },
    "version_number": {
      "type": "string",
      "description": "The draft version number to publish, e.g. 0 — from get_agent"
    }
  },
  "required": [
    "agent_id",
    "version_number"
  ],
  "additionalProperties": false,
  "$schema": "http://json-schema.org/draft-07/schema#"
}
```

## Registered output schema

```json theme={null}
{
  "type": "object",
  "properties": {
    "id": {
      "description": "The agent ID, prefixed agent_"
    },
    "agent_type": {
      "description": "Single_Prompt_Agent, Conversational_Flow_Agent, or IVR_Agent"
    },
    "current_version_number": {
      "description": "Version number currently considered current"
    },
    "versions": {
      "description": "All versions of the agent after publishing, each with its prompt, functions, and settings"
    },
    "running_batches": {
      "description": "Batches already running on this agent (id, title, agent_version_number). They keep that version; tell the user this publish does not change them."
    }
  },
  "additionalProperties": true,
  "$schema": "http://json-schema.org/draft-07/schema#"
}
```

## Before you call

* Connect and initialize the MCP client with OAuth or an API key for the intended workspace.
* Provide the required parameters: `agent_id`, `version_number`.
* If your OAuth grant covers several workspaces, also pass `organization_id` with the workspace to act in, from [List My Organizations](https://dialnexa.com/docs/mcp-tools/organization/list-my-organizations.md).

## Example MCP request

Send `tools/call` after your client completes MCP initialization. Replace placeholder values with IDs and inputs from your workspace. For object and array parameters, follow the nested requirements in the parameter description instead of treating an empty value as complete.

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "publish_agent",
    "arguments": {
      "agent_id": "agent_abc123",
      "version_number": "1"
    }
  }
}
```

Successful results include `structuredContent` and a text content block containing the same JSON. Check `isError` first, then read `structuredContent` or parse `content[0].text`. See [MCP responses and errors](https://dialnexa.com/docs/mcp-tools/errors.md) for the full envelope and failure behavior.

## Verify the result

Confirm the response is not marked `isError`. Call [Get Agent](https://dialnexa.com/docs/mcp-tools/agents/get-agent.md) to read the affected resource. Verify that the intended state is visible before making another change.

## Retry safety

This tool changes workspace state. After a timeout, read the affected resource before retrying so you do not create duplicate or conflicting changes.

## Related MCP tools

* [Get Agent](https://dialnexa.com/docs/mcp-tools/agents/get-agent.md): `get_agent`
* [Create Agent](https://dialnexa.com/docs/mcp-tools/agents/create-agent.md): `create_agent`
* [Update Agent](https://dialnexa.com/docs/mcp-tools/agents/update-agent.md): `update_agent`
* [Attach Phone Number To Agent](https://dialnexa.com/docs/mcp-tools/phone-numbers/add-agent-phone-number.md): `add_agent_phone_number`
* [List Agents](https://dialnexa.com/docs/mcp-tools/agents/list-agents.md): `list_agents`
* [Get Agent Builder Inventory](https://dialnexa.com/docs/mcp-tools/agents/get-agent-builder-inventory.md): `get_agent_builder_inventory`

## Related guides

* [Connect to the DialNexa MCP server](https://dialnexa.com/docs/mcp-tools/overview.md)
* [Agents MCP tools](https://dialnexa.com/docs/mcp-tools/agents/overview.md)
* [MCP responses and errors](https://dialnexa.com/docs/mcp-tools/errors.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.