> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-in-ai/19.latest/mcp/custom-mcp-server/hosted-mcp/deployment.md). Agents can also search and read this documentation through its [MCP server](https://docs.umbraco.com/~gitbook/mcp).

# Deployment

Guide for deploying the Hosted MCP server to Cloudflare Workers for production.

## Local Development

See [Local Development Setup](https://docs.umbraco.com/umbraco-in-ai/19.latest/mcp/custom-mcp-server/hosted-mcp/deployment/local-dev-setup.md) for the full guide to running the Worker locally with `wrangler dev`.

## Production Deployment

{% hint style="info" %}
The steps below use the `wrangler` CLI directly. To provision the same resources with OpenTofu or Terraform, see [Infrastructure as Code](https://docs.umbraco.com/umbraco-in-ai/19.latest/mcp/custom-mcp-server/hosted-mcp/deployment/infrastructure-as-code.md).
{% endhint %}

### 1. Create a KV namespace

```bash
wrangler kv namespace create OAUTH_KV
```

Copy the returned namespace ID into your `wrangler.toml`:

```toml
[[kv_namespaces]]
binding = "OAUTH_KV"
id = "abc123..."
```

### 2. Set secrets

```bash
# Umbraco instance URL
wrangler secret put UMBRACO_BASE_URL
# e.g., https://my-umbraco.example.com

# OAuth client ID (must match Umbraco OpenIdDict registration)
wrangler secret put UMBRACO_OAUTH_CLIENT_ID

# Cookie encryption key (generate with: openssl rand -hex 32)
wrangler secret put COOKIE_ENCRYPTION_KEY
```

{% hint style="info" %}
No client secret is needed. The OAuth client is registered as a **public** client with PKCE.
{% endhint %}

### 3. Deploy

```bash
wrangler deploy
```

### 4. Update Umbraco redirect URI

Ensure the production Worker URL is registered as a redirect URI in Umbraco's OpenIdDict configuration:

```
https://my-umbraco-mcp.<your-subdomain>.workers.dev/callback
```

## Environment-Specific Configuration

### Tool Filtering via Env Vars

Set non-secret configuration in `wrangler.toml`:

```toml
[vars]
UMBRACO_TOOL_MODES = "content,media"
UMBRACO_READONLY = "true"
```

Or per environment:

```toml
[env.staging.vars]
UMBRACO_TOOL_MODES = "content,media"
UMBRACO_READONLY = "true"

[env.production.vars]
UMBRACO_TOOL_MODES = "content,media,settings"
```

### Multiple Environments

```bash
# Deploy to staging
wrangler deploy --env staging

# Deploy to production
wrangler deploy --env production
```

## Consent Screen Customization

You can customize the consent screen with tool selection, branding, custom CSS, or a fully custom renderer.

See the [Customization](https://docs.umbraco.com/umbraco-in-ai/19.latest/mcp/custom-mcp-server/hosted-mcp/customization.md) guide for all options and examples.

## Multi-Site Deployment

A single Worker can serve multiple Umbraco instances. All sites share one MCP endpoint (`/`). Site selection happens during authorization via the consent screen.

See [Multi-Site Deployments](https://docs.umbraco.com/umbraco-in-ai/19.latest/mcp/custom-mcp-server/hosted-mcp/deployment/multi-site.md) for full setup instructions, route structure, and security details. For Umbraco Cloud, [URL-Based Routing](https://docs.umbraco.com/umbraco-in-ai/19.latest/mcp/custom-mcp-server/hosted-mcp/deployment/url-based-routing.md) resolves the site from the connection URL instead, with no consent-screen picker.

## Custom Domain

### 1. Add a custom domain in the Cloudflare dashboard

Navigate to Workers > your-worker > Settings > Domains & Routes.

### 2. Add the domain

```
mcp.example.com
```

### 3. Update Umbraco redirect URI

Register `https://mcp.example.com/callback` as an additional redirect URI. For multi-site, register `https://mcp.example.com/callback/:siteId` for each site as well.

## Monitoring

### View Logs

```bash
wrangler tail
```

### KV Token Inspection

Tokens are stored in KV with automatic TTL expiry. You can inspect stored tokens:

```bash
wrangler kv key list --namespace-id YOUR_KV_NAMESPACE_ID
```

## Known Limitations

* **Cold starts**: The first request to a Durable Object may have slightly higher latency.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/umbraco-in-ai/19.latest/mcp/custom-mcp-server/hosted-mcp/deployment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
