Skip to content

Commit 7d95f0c

Browse files
Id migration wrapper (#311)
* minor change Signed-off-by: Keval Mahajan <[email protected]> * make ruff changes Signed-off-by: Keval Mahajan <[email protected]> * Updated test cases for wrapper Signed-off-by: Keval Mahajan <[email protected]> * Minor logging change Signed-off-by: Madhav Kandukuri <[email protected]> * Linting fixes Signed-off-by: Madhav Kandukuri <[email protected]> --------- Signed-off-by: Keval Mahajan <[email protected]> Co-authored-by: Madhav Kandukuri <[email protected]>
1 parent a735cb7 commit 7d95f0c

File tree

9 files changed

+18
-12
lines changed

9 files changed

+18
-12
lines changed

mcpgateway/alembic/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from logging.config import fileConfig
44

55
# Third-Party
6-
from alembic import context
76
from sqlalchemy import engine_from_config, pool
87

98
# First-Party
9+
from alembic import context
1010
from mcpgateway.config import settings
1111
from mcpgateway.db import Base
1212

mcpgateway/alembic/versions/b77ca9d2de7e_uuid_pk_and_slug_refactor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
Create Date: 2025-06-26 21:29:59.117140
77
88
"""
9+
910
# Standard
1011
from typing import Sequence, Union
1112
import uuid
1213

1314
# Third-Party
14-
from alembic import op
1515
import sqlalchemy as sa
1616
from sqlalchemy.orm import Session
1717

1818
# First-Party
19+
from alembic import op
1920
from mcpgateway.config import settings
2021
from mcpgateway.utils.create_slug import slugify
2122

mcpgateway/alembic/versions/e4fc04d1a442_add_annotations_to_tables.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
Create Date: 2025-06-27 21:45:35.099713
77
88
"""
9+
910
# Standard
1011
from typing import Sequence, Union
1112

1213
# Third-Party
13-
from alembic import op
1414
import sqlalchemy as sa
1515

16+
# First-Party
17+
from alembic import op
18+
1619
# revision identifiers, used by Alembic.
1720
revision: str = "e4fc04d1a442"
1821
down_revision: Union[str, Sequence[str], None] = "b77ca9d2de7e"

mcpgateway/alembic/versions/e75490e949b1_add_improved_status_to_tables.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
from typing import Sequence, Union
1111

1212
# Third-Party
13+
import sqlalchemy as sa
14+
15+
# First-Party
1316
# Alembic / SQLAlchemy
1417
from alembic import op
15-
import sqlalchemy as sa
1618

1719
# Revision identifiers.
1820
revision: str = "e75490e949b1"

mcpgateway/bootstrap_db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
import logging
2626

2727
# Third-Party
28-
from alembic import command
2928
from alembic.config import Config
3029
from sqlalchemy import create_engine, inspect
3130

3231
# First-Party
32+
from alembic import command
3333
from mcpgateway.config import settings
3434
from mcpgateway.db import Base
3535

mcpgateway/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def _parse_federation_peers(cls, v):
167167
# Health Checks
168168
health_check_interval: int = 60 # seconds
169169
health_check_timeout: int = 10 # seconds
170-
unhealthy_threshold: int = 10
170+
unhealthy_threshold: int = 5 # after this many failures, mark as Offline
171171

172172
filelock_path: str = "tmp/gateway_service_leader.lock"
173173

mcpgateway/services/tool_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ async def toggle_tool_status(self, db: Session, tool_id: str, activate: bool, re
375375
await self._notify_tool_activated(tool)
376376
else:
377377
await self._notify_tool_deactivated(tool)
378-
logger.info(f"Tool: {tool.name} is {'enabled' if activate else 'disabled'}{' and accessible' if reachable else 'but inaccessible'}")
378+
logger.info(f"Tool: {tool.name} is {'enabled' if activate else 'disabled'}{' and accessible' if reachable else ' but inaccessible'}")
379379

380380
return self._convert_tool_to_read(tool)
381381
except Exception as e:

mcpgateway/wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ async def tools_metadata(tool_ids: List[str]) -> List[Dict[str, Any]]:
216216
if tool_ids == ["0"]:
217217
return data
218218

219-
return [tool for tool in data if tool["id"] in tool_ids]
219+
return [tool for tool in data if tool["name"] in tool_ids]
220220

221221

222222
async def get_prompts_from_mcp_server(catalog_urls: List[str]) -> List[str]:

tests/unit/mcpgateway/test_wrapper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,20 +415,20 @@ async def _meta(_):
415415
async def test_get_tools_and_metadata(monkeypatch, wrapper):
416416
# fake catalog → two servers with associated tools
417417
catalog = [
418-
{"id": "1", "associatedTools": ["10", "11"]},
419-
{"id": "2", "associatedTools": ["20"]},
418+
{"id": "1", "associatedTools": ["tool1", "tool2"]},
419+
{"id": "2", "associatedTools": ["tool3"]},
420420
]
421421
monkeypatch.setattr(wrapper, "fetch_url", _json_fetcher(catalog))
422422
out = await wrapper.get_tools_from_mcp_server(["https://host.com/servers/1"])
423-
assert out == ["10", "11"]
423+
assert out == ["tool1", "tool2"]
424424

425425
# now cover tools_metadata *filter* & *all* paths
426426
tools_payload = [
427427
{"id": "10", "name": "A"},
428428
{"id": "11", "name": "B"},
429429
]
430430
monkeypatch.setattr(wrapper, "fetch_url", _json_fetcher(tools_payload))
431-
subset = await wrapper.tools_metadata(["10"])
431+
subset = await wrapper.tools_metadata(["A"])
432432
assert subset == [{"id": "10", "name": "A"}]
433433

434434
everything = await wrapper.tools_metadata(["0"])

0 commit comments

Comments
 (0)