-
Notifications
You must be signed in to change notification settings - Fork 137
@W-23757363: clarify Tableau auth/permission errors across all auth modes #894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Alon-ST-DATA
wants to merge
8
commits into
main
Choose a base branch
from
asimantov/W-23757363-auth-error-clarity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4ca9bf8
W-23757363: clarify Tableau auth/permission errors across all auth modes
Alon-ST-DATA 1cb6740
W-23757363: update embedded-authz OAuth assertions for enriched error…
Alon-ST-DATA 68d24eb
chore: bump version to 4.8.4
github-actions[bot] 95984e2
Merge remote-tracking branch 'origin/main' into asimantov/W-23757363-…
Alon-ST-DATA 52243d5
W-23757363: bump version to 4.8.4 after merging main (#893 released 4…
Alon-ST-DATA 60111b7
Merge remote-tracking branch 'origin/asimantov/W-23757363-auth-error-…
Alon-ST-DATA b1f2ae1
Merge remote-tracking branch 'origin/main' into asimantov/W-23757363-…
Alon-ST-DATA faefe4c
W-23757363: fix getViewData 403 test for rewritten permission message
Alon-ST-DATA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| --- | ||
| sidebar_position: 8 | ||
| --- | ||
|
|
||
| # Running Multiple Servers & Diagnosing Auth Errors | ||
|
|
||
| You can configure more than one Tableau MCP server in the same client (for example a | ||
| production site, a stage site, and a local build). When you do, two things become important: | ||
| keeping them **distinctly named** so both you and the AI can tell them apart, and knowing how to | ||
| **read an authentication error** so it is not mistaken for a missing feature. | ||
|
|
||
| ## Name each server distinctly | ||
|
|
||
| The AI client chooses which configured server to send a tool call to. If several servers are | ||
| configured with similar names — or several expose the same tool — a request can land on the | ||
| **wrong** server, or on one that is **not authenticated**. When that happens the failure often | ||
| reads like "the feature isn't set up," when the real cause is *which server answered*. | ||
|
|
||
| Give each server a name that encodes site + purpose, e.g.: | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "tableau-prod-acme": { "command": "npx", "args": ["-y", "@tableau/mcp-server@latest"], "env": { "SERVER": "https://prod.online.tableau.com", "SITE_NAME": "acme", "PAT_NAME": "...", "PAT_VALUE": "..." } }, | ||
| "tableau-stage-acme": { "command": "npx", "args": ["-y", "@tableau/mcp-server@latest"], "env": { "SERVER": "https://stage.online.tableau.com", "SITE_NAME": "acme-stage", "PAT_NAME": "...", "PAT_VALUE": "..." } } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Avoid running two servers that expose the **same admin tools against different sites** unless you | ||
| truly need both — it is the most common source of "why did it query the wrong site?". | ||
|
|
||
| ## Confirm which server answered | ||
|
|
||
| Before trusting an admin/insights result when multiple servers are configured, confirm the | ||
| target. Ask the client to run a cheap, unambiguous call first (for example | ||
| [`list-projects`](../../tools/projects/list-projects.md)) and check it returns *your* site's | ||
| content. In Claude Code, `/mcp` shows which servers are connected vs failed. | ||
|
|
||
| You can also add a line to your client's memory (e.g. `CLAUDE.md`) so the AI self-discloses the | ||
| target and never hides an auth failure: | ||
|
|
||
| > When multiple Tableau MCP servers are configured, state which server a tool call targeted. | ||
| > Surface authentication/connection errors verbatim. Treat a 401 as "wrong or unauthenticated | ||
| > server," **not** as "the feature is missing." | ||
|
|
||
| ## Decode the error | ||
|
|
||
| The server returns **distinct, self-explanatory** errors for the four cases below. Each names the | ||
| cause and — where the server knows them — the targeted **site** and **pod**, so a `401` is never | ||
| mistaken for a missing feature. If the AI still summarizes an error into a single vague phrase | ||
| (e.g. "no admin insights configured"), ask the client for the **raw** error text and match it here: | ||
|
|
||
| | You see (raw text) | Real cause | What to do | | ||
| |---|---|---| | ||
| | `Authentication failed (401): the credentials for this Tableau MCP server (site "...", pod "...") are missing, invalid, or expired. ...` | **Not authenticated** — the PAT/OAuth session for the targeted server is missing, invalid, or expired. | Re-authenticate that server (new PAT, or re-run the OAuth flow). Confirm you targeted the intended server. | | ||
| | The server logs a warning at startup (`Authentication failed (401): ...`) and continues with default settings; the same `401` message is then returned at tool call. | **Not authenticated at startup** — the credentials failed while the server was fetching site settings during launch. The server no longer crashes: it connects, registers the base tools, and surfaces the auth error at the first tool call (matching OAuth). | Fix the credentials for that server, then retry. | | ||
| | `Permission denied (403): you are authenticated to this Tableau MCP server (site "...") but this request was refused. Your account may lack the required site role or permission, or the capability may not be enabled for this site. ...` | **Authenticated, but the request was refused** — missing role/permission, or a capability not enabled for the site. For admin tools you may instead see `This tool requires site administrator permissions. Your site role is: <role>`. | Use an account with the required site role or permissions, or confirm the capability is enabled for the site. | | ||
| | `Admin Insights dataset "<name>" not found in the "Admin Insights" project on this site. This means Admin Insights is not provisioned on the targeted Tableau Cloud site ...` | **Authenticated + admin, but Admin Insights is genuinely not provisioned** on the targeted site. | Enable Admin Insights on that Tableau Cloud site, or target the site where it is provisioned. | | ||
|
|
||
| A `401` is an **authentication** problem, never evidence that Admin Insights is missing. Only the | ||
| last row means the feature itself is absent. | ||
|
|
||
| Over OAuth, a missing or expired token is rejected by the transport before any tool runs: the | ||
| `401` response keeps its `WWW-Authenticate` challenge (so the re-authentication flow still works) | ||
| and its `error_description` carries the same guidance — verify you targeted the intended server and | ||
| re-authenticate. | ||
|
|
||
| ## Related | ||
|
|
||
| - [Authentication](authentication/README.md) | ||
| - [OAuth](authentication/oauth.md) — see **Known Issues** for multi-site connection pitfalls | ||
| - [Query Admin Insights](../../tools/admin-insights/query-admin-insights.md) |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import { Err, Ok } from 'ts-results-es'; | ||
|
|
||
| import { stubDefaultEnvVars } from '../../testShared.js'; | ||
| import { OAUTH_AUTH_CHALLENGE_GUIDANCE } from '../../utils/authErrorMessage.js'; | ||
| import { AccessTokenValidator } from './accessTokenValidator.js'; | ||
| import { authMiddleware } from './authMiddleware.js'; | ||
| import { AuthenticatedRequest } from './types.js'; | ||
|
|
||
| // Minimal Express response double capturing status / headers / json body. | ||
| function makeRes(): any { | ||
| const res: any = { | ||
| statusCode: undefined as number | undefined, | ||
| headers: {} as Record<string, string>, | ||
| body: undefined as unknown, | ||
| headersSent: false, | ||
| status(code: number) { | ||
| res.statusCode = code; | ||
| return res; | ||
| }, | ||
| header(key: string, value: string) { | ||
| res.headers[key] = value; | ||
| return res; | ||
| }, | ||
| json(body: unknown) { | ||
| res.body = body; | ||
| return res; | ||
| }, | ||
| writeHead: vi.fn(() => res), | ||
| write: vi.fn(), | ||
| end: vi.fn(), | ||
| }; | ||
| return res; | ||
| } | ||
|
|
||
| function makeValidator(result: Ok<any> | Err<string>): AccessTokenValidator { | ||
| return { validate: vi.fn().mockResolvedValue(result) } as unknown as AccessTokenValidator; | ||
| } | ||
|
|
||
| describe('authMiddleware auth-error wording (W-23757363)', () => { | ||
| beforeEach(() => { | ||
| vi.unstubAllEnvs(); | ||
| stubDefaultEnvVars(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.unstubAllEnvs(); | ||
| }); | ||
|
|
||
| it('carries the shared guidance in error_description while keeping the WWW-Authenticate challenge when no token is present', async () => { | ||
| const middleware = authMiddleware(makeValidator(new Err('unused'))); | ||
| const req = { headers: {}, method: 'POST', body: {} } as unknown as AuthenticatedRequest; | ||
| const res = makeRes(); | ||
| const next = vi.fn(); | ||
|
|
||
| await middleware(req, res, next); | ||
|
|
||
| expect(next).not.toHaveBeenCalled(); | ||
| expect(res.statusCode).toBe(401); | ||
| // The re-auth challenge must remain intact so the OAuth flow still works. | ||
| expect(res.headers['WWW-Authenticate']).toContain('Bearer realm="MCP"'); | ||
| expect(res.body.error).toBe('unauthorized'); | ||
| expect(res.body.error_description).toContain('Use the OAuth 2.1 flow'); | ||
| expect(res.body.error_description).toContain(OAUTH_AUTH_CHALLENGE_GUIDANCE); | ||
| }); | ||
|
|
||
| it('carries the shared guidance in error_description for an invalid/expired token', async () => { | ||
| const middleware = authMiddleware(makeValidator(new Err('token expired'))); | ||
| const req = { | ||
| headers: { authorization: 'Bearer bad-token' }, | ||
| method: 'POST', | ||
| body: {}, | ||
| } as unknown as AuthenticatedRequest; | ||
| const res = makeRes(); | ||
| const next = vi.fn(); | ||
|
|
||
| await middleware(req, res, next); | ||
|
|
||
| expect(next).not.toHaveBeenCalled(); | ||
| expect(res.statusCode).toBe(401); | ||
| expect(res.body.error).toBe('invalid_token'); | ||
| // Underlying validation detail is preserved, followed by the shared guidance. | ||
| expect(res.body.error_description).toContain('token expired'); | ||
| expect(res.body.error_description).toContain(OAUTH_AUTH_CHALLENGE_GUIDANCE); | ||
| }); | ||
| }); |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it that a 401 Unauthorized expected with this issue? When there are multiple servers connected, a client does not user credentials from one server when calling the other right? It uses the credentials that pertains to the connection. So it shouldn't be 401 Unauthorized, it would be more like 404 Not Found when you specify a target. For example, if I ask it to get me metadata for a Datasource belonging to MCP server A, but instead it calls MCP server B. The request will be authorized right, just fail with 404 because the datasource was not found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hear your point @stephendeoca, but this can be debatable. You can look at it as we have an authenticated user (for a session on server A) that cannot see resources because no authorization on target server B... catching this error with proper logging.
For me, having 404 error hide the real auth error.