Commit ad60641
REST API and UI pagination (#1277)
* Tools pagination
Signed-off-by: Mihai Criveti <[email protected]>
* Tools pagination still broken
Signed-off-by: Mihai Criveti <[email protected]>
* Tools pagination still broken
Signed-off-by: Mihai Criveti <[email protected]>
* copied from rest-api-and-ui-pagination-v2
Signed-off-by: Madhav Kandukuri <[email protected]>
* Use jsonable_encoder for tools_pydantic
Signed-off-by: Madhav Kandukuri <[email protected]>
* Fix console error from tools_partial
Signed-off-by: Madhav Kandukuri <[email protected]>
* Multiple changes
Signed-off-by: Madhav Kandukuri <[email protected]>ok, d
* Swapping working but styling needs update
Signed-off-by: Madhav Kandukuri <[email protected]>
* Some working versions
Signed-off-by: Madhav Kandukuri <[email protected]>
* Fix everything
Signed-off-by: Madhav Kandukuri <[email protected]>
* Use tools_partial for first load
Signed-off-by: Madhav Kandukuri <[email protected]>
* Fix minor bug
Signed-off-by: Madhav Kandukuri <[email protected]>
* Fix failing tests
Signed-off-by: Madhav Kandukuri <[email protected]>
* Remove extra logging
Signed-off-by: Madhav Kandukuri <[email protected]>
* add uv.lock from main
Signed-off-by: Madhav Kandukuri <[email protected]>
* Fixes revision in latest alembic script
Signed-off-by: Madhav Kandukuri <[email protected]>
* Fix one doctest
Signed-off-by: Madhav Kandukuri <[email protected]>
* Fix doctest
Signed-off-by: Madhav Kandukuri <[email protected]>
* Fix some doctests
Signed-off-by: Madhav Kandukuri <[email protected]>
* Minor updates to pagination doctests
Signed-off-by: Madhav Kandukuri <[email protected]>
* Mock db in doctests
Signed-off-by: Madhav Kandukuri <[email protected]>
* Fix doctests in pagination
Signed-off-by: Madhav Kandukuri <[email protected]>
* Add trailing line in tools_with_pagination
Signed-off-by: Madhav Kandukuri <[email protected]>
* pre-commit fixes
Signed-off-by: Madhav Kandukuri <[email protected]>
* Fix key navigation in pagination
Signed-off-by: Madhav Kandukuri <[email protected]>
* pylint fix
Signed-off-by: Madhav Kandukuri <[email protected]>
* fix: Update pagination migration to follow correct alembic chain
The pagination indexes migration now correctly follows e5a59c16e041
(unique constraints for prompts/resources) which was merged to main
after this PR branch was created.
Migration chain:
- e5a59c16e041 (main)
- g1a2b3c4d5e6 (pagination indexes) <- this PR
- 9aaa90ad26d9 (output schema)
- 8a2934be50c0 (rest pass api)
Signed-off-by: Mihai Criveti <[email protected]>
* fix: Restore correct down_revision for output_schema migration
The output_schema migration (9aaa90ad26d9) should point to 9c99ec6872ed,
not to g1a2b3c4d5e6, to avoid creating a circular dependency.
Correct migration chain:
- 9c99ec6872ed (token usage logs fix)
- 9aaa90ad26d9 (output schema) <- restored
- 8a2934be50c0 (rest pass api)
- e5a59c16e041 (unique constraints)
- g1a2b3c4d5e6 (pagination indexes) <- this PR
Signed-off-by: Mihai Criveti <[email protected]>
* docs: Update CHANGELOG.md with REST API and UI pagination feature
Add comprehensive documentation for PR #1277 pagination feature including:
- Paginated REST API endpoints with backward compatibility
- Database indexes for efficient pagination queries
- HTMX-based UI pagination with keyboard navigation
- 11 new pagination configuration environment variables
- Pagination utilities module for offset and cursor-based pagination
- 1,089+ lines of test coverage
Addresses #1224
Signed-off-by: Mihai Criveti <[email protected]>
* fix: PostgreSQL foreign key handling in e5a59c16e041 migration
The unique constraint migration was failing on PostgreSQL during upgrades
from 0.8.0 because it attempted to drop tables that have foreign key
dependencies without first dropping those constraints.
Changes:
- Detect PostgreSQL and query information_schema for incoming FKs
- Drop foreign key constraints before dropping/recreating tables
- Recreate foreign key constraints after table recreation
- Apply same fix to both upgrade() and downgrade() functions
This fixes the error:
'cannot drop table prompts because other objects depend on it'
Affected tables: prompts, resources, a2a_agents
Dependent tables: server_prompt_association, prompt_metrics, etc.
Tested on: SQLite (unchanged behavior), PostgreSQL (now works)
Addresses upgrade path from 0.8.0 -> 0.9.0 (unreleased)
Signed-off-by: Mihai Criveti <[email protected]>
* fix: Use correct column name in email_api_tokens pagination index
The email_api_tokens table has a column 'user_email', not 'owner_email'.
The pagination migration was trying to create an index on a non-existent
column, causing PostgreSQL migrations to fail.
Changes:
- Renamed index from 'ix_email_api_tokens_owner_created_at' to
'ix_email_api_tokens_user_email_created_at'
- Updated both upgrade() and downgrade() functions
- Index now correctly references the 'user_email' column
Error fixed:
'column "owner_email" does not exist'
Table schema reference:
mcpgateway/alembic/versions/cfc3d6aa0fb2 (line 208)
defines email_api_tokens.user_email
Addresses upgrade path from 0.8.0 -> 0.9.0 (unreleased)
Signed-off-by: Mihai Criveti <[email protected]>
* fix: Use correct column name in email_auth_events pagination index
The email_auth_events table has a column 'user_email', not 'email'.
The pagination migration was trying to create an index on a non-existent
column, causing PostgreSQL migrations to fail.
Changes:
- Renamed index from 'ix_email_auth_events_user_timestamp' to
'ix_email_auth_events_user_email_timestamp'
- Changed column from 'email' to 'user_email' in index definition
- Updated both upgrade() and downgrade() functions
Error fixed:
'column "email" does not exist'
Table schema reference:
mcpgateway/alembic/versions/cfc3d6aa0fb2 (line 100)
defines email_auth_events.user_email
This is the second column name fix for the pagination migration.
First fix was for email_api_tokens (owner_email -> user_email).
Addresses upgrade path from 0.8.0 -> 0.9.0 (unreleased)
Signed-off-by: Mihai Criveti <[email protected]>
* fix: Correct field name for tool reachability status in pagination templates
The pagination templates were using 'tool.gatewayReachable' which doesn't
exist in the serialized JSON. The correct field name is 'tool.reachable'.
This caused all tools to show as 'Offline' with the message 'The host
gateway for this tool is unreachable' even when the MCP Server status
was Active.
Root Cause:
- ToolRead schema has 'reachable: bool' field
- BaseModelWithConfigDict uses alias_generator=to_camel_case
- Since 'reachable' has no underscores, it stays as 'reachable' in JSON
- Templates incorrectly expected 'gatewayReachable' instead
Changes:
- tools_partial.html: tool.gatewayReachable → tool.reachable (1 occurrence)
- tools_with_pagination.html: tool.gatewayReachable → tool.reachable (2 occurrences)
The 'reachable' field was originally added in PR #215 for gateway/tool
health monitoring and works correctly throughout the codebase except
for these template references introduced in the pagination PR.
Fixes incorrect status display in Tools UI pagination.
Signed-off-by: Mihai Criveti <[email protected]>
---------
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Madhav Kandukuri <[email protected]>
Co-authored-by: Mihai Criveti <[email protected]>1 parent 096ba2a commit ad60641
File tree
20 files changed
+3296
-514
lines changed- mcpgateway
- alembic/versions
- static
- templates
- utils
- tests
- e2e
- integration
- unit/mcpgateway
- utils
20 files changed
+3296
-514
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
961 | 961 | | |
962 | 962 | | |
963 | 963 | | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
22 | 55 | | |
23 | 56 | | |
24 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
473 | | - | |
| 473 | + | |
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
| 479 | + | |
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
| |||
0 commit comments