tableau-mcp / rules
Cursor rule347 starsChanged 6 months agoApache-2.0View on GitHub
Auth architecture, middleware chain, and auth-specific coding standards
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/tableau-mcp.mdcCursor rule
- .cursor/rules/testing.mdcCursor rule
- .cursor/rules/tools.mdcCursor rule
- create-pr-from-commitsSkill
The file
We split this auth.mdc into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 74
Every tool touching Tableau APIs requires auth verification BEFORE execution
- Distinctive: line 84
Check if a similar pattern exists in the other auth paths
- Very specific: line 86
Consider scope implications — does this change affect toolScopeMap?
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Auth architecture, middleware chain, and auth-specific coding standards
globs:
- "src/server/**/*.ts"
- "src/restApiInstance.ts"
---
# Auth Standards
## Three Auth Paths
### 1. Passthrough Auth
- Header `x-tableau-auth` or cookie `workgroup_session_id`
- Validated via `RestApi.authenticatedServerMethods.getCurrentServerSession()`
- Optional session caching via `ExpiringMap` (configurable interval)
- Location: `src/server/passthroughAuthMiddleware.ts`
- Enabled when `config.enablePassthroughAuth` is true
- MCP scopes NOT enforced (no way to verify original token scopes)
### 2. Embedded OAuth (PKCE)
- JWE-encrypted MCP access tokens signed with server's private key
- Contains embedded Tableau access/refresh tokens
- `EmbeddedAccessTokenValidator` validates via `jose`
- Location: `src/server/oauth/provider.ts`, `accessTokenValidator.ts`,
`token.ts`, `authorize.ts`, `callback.ts`
### 3. Tableau Cloud OAuth
- Tableau Cloud JWT Bearer tokens
- `TableauAccessTokenValidator` validates JWT claims
- Location: `src/server/oauth/provider.ts`, `accessTokenValidator.ts`
## Middleware Chain Order (express.ts)
```
handlePingRequest
→ passthroughAuthMiddleware (if enabled)
→ oauthProvider.authMiddleware
→ validateProtocolVersion
→ createMcpServer
```
## Auth Info Flow
```
req.auth
→ getTableauAuthInfo(req.auth)
→ TableauAuthInfo (discriminated union: 'X-Tableau-Auth' | 'Bearer' | 'Passthrough')
→ TableauRequestHandlerExtra.tableauAuthInfo
→ useRestApi() (handles sign-in, token setup, sign-out lifecycle)
```
## TableauAuthInfo Type (src/server/oauth/schemas.ts)
Discriminated union on `type` field:
- `'X-Tableau-Auth'` — username, server, siteId?, userId?, accessToken?, refreshToken?
- `'Bearer'` — username, server, siteId, userId?, raw (the JWT string)
- `'Passthrough'` — username, userId, server, siteId, raw (the session token)
## REST API Auth Lifecycle (src/restApiInstance.ts)
`useRestApi()` is the single entry point for all authenticated API calls:
- Creates a fresh `RestApi` instance per call
- Routes to correct auth method based on `tableauAuthInfo.type` and `config.auth`
- Auth methods: `pat`, `direct-trust`, `uat`, `oauth`
- PAT/direct-trust sessions are ephemeral (signed out after use)
- OAuth/passthrough sessions are long-lived (NOT signed out)
- Accepts `jwtScopes` for direct-trust/UAT token generation
## Scope System (src/server/oauth/scopes.ts)
Two scope layers:
- **MCP scopes** (`tableau:mcp:*`) — permissions clients request from MCP server
- **Tableau API scopes** (`tableau:*`) — permissions for Tableau REST API calls
- `toolScopeMap` maps each tool → required MCP scopes + required API scopes
- MCP scope enforcement is optional (`oauth.enforceScopes` config)
- API scopes always passed to `useRestApi()` via `tool.requiredApiScopes`
## Non-Negotiable Auth Rules
- Every tool touching Tableau APIs requires auth verification BEFORE execution
- Auth context must be explicitly passed — never assume it exists in scope
- Token refresh is transient and retryable
- Invalid credentials are validation errors — not retryable
- Insufficient permissions are permission errors — escalate, don't retry
- No `any` types in auth-related code (see ESLint override)
## Before Changing Auth Code
1. Identify which of the three auth paths this change affects
2. Trace the middleware chain to understand where this change sits
3. Check if a similar pattern exists in the other auth paths
4. Plan error cases — what happens when auth fails at this point?
5. Consider scope implications — does this change affect `toolScopeMap`?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

