-
Notifications
You must be signed in to change notification settings - Fork 89
feat(mcp): OAuth2 PKCE flow with dynamic client registration for MCP agents #8264
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
Merged
andypalmi
merged 7 commits into
feat/7431-mcp-wellknown-discovery
from
feat/7432-mcp-oauth-pkce
Aug 26, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6747cbd
feat(mcp): OAuth2 PKCE flow with dynamic client registration for MCP …
43cda9a
Merge branch 'feat/7431-mcp-wellknown-discovery' into feat/7432-mcp-o…
d07d505
fix(mcp): keep the refresh token alive after access-token expiry
3ce33b3
test(mcp): make the refresh-expiry slide assertion deterministic
39e94a7
fix(mcp): include token_type in the refresh token response
3174417
chore(mcp): make migration down a no-op to match convention
7209333
refactor(mcp): identify MCP clients via ownerType and widen refresh c…
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
30 changes: 30 additions & 0 deletions
30
forge/db/migrations/20260824-01-add-mcp-authclient-fields.js
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,30 @@ | ||
| /** | ||
| * Add fields to AuthClients so MCP agents can register dynamically (RFC 7591). | ||
| * | ||
| * Existing clients (project/device editor auth) are owned by a resource via | ||
| * ownerType/ownerId and authenticate with a clientSecret. MCP clients have no | ||
| * owning resource and are public (PKCE, no secret): they reuse ownerType with | ||
| * ownerType='mcp' and add a display name and the redirect URIs approved at | ||
| * registration. | ||
| * | ||
| * name - the client_name supplied at registration | ||
| * redirectURIs - JSON array of redirect URIs the client may use | ||
| */ | ||
|
|
||
| const { DataTypes } = require('sequelize') | ||
|
|
||
| module.exports = { | ||
| up: async (context) => { | ||
| await context.addColumn('AuthClients', 'name', { | ||
| type: DataTypes.STRING, | ||
| allowNull: true, | ||
| defaultValue: null | ||
| }) | ||
| await context.addColumn('AuthClients', 'redirectURIs', { | ||
| type: DataTypes.TEXT, | ||
| allowNull: true, | ||
| defaultValue: null | ||
| }) | ||
| }, | ||
| down: async (context) => {} | ||
| } |
27 changes: 27 additions & 0 deletions
27
forge/db/migrations/20260825-01-add-refreshTokenExpiresAt-to-AccessTokens.js
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,27 @@ | ||
| /** | ||
| * Give refresh tokens a lifetime independent of the access token. | ||
| * | ||
| * An AccessToken row holds both the access token and its refresh token. The | ||
| * access token is short-lived (expiresAt); the refresh token is meant to | ||
| * outlive it so a client can obtain a new access token after expiry | ||
| * (RFC 6749 §1.5). Without a separate expiry the refresh token's lifetime was | ||
| * tied to the access token's, so expiring the access token also discarded the | ||
| * refresh token and made refresh impossible. | ||
| * | ||
| * refreshTokenExpiresAt - when the refresh token itself expires. Null for | ||
| * tokens that do not use a refresh lifetime, which | ||
| * keep the previous behaviour. | ||
| */ | ||
|
|
||
| const { DataTypes } = require('sequelize') | ||
|
|
||
| module.exports = { | ||
| up: async (context) => { | ||
| await context.addColumn('AccessTokens', 'refreshTokenExpiresAt', { | ||
| type: DataTypes.DATE, | ||
| allowNull: true, | ||
| defaultValue: null | ||
| }) | ||
| }, | ||
| down: async (context) => {} | ||
| } |
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,34 @@ | ||
| module.exports = [ | ||
| { | ||
| name: 'platform_get_active_user', | ||
|
andypalmi marked this conversation as resolved.
|
||
| title: 'Get Active User', | ||
| description: `FlowFuse platform automation tool: | ||
| Get the profile of the user this MCP session is authenticated as, along with what the session's token is allowed to do. | ||
| Returns the user's ID (hashid), username, name, email and admin flag, plus a token object: | ||
| token.readOnly - when true, write and delete tools are rejected, so only read tools can be used. | ||
| token.allTeams - when true, the token is not restricted to a subset of teams and every team the user belongs to is in reach. | ||
| token.teams - when allTeams is false, the IDs of the only teams the token may act on. Calls against any other team will fail. | ||
| Use this to resolve the current user's ID before calling tools that need a userId, such as listing browser sessions, | ||
| and to check up front whether an action the user asked for is within the session's access.`, | ||
| annotations: { readOnlyHint: true, destructiveHint: false }, | ||
| inputSchema: {}, | ||
| handler: async (args, { inject, scope }) => { | ||
| const response = await inject({ method: 'GET', url: '/api/v1/user' }) | ||
| if (response.statusCode >= 400) { | ||
| return response | ||
| } | ||
|
|
||
| // No scope means the tool was not called through a scoped token (the FlowFuse | ||
| // Expert path), so the session has the user's full access. | ||
| const teams = Array.isArray(scope?.teams) ? scope.teams : [] | ||
| return { | ||
| ...response.json(), | ||
| token: { | ||
| readOnly: scope?.readOnly === true, | ||
| allTeams: teams.length === 0, | ||
| teams | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
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.
Uh oh!
There was an error while loading. Please reload this page.