From 10ea45c0cd2c3d2171301918aa8c7946f44ab981 Mon Sep 17 00:00:00 2001 From: rakdutta Date: Tue, 25 Nov 2025 11:57:27 +0530 Subject: [PATCH 01/14] fix teamname in resources Signed-off-by: rakdutta --- mcpgateway/admin.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mcpgateway/admin.py b/mcpgateway/admin.py index bff61268b..1b01e59f3 100644 --- a/mcpgateway/admin.py +++ b/mcpgateway/admin.py @@ -5083,7 +5083,7 @@ async def admin_tools_partial_html( # Serialize tools data = jsonable_encoder(tools_pydantic) - + # Build pagination metadata pagination = PaginationMeta( page=page, @@ -5572,13 +5572,20 @@ async def admin_resources_partial_html( resources_data = [] for r in resources_db: try: + # Ensure the resource has a resolved team name before conversion + try: + team_name = local_resource_service._get_team_name(db, getattr(r, "team_id", None)) + except Exception: + team_name = None + r.team = team_name resources_data.append(local_resource_service._convert_resource_to_read(r)) # pylint: disable=protected-access except Exception as e: LOGGER.warning(f"Failed to convert resource {getattr(r, 'id', '')} to schema: {e}") continue data = jsonable_encoder(resources_data) - + LOGGER.info(f"resources_data: {resources_data}") + LOGGER.info(f"data: {data}") # Build pagination metadata pagination = PaginationMeta( page=page, From 6615939bcb90d1f03ab38af72f15fc46c7be010f Mon Sep 17 00:00:00 2001 From: rakdutta Date: Tue, 25 Nov 2025 14:38:09 +0530 Subject: [PATCH 02/14] endpoints Signed-off-by: rakdutta --- CHANGELOG.md | 2 +- README.md | 12 +++++----- docs/docs/index.md | 12 +++++----- docs/docs/manage/api-usage.md | 12 +++++----- docs/docs/using/grpc-services.md | 2 +- mcpgateway/admin.py | 14 ++++++------ mcpgateway/main.py | 12 +++++----- mcpgateway/templates/admin.html | 18 +++++++-------- mcpgateway/templates/prompts_partial.html | 2 +- mcpgateway/templates/resources_partial.html | 4 ++-- mcpgateway/templates/tools_partial.html | 4 ++-- .../templates/tools_with_pagination.html | 8 +++---- tests/e2e/test_admin_apis.py | 8 +++---- tests/e2e/test_main_apis.py | 22 +++++++++---------- tests/unit/mcpgateway/test_main.py | 16 +++++++------- tests/unit/mcpgateway/test_main_extended.py | 4 ++-- 16 files changed, 76 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4eadcbcb4..7c191ec4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -584,7 +584,7 @@ This release focuses on **Advanced OAuth Integration, Plugin Ecosystem, MCP Regi - `GET /grpc` - List all gRPC services with team filtering - `GET /grpc/{id}` - Get service details - `PUT /grpc/{id}` - Update service configuration - - `POST /grpc/{id}/toggle` - Enable/disable service + - `POST /grpc/{id}/state` - Enable/disable service - `POST /grpc/{id}/delete` - Delete service - `POST /grpc/{id}/reflect` - Re-trigger service discovery - `GET /grpc/{id}/methods` - List discovered methods diff --git a/README.md b/README.md index a0d8dab20..bb342e1c3 100644 --- a/README.md +++ b/README.md @@ -2264,9 +2264,9 @@ curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ # Toggle active status curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/tools/1/toggle?activate=false + http://localhost:4444/tools/1/state?activate=false curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/tools/1/toggle?activate=true + http://localhost:4444/tools/1/state?activate=true # Delete tool curl -X DELETE -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/tools/1 @@ -2326,7 +2326,7 @@ curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ # Toggle agent status curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/a2a/agent-id/toggle?activate=false + http://localhost:4444/a2a/agent-id/state?activate=false # Delete agent curl -X DELETE -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ @@ -2376,7 +2376,7 @@ curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ # Toggle active status curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/gateways/1/toggle?activate=false + http://localhost:4444/gateways/1/state?activate=false # Delete gateway curl -X DELETE -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/gateways/1 @@ -2462,7 +2462,7 @@ curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ # Toggle active curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/prompts/5/toggle?activate=false + http://localhost:4444/prompts/5/state?activate=false # Delete prompt curl -X DELETE -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/prompts/greet @@ -2520,7 +2520,7 @@ curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ # Toggle active curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/servers/UUID_OF_SERVER_1/toggle?activate=false + http://localhost:4444/servers/UUID_OF_SERVER_1/state?activate=false ``` diff --git a/docs/docs/index.md b/docs/docs/index.md index 43b68af99..44079078a 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -1716,9 +1716,9 @@ curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ # Toggle active status curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/tools/1/toggle?activate=false + http://localhost:4444/tools/1/state?activate=false curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/tools/1/toggle?activate=true + http://localhost:4444/tools/1/state?activate=true # Delete tool curl -X DELETE -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/tools/1 @@ -1778,7 +1778,7 @@ curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ # Toggle agent status curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/a2a/agent-id/toggle?activate=false + http://localhost:4444/a2a/agent-id/state?activate=false # Delete agent curl -X DELETE -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ @@ -1828,7 +1828,7 @@ curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ # Toggle active status curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/gateways/1/toggle?activate=false + http://localhost:4444/gateways/1/state?activate=false # Delete gateway curl -X DELETE -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/gateways/1 @@ -1914,7 +1914,7 @@ curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ # Toggle active curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/prompts/5/toggle?activate=false + http://localhost:4444/prompts/5/state?activate=false # Delete prompt curl -X DELETE -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/prompts/greet @@ -1972,7 +1972,7 @@ curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ # Toggle active curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ - http://localhost:4444/servers/UUID_OF_SERVER_1/toggle?activate=false + http://localhost:4444/servers/UUID_OF_SERVER_1/state?activate=false ``` diff --git a/docs/docs/manage/api-usage.md b/docs/docs/manage/api-usage.md index 54e9f2498..beb7c941c 100644 --- a/docs/docs/manage/api-usage.md +++ b/docs/docs/manage/api-usage.md @@ -164,7 +164,7 @@ curl -s -X PUT -H "Authorization: Bearer $TOKEN" \ ```bash # Toggle gateway enabled status curl -s -X POST -H "Authorization: Bearer $TOKEN" \ - $BASE_URL/gateways/$GATEWAY_ID/toggle?activate=false | jq '.' + $BASE_URL/gateways/$GATEWAY_ID/state?activate=false | jq '.' ``` ### Delete Gateway @@ -286,7 +286,7 @@ curl -s -X PUT -H "Authorization: Bearer $TOKEN" \ ```bash # Toggle tool enabled status curl -s -X POST -H "Authorization: Bearer $TOKEN" \ - $BASE_URL/tools/$TOOL_ID/toggle?activate=false | jq '.' + $BASE_URL/tools/$TOOL_ID/state?activate=false | jq '.' ``` ### Delete Tool @@ -409,7 +409,7 @@ curl -s -X PUT -H "Authorization: Bearer $TOKEN" \ ```bash # Toggle server enabled status curl -s -X POST -H "Authorization: Bearer $TOKEN" \ - $BASE_URL/servers/$SERVER_ID/toggle?activate=false | jq '.' + $BASE_URL/servers/$SERVER_ID/state?activate=false | jq '.' ``` ### Delete Server @@ -501,7 +501,7 @@ curl -s -X PUT -H "Authorization: Bearer $TOKEN" \ ```bash # Toggle resource enabled status curl -s -X POST -H "Authorization: Bearer $TOKEN" \ - $BASE_URL/resources/$RESOURCE_ID/toggle?activate=false | jq '.' + $BASE_URL/resources/$RESOURCE_ID/state?activate=false | jq '.' ``` ### Delete Resource @@ -583,7 +583,7 @@ curl -s -X PUT -H "Authorization: Bearer $TOKEN" \ ```bash # Toggle prompt enabled status curl -s -X POST -H "Authorization: Bearer $TOKEN" \ - $BASE_URL/prompts/$PROMPT_ID/toggle?activate=false | jq '.' + $BASE_URL/prompts/$PROMPT_ID/state?activate=false | jq '.' ``` ### Delete Prompt @@ -1038,7 +1038,7 @@ TOOLS=$(curl -s -H "Authorization: Bearer $TOKEN" $BASE_URL/tools | \ for TOOL_ID in $TOOLS; do echo "Enabling tool: $TOOL_ID" curl -s -X POST -H "Authorization: Bearer $TOKEN" \ - $BASE_URL/tools/$TOOL_ID/toggle > /dev/null + $BASE_URL/tools/$TOOL_ID/state > /dev/null done echo "Done!" diff --git a/docs/docs/using/grpc-services.md b/docs/docs/using/grpc-services.md index af6d91cbf..9ffcc3f4a 100644 --- a/docs/docs/using/grpc-services.md +++ b/docs/docs/using/grpc-services.md @@ -307,7 +307,7 @@ Content-Type: application/json ### Toggle Service ```bash -POST /grpc/{service_id}/toggle +POST /grpc/{service_id}/state ``` ### Delete Service diff --git a/mcpgateway/admin.py b/mcpgateway/admin.py index 1b01e59f3..fc95ea103 100644 --- a/mcpgateway/admin.py +++ b/mcpgateway/admin.py @@ -1337,7 +1337,7 @@ async def admin_edit_server( return JSONResponse(content={"message": str(ex), "success": False}, status_code=500) -@admin_router.post("/servers/{server_id}/toggle") +@admin_router.post("/servers/{server_id}/state") async def admin_toggle_server( server_id: str, request: Request, @@ -1917,7 +1917,7 @@ async def admin_list_gateway_ids( return {"gateway_ids": ids} -@admin_router.post("/gateways/{gateway_id}/toggle") +@admin_router.post("/gateways/{gateway_id}/state") async def admin_toggle_gateway( gateway_id: str, request: Request, @@ -6585,7 +6585,7 @@ async def admin_delete_tool(tool_id: str, request: Request, db: Session = Depend return RedirectResponse(f"{root_path}/admin#tools", status_code=303) -@admin_router.post("/tools/{tool_id}/toggle") +@admin_router.post("/tools/{tool_id}/state") async def admin_toggle_tool( tool_id: str, request: Request, @@ -7953,7 +7953,7 @@ async def admin_delete_resource(resource_id: str, request: Request, db: Session return RedirectResponse(f"{root_path}/admin#resources", status_code=303) -@admin_router.post("/resources/{resource_id}/toggle") +@admin_router.post("/resources/{resource_id}/state") async def admin_toggle_resource( resource_id: int, request: Request, @@ -8508,7 +8508,7 @@ async def admin_delete_prompt(prompt_id: str, request: Request, db: Session = De return RedirectResponse(f"{root_path}/admin#prompts", status_code=303) -@admin_router.post("/prompts/{prompt_id}/toggle") +@admin_router.post("/prompts/{prompt_id}/state") async def admin_toggle_prompt( prompt_id: int, request: Request, @@ -10869,7 +10869,7 @@ async def admin_edit_a2a_agent( return JSONResponse({"message": str(e), "success": False}, status_code=500) -@admin_router.post("/a2a/{agent_id}/toggle") +@admin_router.post("/a2a/{agent_id}/state") async def admin_toggle_a2a_agent( agent_id: str, request: Request, @@ -11162,7 +11162,7 @@ async def admin_update_grpc_service( raise HTTPException(status_code=500, detail=str(e)) -@admin_router.post("/grpc/{service_id}/toggle") +@admin_router.post("/grpc/{service_id}/state") async def admin_toggle_grpc_service( service_id: str, db: Session = Depends(get_db), diff --git a/mcpgateway/main.py b/mcpgateway/main.py index 7e2bd787f..5d83f21b4 100644 --- a/mcpgateway/main.py +++ b/mcpgateway/main.py @@ -1815,7 +1815,7 @@ async def update_server( raise HTTPException(status_code=409, detail=ErrorFormatter.format_database_error(e)) -@server_router.post("/{server_id}/toggle", response_model=ServerRead) +@server_router.post("/{server_id}/state", response_model=ServerRead) @require_permission("servers.update") async def toggle_server_status( server_id: str, @@ -2290,7 +2290,7 @@ async def update_a2a_agent( raise HTTPException(status_code=409, detail=ErrorFormatter.format_database_error(e)) -@a2a_router.post("/{agent_id}/toggle", response_model=A2AAgentRead) +@a2a_router.post("/{agent_id}/state", response_model=A2AAgentRead) @require_permission("a2a.update") async def toggle_a2a_agent_status( agent_id: str, @@ -2689,7 +2689,7 @@ async def delete_tool(tool_id: str, db: Session = Depends(get_db), user=Depends( raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e)) -@tool_router.post("/{tool_id}/toggle") +@tool_router.post("/{tool_id}/state") @require_permission("tools.update") async def toggle_tool_status( tool_id: str, @@ -2753,7 +2753,7 @@ async def list_resource_templates( return ListResourceTemplatesResult(_meta={}, resource_templates=resource_templates, next_cursor=None) # No pagination for now -@resource_router.post("/{resource_id}/toggle") +@resource_router.post("/{resource_id}/state") @require_permission("resources.update") async def toggle_resource_status( resource_id: int, @@ -3101,7 +3101,7 @@ async def subscribe_resource(resource_id: str, user=Depends(get_current_user_wit ############### # Prompt APIs # ############### -@prompt_router.post("/{prompt_id}/toggle") +@prompt_router.post("/{prompt_id}/state") @require_permission("prompts.update") async def toggle_prompt_status( prompt_id: int, @@ -3460,7 +3460,7 @@ async def delete_prompt(prompt_id: str, db: Session = Depends(get_db), user=Depe ################ # Gateway APIs # ################ -@gateway_router.post("/{gateway_id}/toggle") +@gateway_router.post("/{gateway_id}/state") @require_permission("gateways.update") async def toggle_gateway_status( gateway_id: str, diff --git a/mcpgateway/templates/admin.html b/mcpgateway/templates/admin.html index 3fe94e430..a27833dff 100644 --- a/mcpgateway/templates/admin.html +++ b/mcpgateway/templates/admin.html @@ -1962,7 +1962,7 @@

{% if server.isActive %}
@@ -1978,7 +1978,7 @@

{% else %} @@ -4173,7 +4173,7 @@

{% if gateway.enabled %} @@ -4189,7 +4189,7 @@

{% else %} @@ -5438,7 +5438,7 @@

{% if agent.enabled %} - + {% else %} -
+
- + ` : - `
+ `
`; diff --git a/mcpgateway/templates/prompts_partial.html b/mcpgateway/templates/prompts_partial.html index ff3b2914e..b813794fc 100644 --- a/mcpgateway/templates/prompts_partial.html +++ b/mcpgateway/templates/prompts_partial.html @@ -41,7 +41,7 @@
-
+
diff --git a/mcpgateway/templates/resources_partial.html b/mcpgateway/templates/resources_partial.html index 5d013f0c1..a72c37e27 100644 --- a/mcpgateway/templates/resources_partial.html +++ b/mcpgateway/templates/resources_partial.html @@ -34,12 +34,12 @@
{% if resource.isActive %} -
+
{% else %} -
+
diff --git a/mcpgateway/templates/tools_partial.html b/mcpgateway/templates/tools_partial.html index 3436696a3..baeb58457 100644 --- a/mcpgateway/templates/tools_partial.html +++ b/mcpgateway/templates/tools_partial.html @@ -222,7 +222,7 @@ {% if tool.enabled %}
@@ -238,7 +238,7 @@ {% else %} diff --git a/mcpgateway/templates/tools_with_pagination.html b/mcpgateway/templates/tools_with_pagination.html index f7a628374..41cc7ffa2 100644 --- a/mcpgateway/templates/tools_with_pagination.html +++ b/mcpgateway/templates/tools_with_pagination.html @@ -128,14 +128,14 @@
{% if tool.enabled %} - + {% else %} -
+
{% else %} -
+