APS MCP Auth0 Example
Example MCP server for Autodesk Platform Services that demonstrates proper OAuth authorization with Auth0 as the first layer and APS 3-legged OAuth as the second layer. Enables querying APS projects and issues through natural language after authenticating via Auth0 and APS.
README
APS MCP Auth0 Example
Example MCP server for Autodesk Platform Services demonstrating proper auth implementation.
Auth0 is just one option here. This example uses Auth0 as the Layer 1 authorization server, but nothing about the MCP server is tied to it — the server only verifies bearer tokens against a standard OAuth/JWKS endpoint. You can swap in any OAuth 2.0 authorization server that fits your needs, such as WorkOS, Okta, Microsoft Entra ID, Keycloak, or your own. If you do, adapt
auth/auth0.js(token verification and metadata discovery) and the corresponding config accordingly; the Layer 2 APS flow stays the same.
Features
Two-layer authentication, targeting the 2026-07-28 MCP specification release candidate:
- Layer 1 (MCP client -> MCP server): every
/mcprequest must carry anAuthorization: Bearertoken issued by Auth0, which acts as the OAuth authorization server for this MCP server. Clients register via a Client ID Metadata Document (CIMD) instead of Dynamic Client Registration — see Setting up Auth0 below. - Layer 2 (MCP server -> APS): standard APS 3-legged OAuth, run out-of-band in the user's browser. The MCP client's own token is never forwarded to APS (no token passthrough).
- The server is fully stateless — a fresh MCP server instance is built per request (no
Mcp-Session-Id), from just the validated Layer-1 subject. Each tool then tries to resolve that user's cached APS token itself. - When a tool needs the user to sign in, it returns a plain-text login link in the tool result. (URL elicitation, so clients can prompt the user directly, may be reintroduced later.)
What's inside
app.js: Express app wiring Layer 1 (Auth0 bearer auth + OAuth protected-resource metadata) in front of the stateless MCP handler frommcp.jsmcp.js: Defines the MCP tools for APS projects and builds the per-request MCP server — a fresh server is built per request from just the caller's user ID. A sharedwithAuthhelper wraps every tool handler: it resolves the caller's APS access token (or returns a login prompt if they haven't signed in yet) before the handler runs, which then calls@aps_sdk/*clients directly with that tokenauth/auth0.js: Layer 1 — verifies Auth0-issued access tokens (OAuthTokenVerifier) and fetches Auth0's OAuth metadataauth/aps.js: Layer 2 — APS 3-legged OAuth via@aps_sdk/authentication(authorization URL, code exchange, token refresh, per-user token cache)
This example targets
@modelcontextprotocol/server/@modelcontextprotocol/node2.0.0-beta, which implement the still-unreleased 2026-07-28 spec revision.@modelcontextprotocol/expresssupplies the Express-specific OAuth resource-server helpers (requireBearerAuth,mcpAuthMetadataRouter) for that same beta line — APIs may still change before the spec and packages are finalized.
Architecture
Two independent OAuth relationships meet at the MCP server. Layer 1 guards the /mcp endpoint itself (MCP client ↔ MCP server, via Auth0). Layer 2 lets the server call APS on the user's behalf (MCP server ↔ APS, standard 3-legged OAuth). The two never mix: the client's Auth0 token is only ever used to identify the caller, and is never forwarded to APS.
flowchart LR
Client["MCP Client<br/>(OAuth + CIMD)"]
subgraph Server["MCP Server — Express (app.js)"]
direction TB
Bearer["requireBearerAuth<br/>auth0TokenVerifier<br/>(auth/auth0.js)"]
Handler["createMcpServer(userId)<br/>withAuth → tools<br/>(mcp.js)"]
Callback["GET /auth/callback<br/>completeLogin<br/>(auth/aps.js)"]
Cache[("Per-user APS<br/>token cache")]
end
Auth0["Auth0<br/>(Layer 1 authorization server)"]
subgraph APS["Autodesk Platform Services"]
APSOAuth["3-legged OAuth"]
DM["Data Management API"]
end
Client -->|"1 · Bearer token on /mcp"| Bearer
Bearer -.->|"verify JWT via JWKS"| Auth0
Bearer -->|"userId = sub"| Handler
Handler -->|"resolve cached token"| Cache
Handler -.->|"no token → return login link"| Client
Handler ==>|"with token → call API"| DM
Client -.->|"2 · browser sign-in"| APSOAuth
APSOAuth -->|"redirect w/ code"| Callback
Callback -->|"exchange code, cache tokens"| Cache
Authentication flow
The full round trip the first time a user connects and asks a question — the two layers are numbered to match the diagram above.
sequenceDiagram
autonumber
participant C as MCP Client
participant S as MCP Server<br/>(/mcp)
participant A as Auth0
participant B as User Browser
participant P as APS
rect rgb(235, 244, 255)
Note over C,A: Layer 1 — MCP client ↔ MCP server
C->>S: GET /mcp (no token)
S-->>C: 401 + WWW-Authenticate<br/>(resource metadata URL)
C->>S: GET /.well-known/oauth-protected-resource/mcp
S-->>C: metadata → Auth0 is the authorization server
C->>A: OAuth (CIMD registration, RFC 8707 resource)
A-->>C: access token (JWT)
C->>S: /mcp + Bearer <Auth0 JWT>
S->>S: verify JWT via JWKS → userId = sub
end
rect rgb(235, 255, 240)
Note over S,P: Layer 2 — MCP server ↔ APS (per user, out-of-band)
S->>S: getValidAccessToken(userId) → none yet
S-->>C: tool result: "Sign in" link<br/>(buildAuthorizationUrl)
B->>P: open link, authenticate + consent
P-->>B: redirect /auth/callback?code&state
B->>S: GET /auth/callback?code&state
S->>P: exchange code → APS tokens (completeLogin)
S->>S: cache tokens under userId
end
Note over C,P: Subsequent calls reuse cached tokens
C->>S: retry /mcp tool call
S->>P: call Data Management API with APS token
P-->>S: data
S-->>C: tool result
Setting up Auth0 (Layer 1)
This protects /mcp itself — separate from, and in addition to, the APS sign-in below.
- In your Auth0 tenant, create an API (Applications > APIs > Create API) representing this MCP server. Use the server's public
/mcpURL —https://<PUBLIC_HOST>/mcp(e.g.https://your-server.example.com/mcp) — as the Identifier. The server derives its Auth0 audience fromPUBLIC_HOST, so the Identifier must match exactly. - Enable Client ID Metadata Documents so MCP clients (which host their own CIMD instead of registering an app in your tenant) can connect: go to Settings > Advanced, and toggle on Client ID Metadata Document Registration.
- For MCP-specific resource-parameter handling (RFC 8707), also enable the Resource Parameter Compatibility Profile in the same Settings > Advanced section.
- Grant the MCP client(s) you intend to use access to the API you created in step 1 (Applications > APIs > your API > Application Access, or authorize the scopes by default for third-party applications in the API's settings).
- Set
AUTH0_DOMAIN(your tenant domain, e.g.your-tenant.us.auth0.com) in.env. The audience is computed fromPUBLIC_HOSTand does not need to be set separately.
With this in place, MCP clients that support CIMD (per SEP-991) can discover Auth0 via this server's /.well-known/oauth-protected-resource/mcp and authenticate without any manual app registration in your tenant.
Setting up APS 3-legged OAuth (Layer 2)
- Reuse or create an APS app (Traditional Web App type) at https://aps.autodesk.com/myapps.
- Add the callback URL
https://<PUBLIC_HOST>/auth/callback(the server derives it fromPUBLIC_HOST) to the app's allowed callback URLs. - Set
APS_CLIENT_ID,APS_CLIENT_SECRET, andPUBLIC_HOSTin.env.
The per-user APS token cache in auth/aps.js (and the state -> user correlation map used during login) are kept in memory for this example — swap them for Redis (or similar) in production.
Deploy
This server cannot be run locally. Everything (the
/mcpURL, the APS callback, and the Auth0 audience) is derived from a singlePUBLIC_HOST, and that host must be publicly reachable over HTTPS and registered as the API Identifier ("audience") in Auth0 — see Setting up Auth0. Deploy it to a public host; there is nolocalhostfallback.
- Install dependencies:
npm install - Create a
.envin the repo root (see.envfor the full list):APS_CLIENT_ID,APS_CLIENT_SECRET(see Setting up APS 3-legged OAuth)AUTH0_DOMAIN(see Setting up Auth0)PUBLIC_HOST— the server's public host (e.g.your-server.example.com, no scheme). The server derives all of the following from it:- the public
/mcpURL and Auth0 audience:https://<PUBLIC_HOST>/mcp - the APS callback URL:
https://<PUBLIC_HOST>/auth/callback - the host allowlist
- the public
- Optional:
PORT(default3000)
- Start the server:
npm start
Connect an MCP client that supports OAuth (and ideally CIMD + the 2026-07-28 revision) to https://<PUBLIC_HOST>/mcp, and start asking questions such as:
- What projects do I have access to?
- What issues are open in that project?
The first request will prompt you to sign in with your Autodesk account (Layer 2); once that completes, retry the same request.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。