Skip to content

Commit 1fc6e26

Browse files
committed
add tools to create vcns and manage subnets (oracle#13)
Signed-off-by: Richard Gebhardt <[email protected]>
1 parent de78029 commit 1fc6e26

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

oci_networking.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,47 @@ def delete_vcn(vcn_id: str):
4848
return networking.delete_vcn(vcn_id).data
4949

5050

51+
@mcp.tool
52+
def create_vcn(compartment_id: str, cidr_block: str, display_name: str):
53+
networking = get_networking_client()
54+
vcn_details = oci.core.models.CreateVcnDetails(
55+
compartment_id=compartment_id, cidr_block=cidr_block, display_name=display_name
56+
)
57+
return networking.create_vcn(vcn_details).data
58+
59+
60+
@mcp.tool
61+
def create_subnet(vcn_id: str, compartment_id: str, cidr_block: str, display_name: str):
62+
networking = get_networking_client()
63+
subnet_details = oci.core.models.CreateSubnetDetails(
64+
compartment_id=compartment_id,
65+
vcn_id=vcn_id,
66+
cidr_block=cidr_block,
67+
display_name=display_name,
68+
)
69+
return networking.create_subnet(subnet_details).data
70+
71+
72+
@mcp.tool
73+
def list_subnets(compartment_id: str, vcn_id: str):
74+
networking = get_networking_client()
75+
subnets = networking.list_subnets(compartment_id, vcn_id).data
76+
return [
77+
{
78+
"subnet_id": subnet.id,
79+
"display_name": subnet.display_name,
80+
"lifecycle_state": subnet.lifecycle_state,
81+
}
82+
for subnet in subnets
83+
]
84+
85+
86+
@mcp.tool
87+
def get_subnet(subnet_id: str):
88+
networking = get_networking_client()
89+
return networking.get_subnet(subnet_id).data
90+
91+
5192
if __name__ == "__main__":
5293
# MCP spec: OpenAPI exposed at /openapi.json, native MCP at /mcp/v1
5394
# mcp.run(transport="http", host="127.0.0.1", port=8000, path="/mcp")

0 commit comments

Comments
 (0)