address_remove
Delete an address or permissions entry using its ID. Optionally reload the address table to apply changes immediately.
Instructions
Remove an address/permissions entry by ID. Optionally triggers MI address_reload.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| reload | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The address_remove MCP tool handler. Decorated with @mcp.tool(), @audited('address_remove'), and @require_permission('db.write'). Accepts an address ID and optional reload flag. Calls crud.delete_address() to remove the entry, and optionally triggers MI address_reload.
@mcp.tool() @audited("address_remove") @require_permission("db.write") async def address_remove( ctx: Context, id: int, reload: bool = True, ) -> dict[str, Any]: """Remove an address/permissions entry by ID. Optionally triggers MI address_reload.""" from opensips_mcp.db.crud import address as crud app = ctx.request_context.lifespan_context async with app.db_session_factory() as session: deleted = await crud.delete_address(session, id) if not deleted: return {"error": "Address not found", "deleted": False} result: dict[str, Any] = {"id": id, "deleted": True} if reload: try: await app.mi_client.execute("address_reload") result["reloaded"] = True except Exception as exc: logger.warning("address_reload failed: %s", exc) result["reloaded"] = False result["reload_error"] = str(exc) return result - src/opensips_mcp/tools/permissions_tools.py:107-107 (registration)The @mcp.tool() decorator on address_remove registers it as an MCP tool with the framework.
@mcp.tool() - The delete_address CRUD function that performs the actual database deletion of an address record by ID using SQLAlchemy.
async def delete_address(session: AsyncSession, id: int) -> bool: stmt = delete(Address).where(Address.id == id) result = await session.execute(stmt) await session.commit() return result.rowcount > 0 - The Address SQLAlchemy model representing the 'address' database table with columns: id, grp, ip, mask, port, proto, pattern, context_info.
class Address(Base): __tablename__ = "address" id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) grp: Mapped[int] = mapped_column(Integer, default=1) ip: Mapped[str] = mapped_column(String(50), nullable=False) mask: Mapped[int] = mapped_column(Integer, default=32) port: Mapped[int] = mapped_column(Integer, default=0) proto: Mapped[str] = mapped_column(String(8), default="any") pattern: Mapped[str | None] = mapped_column(String(64), nullable=True) context_info: Mapped[str | None] = mapped_column(String(64), nullable=True) - src/opensips_mcp/server.py:194-194 (registration)The import statement in server.py that triggers registration of all permissions tools (including address_remove) by importing the module.
from opensips_mcp.tools import permissions_tools as _permissions_tools # noqa: E402, F401