tls_add
Add a new TLS domain configuration to secure SIP traffic by specifying domain, certificate, private key, CA list, and other TLS settings for OpenSIPS.
Instructions
Add a new TLS domain configuration.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | ||
| type | No | ||
| method | No | TLSv1_2 | |
| verify_cert | No | ||
| require_cert | No | ||
| certificate | No | ||
| private_key | No | ||
| ca_list | No | ||
| ca_dir | No | ||
| cipher_list | No | ||
| dh_params | No | ||
| ec_curve | No | ||
| match_ip_address | No | ||
| match_sip_domain | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The tls_add MCP tool handler. Decorated with @mcp.tool(), @audited('tls_add'), and @require_permission('db.write'). Accepts TLS domain parameters and delegates persistence to crud.create_tls_domain().
@mcp.tool() @audited("tls_add") @require_permission("db.write") async def tls_add( ctx: Context, domain: str, type: int = 1, method: str = "TLSv1_2", verify_cert: int = 1, require_cert: int = 1, certificate: str | None = None, private_key: str | None = None, ca_list: str | None = None, ca_dir: str = "", cipher_list: str = "", dh_params: str | None = None, ec_curve: str = "", match_ip_address: str = "", match_sip_domain: str = "", ) -> dict[str, Any]: """Add a new TLS domain configuration.""" from opensips_mcp.db.crud import tls as crud app = ctx.request_context.lifespan_context async with app.db_session_factory() as session: result = await crud.create_tls_domain( session, domain=domain, type=type, method=method, verify_cert=verify_cert, require_cert=require_cert, certificate=certificate, private_key=private_key, ca_list=ca_list, ca_dir=ca_dir, cipher_list=cipher_list, dh_params=dh_params, ec_curve=ec_curve, match_ip_address=match_ip_address, match_sip_domain=match_sip_domain, ) return {"created": True, **result} - The CRUD helper create_tls_domain() that creates a TLSDomain ORM object, persists it, and returns the serialized result.
async def create_tls_domain( session: AsyncSession, domain: str, type: int = 1, method: str = "TLSv1_2", verify_cert: int = 1, require_cert: int = 1, certificate: str | None = None, private_key: str | None = None, ca_list: str | None = None, ca_dir: str = "", cipher_list: str = "", dh_params: str | None = None, ec_curve: str = "", match_ip_address: str = "", match_sip_domain: str = "", ) -> dict[str, Any]: t = TLSDomain( domain=domain, match_ip_address=match_ip_address, match_sip_domain=match_sip_domain, type=type, method=method, verify_cert=verify_cert, require_cert=require_cert, certificate=certificate, private_key=private_key, ca_list=ca_list, ca_dir=ca_dir, cipher_list=cipher_list, dh_params=dh_params, ec_curve=ec_curve, ) session.add(t) await session.commit() await session.refresh(t) return _to_dict(t) - The _to_dict() helper that serializes a TLSDomain object into a dictionary.
def _to_dict(t: TLSDomain) -> dict[str, Any]: return { "id": t.id, "domain": t.domain, "match_ip_address": t.match_ip_address, "match_sip_domain": t.match_sip_domain, "type": t.type, "method": t.method, "verify_cert": t.verify_cert, "require_cert": t.require_cert, "certificate": t.certificate, "private_key": t.private_key, "ca_list": t.ca_list, "ca_dir": t.ca_dir, "cipher_list": t.cipher_list, "dh_params": t.dh_params, "ec_curve": t.ec_curve, } - src/opensips_mcp/tools/tls_tools.py:345-345 (registration)Registration via @mcp.tool() decorator on the tls_add function at line 345.
@mcp.tool() - The TLSDomain SQLAlchemy ORM model (table 'tls_mgm') defining all TLS domain columns.
class TLSDomain(Base): __tablename__ = "tls_mgm" id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) domain: Mapped[str] = mapped_column(String(64), nullable=False) match_ip_address: Mapped[str] = mapped_column(String(255), default="") match_sip_domain: Mapped[str] = mapped_column(String(255), default="") type: Mapped[int] = mapped_column(Integer, default=1) # 1=client, 2=server method: Mapped[str] = mapped_column(String(16), default="TLSv1_2") verify_cert: Mapped[int] = mapped_column(Integer, default=1) require_cert: Mapped[int] = mapped_column(Integer, default=1) certificate: Mapped[str | None] = mapped_column(Text, nullable=True) private_key: Mapped[str | None] = mapped_column(Text, nullable=True) ca_list: Mapped[str | None] = mapped_column(Text, nullable=True) ca_dir: Mapped[str] = mapped_column(String(255), default="") cipher_list: Mapped[str] = mapped_column(String(255), default="") dh_params: Mapped[str | None] = mapped_column(Text, nullable=True) ec_curve: Mapped[str] = mapped_column(String(64), default="")