Skip to content

fix: ChatGPT cannot find allowed workspaces without a root catalog - #177

Open
dbc-hbin wants to merge 2 commits into
Waishnav:mainfrom
dbc-hbin:agent/chatgpt-find-allowed-workspaces
Open

fix: ChatGPT cannot find allowed workspaces without a root catalog#177
dbc-hbin wants to merge 2 commits into
Waishnav:mainfrom
dbc-hbin:agent/chatgpt-find-allowed-workspaces

Conversation

@dbc-hbin

@dbc-hbin dbc-hbin commented Aug 10, 2026

Copy link
Copy Markdown

ChatGPT cannot know an arbitrary local filesystem path before it opens a workspace. With multiple configured roots, it can therefore guess a path outside the DevSpace boundary and fail before it has a usable workspace ID.

Add a read-only list_allowed_roots tool that returns only the configured root catalog. Server instructions direct the host to use it when the project path is unknown, and rejected paths now include the same actionable catalog. The change does not scan directories or widen filesystem access.

Validated with npm run typecheck, npx tsx src/roots.test.ts, npx tsx src/server.test.ts, and npm run build.

Development attribution

Built with the Codex desktop coding harness using gpt-5.6-sol. The change was inspected, implemented, and validated against the local repository checkout; the tests listed above were run on the submitted commit.

Summary by CodeRabbit

  • New Features
    • Added a tool to list configured workspace names and paths before opening a workspace.
    • Workspace discovery now guides users to identify an available workspace when none is specified.
    • Workspace listings are available in both structured and readable text formats.
  • Bug Fixes
    • Access-denied messages now include allowed workspace locations, making path restrictions clearer.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The server adds a read-only list_allowed_roots tool. It returns configured workspace names and paths. Instructions require root discovery before opening an unspecified workspace. Access-denied errors now include the configured allowed roots.

Changes

Allowed root discovery and diagnostics

Layer / File(s) Summary
Allowed roots in access errors
src/roots.ts, src/roots.test.ts
Access-denied messages now include the rejected path and all configured allowed roots. Tests verify the error type and message.
Root listing tool and discovery guidance
src/server.ts, src/server.test.ts
The server lists configured roots as structured and text content. Instructions require list_allowed_roots before opening an unspecified workspace. Tests verify names, paths, response text, and instruction omission.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant MCPServer
  participant AllowedRoots
  Caller->>MCPServer: Call list_allowed_roots
  MCPServer->>AllowedRoots: Read configured root paths
  AllowedRoots-->>MCPServer: Return root names and paths
  MCPServer-->>Caller: Return structured and text content
Loading

Possibly related PRs

Suggested reviewers: waishnav

Poem

A rabbit lists each allowed root,
With name and path in clear pursuit.
Unknown workspaces wait to start,
Rejected paths show every part.
Hop, hop—root discovery is smart!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding a root catalog so ChatGPT can discover allowed workspaces.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a read-only workspace-root discovery tool so MCP hosts can select a configured project boundary before opening a workspace.

  • Registers list_allowed_roots in every tool mode with text and structured output.
  • Updates server instructions to use root discovery rather than guessing paths.
  • Adds the allowed-root catalog to rejected-path diagnostics.
  • Tests discovery before workspace creation and verifies that project instructions are not exposed.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking defects identified.

The new tool exposes only the intentionally configured root catalog to authenticated MCP clients, while existing path validation remains responsible for enforcing workspace boundaries.

Important Files Changed

Filename Overview
src/server.ts Adds root discovery, updates host instructions, and returns the configured catalog without widening workspace access.
src/roots.ts Makes denied-path errors actionable by including the same configured allowed-root catalog.
src/server.test.ts Verifies pre-workspace root discovery and confirms the response excludes project instructions.

Sequence Diagram

sequenceDiagram
    participant Host as MCP Host
    participant Server as DevSpace Server
    Host->>Server: list_allowed_roots()
    Server-->>Host: Configured root names and paths
    Host->>Server: open_workspace(path under listed root)
    Server->>Server: Validate path against allowed roots
    Server-->>Host: workspaceId
Loading

Reviews (1): Last reviewed commit: "feat: expose allowed workspace roots" | Re-trigger Greptile

@Waishnav

Copy link
Copy Markdown
Owner

Thanks for the PR, btw can you attach and attribute info about which model/harness you made this PR with?

@Waishnav

Copy link
Copy Markdown
Owner

tbh, this is not needed to be exposed to the model, but fair enough you have to type out the folder/project path again and again for it's session

you can solve this by creating projects inside ChatGPT and add custom project instructions like this

work inside `~/personal/devspace, use DevSpace connector
image

@dbc-hbin

Copy link
Copy Markdown
Author

Thanks — I added the model/harness attribution to the PR description.

ChatGPT Project instructions are a useful workaround for a stable single-root project. The gap this PR addresses is the generic connector path: a fresh normal chat has no project instructions, and a DevSpace server can expose multiple explicitly configured roots. Before open_workspace, the host has no authenticated MCP capability that tells it which local path is valid, so it must guess or ask the user to repeat an implementation detail.

list_allowed_roots only returns the roots the owner already configured, to an authenticated client. It does not scan directories, read repository contents, or widen assertAllowedPath; open_workspace already returns the selected absolute root after opening it. This makes the configured boundary discoverable before the first open rather than expanding that boundary.

I am happy to adjust the name or response shape if you prefer this under a more general read-only server metadata tool.

@dbc-hbin
dbc-hbin marked this pull request as ready for review August 10, 2026 07:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/roots.ts`:
- Around line 40-42: Extend the tests covering the access-denied path around
AccessDeniedError to assert the complete message contract, including the
rejected path and every allowed root. Remove the platform-gated-only matching so
the Windows branch is exercised as well, while preserving platform-specific path
handling where needed.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b6022704-b9ec-49b6-8928-fe3ac883db39

📥 Commits

Reviewing files that changed from the base of the PR and between 1def8ce and db26843.

📒 Files selected for processing (3)
  • src/roots.ts
  • src/server.test.ts
  • src/server.ts

Comment thread src/roots.ts
@dbc-hbin

Copy link
Copy Markdown
Author

Addressed the review comment in 8561071. roots.test.ts now runs a platform-independent AccessDeniedError assertion that checks the complete message contract: the rejected path and every configured allowed root. The existing Windows-specific path case remains covered. Typecheck, roots/server tests, and build pass.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/roots.test.ts (1)

33-47: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add MCP-level coverage for outside-root rejection.

src/workspaces.test.ts already covers WorkspaceRegistry.openWorkspace() for paths outside allowed roots, but the new src/roots.test.ts contract should be linked through an open_workspace call failure or an MCP tool-response test. This does not require broad real-host testing; use the existing in-memory MCP test fixture.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/roots.test.ts` around lines 33 - 47, Add MCP-level coverage using the
existing in-memory MCP test fixture to invoke the open_workspace tool with a
path outside the configured allowed roots. Assert that the tool call fails or
returns the expected access-denied response, linking the roots.test.ts rejection
contract through the MCP boundary rather than only testing assertAllowedPath
directly.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/roots.test.ts`:
- Around line 33-47: Add MCP-level coverage using the existing in-memory MCP
test fixture to invoke the open_workspace tool with a path outside the
configured allowed roots. Assert that the tool call fails or returns the
expected access-denied response, linking the roots.test.ts rejection contract
through the MCP boundary rather than only testing assertAllowedPath directly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d404fb0c-3630-4aaf-bb6d-9b1e426a517d

📥 Commits

Reviewing files that changed from the base of the PR and between db26843 and 8561071.

📒 Files selected for processing (1)
  • src/roots.test.ts

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