Add scoped chat MCP tool#58
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new MCP tool to send messages (and optional file uploads) into an existing provider “scoped workspace” (ChatGPT Projects, Claude Projects, Perplexity Spaces, Gemini Gems) via the logged-in browser session.
Changes:
- Introduce scoped-chat URL parsing/normalization helpers and local file path resolution for uploads.
- Add
AIProvider.scopedChat()with queueing, navigation-to-scope, optional uploads, and DOM-mode sending. - Document the new
ask_scoped_chattool and provide example payloads.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/mcp-server-v3.js | Implements scoped-chat URL parsing, file resolution, provider method + MCP tool wiring, and result formatting. |
| README.md | Documents ask_scoped_chat and provides provider-specific examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review by Qodo
1.
|
PR Summary by QodoAdd ask_scoped_chat MCP tool for project-scoped provider workspaces WalkthroughsDescription• Add ask_scoped_chat tool to send messages inside existing provider workspaces via DOM mode. • Validate scoped workspace URLs and match identity before reusing the logged-in browser session. • Document scoped chat usage and examples for ChatGPT, Claude, Perplexity, and Gemini. Diagramgraph TD
A{{"ask_scoped_chat"}} --> B["mcp-server-v3"] --> C["AIProvider.scopedChat (queue)"] --> D["IPC actions (navigate/upload/send)"] --> E["Embedded browser session"] --> F["Scoped workspace page"]
B --> G["Scoped URL + identity validation"]
High-Level AssessmentThe following are alternative approaches to this PR: 1. Auto-detect provider from scopeUrl
2. Provider-specific scoped tools (ask_chatgpt_project, ask_claude_project, ...)
3. Persist scope identity as session state (implicit continuation)
Recommendation: The PR’s approach (explicit provider + validated scopeUrl, identity matching, and DOM-mode sending) is a solid default: it keeps workspace context correctly and reuses existing IPC primitives without expanding provider-specific tooling. If ergonomics become a pain point, consider optional provider auto-detection as a follow-up, but keep explicit File ChangesEnhancement (1)
Documentation (1)
|
- Canonicalize scope identity using the first configured segment so equivalent URLs (e.g. /project/<id> vs /projects/<id>) resolve to the same identity; ask_scoped_chat(newChat=false) now reuses the current scope instead of re-navigating. - Only count successful file uploads. Check uploadResult.success, skip the post-upload settle/wait for failures, and surface failed uploads in the result instead of reporting every attempt as uploaded. - Return a canonical /gem/<id> landing URL for the Gemini gem-ID query form, clearing hash/query to match the segment-based branch behavior.
a458976 to
23a2f17
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 145e530 |
ask_scoped_chat sends with forceDOM=true and then reads the result via getResponseWithTyping, which prefers _apiResponseCache[provider] when present. The forceDOM branch of sendMessageToProvider never cleared that cache, so a stale API response left populated by a prior request (e.g. a REST queryProvider that used sendResult.result.response directly and skipped getResponseWithTyping) could be returned instead of the actual DOM response. Delete _apiResponseCache[provider] when forceDOM=true so DOM-mode sends are always answered by the live DOM response. This closes the only staleness vector: every non-DOM caller of getResponseWithTyping is already preceded by an API-first send that refreshes or clears the cache.
Summary
Closes #57.
Adds a generic
ask_scoped_chatMCP tool for sending messages inside existing project-like provider workspaces through the logged-in embedded browser session.What changed
scopedChatpath that reuses existing IPC actions: provider init, navigation, uploads, send-button readiness, DOM-mode send, and response capture.Why
Regular provider tools are useful for ordinary chats, but project-like workspaces have saved instructions, files, and knowledge that apply only inside the scoped provider page. This tool intentionally uses DOM mode instead of API-first sending so the provider page keeps that workspace context.
Validation
npm cinode --check src/mcp-server-v3.jsnode --check electron/main-v2.cjstimeout 5s node src/mcp-server-v3.js </dev/nullThe MCP startup probe reached
MCP Server running; it warned that Agent Hub was not listening on127.0.0.1:19222, which is expected when the Electron app is not running during this check.