Skip to main content
Glama
OpenSIPS

OpenSIPS MCP Server

Official
by OpenSIPS

carrierroute_replace_host

Replace a host in a carrier route to change the IP address of a carrier, domain, and prefix entry; changes apply at runtime without reload.

Instructions

Replace a host in carrier route (e.g. IP change).

Does not require a reload; applies at runtime.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
carrierYes
domainYes
prefixYes
hostYes
new_hostYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Async tool function that replaces a host in a carrier route at runtime. Calls MI command 'cr_replace_host' with carrier, domain, prefix, host, and new_host parameters. Decorated with @mcp.tool(), @audited('carrierroute_replace_host'), and @require_permission('mi.write').
    @mcp.tool()
    @audited("carrierroute_replace_host")
    @require_permission("mi.write")
    async def carrierroute_replace_host(
        ctx: Context,
        carrier: str,
        domain: str,
        prefix: str,
        host: str,
        new_host: str,
    ) -> dict[str, Any]:
        """Replace a host in carrier route (e.g. IP change).
    
        Does not require a reload; applies at runtime.
        """
        app = ctx.request_context.lifespan_context
        return await app.mi_client.execute(
            "cr_replace_host",
            {
                "carrier": carrier,
                "domain": domain,
                "prefix": prefix,
                "host": host,
                "new_host": new_host,
            },
        )
  • Module imports: registers tools via @mcp.tool() decorator pattern on each async function. The 'mcp' instance is imported from opensips_mcp.server, which is a FastMCP instance (line 138 of server.py). The module is imported in server.py line 166 to trigger registration.
    """MCP tools for the ``carrierroute`` module (multi-carrier routing).
    
    Carrier routing provides prefix-based least-cost routing across multiple
    carriers with host activation/deactivation (maintenance windows, failover).
    """
    
    from __future__ import annotations
    
    import logging
    from typing import Any
    
    from mcp.server.fastmcp import Context
    
    from opensips_mcp.security.audit import audited
    from opensips_mcp.security.rbac import require_permission
    from opensips_mcp.server import mcp
    
    logger = logging.getLogger(__name__)
  • FastMCP server instance creation and module import that triggers tool registration. The import of carrierroute_tools (line 166) causes all @mcp.tool() decorated functions to be registered.
    mcp = FastMCP("opensips-mcp-server", lifespan=app_lifespan)
    
    # Register tool modules (imported here to avoid circular imports).
    # Register prompt modules.
    from opensips_mcp.prompts import config_prompts as _cfg_prompts  # noqa: E402, F401
    
    # Register ecosystem prompt modules.
    from opensips_mcp.prompts import ecosystem_prompts as _eco_prompts  # noqa: E402, F401
    from opensips_mcp.prompts import educational_prompts as _edu_prompts  # noqa: E402, F401
    from opensips_mcp.prompts import migration_prompts as _mig_prompts  # noqa: E402, F401
    from opensips_mcp.prompts import security_prompts as _sec_prompts  # noqa: E402, F401
    from opensips_mcp.prompts import sip_prompts as _sip_prompts  # noqa: E402, F401
    from opensips_mcp.prompts import troubleshoot_prompts as _ts_prompts  # noqa: E402, F401
    from opensips_mcp.resources import config_resources as _cfg_res  # noqa: E402, F401
    from opensips_mcp.resources import db_resources as _db_res  # noqa: E402, F401
    from opensips_mcp.resources import docs_resources as _docs_res  # noqa: E402, F401
    
    # Register ecosystem resource modules.
    from opensips_mcp.resources import ecosystem_resources as _eco_res  # noqa: E402, F401
    from opensips_mcp.resources import scenario_resources as _scenario_res  # noqa: E402, F401
    
    # Register resource modules.
    from opensips_mcp.resources import system_resources as _sys_res  # noqa: E402, F401
    from opensips_mcp.tools import acc_tools as _acc_tools  # noqa: E402, F401
    from opensips_mcp.tools import avpops_tools as _avpops_tools  # noqa: E402, F401
    from opensips_mcp.tools import b2b_tools as _b2b_tools  # noqa: E402, F401
    from opensips_mcp.tools import benchmark_tools as _benchmark_tools  # noqa: E402, F401
    from opensips_mcp.tools import call_center_tools as _cc_tools  # noqa: E402, F401
    from opensips_mcp.tools import carrierroute_tools as _carrierroute_tools  # noqa: E402, F401
  • The @audited decorator used on carrierroute_replace_host. Wraps the function to log audit entries on success/failure with operation name, params (masked), result status, and role.
    def audited(operation: str):
        """Decorator that logs audit entries for tool calls."""
    
        def decorator(func):
            @wraps(func)
            async def wrapper(ctx: Context, *args, **kwargs):
                app = ctx.request_context.lifespan_context
                role = getattr(app.settings, "role", "unknown")
                try:
                    result = await func(ctx, *args, **kwargs)
                    audit_log(operation, kwargs, "success", role)
                    return result
                except Exception as e:
                    audit_log(operation, kwargs, f"error: {e}", role)
                    raise
    
            return wrapper
    
        return decorator
Behavior4/5

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

Given no annotations, the description adds valuable behavioral traits: the operation applies at runtime and does not require a reload. It does not disclose error handling or what happens if the host is missing, but the runtime note is helpful.

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

Conciseness5/5

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

Two sentences: first states purpose with example, second adds runtime behavior. No unnecessary words, front-loaded key information.

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?

With 5 required parameters and no schema descriptions, the description lacks essential details for correct invocation. The output schema exists but is not leveraged. The agent cannot confidently infer parameter semantics from the description alone.

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

Parameters2/5

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

Schema coverage is 0%, and the description does not describe any of the 5 parameters. The parameter names (carrier, domain, prefix, host, new_host) provide some clues, but no explanation of expected formats or relationships is given.

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 'Replace a host in carrier route' with an example 'IP change'. It uses a specific verb-resource combination and distinguishes from sibling tools like carrierroute_activate_host or carrierroute_reload.

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?

The description mentions 'Does not require a reload; applies at runtime', implying use when a runtime change is needed without reload. However, it does not explicitly state when to use this tool versus alternatives, nor when not to use it.

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