Skip to content

feat: chat model selector#16

Open
psrednicki wants to merge 14 commits into
operasoftware:mainfrom
psrednicki:feat/model-selector-mcp
Open

feat: chat model selector#16
psrednicki wants to merge 14 commits into
operasoftware:mainfrom
psrednicki:feat/model-selector-mcp

Conversation

@psrednicki
Copy link
Copy Markdown
Contributor

Add opera_list_models tool and model param to opera_chat

MCP-layer support for AI model selection. Adds a new tool to list available models and an optional model parameter on opera_chat to select which model to use [web:26][web:29].

Changes

  • model param on opera_chat — optional string passed through to Opera.dispatchAction({ action: 'chat', prompt, model }); omitted from the payload when not specified so the browser uses its default.
  • opera_list_models tool — new read-only page tool that calls Opera.dispatchAction({ action: 'listModels' }) and returns the JSON response; errors are caught and surfaced as a readable message.
  • CLI options — chrome-devtools-cli-options.ts updated with the new model arg on opera_chat and the new opera_list_models command entry.

CDP contract

Both tools use Opera.dispatchAction — no new CDP methods required.

ActionPayloadResponse

listModels

{ "action": "listModels" }
{ "models": [{ "id": "string", "name": "string", "isDefault": true }] }

chat with model

{ "action": "chat", "prompt": "string", "model": "string" }

Same as current chat response.

Usage

opera-browser-cli models
opera-browser-cli chat --model claude-sonnet-4 "Summarize this page"

Notes

  • --model applies to chat only — extensible to other AI commands later.
  • No client-side model persistence; each invocation is stateless.
  • Companion CLI support stays aligned with the MCP contract through opera_chat and opera_list_models.

psrednicki and others added 6 commits May 25, 2026 17:35
@psrednicki psrednicki requested a review from macieju-opera May 27, 2026 09:20
@psrednicki psrednicki self-assigned this May 27, 2026
Copy link
Copy Markdown
Contributor

@macieju-opera macieju-opera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

The implementation is clean and well-structured. Two things need fixing before merge.

Required

1. operaListModels description is missing the Opera Neon caveat

Every other Opera tool says: "Only available when connected to Opera Neon." operaListModels omits this. Without it, users on non-Neon browsers get a cryptic Opera.dispatchAction(listModels) failed error with no hint as to why. Needs to be added to both the definePageTool description in opera.ts and the CLI options entry.

2. chrome-devtools-cli-options.ts is auto-generated — should not be edited manually

The file header says // NOTE: do not edit manually. Auto-generated by 'npm run cli:generate'. The generate script (scripts/generate-cli.ts) spins up the local MCP server and fetches registered tools. Since operaListModels is exported from opera.ts and auto-registered via Object.values(operaTools) in tools.ts, running npm run gen after the opera.ts changes would produce the correct entries automatically. The manual additions will be silently overwritten the next time someone runs npm run gen. Please run npm run gen and commit the output instead of the hand-written entries.

Minor / Style

3. Payload construction inside try {}operaResearch (the direct precedent for optional-param payload building) builds the payload before the try block. The new operaChat handler builds it inside. Not a bug, but inconsistent with the established pattern.

4. Bracket notation: payload['model']payload.model for consistency with the rest of the file.

Not Issues

Auto-registration is fine — operaListModels is correctly picked up via Object.values(operaTools) in tools.ts. The Record<string, unknown> type and optional-field pattern match existing precedent.

- Introduced the `opera_list_models` tool to list available AI models for Opera chat.
- Updated README and tool reference documentation to reflect the addition of the new tool and its parameters.
- Added optional `model` parameter to the `opera_chat` tool documentation.
…y availability

- Enhanced the description of the `opera_list_models` tool to specify that it is only available when connected to Opera Neon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants