> 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/17.latest/mcp/base-mcp/hosted-mcp/manual-setup.md).

# Manual Setup

{% hint style="info" %}
The [`create-umbraco-mcp-server`](/umbraco-in-ai/17.latest/mcp/base-mcp/create-umbraco-mcp-server.md) CLI generates all of this for you. Use this page as a reference if you need to set up the Worker manually or understand what the generated code does.
{% endhint %}

## 1. Add the hosted package

```bash
npm install @umbraco-cms/mcp-hosted
```

## 2. Create a Worker entry point

The Worker entry point imports Wrangler virtual modules (`agents/mcp`, `@cloudflare/workers-oauth-provider`) and uses building blocks from this package.

```typescript
// src/worker.ts
import { McpAgent } from "agents/mcp";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import OAuthProvider from "@cloudflare/workers-oauth-provider";
import {
  createDefaultHandler,
  createWorkerExport,
  createPerRequestServer,
  getServerOptions,
  type HostedMcpEnv,
  type AuthProps,
} from "@umbraco-cms/mcp-hosted";
import myCollection from "./tools/my-collection/index.js";
import { allModes, allModeNames, allSliceNames } from "./config/index.js";

const options = {
  name: "my-umbraco-mcp",
  version: "1.0.0",
  collections: [myCollection],
  modeRegistry: allModes,
  allModeNames,
  allSliceNames,
};

const serverOptions = getServerOptions(options);

export class UmbracoMcpAgent extends McpAgent<HostedMcpEnv, unknown, AuthProps> {
  server: McpServer | undefined;
  async init() {
    this.server = await createPerRequestServer(serverOptions, this.env, this.props);
  }
}

const provider = new OAuthProvider({
  apiRoute: "/mcp",
  apiHandler: UmbracoMcpAgent.serve("/mcp", { binding: "MCP_AGENT" }),
  defaultHandler: createDefaultHandler(options),
  authorizeEndpoint: "/authorize",
  tokenEndpoint: "/token",
  clientRegistrationEndpoint: "/register",
});

export default createWorkerExport(provider, options);
```

## 3. Configure wrangler.toml

```toml
name = "my-umbraco-mcp"
main = "dist/worker.js"
compatibility_date = "2025-02-24"
compatibility_flags = ["nodejs_compat"]

[[kv_namespaces]]
binding = "OAUTH_KV"
id = "YOUR_KV_NAMESPACE_ID"

[durable_objects]
bindings = [
  { name = "MCP_AGENT", class_name = "UmbracoMcpAgent" }
]

[[migrations]]
tag = "v1"
new_sqlite_classes = ["UmbracoMcpAgent"]
```

{% hint style="warning" %}
Use `new_sqlite_classes` (not `new_classes`). The `agents` library requires SQLite-backed Durable Objects.
{% endhint %}

{% hint style="info" %}
The default Durable Object binding name expected by `agents/mcp` is `MCP_OBJECT`. If you use a different name (such as `MCP_AGENT`), pass `{ binding: "MCP_AGENT" }` to `.serve()`.
{% endhint %}

## 4. Set secrets

```bash
# Single-site only (multi-site defines these per site in code)
wrangler secret put UMBRACO_BASE_URL
wrangler secret put UMBRACO_OAUTH_CLIENT_ID

# Always required
wrangler secret put COOKIE_ENCRYPTION_KEY  # openssl rand -hex 32
```

## 5. Create a KV namespace

```bash
wrangler kv namespace create OAUTH_KV
# Update wrangler.toml with the returned namespace ID
```

## 6. Deploy

```bash
wrangler deploy
```

Your MCP server is now accessible at `https://my-umbraco-mcp.<your-subdomain>.workers.dev/`.

For troubleshooting, see the [Troubleshooting](/umbraco-in-ai/17.latest/mcp/base-mcp/hosted-mcp/troubleshooting.md) guide.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.umbraco.com/umbraco-in-ai/17.latest/mcp/base-mcp/hosted-mcp/manual-setup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
