Skip to content

[Feature] API: database selection via query parameter or header #104

Description

@npozs77

Description Allow external API callers (service-accounts, MCP server) to target a specific database per request, rather than always using the server's currently active database. ## Use Case An MCP server or automation container authenticated via API key needs to query a specific vocabulary database (e.g., vocabgen-dutch.db) without depending on which database was last selected in the web UI. ## Current Behavior The API always reads from the server's active database (configured via config.yaml db_path or last switched via the web UI database picker). External callers have no way to specify which database to target. ## Proposed Options ### Option A: Query parameter GET /api/words?db=vocabgen-dutch.db ### Option B: Request header X-VocabGen-Database: vocabgen-dutch.db ### Option C: Per-service-account binding in users.yaml yaml service_accounts: - name: mcp-server key_hash: "$2a$..." scope: read-only database: vocabgen-dutch.db ## Acceptance Criteria - WHEN an API request specifies a database, THE server SHALL use that database for the request - WHEN the specified database does not exist, THE server SHALL return 404 JSON - WHEN no database is specified, THE server SHALL use the default (current behavior) - WHEN a service-account has a bound database, THE server SHALL use it regardless of the active UI database ## Notes - This is a follow-up to #101 (API-key auth for service-accounts) - Low priority — default DB is sufficient for most single-DB deployments - Security: restrict to databases in the config directory only (no arbitrary path traversal) ## Target Release v1.6.0 (or later)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions