Skip to main content
Glama
OpenSIPS

OpenSIPS MCP Server

Official
by OpenSIPS

drouting_delete_gateway

Delete a dynamic routing gateway by its gateway ID, with an option to reload routing tables after the deletion.

Instructions

Delete a dynamic routing gateway by gwid.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gwidYes
reloadNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual tool handler for drouting_delete_gateway. It is decorated with @mcp.tool(), @audited('drouting_delete_gateway'), and @require_permission('db.write'). It accepts a gwid (int) and optional reload (bool), calls crud.delete_gateway to delete from the DB, and optionally triggers dr_reload via MI.
    @mcp.tool()
    @audited("drouting_delete_gateway")
    @require_permission("db.write")
    async def drouting_delete_gateway(
        ctx: Context,
        gwid: int,
        reload: bool = True,
    ) -> dict[str, Any]:
        """Delete a dynamic routing gateway by gwid."""
        from opensips_mcp.db.crud import drouting as crud
    
        app = ctx.request_context.lifespan_context
        async with app.db_session_factory() as session:
            deleted = await crud.delete_gateway(session, gwid)
        if not deleted:
            return {"error": "Gateway not found", "deleted": False}
        result: dict[str, Any] = {"gwid": gwid, "deleted": True}
        if reload:
            result.update(await _dr_reload(app))
        return result
  • The CRUD helper function delete_gateway that performs the actual deletion from the dr_gateways table. Uses SQLAlchemy delete statement on DRGateway model filtered by gwid, commits, and returns whether any row was deleted.
    async def delete_gateway(session: AsyncSession, gwid: int) -> bool:
        stmt = delete(DRGateway).where(DRGateway.gwid == gwid)
        result = await session.execute(stmt)
        await session.commit()
        return result.rowcount > 0
  • The SQLAlchemy ORM model DRGateway, mapped to the 'dr_gateways' table. Defines columns: gwid (PK), 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 _dr_reload helper function that attempts to reload dynamic routing via MI command 'dr_reload'. Used optionally by the handler when reload=True.
    async def _dr_reload(app: Any) -> dict[str, Any]:
        """Attempt MI dr_reload and return status dict."""
        try:
            await app.mi_client.execute("dr_reload")
            return {"reloaded": True}
        except Exception as exc:
            logger.warning("dr_reload failed: %s", exc)
            return {"reloaded": False, "reload_error": str(exc)}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behaviors. It only states 'Delete', implying destructiveness, but fails to explain side effects, reload behavior, or error conditions. Crucial context is missing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise but under-specified. It does not waste words, but the brevity sacrifices necessary detail, making it only adequate for a minimal viable description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description lacks crucial context for a deletion tool: no mention of required permissions, impact on associated data, return values (despite an output schema), or when reload is needed. The agent would need additional information to use it safely.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, yet the description adds no explanation for either parameter. 'gwid' and 'reload' are not described beyond their schema types and default, leaving the agent without guidance on values or behavior.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete'), the resource ('dynamic routing gateway'), and the identifier ('by gwid'). It distinguishes from sibling tools like drouting_delete_carrier and drouting_delete_rule by specifying the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives, no prerequisites or consequences mentioned. The description does not help the agent decide between this and similar deletion tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/OpenSIPS/opensips-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server