fix(mcp): report config:read restriction on llmModels/embeddingModels… - #70
Open
krishsingh120 wants to merge 2 commits into
Open
fix(mcp): report config:read restriction on llmModels/embeddingModels…#70krishsingh120 wants to merge 2 commits into
krishsingh120 wants to merge 2 commits into
Conversation
… instead of silent empty array
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2942
Problem
pipeshub_sourcesreturnsllmModels/embeddingModelsas an empty array ([]) with HTTP 200 when the caller's token lacksconfig:read, instead of surfacing the denial. A client can't distinguish "nothing is configured" from "you're not authorized to see it."Root cause
The underlying backend routes (
GET /aiModelsConfig,GET /ai-models) correctly return a 403 whenconfig:readis missing — the backend itself isn't buggy. The issue is at the MCP tool layer:pipeshub_sources(in this repo,src/mcp-server/tools/pipeshubSources.ts) swallows that 403 and silently returns an empty array instead of propagating the denial.I initially suspected the fix belonged in the main
pipeshub-airepo's Node.js backend, but traced it through therequire-scopes.middleware.ts(working correctly) before finding the actual tool implementation lives in this separatemcp-serverrepo.Why not gate the whole tool with
config:read(Option A from the issue)?MCPScope(src/mcp-server/scopes.ts) is auto-generated by Speakeasy ("DO NOT EDIT") and only exposes"read"as a valid scope — there's no way to requireconfig:readspecifically at the tool level. So I went with Option B: explicitly flag the restriction in the response instead.Fix
In
pipeshubSources.ts, when aconfig:read-gated field returns a 403 (checked viaAPIError.httpMeta.response.status), the tool now returns:instead of silently returning
llmModels: []with no indication of why. Same handling applies toembeddingModels. Any other error status still returns the existing error result unchanged.This mirrors a workaround already present in the CLI's
sources()command (src/cli/commands.ts), which had manually detected this same silent-empty-array behavior for CLI users only — this fix makes the distinction available to all MCP clients (Claude Desktop, Cursor, etc.), not just the CLI.Testing
npx tsc --noEmitpasses cleanly with no errors.config:readvs. full-scope token).Files changed
src/mcp-server/tools/pipeshubSources.ts— addedAPIErrorimport, updated tool description to document the new*Restrictedfields, replaced the silent-swallow error branch with explicit 403 detection.