dialplan_translate
Test a dialplan translation by providing a dialplan ID and input string to retrieve the translated output and matching rule metadata, without initiating a call.
Instructions
Test a dialplan translation without dispatching a call.
Parameters
dpid:
Dialplan table id.
input:
Input string to translate (e.g. +14155551212).
Returns
The translated output string and matching rule metadata.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dpid | Yes | ||
| input | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The async function dialplan_translate that executes the tool logic. It uses the MI client to call 'dp_translate' with dpid and input parameters.
async def dialplan_translate(ctx: Context, dpid: int, input: str) -> dict[str, Any]: """Test a dialplan translation without dispatching a call. Parameters ---------- dpid: Dialplan table id. input: Input string to translate (e.g. ``+14155551212``). Returns ------- The translated output string and matching rule metadata. """ app = ctx.request_context.lifespan_context return await app.mi_client.execute( "dp_translate", {"dpid": str(dpid), "input": input} ) - src/opensips_mcp/tools/dialplan_tools.py:202-204 (registration)The @mcp.tool() decorator registers dialplan_translate as an MCP tool. The module is imported in server.py line 173 to ensure registration.
@mcp.tool() @require_permission("mi.read") async def dialplan_translate(ctx: Context, dpid: int, input: str) -> dict[str, Any]: - Type hints serve as the input schema: ctx (Context), dpid (int), input (str). Returns dict[str, Any].
async def dialplan_translate(ctx: Context, dpid: int, input: str) -> dict[str, Any]: - Imports the 'mcp' instance (the FastMCP server) used for tool registration, and 'require_permission' for RBAC enforcement.
from opensips_mcp.security.audit import audited from opensips_mcp.security.rbac import require_permission from opensips_mcp.server import mcp - src/opensips_mcp/server.py:173-173 (registration)The dialplan_tools module is imported in server.py, which triggers the @mcp.tool() decorators and registers all dialplan tools including dialplan_translate.
from opensips_mcp.tools import dialplan_tools as _dialplan_tools # noqa: E402, F401