# Run with Docker

{% stepper %}
{% step %}

### Clone the Repository

```shellscript
git clone git@github.com:lensesio/lenses-mcp.git
```

{% endstep %}

{% step %}

### Build and Tag Image

Build and tag a Docker image using the Dockerfile included at the root of the repository.

```shellscript
docker build -t lenses-mcp:local
```

{% endstep %}

{% step %}

### Run using Docker

Run using Docker by passing in configuration as environment variables for the default setup that uses OAuth for authentication and authorization. This example runs the MCP server using HTTP transport, available on port 8000 on the local machine. This is set in the `MCP_ADVERTISED_URL` variable.

```shellscript
docker run --rm -it --name lenses-mcp \
-p 8000:8000 \
-e TRANSPORT=http \
-e HOST=0.0.0.0 \
-e PORT=8000 \
-e OAUTH_ENABLED=True \
-e LENSES_URL=https://your-lenses.io \
-e LENSES_ADVERTISED_URL=https://your-publicly-available-lenses.io \
-e MCP_ADVERTISED_URL=http://localhost:8000 \
lenses-mcp:local
```

{% endstep %}

{% step %}

### Configure in your AI tool

To run in Cursor, Claude, Codex, etc. use the following `mcp.json` configuration to configure the client to connect using HTTP transport.

<pre class="language-json"><code class="lang-json"><strong>{
</strong>  "mcpServers": {
    "Lenses": {
      "type": "http",
      "url": "http://localhost:8000/mcp"
    }
}
</code></pre>

{% hint style="info" %}
The MCP server endpoint is the advertised URL with `/mcp` on the end
{% endhint %}
{% endstep %}

{% step %}

### Authenticate with OAuth

Navigate to your AI tool's MCP server settings and connect to authenticate with the Lenses OAuth authorization server (visible to your AI tool's client and configured with `LENSES_ADVERTISED_URL`). Here is an example using Cursor.

<figure><img src="/files/zCQdEyg9P106qeswvkPY" alt=""><figcaption></figcaption></figure>

This opens a web browser at `LENSES_ADVERTISED_URL`/oauth2/authorize and passes OAuth parameters. Log in with your username/password or SSO (example shown is the Community Edition screen).

<figure><img src="/files/78pZDfoZdHIU1mdoXxGZ" alt=""><figcaption></figcaption></figure>

You will be presented with an OAuth authorization consent screen where you can set read, write and delete scopes.

<figure><img src="/files/GF3F56GdtMGXSTBLI5Zz" alt=""><figcaption></figcaption></figure>

Completing this flow should take you back to your AI tool, authenticated and ready to use Lenses MCP Server with the granted authorization scopes.

<figure><img src="/files/JEYtLQ0Zt4mhGZxu4zQO" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Lenses documentation is available on [Context7](https://context7.com/websites/lenses_io). Use the [Context7 MCP Server](https://github.com/upstash/context7) and adjust your prompts with `use context7` to ensure the documentation available to your AI tool is up to date
{% endhint %}
{% endstep %}
{% endstepper %}


---

# Agent Instructions: 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:

```
GET https://docs.lenses.io/latest/mcp/lenses-mcp-server/getting-started/run-with-docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
