Skip to content

MCP configuration coverage: expose trigger access settings (user allowlist, blocklist and exempt/allowed bots) and audit which settings are MCP-reachable #2607

Closed

Description

@propr-dev

Context

Some instance settings exist in the Web UI (Settings) but are neither readable nor editable through MCP. The reported example: an agent asked to "add a bot to the whitelist" could not find the whitelisted/exempt bots list anywhere. Related trigger-access settings are also UI/CLI-only today:

  • github_user_whitelist (settings key, also GITHUB_USER_WHITELIST env; see packages/cli/src/api/settings.ts),
  • GITHUB_USER_BLACKLIST (env; see docs/docs/features/pr-commands.md "Who Can Trigger Commands"),
  • the whitelisted/exempt bots list edited in the Settings UI. Bot accounts are ignored by default ([bot] suffix or type Bot); per packages/shared/src/userWhitelist.ts, bots must be listed explicitly (name[bot]) to be allowed.

Existing MCP configuration tools live in packages/api/mcp/toolsConfiguration.ts and packages/api/mcp/toolsManagement.ts (get_execution_settings / update_execution_settings).

Requirements

  1. Locate the bot list setting before coding: search propr-ui/src (Settings page components) for "bot" and follow the save call to its backend key in packages/api/routes/configSettings.ts / configRoutesSettings.ts (extractSettingSaves). Record the exact key in a single constant BOT_ALLOWLIST_SETTING in the new module. If the UI actually writes it into github_user_whitelist (as name[bot] entries), model bots as the [bot]-suffixed subset of that list instead of a separate key — the tool contract below stays the same.
  2. New tools (permission instance.manage_settings, scope manage):
    • get_trigger_access_configuration → { revision, users: { allowlist: string[], blocklist: string[], source: { allowlist: 'settings'|'environment'|'both', blocklist: 'environment' } }, bots: { allowlist: string[], source }, notes }. Environment-sourced values are reported read-only (editable: false) with the env variable name.
    • update_trigger_access_configuration → mutation with expectedRevision and explicit operations: { addUsers?, removeUsers?, addBots?, removeBots? } (arrays of GitHub logins, validated ^[A-Za-z0-9-]{1,39}(\[bot\])?$, bots normalised to name[bot]). Replace-all is deliberately not offered (avoids accidentally locking everyone out). Removing the last allowlisted user when the allowlist is non-empty requires confirmOpenAccess: true because an empty allowlist means "everyone" (per isGithubUserWhitelisted).
    • Refuse to edit values that are environment-controlled with SETTING_ENVIRONMENT_MANAGED (409, precondition) and a message naming the variable.
  3. Persistence goes through the existing settings route handler (config.postSettings via callWorkflow) so validation, Redis lock, revision checks, events and activity logging are identical to the UI.
  4. Audit: produce the table of instance and repository settings with columns setting, UI location, MCP read, MCP write, CLI, env, status (covered / added in this issue / intentionally browser-only with reason) in docs/mcp-coverage.md under a new heading "Settings reachability". Source the list by reading SystemSettings in packages/cli/src/api/settings.ts, extractSettingSaves in configSettings.ts, repository options in configRepoValidation.ts, and the Settings UI sections. Add MCP read/update for any safe setting found missing (non-secret, not credential paths) — at minimum the trigger access settings; list the rest with justification.
  5. The audit data is also encoded in packages/api/mcp/settingsCatalog.ts (created in the next issue); keep the table and catalog in sync (next issue adds a test).

Implementation Specification

  • New packages/api/mcp/toolsTriggerAccess.ts; register in createToolCatalog (or from addConfigurationTools).
  • Reuse configRevision from packages/api/routes/configRevision.ts for expectedRevision.
  • Edit docs/mcp-coverage.md (audit table) and docs/docs/features/pr-commands.md ("Who Can Trigger Commands" → mention the MCP tools and the bot list).
  • Tests packages/api/test/mcpTriggerAccess.test.ts.

Acceptance Criteria

  • get_trigger_access_configuration shows the bot list exactly as the Settings UI shows it.
  • update_trigger_access_configuration({ addBots: ['renovate'] }) persists renovate[bot], and the UI shows it after reload; the daemon/worker filter then accepts comments from renovate[bot].
  • A stale expectedRevision fails with STALE_REVISION; a concurrent UI save is not overwritten.
  • Without instance.manage_settings both tools are hidden from tools/list and denied on call.
  • Removing the last allowlisted user without confirmOpenAccess fails with CONFIRMATION_REQUIRED.
  • The audit table is present and every row with MCP read = "yes" names an existing tool.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Sep 28, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    We add a purpose-named tool pair for trigger access instead of adding the keys to the generic update_execution_settings. Access control lists are security-sensitive; explicit add/remove operations with an open-access confirmation are much safer for an agent than replacing a whole list, and a dedicated name makes the capability discoverable ("add a bot to the whitelist" maps directly to update_trigger_access_configuration). Persistence still goes through the existing settings workflow so the UI, CLI and MCP share validation, locking and events.

    File: packages/api/mcp/toolsTriggerAccess.ts (new file)

    Why this file: Keeps the security-sensitive access-list logic isolated and reviewable.

    import { z } from 'zod';
    import type { createConfigRoutes } from '../routes/configRoutes.js';
    import { configRevision } from '../routes/configRevision.js';
    import { callWorkflow } from './adapter.js';
    import { McpError } from './config.js';
    import { type McpTool, type ToolDeps, mutationShape, ok } from './tools.js';
    
    /**
     * Settings key used by the Settings UI for allowed (exempt) bot accounts.
     * Confirm against propr-ui Settings + configSettings.ts before merging; if bots
     * live inside github_user_whitelist, set this to null and see `botsFromUsers`.
     */
    export const BOT_ALLOWLIST_SETTING: string | null = 'github_bot_whitelist';
    const USER_ALLOWLIST_SETTING = 'github_user_whitelist';
    
    const LOGIN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})(\[bot\])?$/;
    const login = z.string().regex(LOGIN);
    const toBot = (name: string) => name.endsWith('[bot]') ? name : `${name}[bot]`;
    const envList = (name: string) => (process.env[name] ?? '').split(',').map(entry => entry.trim()).filter(Boolean);
    const same = (a: string, b: string) => a.toLowerCase() === b.toLowerCase();
    
    interface AccessSnapshot { users: string[]; bots: string[]; settings: Record<string, unknown> }
    
    async function readAccess(config: ReturnType<typeof createConfigRoutes>, principal: Parameters<McpTool['run']>[0]['principal']): Promise<AccessSnapshot> {
      const response = await callWorkflow(config.getSettings, principal, {});
      const settings = response.data as Record<string, unknown>;
      const asList = (value: unknown) => Array.isArray(value) ? value.map(String) : typeof value === 'string' ? value.split(',').map(s => s.trim()).filter(Boolean) : [];
      const combined = asList(settings[USER_ALLOWLIST_SETTING]);
      const bots = BOT_ALLOWLIST_SETTING ? asList(settings[BOT_ALLOWLIST_SETTING]) : combined.filter(entry => entry.endsWith('[bot]'));
      const users = BOT_ALLOWLIST_SETTING ? combined : combined.filter(entry => !entry.endsWith('[bot]'));
      return { users, bots, settings };
    }
    
    export function addTriggerAccessTools(tools: McpTool[], _deps: ToolDeps, config: ReturnType<typeof createConfigRoutes>): void {
      tools.push({ name: 'get_trigger_access_configuration', description: 'Read who may trigger ProPR from GitHub: the user allowlist and blocklist, and the allowlisted (exempt) bot accounts. Values set by environment variables are reported as read-only.', scope: 'manage', permission: 'instance.manage_settings', readOnly: true,
        schema: z.object({}).strict(), run: async ({ principal }) => {
          const access = await readAccess(config, principal);
          const envAllow = envList('GITHUB_USER_WHITELIST');
          return ok({
            revision: configRevision({ users: access.users, bots: access.bots }),
            users: { allowlist: access.users, blocklist: envList('GITHUB_USER_BLACKLIST'),
              source: { allowlist: envAllow.length ? (access.users.length ? 'both' : 'environment') : 'settings', blocklist: 'environment' },
              environmentAllowlist: envAllow, editable: { allowlist: true, blocklist: false } },
            bots: { allowlist: access.bots, editable: true },
            notes: [
              'An empty user allowlist means every GitHub user may trigger ProPR.',
              'Bot accounts are ignored unless listed here as name[bot].',
              'GITHUB_USER_BLACKLIST is environment-only; change it in the stack .env and restart.',
            ],
          });
        } });
      tools.push({ name: 'update_trigger_access_configuration', description: 'Add or remove GitHub users and bots allowed to trigger ProPR (e.g. "add renovate to the bot whitelist"). Uses explicit add/remove operations at an exact revision; removing the last allowlisted user requires confirmOpenAccess because an empty list allows everyone.', scope: 'manage', permission: 'instance.manage_settings',
        schema: z.object({ ...mutationShape, expectedRevision: z.string().min(1).max(128),
          addUsers: z.array(login).max(50).default([]), removeUsers: z.array(login).max(50).default([]),
          addBots: z.array(login).max(50).default([]), removeBots: z.array(login).max(50).default([]),
          confirmOpenAccess: z.boolean().default(false) }).strict(),
        run: async ({ principal, args }) => {
          const access = await readAccess(config, principal);
          const revision = configRevision({ users: access.users, bots: access.bots });
          if (revision !== args.expectedRevision) {
            throw new McpError('STALE_REVISION', 'Trigger access changed since you read it. Read it again and reapply your change.', 409, { stage: 'precondition' });
          }
          if (args.addUsers.some((user: string) => user.endsWith('[bot]'))) {
            throw new McpError('INVALID_INPUT', 'Add bot accounts with addBots, not addUsers.', 400, { stage: 'validation' });
          }
          const users = [...access.users.filter(user => !args.removeUsers.some((r: string) => same(r, user))),
            ...args.addUsers.filter((user: string) => !access.users.some(existing => same(existing, user)))];
          const bots = [...access.bots.filter(bot => !args.removeBots.map(toBot).some((r: string) => same(r, bot))),
            ...args.addBots.map(toBot).filter((bot: string) => !access.bots.some(existing => same(existing, bot)))];
          if (access.users.length > 0 && users.length === 0 && !args.confirmOpenAccess) {
            throw new McpError('CONFIRMATION_REQUIRED', 'This removes every allowlisted user, which lets ANY GitHub user trigger ProPR. Repeat with confirmOpenAccess: true if that is intended.', 409, { stage: 'precondition' });
          }
          // Same handler as the Settings UI: validation, lock, events, activity log.
          const settings = BOT_ALLOWLIST_SETTING
            ? { [USER_ALLOWLIST_SETTING]: users, [BOT_ALLOWLIST_SETTING]: bots }
            : { [USER_ALLOWLIST_SETTING]: [...users, ...bots] };
          await callWorkflow(config.postSettings, principal, { body: { settings } });
          return ok({ users, bots, revision: configRevision({ users, bots }),
            changed: { addedUsers: args.addUsers, removedUsers: args.removeUsers, addedBots: args.addBots.map(toBot), removedBots: args.removeBots.map(toBot) } });
        } });
    }

    Wire it in toolsConfiguration.ts (it already receives config):

    +import { addTriggerAccessTools } from './toolsTriggerAccess.js';
     export function addConfigurationTools(tools: McpTool[], deps: ToolDeps, config: ReturnType<typeof createConfigRoutes>): void {
    +  addTriggerAccessTools(tools, deps, config);

    If config.getSettings/config.postSettings have different names in createConfigRoutes, use the handlers the Settings page calls for /api/config/settings (GET/POST), exactly as packages/cli/src/api/settings.ts does.

    File: docs/mcp-coverage.md

    Why this file: The authoritative capability matrix; the audit belongs here so operators and the docs tool can answer "where is setting X?".

    ## Settings reachability
    
    | Setting | UI location | MCP read | MCP write | CLI | Env | Status |
    |---|---|---|---|---|---|---|
    | User trigger allowlist (`github_user_whitelist`) | Settings → Automation → Access | `get_trigger_access_configuration` | `update_trigger_access_configuration` | `propr setting update github_user_whitelist` | `GITHUB_USER_WHITELIST` | added |
    | Allowed/exempt bots | Settings → Automation → Access | `get_trigger_access_configuration` | `update_trigger_access_configuration` | — | — | added |
    | User blocklist | — | `get_trigger_access_configuration` | — | — | `GITHUB_USER_BLACKLIST` | env-only (restart required) |
    | Worker concurrency, review model/prompt/budget, ultrafix defaults, reasoning level | Settings → AI & Models / Automation | `get_execution_settings` | `update_execution_settings` | `propr setting update …` | — | covered |
    | Follow-up keywords / ignore keywords, processing labels, PR label, AI tag | Settings → Automation | `get_followup_keywords` … | `update_…` | `propr setting update …` | `PR_FOLLOWUP_TRIGGER_KEYWORDS`, `PRIMARY_PROCESSING_LABELS` | covered |
    | Repository branch/alias/enabled/CI follow-up/visual previews | Repositories → repository → Settings | `get_repository_configuration` | `update_repository_configuration` | `propr repo toggle` | — | covered |
    | Visual preview upload credential | Settings → Integrations | — | — | — | `GITHUB_VISUAL_PREVIEW_TOKEN` | browser-only: credential entry |
    | Agent credentials / login | AI Agents | `get_agent_configuration` (no secrets) | — | `propr agent login` | `HOST_*_DIR` | browser-only: secret entry |
    | MCP enablement / scope ceiling | Settings → MCP | — | — | — | `MCP_ENABLED` | browser-only: grant boundary |
    | … (complete from the sources listed in the issue) | | | | | | |

    File: packages/api/test/mcpTriggerAccess.test.ts (new file)

    Why this file: Proves revision safety, bot normalisation, permission gating and the open-access guard.

    // Pattern: mcpReviewerConcurrency.test.ts (migrated SQLite, in-memory Redis stub, executeTool).
    // - admin principal with instance.manage_settings: get -> revision R; update(addBots:['renovate'], expectedRevision R)
    //   -> settings row contains 'renovate[bot]'; get again shows it.
    // - update with stale revision -> STALE_REVISION.
    // - allowlist ['alice']; update(removeUsers:['alice']) -> CONFIRMATION_REQUIRED; with confirmOpenAccess -> []
    // - member principal without permission -> tools absent from catalog listing and executeTool denies.
    // - isGithubUserWhitelisted('renovate[bot]') true after the update (when bots share the user list) or the
    //   daemon's bot filter reads BOT_ALLOWLIST_SETTING (assert via the same loader the daemon uses).
  2. propr-dev commented on Sep 30, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using codex agent with gpt-5.6-sol model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: codex
    • Model: gpt-5.6-sol
    • Branch: 2607/gpt-5.6-sol-mcp-configuration-coverag-20260930-0107-qha
    • Base Branch: 2593-epic-mcp-observability-cf6
    • Worktree: issue-2607-20260930-0107-gpt-5.6-sol-qha

    🔍 Track Task Execution

  3. added a commit that references this issue on Sep 30, 2026
  4. added a commit that references this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions