Skip to main content
Glama

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
NameRequiredDescriptionDefault
ipYesIP address to allow
sipaccount_nameYesName 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
  • 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)
  • 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

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/UserAd/didlogic_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server