Skip to main content
Glama
OpenSIPS

OpenSIPS MCP Server

Official
by OpenSIPS

dispatcher_update

Modify an existing dispatcher destination by its ID. Update attributes such as destination, set ID, flags, priority, weight, socket, state, and more. Optionally reload the dispatcher module to apply changes.

Instructions

Update a dispatcher destination by ID. Optionally triggers MI ds_reload.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
destinationNo
setidNo
flagsNo
priorityNo
attrsNo
descriptionNo
weightNo
socketNo
stateNo
reloadNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The 'dispatcher_update' MCP tool handler function. Decorated with @mcp.tool(), @audited('dispatcher_update'), and @require_permission('db.write'). Accepts an ID and optional fields to update, then calls crud.update_dispatcher() and optionally triggers MI ds_reload.
    @mcp.tool()
    @audited("dispatcher_update")
    @require_permission("db.write")
    async def dispatcher_update(
        ctx: Context,
        id: int,
        destination: str | None = None,
        setid: int | None = None,
        flags: int | None = None,
        priority: int | None = None,
        attrs: str | None = None,
        description: str | None = None,
        weight: int | None = None,
        socket: str | None = None,
        state: int | None = None,
        reload: bool = True,
    ) -> dict[str, Any]:
        """Update a dispatcher destination by ID. Optionally triggers MI ds_reload."""
        from opensips_mcp.db.crud import dispatcher as crud
    
        app = ctx.request_context.lifespan_context
        kwargs: dict[str, Any] = {}
        for field in (
            "destination", "setid", "flags", "priority", "attrs",
            "description", "weight", "socket", "state",
        ):
            val = locals()[field]
            if val is not None:
                kwargs[field] = val
    
        async with app.db_session_factory() as session:
            ds = await crud.update_dispatcher(session, id, **kwargs)
            if not ds:
                return {"error": "Dispatcher not found"}
    
        result: dict[str, Any] = {
            "id": ds.id,
            "destination": ds.destination,
            "setid": ds.setid,
            "updated": True,
        }
        if reload:
            try:
                await app.mi_client.execute("ds_reload")
                result["reloaded"] = True
            except Exception as exc:
                logger.warning("ds_reload failed: %s", exc)
                result["reloaded"] = False
                result["reload_error"] = str(exc)
        return result
  • The update_dispatcher CRUD helper that performs the actual database update. Selects by ID, sets any provided non-id attributes on the Dispatcher ORM model, commits, and returns the updated object.
    async def update_dispatcher(
        session: AsyncSession, id: int, **kwargs
    ) -> Dispatcher | None:
        stmt = select(Dispatcher).where(Dispatcher.id == id)
        result = await session.execute(stmt)
        ds = result.scalar_one_or_none()
        if not ds:
            return None
        for k, v in kwargs.items():
            if hasattr(ds, k) and k != "id":
                setattr(ds, k, v)
        await session.commit()
        await session.refresh(ds)
        return ds
  • The Dispatcher SQLAlchemy model (schema) defining the 'dispatcher' table columns: id, setid, destination, flags, priority, attrs, description, weight, socket, state.
    class Dispatcher(Base):
        __tablename__ = "dispatcher"
    
        id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
        setid: Mapped[int] = mapped_column(Integer, default=0)
        destination: Mapped[str] = mapped_column(String(256), nullable=False)
        flags: Mapped[int] = mapped_column(Integer, default=0)
        priority: Mapped[int] = mapped_column(Integer, default=0)
        attrs: Mapped[str] = mapped_column(String(128), default="")
        description: Mapped[str] = mapped_column(String(64), default="")
        weight: Mapped[int] = mapped_column(Integer, default=1)
        socket: Mapped[str] = mapped_column(String(128), default="")
        state: Mapped[int] = mapped_column(Integer, default=0)
  • Registration of the dispatcher_tools module in the main server file, which causes the @mcp.tool() decorator on dispatcher_update to register it.
    from opensips_mcp.tools import dispatcher_tools as _dispatcher_tools  # noqa: E402, F401
Behavior2/5

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

Mentions optional side effect 'triggers MI ds_reload', but otherwise lacks behavioral disclosure beyond what annotations (none) provide. No details on permissions, reversibility, or error handling.

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

Conciseness4/5

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

Two efficient sentences with no waste, but front-loading is fine; however, more detail could be added without sacrificing conciseness.

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?

For a tool with 11 parameters and a side effect, the description is too minimal. Does not explain return values (output schema exists) or provide sufficient context for correct invocation.

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?

With 0% schema description coverage, the description must add meaning but only references 'by ID'. The 10 optional parameters are completely undocumented.

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?

Clearly states 'Update a dispatcher destination by ID' with specific verb and resource, and distinguishes from sibling tools like dispatcher_add and dispatcher_remove.

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

Usage Guidelines3/5

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

Implies usage for updating existing dispatcher destinations, but provides no explicit guidance on when to use vs alternatives or prerequisites.

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