> For the complete documentation index, see [llms.txt](https://docs.uibakery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uibakery.io/on-premise/additional-configurations/mcp-server.md).

# Enable MCP server on-premise

See the [MCP server guide](https://docs.uibakery.io/build-with-ai/mcp-server) for connection instructions and supported capabilities.

{% hint style="warning" %}
MCP is in beta. Configuration requirements and the MCP API can change. The environment variable described on this page is for UI Bakery on-premise only; do not configure it in UI Bakery Cloud.
{% endhint %}

### Before you begin

* You need access to the UI Bakery deployment configuration and its `.env` file.
* The instance must be reachable through its public HTTPS URL.
* `UI_BAKERY_APP_SERVER_NAME` must match the externally reachable host. This ensures OAuth redirects use the correct URL.

### Enable the MCP server

1. Generate a cryptographically secure random secret. Use at least 32 random bytes.

   ```shell
   openssl rand -hex 32
   ```
2. Add the following line to the UI Bakery `.env` file.

   ```dotenv
   UI_BAKERY_JWT_MCP_SECRET=<generated-value>
   ```
3. Restart UI Bakery using the existing [Updating environment variables](https://docs.uibakery.io/on-premise/install-and-update/updating-environment-variables) procedure.
4. Configure MCP clients with this remote Streamable HTTP endpoint:

   ```
   https://<your-ui-bakery-instance>/api/mcp
   ```
5. Follow the general [MCP server guide](https://docs.uibakery.io/build-with-ai/mcp-server) to connect Codex, Claude Code, Cursor, or another MCP-compatible client.

{% hint style="info" %}
Store `UI_BAKERY_JWT_MCP_SECRET` in the deployment secret store, never in source control or documentation. Changing the secret invalidates all previously issued MCP tokens, so connected clients must authenticate again.
{% endhint %}

### Related documentation

* [MCP server guide](https://docs.uibakery.io/build-with-ai/mcp-server)
* [Environment variables](https://docs.uibakery.io/on-premise/environment-variables)
* [Updating environment variables](https://docs.uibakery.io/on-premise/install-and-update/updating-environment-variables)


---

# 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.uibakery.io/on-premise/additional-configurations/mcp-server.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.
