⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
improvement(web): the MCP consent screen names the client that asks (#578)
Pasqual Tronconed098c720edbe
diff --git a/apps/api/src/__tests__/integration/mcp-authorize-consent.test.ts b/apps/api/src/__tests__/integration/mcp-authorize-consent.test.tsindex a4f2be94..0bc753ef 100644--- a/apps/api/src/__tests__/integration/mcp-authorize-consent.test.ts+++ b/apps/api/src/__tests__/integration/mcp-authorize-consent.test.ts@@ -126,4 +126,23 @@ describe('MCP authorization asks for consent', () => {expect(`${location.origin}${location.pathname}`).toBe('https://client.example.com/callback');expect(location.searchParams.get('error')).toBe('invalid_scope');});++ // The consent page names the client and where the answer goes from these.+ it('tells the consent page which client asks and where the answer goes', async () => {+ const user = await signUpTestUser({ team: false });++ const consentPage = await authorize(user.cookie);+ const clientId = consentPage.searchParams.get('client_id') ?? '';+ expect(consentPage.searchParams.get('redirect_uri')).toBe(+ 'https://client.example.com/callback',+ );++ const res = await app.handle(+ new Request(`http://localhost/api/auth/oauth2/public-client?client_id=${clientId}`, {+ headers: { cookie: user.cookie },+ }),+ );+ expect(res.status).toBe(200);+ expect(((await res.json()) as { client_name?: string }).client_name).toBe('Test client');+ });});diff --git a/apps/web/messages/ar/mcp.json b/apps/web/messages/ar/mcp.jsonindex 2c756b1e..32ce4f8f 100644--- a/apps/web/messages/ar/mcp.json+++ b/apps/web/messages/ar/mcp.json@@ -34,8 +34,11 @@},"security": "يستخدم OAuth آلية PKCE (S256) وتسجيل العملاء الديناميكي ورموز وصول مقيّدة بحساب Itsaplan.","consent": {- "title": "تفويض Itsaplan",- "description": "اسمح لعميل MCP هذا بالعمل بصلاحيات حساب Itsaplan الخاص بك.",+ "title": "يريد {client} الاتصال بحسابك",+ "titleUnnamed": "يريد عميل MCP الاتصال بحسابك",+ "description": "سيتصرف بصلاحياتك: كل ما يمكنك رؤيته وتغييره، يمكنه هو أيضًا.",+ "account": "تم تسجيل الدخول باسم {email}",+ "redirect": "بعد الرد، ستعود إلى {host}.","missingCode": "طلب التفويض هذا يفتقد رمز الموافقة.","cancel": "إلغاء","pending": "جارٍ التفويض…",diff --git a/apps/web/messages/en/mcp.json b/apps/web/messages/en/mcp.jsonindex 1427ac58..02465779 100644--- a/apps/web/messages/en/mcp.json+++ b/apps/web/messages/en/mcp.json@@ -34,8 +34,11 @@},"security": "OAuth uses PKCE (S256), dynamic client registration, and access tokens scoped to your Itsaplan account.","consent": {- "title": "Authorize Itsaplan",- "description": "Allow this MCP client to act with the permissions of your Itsaplan account.",+ "title": "{client} wants to connect to your account",+ "titleUnnamed": "An MCP client wants to connect to your account",+ "description": "It will act with your permissions: whatever you can see and change, it can too.",+ "account": "Signed in as {email}",+ "redirect": "After you answer, you go back to {host}.","missingCode": "This authorization request is missing its consent code.","cancel": "Cancel","pending": "Authorizing…",diff --git a/apps/web/messages/es-ES/mcp.json b/apps/web/messages/es-ES/mcp.jsonindex 19981d72..a5f9d34e 100644--- a/apps/web/messages/es-ES/mcp.json+++ b/apps/web/messages/es-ES/mcp.json@@ -34,8 +34,11 @@},"security": "OAuth usa PKCE (S256), registración dinámica de clientes y tokens de acceso acotados a tu cuenta de Itsaplan.","consent": {- "title": "Autorizar Itsaplan",- "description": "Permite que este cliente MCP actúe con los permisos de tu cuenta de Itsaplan.",+ "title": "{client} quiere conectarse a tu cuenta",+ "titleUnnamed": "Un cliente MCP quiere conectarse a tu cuenta",+ "description": "Actuará con tus permisos: todo lo que tú puedes ver y cambiar, podrá hacerlo también.",+ "account": "Has iniciado sesión como {email}",+ "redirect": "Después de responder, vuelves a {host}.","missingCode": "A esta petición de autorización le falta su código de consentimiento.","cancel": "Cancelar","pending": "Autorizando…",diff --git a/apps/web/messages/fr/mcp.json b/apps/web/messages/fr/mcp.jsonindex da019dd8..b2ce4653 100644--- a/apps/web/messages/fr/mcp.json+++ b/apps/web/messages/fr/mcp.json@@ -34,8 +34,11 @@},"security": "OAuth utilise PKCE (S256), l'enregistrement dynamique des clients et des jetons d'accès limités à votre compte Itsaplan.","consent": {- "title": "Autoriser Itsaplan",- "description": "Autorisez ce client MCP à agir avec les droits de votre compte Itsaplan.",+ "title": "{client} souhaite se connecter à votre compte",+ "titleUnnamed": "Un client MCP souhaite se connecter à votre compte",+ "description": "Il agira avec vos autorisations : tout ce que vous pouvez voir et modifier, il le pourra aussi.",+ "account": "Connecté en tant que {email}",+ "redirect": "Après votre réponse, vous revenez sur {host}.","missingCode": "Cette demande d'autorisation n'a pas de code de consentement.","cancel": "Annuler","pending": "Autorisation…",diff --git a/apps/web/messages/id/mcp.json b/apps/web/messages/id/mcp.jsonindex 8264af98..a25c6a91 100644--- a/apps/web/messages/id/mcp.json+++ b/apps/web/messages/id/mcp.json@@ -34,8 +34,11 @@},"security": "OAuth menggunakan PKCE (S256), pendaftaran klien dinamis, dan token akses yang dicakupkan ke akun Itsaplan Anda.","consent": {- "title": "Otorisasi Itsaplan",- "description": "Izinkan klien MCP ini bertindak dengan izin dari akun Itsaplan Anda.",+ "title": "{client} ingin terhubung ke akun Anda",+ "titleUnnamed": "Sebuah klien MCP ingin terhubung ke akun Anda",+ "description": "Aplikasi ini akan bertindak dengan izin Anda: apa pun yang dapat Anda lihat dan ubah, ia juga bisa.",+ "account": "Masuk sebagai {email}",+ "redirect": "Setelah Anda menjawab, Anda kembali ke {host}.","missingCode": "Permintaan otorisasi ini kehilangan kode persetujuannya.","cancel": "Batal","pending": "Mengotorisasi…",diff --git a/apps/web/messages/ko/mcp.json b/apps/web/messages/ko/mcp.jsonindex 93aa3c5f..264ea94d 100644--- a/apps/web/messages/ko/mcp.json+++ b/apps/web/messages/ko/mcp.json@@ -34,8 +34,11 @@},"security": "OAuth는 PKCE(S256), 동적 클라이언트 등록 및 Itsaplan 계정의 권한 범위가 적용된 액세스 토큰을 사용합니다.","consent": {- "title": "Itsaplan 권한 승인",- "description": "이 MCP 클라이언트가 Itsaplan 계정의 권한으로 작업하도록 허용합니다.",+ "title": "{client}에서 계정에 연결하려고 합니다",+ "titleUnnamed": "MCP 클라이언트가 계정에 연결하려고 합니다",+ "description": "이 앱은 사용자의 권한으로 동작합니다. 사용자가 보고 바꿀 수 있는 것은 이 앱도 할 수 있습니다.",+ "account": "{email}(으)로 로그인됨",+ "redirect": "응답하면 {host}(으)로 돌아갑니다.","missingCode": "이 인증 요청에 동의 코드가 없습니다.","cancel": "취소","pending": "승인 중…",diff --git a/apps/web/messages/pt-BR/mcp.json b/apps/web/messages/pt-BR/mcp.jsonindex c9d54986..ba1920e3 100644--- a/apps/web/messages/pt-BR/mcp.json+++ b/apps/web/messages/pt-BR/mcp.json@@ -34,8 +34,11 @@},"security": "O OAuth usa PKCE (S256), registro dinâmico de cliente e tokens de acesso com escopo limitado à sua conta Itsaplan.","consent": {- "title": "Autorizar Itsaplan",- "description": "Permitir que este cliente MCP aja com as permissões da sua conta Itsaplan.",+ "title": "{client} quer se conectar à sua conta",+ "titleUnnamed": "Um cliente MCP quer se conectar à sua conta",+ "description": "Ele vai agir com as suas permissões: tudo o que você pode ver e alterar, ele também poderá.",+ "account": "Conectado como {email}",+ "redirect": "Depois de responder, você volta para {host}.","missingCode": "Esta requisição de autorização não tem seu código de consentimento.","cancel": "Cancelar","pending": "Autorizando…",diff --git a/apps/web/messages/ru/mcp.json b/apps/web/messages/ru/mcp.jsonindex 3723818a..334051bd 100644--- a/apps/web/messages/ru/mcp.json+++ b/apps/web/messages/ru/mcp.json@@ -34,8 +34,11 @@},"security": "OAuth использует PKCE (S256), динамическую регистрацию клиентов и токены доступа, ограниченные вашей учётной записью Itsaplan.","consent": {- "title": "Авторизовать Itsaplan",- "description": "Разрешите этому MCP-клиенту действовать с правами вашей учётной записи Itsaplan.",+ "title": "{client} хочет подключиться к вашему аккаунту",+ "titleUnnamed": "MCP-клиент хочет подключиться к вашему аккаунту",+ "description": "Он будет действовать с вашими правами: всё, что можете видеть и менять вы, сможет и он.",+ "account": "Вы вошли как {email}",+ "redirect": "После ответа вы вернётесь на {host}.","missingCode": "В этом запросе авторизации отсутствует код согласия.","cancel": "Отмена","pending": "Авторизация…",diff --git a/apps/web/messages/uk/mcp.json b/apps/web/messages/uk/mcp.jsonindex db1c753c..601869f0 100644--- a/apps/web/messages/uk/mcp.json+++ b/apps/web/messages/uk/mcp.json@@ -34,8 +34,11 @@},"security": "OAuth використовує PKCE (S256), динамічну реєстрацію клієнтів і токени доступу, обмежені вашим обліковим записом Itsaplan.","consent": {- "title": "Авторизувати Itsaplan",- "description": "Дозвольте цьому MCP-клієнту діяти з правами вашого облікового запису Itsaplan.",+ "title": "{client} хоче під’єднатися до вашого облікового запису",+ "titleUnnamed": "MCP-клієнт хоче під’єднатися до вашого облікового запису",+ "description": "Він діятиме з вашими правами: усе, що можете бачити й змінювати ви, зможе і він.",+ "account": "Ви увійшли як {email}",+ "redirect": "Після відповіді ви повернетеся на {host}.","missingCode": "У цьому запиті авторизації відсутній код згоди.","cancel": "Скасувати","pending": "Авторизація…",diff --git a/apps/web/messages/zh-CN/mcp.json b/apps/web/messages/zh-CN/mcp.jsonindex 39ce09e9..ba4947c2 100644--- a/apps/web/messages/zh-CN/mcp.json+++ b/apps/web/messages/zh-CN/mcp.json@@ -34,8 +34,11 @@},"security": "OAuth 使用 PKCE (S256)、动态客户端注册以及限定到您的 Itsaplan 帐户的访问令牌。","consent": {- "title": "授权 Itsaplan",- "description": "允许此 MCP 客户端使用您的 Itsaplan 帐户权限执行操作。",+ "title": "{client} 想要连接到你的账户",+ "titleUnnamed": "一个 MCP 客户端想要连接到你的账户",+ "description": "它将以你的权限行事:你能查看和修改的内容,它也都可以。",+ "account": "已登录为 {email}",+ "redirect": "回答后,你将返回 {host}。","missingCode": "此授权请求缺少同意代码。","cancel": "取消","pending": "正在授权…",diff --git a/apps/web/src/features/mcp/components/OAuthConsentPage.tsx b/apps/web/src/features/mcp/components/OAuthConsentPage.tsxindex b36884f3..9e98f17d 100644--- a/apps/web/src/features/mcp/components/OAuthConsentPage.tsx+++ b/apps/web/src/features/mcp/components/OAuthConsentPage.tsx@@ -3,7 +3,9 @@import { useSearchParams } from 'next/navigation';import { useState } from 'react';import { useTranslations } from 'next-intl';-import { authClient } from '@/lib/auth-client';+import { authClient, useSession } from '@/lib/auth-client';+import { useOAuthClientNameQuery } from '../services/oauthClients.service';+import { consentRequest } from '../utils/consentRequest';export default function OAuthConsentPage() {const t = useTranslations('mcp');@@ -12,6 +14,9 @@ export default function OAuthConsentPage() {const signed = searchParams.has('sig');const [error, setError] = useState<string | null>(null);const [pending, setPending] = useState(false);+ const { clientId, redirectHost } = consentRequest(searchParams);+ const { data: session } = useSession();+ const { data: clientName } = useOAuthClientNameQuery(clientId);async function decide(accept: boolean) {if (!signed || pending) return;@@ -35,8 +40,22 @@ export default function OAuthConsentPage() {<main className="flex min-h-screen items-center justify-center bg-background p-6 text-foreground"><section className="w-full max-w-md space-y-5 rounded-lg border bg-card p-6 shadow-sm"><div className="space-y-2">- <h1 className="text-xl font-semibold">{t('oauth.consent.title')}</h1>+ <h1 className="text-xl font-semibold">+ {clientName+ ? t('oauth.consent.title', { client: clientName })+ : t('oauth.consent.titleUnnamed')}+ </h1><p className="text-sm text-muted-foreground">{t('oauth.consent.description')}</p>+ {session?.user.email ? (+ <p className="text-sm text-muted-foreground">+ {t('oauth.consent.account', { email: session.user.email })}+ </p>+ ) : null}+ {redirectHost ? (+ <p className="text-sm text-muted-foreground">+ {t('oauth.consent.redirect', { host: redirectHost })}+ </p>+ ) : null}</div>{!signed ? (<p className="text-sm text-destructive">{t('oauth.consent.missingCode')}</p>diff --git a/apps/web/src/features/mcp/services/oauthClients.service.ts b/apps/web/src/features/mcp/services/oauthClients.service.tsnew file mode 100644index 00000000..08a03e5c--- /dev/null+++ b/apps/web/src/features/mcp/services/oauthClients.service.ts@@ -0,0 +1,22 @@+'use client';++import { useQuery } from '@tanstack/react-query';+import { authClient } from '@/lib/auth-client';+import { qk } from '@/services/queryKeys';++// The name an MCP client registered with, or null when it gave none.+async function fetchClientName(clientId: string): Promise<string | null> {+ const { data } = await authClient.$fetch<{ client_name?: string }>('/oauth2/public-client', {+ method: 'GET',+ query: { client_id: clientId },+ });+ return data?.client_name?.trim() || null;+}++export function useOAuthClientNameQuery(clientId: string | null) {+ return useQuery({+ queryKey: qk.oauthClientName(clientId ?? ''),+ queryFn: () => fetchClientName(clientId ?? ''),+ enabled: clientId !== null,+ });+}diff --git a/apps/web/src/features/mcp/utils/consentRequest.test.ts b/apps/web/src/features/mcp/utils/consentRequest.test.tsnew file mode 100644index 00000000..6d13bbc3--- /dev/null+++ b/apps/web/src/features/mcp/utils/consentRequest.test.ts@@ -0,0 +1,27 @@+import assert from 'node:assert/strict';+import { describe, it } from 'node:test';+import { consentRequest } from './consentRequest';++describe('consentRequest', () => {+ it('reads the client and the host the answer goes to', () => {+ const params = new URLSearchParams({+ client_id: 'abc',+ redirect_uri: 'http://127.0.0.1:33418/callback',+ sig: 'signed',+ });++ assert.deepEqual(consentRequest(params), { clientId: 'abc', redirectHost: '127.0.0.1:33418' });+ });++ it('names no host when the redirect is missing or not a URL', () => {+ assert.deepEqual(consentRequest(new URLSearchParams({ client_id: 'abc' })), {+ clientId: 'abc',+ redirectHost: null,+ });+ assert.equal(+ consentRequest(new URLSearchParams({ redirect_uri: 'not a url' })).redirectHost,+ null,+ );+ assert.equal(consentRequest(new URLSearchParams()).clientId, null);+ });+});diff --git a/apps/web/src/features/mcp/utils/consentRequest.ts b/apps/web/src/features/mcp/utils/consentRequest.tsnew file mode 100644index 00000000..fda5dc1f--- /dev/null+++ b/apps/web/src/features/mcp/utils/consentRequest.ts@@ -0,0 +1,18 @@+// The consent page's URL carries the authorization request better-auth signed: which+// client asks, and where the answer is sent. The client picks its own name when it+// registers, so the redirect host is what tells the person where access really goes.+export function consentRequest(params: URLSearchParams): {+ clientId: string | null;+ redirectHost: string | null;+} {+ const redirect = params.get('redirect_uri');+ let redirectHost: string | null = null;+ if (redirect) {+ try {+ redirectHost = new URL(redirect).host || null;+ } catch {+ redirectHost = null;+ }+ }+ return { clientId: params.get('client_id'), redirectHost };+}diff --git a/apps/web/src/services/queryKeys.ts b/apps/web/src/services/queryKeys.tsindex 94afe7d1..2be8647c 100644--- a/apps/web/src/services/queryKeys.ts+++ b/apps/web/src/services/queryKeys.ts@@ -285,6 +285,8 @@ export const qk = {linkedAccounts: ['linkedAccounts'] as const,// The instance sign-in policy, including which social providers are configured.authConfig: ['authConfig'] as const,+ // The name an MCP client registered with, shown on the OAuth consent page.+ oauthClientName: (clientId: string) => ['oauthClientName', clientId] as const,// The signed-in user's personal API keys (API keys page).apiKeys: ['apiKeys'] as const,// The signed-in user's interface preferences (timezone, theme, issue open mode,