avp_get
Retrieve the value of a global AVP by name from an OpenSIPS server. This tool accesses global-scope AVPs via MI; per-transaction AVPs are not available.
Instructions
Get an AVP value (global scope only — per-transaction AVPs are not MI-accessible).
Parameters
name:
AVP name (e.g. $avp(my_var) — pass as my_var).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- MCP tool handler that executes the avp_get MI command via the MI client, passing the AVP name as a parameter.
@mcp.tool() @require_permission("mi.read") async def avp_get(ctx: Context, name: str) -> dict[str, Any]: """Get an AVP value (global scope only — per-transaction AVPs are not MI-accessible). Parameters ---------- name: AVP name (e.g. ``$avp(my_var)`` — pass as ``my_var``). """ app = ctx.request_context.lifespan_context return await app.mi_client.execute("avp_get", {"name": name}) - The function signature and docstring define the input schema: a single 'name' parameter (str) representing the AVP name. Output is a dict.
@mcp.tool() @require_permission("mi.read") async def avp_get(ctx: Context, name: str) -> dict[str, Any]: """Get an AVP value (global scope only — per-transaction AVPs are not MI-accessible). Parameters ---------- name: AVP name (e.g. ``$avp(my_var)`` — pass as ``my_var``). """ app = ctx.request_context.lifespan_context return await app.mi_client.execute("avp_get", {"name": name}) - src/opensips_mcp/mi/commands.py:297-297 (registration)Registers 'avp_get' as an MI command in the 'avpops' module with a 'name' parameter, category 'avpops'.
_r("avp_get", "avpops", "Get an AVP value", ["name"], category="avpops") - src/opensips_mcp/server.py:162-162 (registration)Imports the avpops_tools module, which triggers the @mcp.tool() decorator registration of avp_get.
from opensips_mcp.tools import avpops_tools as _avpops_tools # noqa: E402, F401 - src/opensips_mcp/mi/client.py:71-90 (helper)MIClient.execute() sends the JSON-RPC request. The avp_get handler calls this with method='avp_get' and params={'name': name}.
async def execute( self, method: str, params: dict[str, Any] | list[Any] | None = None, ) -> dict[str, Any]: """Send a JSON-RPC 2.0 request to the MI endpoint. Returns the ``result`` field on success. Raises an appropriate :class:`MIError` subclass on failure. """ payload: dict[str, Any] = { "jsonrpc": "2.0", "method": method, "id": next(self._id_counter), } if params is not None: payload["params"] = params response_data = await self._send_with_retry(payload, method=method) return self._parse_response(response_data, method)