Skip to content

Settings location catalog: find_setting tool and a generated "Where each setting lives" docs page #2608

Closed

Description

@propr-dev

Context

Area 10 of the request asks that the documentation tool "be able to say where each remaining setting lives" — including settings that are intentionally not MCP-editable (secrets, credential paths, environment-only values). The previous issue produced an audit table in docs/mcp-coverage.md. A table in prose is hard for an agent to query reliably and drifts easily. This issue turns it into structured data served by MCP and a generated docs page, and adds a drift test.

Requirements

  1. New packages/api/mcp/settingsCatalog.ts exporting SETTINGS_CATALOG: SettingEntry[]:
    interface SettingEntry {
      id: string;                 // stable slug, e.g. 'trigger.bot_allowlist'
      label: string;              // "Allowed bot accounts"
      aliases: string[];          // "bot whitelist", "exempt bots", "github_bot_whitelist"
      scope: 'instance' | 'repository' | 'user' | 'environment';
      ui?: string;                // "Settings → Automation → Access"
      mcp?: { read?: string; write?: string };  // tool names
      cli?: string;               // "propr setting update github_user_whitelist <csv>"
      env?: string[];             // ["GITHUB_USER_WHITELIST"]
      restartRequired?: boolean;
      mcpStatus: 'read_write' | 'read_only' | 'browser_only' | 'environment_only';
      reason?: string;            // why browser/env only (e.g. "credential entry")
      docs?: string;              // docs page path for get_doc, e.g. 'operations/configuration-reference'
    }
    Seed it from the audit in docs/mcp-coverage.md and docs/docs/operations/configuration-reference.md (every documented env variable group gets an entry; group closely related variables, e.g. all *_TIMEOUT_MS agent timeouts as one entry with several env values).
  2. New tool find_setting (scope read, in toolsDocs.ts): { query (2..100 chars), limit ≤ 10 } → matching entries ranked by label/alias/id/env-name match, each with a one-sentence howToChange built from the entry (e.g. "Change it with update_trigger_access_configuration, or in Settings → Automation → Access."). Entries whose MCP tool requires a permission the caller lacks still appear (location info is not secret) but say "requires instance.manage_settings".
  3. Script scripts/generate-settings-docs.mjs renders the catalog to docs/docs/operations/settings-locations.md (front matter title: Where Each Setting Lives, sidebar_position), grouped by scope, one table per group. Add the page to docs/sidebars.ts under Operations next to Configuration Reference.
    • The script imports the catalog via tsx (already a dev dependency) or reads a JSON export; choose the simplest that works in CI without building.
  4. Drift tests (packages/api/test/settingsCatalog.test.ts):
    • every mcp.read/mcp.write name exists in createToolCatalog(...);
    • every tool whose name matches /^(get|update)_.*(settings|configuration|keywords|labels|label|tag|policy)$/ appears in at least one catalog entry (so new config tools must be catalogued);
    • every docs path exists in the docs index;
    • the committed settings-locations.md equals the generator's output (run generator in-memory and compare).
  5. docs/mcp-coverage.md "Settings reachability" section is replaced by a pointer to the generated page and find_setting (single source of truth).

Implementation Specification

  • New packages/api/mcp/settingsCatalog.ts, edit packages/api/mcp/toolsDocs.ts (find_setting), new scripts/generate-settings-docs.mjs, new docs/docs/operations/settings-locations.md (generated, committed), edit docs/sidebars.ts, docs/mcp-coverage.md, new test.
  • Add an npm script docs:settings in the root package.json running the generator.

Acceptance Criteria

  • find_setting({ query: 'bot whitelist' }) returns the bot allowlist entry with mcp.write === 'update_trigger_access_configuration' and the UI location.
  • find_setting({ query: 'CODEX_TIMEOUT_MS' }) returns the agent timeout entry with mcpStatus: 'environment_only', restartRequired: true and docs: 'operations/configuration-reference'.
  • find_setting({ query: 'visual preview token' }) explains it is browser-only (credential entry) and where.
  • Drift tests fail if a new update_*_settings tool is added without a catalog entry, or the generated page is stale.
  • The docs site builds with the new page (cd docs && npm run build).

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Sep 28, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    We make the setting-location knowledge data (a typed catalog in the API package), render the docs page from it, and test both directions (tools ↔ catalog, catalog ↔ docs). Hand-maintained prose was rejected because it silently drifts, and scraping the Settings UI at runtime is brittle. Placing the catalog in packages/api lets the drift test import the live tool catalog directly.

    find_setting lives with the docs tools because it answers a documentation question ("where do I change X?") and works even for settings MCP cannot edit.

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

    Why this file: Single source of truth for where each setting lives.

    export type SettingScope = 'instance' | 'repository' | 'user' | 'environment';
    export type SettingMcpStatus = 'read_write' | 'read_only' | 'browser_only' | 'environment_only';
    
    export interface SettingEntry {
      id: string; label: string; aliases: string[]; scope: SettingScope;
      ui?: string; mcp?: { read?: string; write?: string; permission?: string }; cli?: string; env?: string[];
      restartRequired?: boolean; mcpStatus: SettingMcpStatus; reason?: string; docs?: string;
    }
    
    export const SETTINGS_CATALOG: SettingEntry[] = [
      { id: 'trigger.user_allowlist', label: 'Users allowed to trigger ProPR', aliases: ['user whitelist', 'allowed users', 'github_user_whitelist'],
        scope: 'instance', ui: 'Settings → Automation → Access',
        mcp: { read: 'get_trigger_access_configuration', write: 'update_trigger_access_configuration', permission: 'instance.manage_settings' },
        cli: 'propr setting update github_user_whitelist "alice,bob"', env: ['GITHUB_USER_WHITELIST'], mcpStatus: 'read_write', docs: 'features/pr-commands' },
      { id: 'trigger.bot_allowlist', label: 'Allowed (exempt) bot accounts', aliases: ['bot whitelist', 'exempt bots', 'whitelisted bots', 'allowed bots'],
        scope: 'instance', ui: 'Settings → Automation → Access',
        mcp: { read: 'get_trigger_access_configuration', write: 'update_trigger_access_configuration', permission: 'instance.manage_settings' },
        mcpStatus: 'read_write', docs: 'features/pr-commands' },
      { id: 'trigger.user_blocklist', label: 'Users blocked from triggering ProPR', aliases: ['blacklist', 'blocked users'],
        scope: 'environment', env: ['GITHUB_USER_BLACKLIST'], restartRequired: true, mcp: { read: 'get_trigger_access_configuration' },
        mcpStatus: 'environment_only', reason: 'Only configurable in the stack .env file.', docs: 'operations/configuration-reference' },
      { id: 'agents.timeouts', label: 'Agent run timeouts', aliases: ['timeout', 'agent timeout', 'max turns'],
        scope: 'environment', env: ['CLAUDE_TIMEOUT_MS', 'CODEX_TIMEOUT_MS', 'ANTIGRAVITY_TIMEOUT_MS', 'OPENCODE_TIMEOUT_MS', 'VIBE_TIMEOUT_MS', 'CLAUDE_MAX_TURNS', 'VIBE_MAX_TURNS'],
        restartRequired: true, mcpStatus: 'environment_only', reason: 'Host process configuration read at worker start.', docs: 'operations/configuration-reference' },
      { id: 'visual_previews.upload_credential', label: 'Visual preview upload credential', aliases: ['visual preview token', 'preview uploads', 'GITHUB_VISUAL_PREVIEW_TOKEN'],
        scope: 'instance', ui: 'Settings → Integrations → Visual preview uploads', env: ['GITHUB_VISUAL_PREVIEW_TOKEN'],
        mcpStatus: 'browser_only', reason: 'Credential entry is never accepted through MCP.', docs: 'features/visual-previews' },
      // ...complete from the audit table and configuration-reference.md (execution settings, review settings,
      // ultrafix defaults, follow-up keywords, labels, repository settings, indexing, provider policy, agents,
      // synthetic agents, runtime packages, notification preferences, MCP settings, tunnel, intake mode, ...)
    ];
    
    const normalize = (value: string) => value.toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
    
    export function findSettings(query: string, limit: number): Array<SettingEntry & { score: number; howToChange: string }> {
      const terms = normalize(query).split(' ').filter(Boolean);
      return SETTINGS_CATALOG.map(entry => {
        const haystacks: Array<[string, number]> = [[entry.label, 4], [entry.id, 3], ...entry.aliases.map(alias => [alias, 5] as [string, number]),
          ...(entry.env ?? []).map(env => [env, 6] as [string, number]), [entry.ui ?? '', 1]];
        let score = 0;
        for (const term of terms) for (const [text, weight] of haystacks) if (normalize(text).includes(term)) score += weight;
        // Exact env-var or alias matches should win outright.
        if (haystacks.some(([text]) => normalize(text) === normalize(query))) score += 20;
        return { ...entry, score, howToChange: howToChange(entry) };
      }).filter(entry => entry.score > 0).sort((a, b) => b.score - a.score).slice(0, limit);
    }
    
    export function howToChange(entry: SettingEntry): string {
      const parts: string[] = [];
      if (entry.mcp?.write) parts.push(`with the MCP tool ${entry.mcp.write}${entry.mcp.permission ? ` (requires ${entry.mcp.permission})` : ''}`);
      if (entry.ui) parts.push(`in ${entry.ui}`);
      if (entry.cli) parts.push(`with \`${entry.cli}\``);
      if (entry.env?.length) parts.push(`by setting ${entry.env.join(', ')} in the stack .env${entry.restartRequired ? ' and restarting (propr start --restart)' : ''}`);
      const base = parts.length ? `Change it ${parts.join(', or ')}.` : 'It is not user-configurable.';
      return entry.reason ? `${base} ${entry.reason}` : base;
    }

    File: packages/api/mcp/toolsDocs.ts

    Why this file: find_setting is a documentation lookup; it sits with search_docs.

    +import { findSettings } from './settingsCatalog.js';
    @@ export function addDocsTools(...)
    +  tools.push({ name: 'find_setting', description: 'Find where a ProPR setting lives and how to change it: Web UI location, MCP tool, CLI command or environment variable, including settings MCP deliberately cannot edit (credentials, host configuration).', scope: 'read', readOnly: true,
    +    schema: z.object({ query: z.string().min(2).max(100), limit: z.number().int().min(1).max(10).default(5) }).strict(),
    +    run: async ({ principal, args }) => ok({ results: findSettings(args.query, args.limit).map(({ score: _score, ...entry }) => ({
    +      ...entry,
    +      // Location info is not secret; just tell the caller if they cannot use the write tool.
    +      callerCanWrite: !entry.mcp?.permission || principal.authorization.permissions.includes(entry.mcp.permission as never),
    +    })) }) });

    File: scripts/generate-settings-docs.mjs (new file)

    Why this file: Renders the catalog to Markdown so the docs site and get_doc show the same data.

    #!/usr/bin/env node
    // Usage: node --import tsx scripts/generate-settings-docs.mjs [--check]
    import { readFileSync, writeFileSync } from 'node:fs';
    import path from 'node:path';
    import { fileURLToPath } from 'node:url';
    
    const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
    const target = path.join(root, 'docs', 'docs', 'operations', 'settings-locations.md');
    
    export async function renderSettingsDocs() {
      const { SETTINGS_CATALOG, howToChange } = await import('../packages/api/mcp/settingsCatalog.ts');
      const escape = value => String(value ?? '—').replace(/\|/g, '\\|');
      const groups = { instance: 'Instance settings', repository: 'Repository settings', user: 'Personal settings', environment: 'Environment-only settings' };
      let out = `---\ntitle: Where Each Setting Lives\nsidebar_position: 11\n---\n\n<!-- Generated by scripts/generate-settings-docs.mjs from packages/api/mcp/settingsCatalog.ts. Do not edit by hand. -->\n\n# Where Each Setting Lives\n\nMCP clients can ask \`find_setting\` for the same information.\n`;
      for (const [scope, heading] of Object.entries(groups)) {
        const entries = SETTINGS_CATALOG.filter(entry => entry.scope === scope);
        if (!entries.length) continue;
        out += `\n## ${heading}\n\n| Setting | Web UI | MCP | CLI / environment | How to change |\n|---|---|---|---|---|\n`;
        for (const entry of entries) {
          const mcp = entry.mcp ? [entry.mcp.read, entry.mcp.write].filter(Boolean).map(name => `\`${name}\``).join(' / ') : entry.mcpStatus.replace('_', ' ');
          const cliEnv = [entry.cli && `\`${entry.cli}\``, ...(entry.env ?? []).map(env => `\`${env}\``)].filter(Boolean).join('<br />') || '—';
          out += `| ${escape(entry.label)} | ${escape(entry.ui)} | ${mcp} | ${cliEnv} | ${escape(howToChange(entry))} |\n`;
        }
      }
      return out;
    }
    
    if (import.meta.url === `file://${process.argv[1]}`) {
      const content = await renderSettingsDocs();
      if (process.argv.includes('--check')) {
        if (readFileSync(target, 'utf8') !== content) { console.error('settings-locations.md is stale: run npm run docs:settings'); process.exit(1); }
      } else writeFileSync(target, content);
    }

    Root package.json: "docs:settings": "node --import tsx scripts/generate-settings-docs.mjs".

    File: docs/sidebars.ts

             'operations/configuration-reference',
    +        'operations/settings-locations',

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

    Why this file: Enforces that catalog, tools and docs stay in sync.

    import assert from 'node:assert/strict';
    import { test } from 'node:test';
    import { readFileSync } from 'node:fs';
    import { SETTINGS_CATALOG, findSettings } from '../mcp/settingsCatalog.js';
    // Build the catalog with the same stub deps as mcpOperatorSurface.test.ts.
    import { buildTestCatalog } from './fixtures/mcpCatalog.js';
    import { renderSettingsDocs } from '../../../scripts/generate-settings-docs.mjs';
    
    test('catalog tool names exist and config tools are catalogued', async () => {
      const names = new Set((await buildTestCatalog()).map(tool => tool.name));
      for (const entry of SETTINGS_CATALOG) for (const tool of [entry.mcp?.read, entry.mcp?.write].filter(Boolean)) assert.ok(names.has(tool!), `${entry.id}: ${tool}`);
      const referenced = new Set(SETTINGS_CATALOG.flatMap(entry => [entry.mcp?.read, entry.mcp?.write]));
      for (const name of names) {
        if (/^(get|update)_.*(settings|configuration|keywords|labels|label|tag|policy)$/.test(name)) assert.ok(referenced.has(name), `uncatalogued config tool ${name}`);
      }
    });
    
    test('queries resolve to the right entries', () => {
      assert.equal(findSettings('bot whitelist', 1)[0].id, 'trigger.bot_allowlist');
      assert.equal(findSettings('CODEX_TIMEOUT_MS', 1)[0].mcpStatus, 'environment_only');
    });
    
    test('generated docs page is current', async () => {
      assert.equal(readFileSync(new URL('../../../docs/docs/operations/settings-locations.md', import.meta.url), 'utf8'), await renderSettingsDocs());
    });

    If no shared catalog fixture exists, add packages/api/test/fixtures/mcpCatalog.ts exporting buildTestCatalog() that calls createToolCatalog with the stub deps used in mcpOperatorSurface.test.ts.

  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: 2608/gpt-5.6-sol-settings-location-catalog-20260930-0149-j1c
    • Base Branch: 2593-epic-mcp-observability-cf6
    • Worktree: issue-2608-20260930-0149-gpt-5.6-sol-j1c

    🔍 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