feat: add MCP token management UI to My Tokens page#617
Conversation
liuwei08
left a comment
There was a problem hiding this comment.
Two bugs that must be fixed before merge — see inline comments.
| }, | ||
|
|
||
| toggleMcpTrigger (token) { | ||
| const newVal = !token.allow_trigger |
There was a problem hiding this comment.
Bug: switch visual state and data state can diverge on API failure.
vue-material's md-switch fires its @change handler and flips its visual state before the API call resolves. If setMcpTrigger rejects, token.allow_trigger is never mutated in the .then, but the switch already looks toggled to the user.
Fix — revert the visual state on failure:
toggleMcpTrigger (token) {
const newVal = !token.allow_trigger
UserTokenService.setMcpTrigger(token.token_id, newVal)
.then(() => { token.allow_trigger = newVal })
.catch(() => {
// Revert: force Vue to re-render the switch at the original value
token.allow_trigger = !newVal
})
}| <pre>$ export INFRABOX_MCP_TOKEN=<TOKEN_VALUE></pre> | ||
| </md-dialog-content> | ||
| <md-dialog-actions> | ||
| <md-button class="md-primary" @click="$refs['mcpTokenDialog'].close()">OK</md-button> |
There was a problem hiding this comment.
Bug: previous token value leaks if dialog is reopened.
newMcpToken is never cleared after the dialog closes. If the user creates a second token but this dialog re-renders before fully reinitializing, the previous ib_mcp_* value will briefly be visible.
Fix — clear newMcpToken in the click handler:
<md-button class="md-primary" @click="$refs['mcpTokenDialog'].close(); newMcpToken = ''">OK</md-button>Or better, wire a dedicated close method so cleanup is explicit and testable:
closeMcpTokenDialog () {
this.$refs['mcpTokenDialog'].close()
this.newMcpToken = ''
}|
Fixed in 902bf9b:
|
- UserTokenService: add loadMcpTokens, createMcpToken, revokeMcpToken, setMcpTrigger methods calling /api/v1/mcp/tokens/* endpoints - UserGlobalTokens.vue: append MCP Tokens card to /user/tokens page with create form, token list (name, project scope, expiry, last used, trigger toggle), revoke action, and post-create dialog showing the ib_mcp_* token value with INFRABOX_MCP_TOKEN usage hint
…n on dialog close
- createMcpToken form: native checkbox list for project selection - token list: edit button expands inline scope editor per token - PATCH /api/v1/mcp/tokens/<id> via new updateMcpToken service method - NewAPIService: add patch() method - validation: show error messages on invalid name/days input
680ae35 to
94d4e0f
Compare
- projects.py: empty dict falls through to full collaborator query - auth.py: check_project_access_mcp treats empty dict as allow-all
Summary
UserTokenService.js— 4 new methods wiring up the/api/v1/mcp/tokens/*endpoints added in DIARCHERS-1396: MCP-dedicated API layer with rate limiting, auth, and audit #610/user/tokenspage (UserGlobalTokens.vue) — no new route neededib_mcp_*token value (shown once) with aINFRABOX_MCP_TOKEN=...usage hint for the MCP clientWhat users can do after this PR
ib_mcp_*value and setINFRABOX_MCP_TOKENin their MCP client configRelated
Completes the frontend half of DIARCHERS-1396 / #610 (backend MCP API layer).