feat(mcp): always turn on OAuth sign-in and add the MCP tools changelog (#6930)

* chore: add changelog entry for the MCP shared tools

The tools PRs left it for when the milestone was done.

* feat(mcp): always turn on OAuth sign-in

BASEROW_MCP_OAUTH_ENABLED is removed before it ships, so OAuth sign-in is
on everywhere. The settings page opens the endpoint tab when the OAuth
connections fail to load.
This commit is contained in:
alamin-br authored and GitHub committed 2026-12-01 15:44:39 +01:00
1 parent 8aed5fdc85
commit e7381b5384
26 files changed
+70 -219

No files matched your search

-1
View File
@@ -709,7 +709,6 @@ jobs:
-e EMAIL_SMTP_HOST=mailhog \
-e EMAIL_SMTP_PORT=1025 \
-e BASEROW_DATABASE_BUTTON_DISPATCH_USER_RATE_LIMITS=3/m \
-e BASEROW_MCP_OAUTH_ENABLED=true \
-e PRIVATE_BACKEND_URL=http://backend:8000 \
-p 8000:8000 \
${{ needs.build-backend.outputs.image }} gunicorn &
@@ -3,7 +3,6 @@ from urllib.parse import urlparse
from django.conf import settings
from django.db import transaction
from django.db.models import Count
from django.http import Http404
from oauth2_provider.exceptions import OAuthToolkitError
from oauth2_provider.models import get_application_model
@@ -47,11 +46,6 @@ from .oauth_serializers import ConsentSerializer
from .serializers import UpdateAllowedToolsSerializer
def _require_oauth_enabled():
if not settings.BASEROW_MCP_OAUTH_ENABLED:
raise Http404()
def _loopback_only(application) -> bool:
"""
True when every redirect URI is a loopback address. Any local program can
@@ -189,7 +183,6 @@ class MCPOAuthConsentView(APIView):
throttle_classes = (*APIView.throttle_classes, MCPOAuthConsentRateThrottle)
def get(self, request):
_require_oauth_enabled()
query = request.query_params.get("query", "")
try:
authorize_request, credentials = validate_query(
@@ -283,7 +276,6 @@ class MCPOAuthConsentView(APIView):
)
@validate_body(ConsentSerializer)
def post(self, request, data):
_require_oauth_enabled()
# Validated outside the transaction, because validation may fetch the
# client's metadata document over HTTP. The library re-checks the client
# when it issues the code, which only refetches a stale document.
@@ -371,11 +363,6 @@ class MCPOAuthConnectionsView(APIView):
endpoint, with the URL MCP clients connect to.
"""
if not settings.BASEROW_MCP_OAUTH_ENABLED:
return Response(
{"oauth_enabled": False, "mcp_url": None, "connections": []}
)
endpoints = list(
# A grant in a workspace the user left can't be used.
MCPEndpoint.objects.filter(
@@ -393,7 +380,6 @@ class MCPOAuthConnectionsView(APIView):
tools = mcp_tool_registry.get_enabled_tools()
return Response(
{
"oauth_enabled": True,
"mcp_url": settings.MCP_RESOURCE_URL,
"connections": [
_serialize_connection(
@@ -426,7 +412,6 @@ class MCPOAuthConnectionView(APIView):
gets the new tools on its next request.
"""
_require_oauth_enabled()
endpoint = MCPEndpointHandler().get_oauth_grant(
request.user,
connection_id,
@@ -460,7 +445,6 @@ class MCPOAuthConnectionView(APIView):
its tokens. Only needs the grant to be the user's, like listing it.
"""
_require_oauth_enabled()
endpoint = MCPEndpointHandler().get_oauth_grant(request.user, connection_id)
DisconnectMCPOAuthClientActionType.do(request.user, endpoint)
return Response(status=status.HTTP_204_NO_CONTENT)
@@ -1024,10 +1024,6 @@ else:
"PUBLIC_WEB_FRONTEND_URL", "http://localhost:3000"
)
BASEROW_MCP_OAUTH_ENABLED = str_to_bool(
os.getenv("BASEROW_MCP_OAUTH_ENABLED") or "false"
)
def _canonical_url(url: str) -> str:
"""
@@ -158,8 +158,6 @@ STORAGES["default"] = {"BACKEND": BASE_FILE_STORAGE}
BASEROW_LOGIN_ACTION_LOG_LIMIT = RateLimit.from_string("1000/s")
BASEROW_MCP_OAUTH_ENABLED = True
BASEROW_WEBHOOKS_ALLOW_PRIVATE_ADDRESS = False
INTEGRATIONS_ALLOW_PRIVATE_ADDRESS = False
BASEROW_DATA_SYNC_ALLOW_PRIVATE_ADDRESS = False
+1 -2
View File
@@ -30,7 +30,6 @@ urlpatterns = (
if settings.DEBUG and "silk" in settings.INSTALLED_APPS:
urlpatterns += [path("silk/", include("silk.urls", namespace="silk"))]
if settings.BASEROW_MCP_OAUTH_ENABLED:
urlpatterns += [path("", include("baserow.core.mcp.oauth.urls"))]
urlpatterns += [path("", include("baserow.core.mcp.oauth.urls"))]
handler400 = "baserow.api.exceptions.bad_request"
+14 -19
View File
@@ -13,25 +13,22 @@ INSUFFICIENT_SCOPE = "insufficient_scope"
def www_authenticate(error: str | None = None) -> str:
"""
The `WWW-Authenticate` header value for a rejected `/mcp` request. With OAuth on,
it points MCP clients at the protected resource metadata so they can start the
OAuth flow. With it off, that metadata isn't served, so it isn't mentioned.
The `WWW-Authenticate` header value for a rejected `/mcp` request. It points
MCP clients at the protected resource metadata so they can start the OAuth flow.
"""
from baserow.core.mcp.oauth.validators import MCP_SCOPE
params = []
if settings.BASEROW_MCP_OAUTH_ENABLED:
metadata = (
f"{settings.MCP_AUTHORIZATION_SERVER_URL}"
"/.well-known/oauth-protected-resource/mcp"
)
params.append(f'resource_metadata="{metadata}"')
metadata = (
f"{settings.MCP_AUTHORIZATION_SERVER_URL}"
"/.well-known/oauth-protected-resource/mcp"
)
params = [f'resource_metadata="{metadata}"']
if error == INSUFFICIENT_SCOPE:
params += [f'error="{INSUFFICIENT_SCOPE}"', f'scope="{MCP_SCOPE}"']
elif error:
params.append(f'error="{error}"')
return "Bearer " + ", ".join(params) if params else "Bearer"
return "Bearer " + ", ".join(params)
def _load_member_endpoint(**lookup) -> MCPEndpoint | None:
@@ -96,10 +93,9 @@ def _resolve_oauth_token(value: str):
def _resolve_bearer_sync(value: str):
if settings.BASEROW_MCP_OAUTH_ENABLED:
result = _resolve_oauth_token(value)
if result is not None:
return result
result = _resolve_oauth_token(value)
if result is not None:
return result
endpoint = _load_member_endpoint(key=value)
if endpoint is None:
@@ -110,10 +106,9 @@ def _resolve_bearer_sync(value: str):
async def resolve_bearer(value: str) -> tuple[MCPEndpoint | None, str | None]:
"""
Resolves a bearer value to an MCP endpoint. The value is either an OAuth access
token (when `BASEROW_MCP_OAUTH_ENABLED`) or an endpoint key. Returns the endpoint
and `None`, or `None` and an error code (`invalid_token` or
`insufficient_scope`). The endpoint is returned only while its user is a member
of its workspace.
token or an endpoint key. Returns the endpoint and `None`, or `None` and an
error code (`invalid_token` or `insufficient_scope`). The endpoint is returned
only while its user is a member of its workspace.
"""
return await sync_to_async(_resolve_bearer_sync)(value)
@@ -142,7 +142,6 @@ def test_identity_cannot_use_human_database_token(
def test_identity_cannot_use_current_human_mcp_credentials(
identity_account, data_fixture, settings, credential
):
settings.BASEROW_MCP_OAUTH_ENABLED = True
workspace = IdentityHandler.get_workspace(identity_account)
if credential == "key":
endpoint = data_fixture.create_mcp_endpoint(
@@ -47,7 +47,6 @@ def test_list_connections(client, api_client, data_fixture, settings):
response = api_client.get(reverse(LIST_URL), HTTP_AUTHORIZATION=f"JWT {token}")
assert response.status_code == 200
data = response.json()
assert data["oauth_enabled"] is True
assert data["mcp_url"] == settings.MCP_RESOURCE_URL
assert [c["id"] for c in data["connections"]] == [
full["endpoint_id"],
@@ -104,21 +103,6 @@ def test_list_connections_hides_grants_in_workspaces_the_user_left(
assert [c["id"] for c in response.json()["connections"]] == [kept_id]
@pytest.mark.django_db
def test_list_connections_when_oauth_disabled(api_client, data_fixture, settings):
url = reverse(LIST_URL)
settings.BASEROW_MCP_OAUTH_ENABLED = False
user, token = data_fixture.create_user_and_token()
data_fixture.create_mcp_endpoint(user=user, oauth_client_id="https://x/y.json")
response = api_client.get(url, HTTP_AUTHORIZATION=f"JWT {token}")
assert response.status_code == 200
assert response.json() == {
"oauth_enabled": False,
"mcp_url": None,
"connections": [],
}
@pytest.mark.django_db
def test_list_connections_requires_auth(api_client):
assert api_client.get(reverse(LIST_URL)).status_code == 401
@@ -43,26 +43,6 @@ def _post(api_client, token, query, workspace, tools=None, allow=True):
)
@pytest.mark.django_db
def test_consent_is_404_when_oauth_is_disabled(
client, api_client, data_fixture, settings
):
# Resolving first loads the root urlconf with the OAuth routes mounted, so
# later tests in this process still have them.
url = reverse(URL)
settings.BASEROW_MCP_OAUTH_ENABLED = False
user, token = data_fixture.create_user_and_token()
workspace = data_fixture.create_workspace(user=user)
query = _query(client)
get = api_client.get(url, {"query": query}, HTTP_AUTHORIZATION=f"JWT {token}")
post = _post(api_client, token, query, workspace)
assert get.status_code == 404
assert post.status_code == 404
assert not MCPEndpoint.objects.filter(oauth_client_id__isnull=False).exists()
@pytest.mark.django_db
def test_invalid_body_uses_the_baserow_error_envelope(client, api_client, data_fixture):
_, token = data_fixture.create_user_and_token()
@@ -1,6 +1,5 @@
from datetime import timedelta
from django.test import override_settings
from django.utils import timezone
import pytest
@@ -80,16 +79,3 @@ def test_revoke_endpoint_tokens_matches_scope_exactly(data_fixture):
assert not RefreshToken.objects.filter(token="r-a1").exists()
assert AccessToken.objects.filter(id=twelve.id).exists()
assert RefreshToken.objects.filter(token="r-a12").exists()
@pytest.mark.django_db
def test_flag_off_refuses_oauth_token_but_accepts_key(client, api_client, data_fixture):
user, token = data_fixture.create_user_and_token()
workspace = data_fixture.create_workspace(user=user)
tokens = obtain_tokens(client, api_client, token, workspace)
endpoint = data_fixture.create_mcp_endpoint(user=user, workspace=workspace)
with override_settings(BASEROW_MCP_OAUTH_ENABLED=False):
_, error = async_to_sync(resolve_bearer)(tokens["access_token"])
assert error == "invalid_token"
found, error = async_to_sync(resolve_bearer)(endpoint.key)
assert error is None and found.id == endpoint.id
@@ -2,13 +2,10 @@ import importlib
from unittest.mock import patch
from django.http import HttpResponse
from django.urls import Resolver404, path
from django.urls.resolvers import RegexPattern, URLResolver
from django.urls import path
import pytest
from oauth2_provider import urls as oauth2_urls
from baserow.config import urls as root_urls
from baserow.core.mcp.oauth import urls
@@ -21,25 +18,3 @@ def test_unnamed_library_metadata_patterns_are_kept():
assert unnamed in urls.metadata_patterns
finally:
importlib.reload(urls)
@pytest.mark.parametrize("enabled", [False, True])
def test_oauth_routes_follow_the_flag(settings, enabled):
# A fresh resolver, because the cached one was built from the URLconf as first
# imported.
def resolves(url):
resolver = URLResolver(RegexPattern(r"^/"), root_urls.urlpatterns)
try:
resolver.resolve(url)
except Resolver404:
return False
return True
settings.BASEROW_MCP_OAUTH_ENABLED = enabled
try:
importlib.reload(root_urls)
assert resolves("/oauth/register/") is enabled
assert resolves("/.well-known/oauth-authorization-server") is enabled
finally:
settings.BASEROW_MCP_OAUTH_ENABLED = True
importlib.reload(root_urls)
@@ -479,30 +479,6 @@ def test_token_without_an_application_gets_401(data_fixture):
assert 'error="invalid_token"' in response.headers["www-authenticate"]
@pytest.mark.django_db(transaction=True)
def test_oauth_token_rejected_when_oauth_disabled(data_fixture, settings):
user = data_fixture.create_user()
workspace = data_fixture.create_workspace(user=user)
endpoint = data_fixture.create_mcp_endpoint(user=user, workspace=workspace)
grant = _create_grant(data_fixture, user, workspace)
_create_raw_token(
user,
"flag-off-token",
f"mcp endpoint:{grant.id}",
[settings.MCP_RESOURCE_URL],
client_id=grant.oauth_client_id,
)
assert _post(LIST, "flag-off-token").status_code == 200
settings.BASEROW_MCP_OAUTH_ENABLED = False
response = _post(LIST, "flag-off-token")
assert response.status_code == 401
# The metadata routes aren't mounted, so the challenge doesn't point at them.
assert response.headers["www-authenticate"] == 'Bearer error="invalid_token"'
assert _post(INIT).headers["www-authenticate"] == "Bearer"
assert _post(LIST, endpoint.key).status_code == 200
def _get(path):
async def inner():
app = BaserowMCPServer().sse_app()
@@ -0,0 +1,14 @@
{
"type": "feature",
"message": "MCP apps can use Kuma's tools, and you choose which tools each connected app may use",
"issue_origin": "github",
"issue_number": 6345,
"domain": "core",
"bullet_points": [
"Tools for tables, fields, rows and views",
"Tools for automations, applications and dashboards",
"Workspace search, row comments, view settings and the audit log",
"Change a connected app's tools in My settings without reconnecting"
],
"created_at": "2026-11-30"
}
-1
View File
@@ -144,7 +144,6 @@ x-backend-variables:
BASEROW_DJANGO_REQUEST_LOG_LEVEL:
FEATURE_FLAGS:
BASEROW_PRESENCE_VISIBLE_USERS:
BASEROW_MCP_OAUTH_ENABLED:
BASEROW_MCP_OAUTH_CIMD_ENABLED:
BASEROW_MCP_OAUTH_CIMD_ALLOWED_HOSTS:
BASEROW_MCP_OAUTH_TOKEN_RATE_LIMITS:
-1
View File
@@ -155,7 +155,6 @@ x-backend-variables:
BASEROW_DJANGO_REQUEST_LOG_LEVEL:
FEATURE_FLAGS:
BASEROW_PRESENCE_VISIBLE_USERS:
BASEROW_MCP_OAUTH_ENABLED:
BASEROW_MCP_OAUTH_CIMD_ENABLED:
BASEROW_MCP_OAUTH_CIMD_ALLOWED_HOSTS:
BASEROW_MCP_OAUTH_TOKEN_RATE_LIMITS:
+2 -4
View File
@@ -56,8 +56,6 @@ just run-asgi
MCP clients can sign in with OAuth instead of a pasted key. See [ADR 009](../decisions/009-mcp-oauth-authorization.md) for the design.
Set `BASEROW_MCP_OAUTH_ENABLED=true` to turn it on. It is off by default.
All clients share one URL, `<PUBLIC_BACKEND_URL>/mcp`. The user picks a workspace and the allowed tools on the consent screen.
Each grant is stored as an `MCPEndpoint` row with `oauth_client_id` set. Its tokens carry the scope `mcp endpoint:<id>`, which ties them to that row. Deleting the row revokes the tokens. Grants are also revoked when the user leaves the workspace. A password change or reset deletes the user's tokens but keeps the grants, so the apps have to sign in again.
@@ -84,7 +82,7 @@ Access tokens last one hour. Clients always get a refresh token, whether or not
### Running it locally
```bash
BASEROW_MCP_OAUTH_ENABLED=true just run-dev-server
just run-dev-server
claude mcp add --transport http baserow http://localhost:8000/mcp
```
@@ -94,7 +92,7 @@ See the [test plan](../testing/mcp-test-plan.md#1-connect-an-mcp-client) for oth
### ChatGPT app domain verification
OpenAI verifies the domain of a submitted ChatGPT app by fetching `/.well-known/openai-apps-challenge`. Set `BASEROW_MCP_OPENAI_APPS_CHALLENGE` to the token shown in OpenAI's portal and the backend returns it as plain text. When it's empty the route returns a 404. Like the other OAuth routes, it only exists with `BASEROW_MCP_OAUTH_ENABLED=true`.
OpenAI verifies the domain of a submitted ChatGPT app by fetching `/.well-known/openai-apps-challenge`. Set `BASEROW_MCP_OPENAI_APPS_CHALLENGE` to the token shown in OpenAI's portal and the backend returns it as plain text. When it's empty the route returns a 404.
## Tools
@@ -53,8 +53,7 @@ images:
need to:
* Redirect `/api/` and `/ws/` requests to the backend gunicorn service without
dropping these prefixes.
* With `BASEROW_MCP_OAUTH_ENABLED=true`, also send `/mcp`, `/oauth/`,
`/.well-known/oauth-authorization-server` and
* Also send `/mcp`, `/oauth/`, `/.well-known/oauth-authorization-server` and
`/.well-known/oauth-protected-resource` to the backend. See
[MCP OAuth sign-in](mcp-oauth.md).
* Serve the files in the `/baserow/media` folder in the backend gunicorn service
+3 -6
View File
@@ -1,8 +1,8 @@
# MCP OAuth sign-in for self-hosted Baserow
With `BASEROW_MCP_OAUTH_ENABLED=true`, MCP clients such as Claude, ChatGPT, Cursor and
VS Code connect to `<PUBLIC_BACKEND_URL>/mcp` and sign the user in with OAuth instead
of a pasted endpoint key. Users find the URL, and copy-ready setup for Claude Code,
MCP clients such as Claude, ChatGPT, Cursor and VS Code connect to
`<PUBLIC_BACKEND_URL>/mcp` and sign the user in with OAuth instead of a pasted
endpoint key. Users find the URL, and copy-ready setup for Claude Code,
Cursor, VS Code, Codex and Gemini CLI, under *My settings → MCP server*. Steps for
each app are in the [MCP server user docs](https://baserow.io/user-docs/mcp-server),
and the plugins and skills are in the
@@ -34,6 +34,3 @@ self-hosted install:
the first `X-Forwarded-For` entry. The proxy in front of Baserow must replace that
header rather than append to what the client sent, or a client can pick its own IP.
Behind a proxy that doesn't set it at all, every client shares one limit.
* **Turning it off.** Setting `BASEROW_MCP_OAUTH_ENABLED=false` pauses the connected
apps, it doesn't revoke them. Their grants and tokens are kept and work again when
the flag is turned back on. Users can disconnect apps in *My settings → MCP server*.
-1
View File
@@ -3,7 +3,6 @@
## Prerequisites
- A running Baserow instance (local dev or deployed)
- For OAuth: `BASEROW_MCP_OAUTH_ENABLED=true` on the backend
- An MCP-compatible client (see step 1)
## 1. Connect an MCP client
-1
View File
@@ -19,5 +19,4 @@ The suite runs two ways, and which mail variable applies depends on which.
| `E2E_SLACK_STUB` | `./run-e2e-tests-locally.sh` and `yarn run test` | Set to `yes` when the backend under test has `BASEROW_INTEGRATIONS_SLACK_API_URL` pointed at the WireMock stub in `stubs/slack`, which `just e2e` and CI do. The one test in `button_field_slack.spec.ts` that clicks is skipped otherwise, since it would reach slack.com. Locally the script starts the stub on `E2E_SLACK_STUB_PORT` (default 8101); run the dev backend with `BASEROW_INTEGRATIONS_SLACK_API_URL=http://localhost:8101/api` and `BASEROW_INTEGRATIONS_ALLOW_PRIVATE_ADDRESS=true`. |
| `E2E_KUMA_MODEL_STUB` | `yarn run test` | Set to `yes` when the backend and its Celery worker run Kuma against the stub in `stubs/kuma-model` (`BASEROW_ENTERPRISE_ASSISTANT_LLM_MODEL=openai/kuma-e2e` and `OPENAI_BASE_URL` pointing at the stub), which `just e2e` and CI do. The Kuma background run tests are skipped otherwise. |
| `E2E_HTTP_STUB_URL` | both | The endpoint the HTTP action tests call. The local runner starts httpbin in Docker when the backend allows private addresses, and falls back to the public httpbin.org otherwise. |
| `BASEROW_MCP_OAUTH_ENABLED` | the backend under test | Set to `true` on the backend, which `just e2e` and CI do. `tests/auth/mcpOAuth.spec.ts` is skipped when the backend answers 404 on `/.well-known/oauth-authorization-server`. |
| `E2E_BUTTON_RATE_LIMIT` | both | How many external clicks a user gets per minute. The tests that click until they are refused are skipped when it is unset, since the runner cannot set it for a dev backend. |
-1
View File
@@ -273,7 +273,6 @@ up: _ensure-images
-e EMAIL_SMTP_PORT=1025 \
-e BASEROW_DATABASE_BUTTON_DISPATCH_USER_RATE_LIMITS={{ button_rate_limit }}/m \
-e BASEROW_FRONTEND_COOKIE_PREFIX={{ frontend_cookie_prefix }} \
-e BASEROW_MCP_OAUTH_ENABLED=true \
-e PRIVATE_BACKEND_URL=http://e2e-backend:8000 \
-e PUBLIC_BACKEND_URL="{{ public_backend_url }}" \
-e PUBLIC_WEB_FRONTEND_URL="{{ public_frontend_url }}" \
-5
View File
@@ -72,11 +72,6 @@ test("An MCP client connects with OAuth and is disconnected in settings", async
const metadataResponse = await request.get(
`${backendUrl}/.well-known/oauth-authorization-server`
);
// Only a missing route means the flag is off; any other error must fail.
test.skip(
metadataResponse.status() === 404,
"BASEROW_MCP_OAUTH_ENABLED is off on the backend under test"
);
expect(metadataResponse.status()).toBe(200);
const metadata = await metadataResponse.json();
@@ -3,7 +3,6 @@
<template v-if="page === 'list'">
<h2 class="box__title">{{ $t('mcpEndpointSettings.title') }}</h2>
<Tabs
v-if="oauthEnabled"
class="mcp-endpoint-settings__tabs"
header-no-padding
:tab-items="[
@@ -14,11 +13,10 @@
@update:selected-index="selectedTabIndex = $event"
></Tabs>
<!-- v-show keeps the connections loaded while the other tab is open. -->
<McpOAuthConnections v-show="showOAuth" @loaded="oauthLoaded" />
<div v-if="!oauthStatusLoaded" class="loading"></div>
<McpOAuthConnections v-show="showOAuth" @loaded="connectionsLoaded" />
<div v-if="showOAuth && !oauthLoaded" class="loading"></div>
<div v-show="showEndpoints" data-test="mcp-endpoint-list">
<Alert
v-if="oauthEnabled"
type="warning"
class="margin-bottom-2"
data-test="mcp-endpoint-config-only"
@@ -90,8 +88,7 @@ export default {
data() {
return {
page: 'list',
oauthEnabled: false,
oauthStatusLoaded: false,
oauthLoaded: false,
selectedTabIndex: 0,
endpoints: [],
listLoading: true,
@@ -100,13 +97,10 @@ export default {
},
computed: {
showOAuth() {
return this.oauthEnabled && this.selectedTabIndex === 0
return this.selectedTabIndex === 0
},
showEndpoints() {
return (
this.oauthStatusLoaded &&
(!this.oauthEnabled || this.selectedTabIndex === 1)
)
return this.selectedTabIndex === 1
},
},
/**
@@ -124,9 +118,15 @@ export default {
}
},
methods: {
oauthLoaded(enabled) {
this.oauthEnabled = enabled
this.oauthStatusLoaded = true
/**
* Opens the endpoints tab when the OAuth connections failed to load, so the
* page still shows something useful.
*/
connectionsLoaded(success) {
this.oauthLoaded = true
if (!success) {
this.selectedTabIndex = 1
}
},
/**
* When the create endpoint form is submitted the create method is called. It will
@@ -1,5 +1,5 @@
<template>
<div v-if="oauthEnabled" class="mcp-oauth-connections">
<div v-if="loaded" class="mcp-oauth-connections">
<h3 class="mcp-oauth-connections__title">
{{ $t('mcpOAuthConnections.title') }}
</h3>
@@ -268,7 +268,7 @@ const emit = defineEmits(['loaded'])
const { $client } = useNuxtApp()
const { t } = useI18n()
const oauthEnabled = ref(false)
const loaded = ref(false)
const mcpUrl = ref('')
const connections = ref([])
// Every tool a connection can be given, and their groups.
@@ -315,15 +315,15 @@ const vsCodeInstallUrl = computed(() => {
onMounted(async () => {
try {
const { data } = await MCPOAuthService($client).fetchConnections()
oauthEnabled.value = data.oauth_enabled
mcpUrl.value = data.mcp_url
connections.value = data.connections
tools.value = data.tools || []
groups.value = data.groups || []
loaded.value = true
} catch (error) {
notifyIf(error)
}
emit('loaded', oauthEnabled.value)
emit('loaded', loaded.value)
})
function initial(name) {
@@ -13,10 +13,9 @@ describe('McpEndpointSettings', () => {
await testApp.afterEach()
})
async function mount(oauthEnabled) {
async function mount() {
testApp.mock.onGet('/mcp/oauth/connections/').reply(200, {
oauth_enabled: oauthEnabled,
mcp_url: oauthEnabled ? 'https://api.example.com/mcp' : null,
mcp_url: 'https://api.example.com/mcp',
connections: [],
})
testApp.mock.onGet('/mcp/endpoints/').reply(200, [])
@@ -34,17 +33,8 @@ describe('McpEndpointSettings', () => {
'.mcp-endpoint-settings__tabs > .tabs__header > .tabs__item'
)
test('shows only the endpoints without tabs when OAuth is off', async () => {
const wrapper = await mount(false)
expect(wrapper.find('.mcp-endpoint-settings__tabs').exists()).toBe(false)
expect(oauth(wrapper).exists()).toBe(false)
expect(endpoints(wrapper).isVisible()).toBe(true)
expect(configOnly(wrapper).exists()).toBe(false)
})
test('warns that endpoints only work in config files when OAuth is on', async () => {
const wrapper = await mount(true)
test('warns that endpoints only work in config files', async () => {
const wrapper = await mount()
await tabs(wrapper)[1].trigger('click')
@@ -55,7 +45,7 @@ describe('McpEndpointSettings', () => {
})
test('switches between the OAuth and endpoint tabs', async () => {
const wrapper = await mount(true)
const wrapper = await mount()
expect(tabs(wrapper).map((tab) => tab.text())).toEqual([
'mcpEndpointSettings.oauthTab',
@@ -69,4 +59,14 @@ describe('McpEndpointSettings', () => {
expect(oauth(wrapper).isVisible()).toBe(false)
expect(endpoints(wrapper).isVisible()).toBe(true)
})
test('opens the endpoints tab when the OAuth connections fail to load', async () => {
testApp.mock.onGet('/mcp/oauth/connections/').reply(500)
testApp.mock.onGet('/mcp/endpoints/').reply(200, [])
const wrapper = await testApp.mount(McpEndpointSettings)
await flushPromises()
expect(endpoints(wrapper).isVisible()).toBe(true)
expect(wrapper.find('.loading').exists()).toBe(false)
})
})
@@ -81,7 +81,7 @@ describe('McpOAuthConnections', () => {
read_only_preset: false,
},
]
const enabled = { oauth_enabled: true, mcp_url: mcpUrl, tools, groups }
const enabled = { mcp_url: mcpUrl, tools, groups }
beforeEach(() => {
testApp = new TestApp()
@@ -98,19 +98,8 @@ describe('McpOAuthConnections', () => {
return wrapper
}
test('renders nothing and reports disabled when OAuth is off', async () => {
const wrapper = await mount({
oauth_enabled: false,
mcp_url: null,
connections: [],
})
expect(wrapper.find('.mcp-oauth-connections').exists()).toBe(false)
expect(wrapper.emitted('loaded')).toEqual([[false]])
})
test('shows the URL, the setup docs link and the client tabs', async () => {
const wrapper = await mount({
oauth_enabled: true,
mcp_url: mcpUrl,
connections: [],
})
@@ -141,7 +130,6 @@ describe('McpOAuthConnections', () => {
test('opens on the ChatGPT setup steps', async () => {
const wrapper = await mount({
oauth_enabled: true,
mcp_url: mcpUrl,
connections: [],
})
@@ -150,7 +138,6 @@ describe('McpOAuthConnections', () => {
test('builds the Cursor and VS Code install links from the instance URL', async () => {
const wrapper = await mount({
oauth_enabled: true,
mcp_url: mcpUrl,
connections: [],
})
@@ -184,7 +171,6 @@ describe('McpOAuthConnections', () => {
test('install links and config fallbacks work with a non-Latin URL', async () => {
const unicodeUrl = 'https://例子.test/mcp'
const wrapper = await mount({
oauth_enabled: true,
mcp_url: unicodeUrl,
connections: [],
})
@@ -211,7 +197,6 @@ describe('McpOAuthConnections', () => {
test('lists connections with badge, workspace and tool count', async () => {
const wrapper = await mount({
oauth_enabled: true,
mcp_url: mcpUrl,
connections,
})
@@ -235,7 +220,6 @@ describe('McpOAuthConnections', () => {
test('marks a connection whose sign-in expired', async () => {
const wrapper = await mount({
oauth_enabled: true,
mcp_url: mcpUrl,
connections: [{ ...connections[0], expired: true }, connections[1]],
})
@@ -250,7 +234,6 @@ describe('McpOAuthConnections', () => {
test('disconnect asks once, then deletes and removes the row', async () => {
const wrapper = await mount({
oauth_enabled: true,
mcp_url: mcpUrl,
connections,
})
@@ -276,7 +259,6 @@ describe('McpOAuthConnections', () => {
test('uses only its own block elements', async () => {
const wrapper = await mount({
oauth_enabled: true,
mcp_url: mcpUrl,
connections: [],
})