getInstance
Retrieve detailed database instance information from Alibaba Cloud DMS by providing the hostname, port, and optional SID for Oracle databases.
Instructions
Retrieve detailed instance information from DMS using the host and port.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | Yes | The hostname of the database instance | |
| port | Yes | The connection port number | |
| sid | No | Required for Oracle like databases |
Implementation Reference
- The handler function that retrieves detailed instance information from DMS using host and port by calling the Alibaba Cloud API.async def get_instance( host: str = Field(description="The hostname of the database instance"), port: str = Field(description="The connection port number"), sid: Optional[str] = Field(default=None, description="Required for Oracle like databases") ) -> InstanceDetail: client = create_client() req = dms_enterprise_20181101_models.GetInstanceRequest(host=host, port=port) if sid: req.sid = sid if mcp.state.real_login_uid: req.real_login_user_uid = mcp.state.real_login_uid try: resp = client.get_instance(req) instance_data = resp.body.to_map().get('Instance', {}) if resp and resp.body else {} instance_data['InstanceResourceId'] = instance_data.pop('EcsInstanceId', None) return InstanceDetail(**instance_data) except Exception as e: logger.error(f"Error in get_instance: {e}") raise
- Pydantic model defining the output schema for the getInstance tool response, including fields like InstanceId, State, Host, Port, etc.class InstanceDetail(MyBaseModel): InstanceId: Any = Field(description="Unique instance identifier in DMS", default=None) State: Any = Field(description="Current operational status", default=None) InstanceType: Any = Field(description="Database Engine type", default=None) InstanceAlias: Any = Field(description="Instance alias in DMS", default=None) EnvType: Any = Field(description="The environment type of the instance (e.g., production, development, etc.)", default=None) Host: Any = Field(description="The hostname of the database instance", default=None) Port: Any = Field(description="The connection port number", default=None) InstanceSource: Any = Field(description="The instance source (e.g., RDS, VPC_IDC, ECS_OWN, PUBLIC_OWN etc.)", default=None) InstanceResourceId: Any = Field( description="Resource ID of the instance from RDS", default=None)
- src/alibabacloud_dms_mcp_server/server.py:698-700 (registration)Registers the get_instance function as the MCP tool named 'getInstance' with description and annotations.self.mcp.tool(name="getInstance", description="Retrieve detailed instance information from DMS using the host and port.", annotations={"title": "获取DMS实例详情", "readOnlyHint": True})(get_instance)