drouting_list_gateways
Retrieve a list of dynamic routing gateways from OpenSIPS. Supports pagination with limit and offset parameters to control result size.
Instructions
List dynamic routing gateways.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "drouting_list_gateways"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main MCP tool handler for 'drouting_list_gateways'. It is decorated with @mcp.tool() and @require_permission('db.read'). It accepts limit/offset parameters, queries gateways via the CRUD layer, and returns a list of gateway dicts with fields: gwid, type, address, strip, pri_prefix, attrs, probe_mode, state, socket, description, plus a count.
@mcp.tool() @require_permission("db.read") async def drouting_list_gateways( ctx: Context, limit: int = 100, offset: int = 0, ) -> dict[str, Any]: """List dynamic routing gateways.""" from opensips_mcp.db.crud import drouting as crud app = ctx.request_context.lifespan_context async with app.db_session_factory() as session: gateways = await crud.list_gateways(session, limit=limit, offset=offset) return { "gateways": [ { "gwid": g.gwid, "type": g.type, "address": g.address, "strip": g.strip, "pri_prefix": g.pri_prefix, "attrs": g.attrs, "probe_mode": g.probe_mode, "state": g.state, "socket": g.socket, "description": g.description, } for g in gateways ], "count": len(gateways), } - The DRGateway SQLAlchemy model (schema) that defines the structure of the dr_gateways table. Fields: gwid, type, address, strip, pri_prefix, attrs, probe_mode, state, socket, description.
class DRGateway(Base): __tablename__ = "dr_gateways" gwid: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) type: Mapped[int] = mapped_column(Integer, default=0) address: Mapped[str] = mapped_column(String(128), nullable=False) strip: Mapped[int] = mapped_column(Integer, default=0) pri_prefix: Mapped[str] = mapped_column(String(64), default="") attrs: Mapped[str] = mapped_column(String(255), default="") probe_mode: Mapped[int] = mapped_column(Integer, default=0) state: Mapped[int] = mapped_column(Integer, default=0) socket: Mapped[str] = mapped_column(String(128), default="") description: Mapped[str] = mapped_column(String(128), default="") - The CRUD helper function 'list_gateways' that executes the actual SQLAlchemy SELECT query on the DRGateway model with limit/offset pagination.
async def list_gateways( session: AsyncSession, limit: int = 100, offset: int = 0, ) -> list[DRGateway]: stmt = select(DRGateway).limit(limit).offset(offset) result = await session.execute(stmt) return list(result.scalars().all()) - src/opensips_mcp/tools/drouting_tools.py:113-113 (registration)The @mcp.tool() decorator registers this function as an MCP tool named 'drouting_list_gateways' (the function name becomes the tool name).
@mcp.tool() - A resource docstring that references the drouting_list_gateways tool, telling users to use it to query gateways from the database.
"usage": ( "Use the drouting_list_gateways tool to query gateways " "from the database. Gateways are referenced by gwid in " "the dr_rules gwlist column." ),