Skip to content

Manage MCP tokens per user - #179

Merged
ecarreras merged 2 commits into
mainfrom
issue-178-user-tokens
Aug 5, 2026
Merged

Manage MCP tokens per user#179
ecarreras merged 2 commits into
mainfrom
issue-178-user-tokens

Conversation

@pilipilisbot

@pilipilisbot pilipilisbot commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Closes #178.

Summary

  • Add user_login and created_by ownership metadata to MCP token records, with SQLite upgrade handling for existing databases.
  • Let signed-in dashboard users list/create/revoke their own MCP tokens, while admins can list all tokens and create tokens for another GitHub login.
  • Show token owners on the MCP access page and keep one-time secrets hidden from list responses.

Tests

  • . .venv/bin/activate && pytest -q
  • npm test -- --run src/main.test.tsx
  • npm run build

Screenshots

MCP token owner management

Co-authored-by: ecarreras <294235+ecarreras@users.noreply.github.com>
@ecarreras

Copy link
Copy Markdown
Owner

@giscebot revisa aquesta pull-request

@giscebot giscebot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one blocking migration issue:

JobQueue executes schema.sql before _ensure_columns(). On an existing database whose mcp_tokens table predates this PR, CREATE INDEX IF NOT EXISTS idx_mcp_tokens_user ON mcp_tokens(user_login, ...) therefore runs while user_login does not exist and startup fails with sqlite3.OperationalError: no such column: user_login. The later column migration is never reached.

I reproduced this by creating the previous seven-column mcp_tokens table and then constructing JobQueue(db) at this PR's head (7db9123). Please move creation of this index after the column migration (or otherwise ensure the columns exist first), and add an upgrade regression test that starts from the old table shape. Fresh-database behavior is not affected.

Co-authored-by: giscebot <286264155+giscebot@users.noreply.github.com>
@pilipilisbot

Copy link
Copy Markdown
Owner Author

Fixed the requested migration blocker in ff4a3a6.

  • Moved idx_mcp_tokens_user creation out of schema.sql and into the post-column-migration JobQueue initialization path.
  • Added an upgrade regression test that starts from the previous seven-column mcp_tokens table shape before constructing JobQueue.

Verification:

  • .venv/bin/pytest -q tests/test_mcp.py
  • .venv/bin/pytest -q (349 passed, one existing Starlette/httpx deprecation warning)

@ecarreras
ecarreras requested a review from giscebot August 5, 2026 09:27

@giscebot giscebot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration blocker from my previous review is resolved in ff4a3a6.

I verified that the new owner index is now created only after JobQueue._ensure_columns() adds user_login and created_by, and that the regression test constructs the previous seven-column mcp_tokens schema before initializing JobQueue. I also reviewed the ownership boundaries across the API and token helpers: regular users list/revoke only their own tokens, cross-user creation is rejected, admins retain global management, login values are normalized, and list responses still omit token secrets.

CI is green for Python 3.11, Python 3.12, and the dashboard suite/build. I could not rerun the focused tests locally because this dedicated checkout has no virtual environment and the system Python does not have pytest installed.

No remaining blocking findings.

@ecarreras
ecarreras merged commit bbbb263 into main Aug 5, 2026
3 checks passed
@ecarreras
ecarreras deleted the issue-178-user-tokens branch August 5, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gestionar-se tokens a nivell d'usuari

3 participants