add_allowed_ip
Whitelist an IP address for a SIP account to enable secure communication. Input the SIP account name and IP address to return a JSON list of all allowed IPs for the account.
Instructions
Whitelist an IP to a SIP account
Args: sipaccount_name: Name of SIP account ip: IP address to allow
Returns a JSON object with all whitelisted IP addresses for account Example output: { "allowed_ips": [ "88.99.12.33", "99.33.55.11" ] }
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes | IP address to allow | |
| sipaccount_name | Yes | Name of sip account |
Implementation Reference
- The handler function that implements the 'add_allowed_ip' tool logic. It takes sipaccount_name and ip parameters (with Pydantic validation), sends a POST request to the Didlogic API via base.call_didlogic_api, and returns the response.async def add_allowed_ip(ctx: Context, sipaccount_name: str | int = Field( description="Name of sip account" ), ip: str = Field( description="IP address to allow") ) -> str: """ Whitelist an IP to a SIP account Args: sipaccount_name: Name of SIP account ip: IP address to allow Returns a JSON object with all whitelisted IP addresses for account Example output: { "allowed_ips": [ "88.99.12.33", "99.33.55.11" ] } """ data = {"ip": ip} response = await base.call_didlogic_api( ctx, "POST", f"/v1/sipaccounts/{sipaccount_name}/allowed_ips", data=data ) return response.text
- src/didlogic_mcp/server.py:99-105 (registration)Registration block in the main server file where tools.allowed_ips.register_tools(mcp) is called to register the add_allowed_ip tool (among others) to the FastMCP server.tools.balance.register_tools(mcp) tools.sip_accounts.register_tools(mcp) tools.allowed_ips.register_tools(mcp) tools.purchases.register_tools(mcp) tools.purchase.register_tools(mcp) tools.calls.register_tools(mcp) tools.transactions.register_tools(mcp)
- src/didlogic_mcp/tools/allowed_ips.py:6-79 (registration)The register_tools function decorated with @mcp.tool() decorators for add_allowed_ip and related tools, which performs the actual tool registration when called.def register_tools(mcp: FastMCP): @mcp.tool() async def get_allowed_ips( ctx: Context, sipaccount_name: str | int = Field() ) -> str: """ Get list of whitelisted IPs for a SIP account Args: sipaccount_name: Name of SIP account Returns a JSON object with array of whitelisted IP for SIP Account Example output: { "allowed_ips": [ "88.99.12.33" ] } """ response = await base.call_didlogic_api( ctx, "GET", f"/v1/sipaccounts/{sipaccount_name}/allowed_ips" ) return response.text @mcp.tool() async def add_allowed_ip(ctx: Context, sipaccount_name: str | int = Field( description="Name of sip account" ), ip: str = Field( description="IP address to allow") ) -> str: """ Whitelist an IP to a SIP account Args: sipaccount_name: Name of SIP account ip: IP address to allow Returns a JSON object with all whitelisted IP addresses for account Example output: { "allowed_ips": [ "88.99.12.33", "99.33.55.11" ] } """ data = {"ip": ip} response = await base.call_didlogic_api( ctx, "POST", f"/v1/sipaccounts/{sipaccount_name}/allowed_ips", data=data ) return response.text @mcp.tool() async def delete_allowed_ip( ctx: Context, sipaccount_name: str | int = Field( description="Name of sip account" ), ip: str = Field(description="IP address to remove from whitelist") ) -> str: """ Delete an whitelisted IP from a SIP account Args: sipaccount_name: Name of SIP account ip: IP address to remove from whitelist Returns "IP removed successfully" when IP removed from whitelisted """ params = {"ip": ip} await base.call_didlogic_api( ctx, "DELETE", f"/v1/sipaccounts/{sipaccount_name}/allowed_ips", params=params ) return "IP removed successfully"
- Uses the helper base.call_didlogic_api to make the API call for adding the IP.data = {"ip": ip} response = await base.call_didlogic_api( ctx, "POST", f"/v1/sipaccounts/{sipaccount_name}/allowed_ips", data=data ) return response.text