Skip to main content
Glama
claude_modeling_labs.cpython-313.pyc61.8 kB
� A��g����L �SrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJ r J r J r J r J r Jr SSKJrJrJr \"SSS/S9rSq"S S 5r\R-5SZS \S \S \S\S\4 Sjj5rS\ S\ \\444SjrS\S\S\ \\ 44Sjr\R-5S\4Sj5r\R-5S[S\S\S\ \\44Sjj5r\R-5S\S\ \\ 44Sj5r\R-5S\S\4Sj5r \R-5S\ \ \\ 4\44Sj5r!\R-5S\S\ \ \\ 4\44Sj5r"\R-5S\S\S\S\S \#S!\#S"\S#\ \#S$\ \#S%\ \ \\4S\ \\ 44S&jj5r$\R-5S]S\S\S \#S!\#S\ \\ 44 S'jj5r%\R-5S^S\S\S(\#S \#S!\#S\ \\ 44 S)jj5r&\R-5S\S*\S\ \ \\ 4\\ \44S+j5r'\R-5S\S*\S\ \ \\ 4\ \ \\ 4\44S,j5r(\R-5S_S\S*\S-\#S\ \\ 44S.jj5r)S\S*\S\ \\ \\444S/jr*\R-5S\S0\S1\S\ \\ 44S2j5r+\R-5S\S3\S4\S\ \\ 44S5j5r,\R-5S\S\ \ \\ 4\44S6j5r-\R-5S\S7\S\4S8j5r.\R-5S\S*\S9\S\4S:j5r/\R-5S\S*\S\4S;j5r0\R-5S\S\4S<j5r1\R-5S`S\S=\#S\4S>jj5r2\R-5S\S\4S?j5r3\R-5S\S\4S@j5r4\R-5SaS\S\S\ \\ 44SAjj5r5\R-5SBSC/SDQS4SE\SF\SG\SH\ \#SI\ \ \#\ \#4S\4 SJjj5r6\R-5SbS\S\SK\#SL\#S\ \\ 44 SMjj5r7\R-5ScS\S\S\ \\ 44SNjj5r8\RsSO5S\4SPj5r:\RsSQ5S\4SRj5r;\RsSS5S\4STj5r<\R{SU5S\S\4SVj5r>\R{SW5S\4SXj5r?\@SY:Xa\R�5 gg)dai CML MCP Toolkit - Unified Cisco Modeling Labs API Client A comprehensive toolkit for interacting with Cisco Modeling Labs (CML) through the Model Context Protocol (MCP) interface. This toolkit provides a complete set of functions for lab management, node creation, link management, and configuration. Authors: Claude AI Assistant Version: 1.0.0 License: MIT �N)�Dict�List�Optional�Any�Union�Tuple)�FastMCP�Context�ImagezCML Lab Builderz httpx>=0.26.0zurllib3>=2.0.0)� dependenciesc �n�\rSrSrSrSS\S\S\S\4SjjrS\4S jrS \S \S\ R4S jr S r g)�CMLAuth�!z;Authentication and request handling for Cisco Modeling Labs�base_url�username�password� verify_sslc�(�XlX lX0lSUlX@l[ R "XS9UlU(d+SSKnURURR5 gg![a [S[RS9 gf=f)z� Initialize the CML authentication client Args: base_url: Base URL of the CML server username: Username for CML authentication password: Password for CML authentication verify_ssl: Whether to verify SSL certificates N)r�verifyrz7urllib3 not available, SSL warning suppression disabled��file)rrr�tokenr�httpx� AsyncClient�client�urllib3�disable_warnings� exceptions�InsecureRequestWarning� ImportError�print�sys�stderr)�selfrrrrrs �UC:\Users\jscon\Documents\Python_Projects\Claude-Modeling-Labs\claude_modeling_labs.py�__init__�CMLAuth.__init__$s���!� � � � � ��� �$���'�'��M�� �� b���(�(��);�);�)R�)R�S���� b��O�VY�V`�V`�a� b�s�)A,�,"B�B�returnc���# �[SUR3[RS9 URR SUR URS.S9IShv�N nUR5 URRS5Ul URRRSS UR305 URRS 5IShv�N nUR5 [S [RS9 UR$N�N:![a9n[S [!U53[RS9 SnAUR$SnAff=f7f) z� Authenticate with CML and get a token Returns: Authentication token Raises: httpx.HTTPStatusError: If authentication fails zAuthenticating with CML at rz/api/v0/authenticate)rr��jsonN�"� Authorization�Bearer z/api/v0/authokz)Authentication successful, token verifiedz$Warning: Token verification failed: )r!rr"r#r�postrr�raise_for_status�text�stripr�headers�update�get� Exception�str)r$�response� auth_check�es r%� authenticate�CMLAuth.authenticate=s#��� �+�D�M�M�?�;�#�*�*�M����)�)� "�"�m�m����G�*� � �� �!�!�#��]�]�(�(��-�� � � � ���"�"�O�w�t�z�z�l�5K�#L�M� T�#�{�{���/?�@�@�J� � '� '� )� �=�S�Z�Z� P��z�z��! �A��� T� �8��Q���A�� � � S��z�z��� T�sO�AE'�D�A(E'�D!�$D�%,D!� E'�D!�! E$�+$E�E'�E$�$E'�method�endpointc��# �UR(dUR5IShv�N [SUSU3[RS9 SU;a0US'SUR3USS'UR R "X40UD6IShv�N nURS:Xaj[S [RS9 UR5IShv�N SUR3USS'UR R "X40UD6IShv�N nUR5 U$N�N�NTN![a*n[S [U53[RS9 eSnAff=f7f) a Make an authenticated request to CML API Args: method: HTTP method (GET, POST, PUT, DELETE) endpoint: API endpoint to call **kwargs: Additional arguments to pass to httpx Returns: HTTP response Raises: httpx.HTTPStatusError: If the request fails NzMaking z request to rr3r.r-i�z&Got 401 response, re-authenticating...zRequest error: ) rr;r!r"r#r�request� status_coder0r6r7)r$r=r>�kwargsr8r:s r%r@�CMLAuth.requestZsF����z�z��#�#�%� %� %� ���x�|�H�:�6�S�Z�Z�H� �F� "� "�F�9� �07�t�z�z�l�-C��y��/�*� �!�[�[�0�0��L�V�L�L�H��#�#�s�*��>�c�j�j�Q��'�'�)�)�)�7>�t�z�z�l�5K��y�!�/�2�!%���!4�!4�V�!P��!P�P�� � %� %� '��O�1 &�M� *�P��� � �O�C��F�8�,�3�:�:� >� �� �sj�%E�D�AE�+ D$� D� ?D$� D � 9D$�D"�D$�E�D$� D$�"D$�$ E�.%E�E�E)rrrrrrN�T) �__name__� __module__� __qualname__�__firstlineno__�__doc__r7�boolr&r;r�Responser@�__static_attributes__��r%rr!sV��E�b��b��b�s�b�PT�b�2�C��:+�C�+�3�+�U�^�^�+rNrrrrrr(c��\# �URS5(dSU3n[SU3[RS9 [ XX#5q[ R 5IShv�N n[SUSSS3[RS9 U(aS OS nS US US 3$N7![RanS[U53sSnA$SnAf[a^n[S[U53[RS9 [R"[RS9 S[U53sSnA$SnAff=f7f)a� Initialize the CML client with authentication credentials Args: base_url: Base URL of the CML server (e.g., https://cml-server) username: Username for CML authentication password: Password for CML authentication verify_ssl: Whether to verify SSL certificates (set to False for self-signed certificates) Returns: A success message if authentication is successful )zhttp://�https://rPz'Initializing CML client with base_url: rNzToken received: � z...�enabledz-disabled (accepting self-signed certificates)z'Successfully authenticated with CML at z (SSL verification: �)zAuthentication failed: zError connecting to CML: ) � startswithr!r"r#r�cml_authr;r�HTTPStatusErrorr7r6� traceback� print_exc)rrrrr� ssl_statusr:s r%�initialize_clientrZ�s���" � � �6� 7� 7��h�Z�(�� � 3�H�:� >�S�Z�Z�P��x�8�@�H� 4��+�+�-�-�� � ��s��� �C�0�s�z�z�B�",�Y�2a� �8�� �BV�Wa�Vb�bc�d�d�.�� � � �2�(��Q���1�1�� �4� �)�#�a�&��2����D�������,�*�3�q�6�(�3�3��4�sa�AD,�B�B�6B�D,�B�D)�+ B>�8D)�9D,�> D)� AD$�D)�D,�$D)�)D,c�"�[(dSS0$g)zc Check if the client is authenticated Returns: None if authenticated, error dictionary if not �errorz=You must initialize the client first with initialize_client()N)rUrMrNr%� _check_authr]�s�� �8��X�Y�Y� rN� operationr\c��[SUS[U53[RS9 [R "[RS9 SSUS[U530$)z� Handle API errors consistently Args: operation: Description of the operation that failed error: Exception that was raised Returns: Error dictionary with consistent format z Error during �: rr\)r!r7r"r#rWrX)r^r\s r%�_handle_api_errorra�sQ�� �M�)��B�s�5�z�l� 3�#�*�*�E� ���S�Z�Z�(� �}�Y�K�r�#�e�*��>� ?�?rNc��T# �[5nU(aUS$[S[RS9 [R SS5IShv�N nUR 5n[S[U5S3[RS9 U(dg S nUR5H\upEUS URS S 5SUS3- nURS5(a USUSS3- nUSURSS5S3- nM^ U$N�![anS[U53sSnA$SnAff=f7f)zK List all labs in CML Returns: A formatted list of all available labs r\zAttempting to list labs...r�GET� /api/v0/labsNzFound z labszNo labs found in CML.zAvailable Labs: �- �title�Untitled� (ID: �) � descriptionz Description: � � State: �state�unknownzError listing labs: ) r]r!r"r#rUr@r+�len�itemsr5r6r7)r9r8�labs�result�lab_id�lab_infor:s r%� list_labsru�s&�����J���'�"�"�/� �*����<�!�)�)�%��@�@���}�}��� ��s�4�y�k��'�c�j�j�9��*�'�� $� � � � �F� ��8�<�<���<�=�V�F�8�3�O� O�F��|�|�M�*�*��O�H�]�,C�+D�B�G�G�� � �(�,�,�w� �"B�!C�2�F� F�F� !-� � �!A��" �/�%�c�!�f�X�.�.��/�sT�D(�1D� D� AD� D(� A3D�D(�D� D%� D �D%�D(� D%�%D(rfrjc��# �[5nU(aU$[SU3[RS9 [R SSXS.S9IShv�N nUR 5n[SU3[RS9 URS 5nU(dS S 0$US US U3SS.$NW![an[SU5sSnA$SnAff=f7f)z� Create a new lab in CML Args: title: Title of the new lab description: Optional description for the lab Returns: Dictionary containing lab ID and confirmation message zCreating lab with title: r�POSTrd)rfrjr*NzLab creation response: �idr\z(Failed to create lab, no lab ID returnedz Created lab '� ' with ID: �success)rs�message�status� create_lab) r]r!r"r#rUr@r+r5r6ra)rfrjr9r8�lab_datarsr:s r%r}r}�s������J����2� �)�%��1�� � �C�!�)�)� � � �=�*� � �� �=�=�?�� �'��z�2����D����d�#����G�H� H��&�u�g�[���A�� � � ��& �2� ��q�1�1��2�sS�C �5B&� B$� A B&�C � B&�#C �$B&�& C�0 C�;C�<C �C�C rsc���# �[5nU(aU$[RSSU35IShv�N nUR5nU$N![an[ SU5sSnA$SnAff=f7f)z� Get detailed information about a specific lab Args: lab_id: ID of the lab to get details for Returns: Dictionary containing lab details rc� /api/v0/labs/N�get_lab_details)r]rUr@r+r6ra)rsr9r8� lab_detailsr:s r%r�r�sn�����J����7�!�)�)�%�=���1I�J�J���m�m�o� ���K�� �7� �!2�A�6�6��7�sD�A/�A �A �A � A/� A � A,� A'�!A,�"A/�'A,�,A/c��# �[5nU(aUS$[U5IShv�N n[U[5(aFUR S5S:Xa1[ U5IShv�N [ R"S5IShv�N [RSSU35IShv�N nSUS 3$N�NKN/N![anS [U53sSnA$SnAff=f7f) ze Delete a lab from CML Args: lab_id: ID of the lab to delete Returns: Confirmation message r\Nrm�STARTED��DELETEr��Lab � deleted successfullyzError deleting lab: ) r]r�� isinstance�dictr5�stop_lab�asyncio�sleeprUr@r6r7)rsr9r�r8r:s r%� delete_labr�2s������J���'�"�"� /�+�F�3�3� � �k�4� (� (�[�_�_�W�-E��-R��6�"� "� "��-�-��"� "� "�!�)�)�(�m�F�8�4L�M�M���f�X�2�3�3�4� #� "�M�� �/�%�c�!�f�X�.�.��/�sz�C�B7�B/�<B7�%B1�&B7�B3� B7�$B5�% B7�.C�/B7�1B7�3B7�5B7�7 C� C�C�C�C�Cc��<# �[5nU(aUS$[RSS5IShv�N nUR5n[ U[ 5(aC[ S[RS9 0nUH!nURS5nU(dMXCU'M# U$0nUR5H=upVURSS 5URS S 5URS /5S .X5'M? U$N�![anS [U53sSnA$SnAff=f7f)zt List all available node definitions in CML Returns: Dictionary of available node definitions or error message r\rcz/api/v0/node_definitionsNz.Converting node definitions list to dictionaryrrxrj��type� interfaces)rjr�r�z Error listing node definitions: ) r]rUr@r+r��listr!r"r#r5rpr6r7)r9r8� node_defsrr�node_def�node_id� node_infor:s r%�list_node_definitionsr�Rs �����J���'�"�"�;�!�)�)�%�1K�L�L���M�M�O� � �i�� &� &� �B�#�*�*� U��F�%��"�,�,�t�,���7�&.�7�O�&��M���"+�/�/�"3� �G�(�}�}�]�B�?�!� � �f�b�1�'�m�m�L�"�=��F�O�#4�� �-M��. �;�1�#�a�&��:�:��;�sX�D�C7�C5�AC7� C7�D� AC7�4D�5C7�7 D� D�D�D�D�Dc��# �[5nU(aUS$[RSSUS35IShv�N nUR5n[ U[ 5(aC[ S[RS9 0nUH!nURS5nU(dMXTU'M# U$U$Nn![anS [U53sSnA$SnAff=f7f) z� Get all nodes in a specific lab Args: lab_id: ID of the lab Returns: Dictionary of nodes in the lab or error message r\rcr��/nodesNz#Converting nodes list to dictionaryrrxzError getting lab nodes: � r]rUr@r+r�r�r!r"r#r5r6r7)rsr9r8�nodesrr�noder�r:s r%� get_lab_nodesr�|�������J���'�"�"�4�!�)�)�%�=����1O�P�P��� � ��� �e�T� "� "� �7�s�z�z� J��F����(�(�4�.���7�&*�7�O���M�� �Q�� �4�*�3�q�6�(�3�3��4��W�C �B(�B&�AB(� B(�#C �$B(�%C �&B(�( C �2 C�?C �C �C � C �label�node_definition�x�y�populate_interfaces�ram� cpu_limit� parametersc ��# �[5n U (aU $UUUUU=(d 0/SS.n UbXjS'UbXzS'SUS3n U(aU S- n S S 0n [RS U U U S 9IShv�N n U R5nUR S 5nU(dSUS.$USUSU3SUS.$N>![ an[ SU5sSnA$SnAff=f7f)a Add a node to the specified lab Args: lab_id: ID of the lab label: Label for the new node node_definition: Type of node (e.g., 'iosv', 'csr1000v') x: X coordinate for node placement y: Y coordinate for node placement populate_interfaces: Whether to automatically create interfaces ram: RAM allocation for the node (optional) cpu_limit: CPU limit for the node (optional) parameters: Node-specific parameters (optional) Returns: Dictionary with node ID and confirmation message F)r�r�r�r�r��tags� hide_linksNr�r�r�r�z?populate_interfaces=true� Content-Type�application/jsonrw�r+r3rxz*Failed to create node, no node ID returned�r\r8z Added node 'ryrz)r�r{r|�details�add_node)r]rUr@r+r5r6ra)rsr�r�r�r�r�r�r�r�r9� node_datar>r3r8rrr�r:s r%r�r��s���:��J����/0��.���$�*���� � � �?�"�e� � � �%.�k� "�#�6�(�&�1�� � �3� 3�H�"�#5�6��!�)�)� � ��� *� � ��������*�*�T�"���I�W]�^� ^��%�e�W�K��y�A���  � � ��( �0� ��Q�/�/��0�sS�C �AB(�'B&�(0B(�C � B(�%C �&B(�( C�2 C�=C�>C �C�C c��`# �[5nU(aU$[XSX#S5IShv�N $N7f)a Create a router with the 'iosv' node definition Args: lab_id: ID of the lab label: Label for the new router x: X coordinate for node placement y: Y coordinate for node placement Returns: Dictionary with node ID and confirmation message �iosvTN)r]r�)rsr�r�r�r9s r%� create_routerr��s0���&��J�����&���t�<� <�<� <�s �%.�,�.�num_interfacesc���# �[5nU(aU$[UUSUUSSSS[U50S9 IShv�N $N![an[ SU5sSnA$SnAff=f7f)aI Create a switch with a specified number of interfaces Args: lab_id: ID of the lab label: Label for the new switch num_interfaces: Number of interfaces to create (default: 8) x: X coordinate for node placement y: Y coordinate for node placement Returns: Dictionary with node ID and confirmation message �iosvl2TN�slot1)r�r�r�� create_switch)r]r�r7r6ra)rsr�r�r�r�r9r:s r%r�r� sv���*��J����5�� � � � � � �����^�!4�5�  �  � �  �� �5� ��!�4�4��5�s=�A �=�;�=�A �=� A� A�A�A �A�A r�c���# �[5nU(aUS$[RSSUSUS35IShv�N nUR5n[ U[ 5(a[ SU3[RS9 U$[ U[5(aZ[ S U3[RS9 [U5S -S :Xa+[S [U5S 5Vs/sH oTXUS -PM sn$U$U$N�s snf![a^n[ S [U53[RS9 [R"[RS9 S [U53sSnA$SnAff=f7f) z� Get interfaces for a specific node Args: lab_id: ID of the lab node_id: ID of the node Returns: Dictionary of node interfaces or error message or list of interface IDs r\rcr��/nodes/� /interfacesNzGot list of interface IDs: rzGot string of interface IDs: �$rzError getting node interfaces: )r]rUr@r+r�r�r!r"r#r7ro�ranger6rWrX)rsr�r9r8r��ir:s r%�get_node_interfacesr�8sD�����J���'�"�"�:�!�)�)�%�=����PW�y�Xc�1d�e�e���]�]�_� � �j�$� '� '� �/� �|�<�3�:�:� N�� � � �C� (� (� �1�*��>�S�Z�Z� P��:���#�q�(�49�!�S��_�b�4Q�R�4Q�q�1�r�T�*�4Q�R�R�!�!�� �#f��S�� �:� �/��A��x�8�s�z�z�J�������,�0��Q���9�9��:�s}�E$� C9�C2�AC9�E$�AC9�C4�+C9�-E$�.C9�/E$�0C9�1E$�2C9�4C9�9 E!�AE�E!�E$�E!�!E$c��`# �[5nU(aUS$[X5IShv�N n/n[U[5(aSU;aU$[U[5(aUnO�[U[5(aB[ U5S-S:Xa+[ S[ U5S5Vs/sH oSXUS-PM nnOBSU3$[U[5(a[ UR55nOS[U53$/nUHsn[RSS US U35IShv�N nUR5n U RS 5S :Hn S U ;aS U ;aSn U (dMbURU 5 Mu U(dSU3$U$GNYs snfNj![an [!SU 5sSn A $Sn A ff=f7f)z� Get all physical interfaces for a specific node Args: lab_id: ID of the lab node_id: ID of the node Returns: List of physical interfaces or error message r\N�Errorr�rz&Unexpected interface response format: z$Unexpected interface response type: rcr�� /interfaces/r��physical�slotTz&No physical interfaces found for node �get_physical_interfaces)r]r�r�r7r�ror�r��keysr�rUr@r+r5�appendr6ra) rsr�r9�interfaces_response� interface_idsr��physical_interfaces� interface_id�interface_details�interface_data� is_physicalr:s r%r�r�as������J���'�"�"�,?�$7��$H�H��� � �)�3� /� /�G�?R�4R�&� &� �+�T� 2� 2�/�M� �+�S� 1� 1��&�'�"�,��1�FK�A�s�Sf�Og�ik�Fl� m�Fl��Q��t�!<�Fl� � m� �?�@S�?T�U�U� �+�T� 2� 2� �!4�!9�!9�!;�<�M�9�$�?R�:S�9T�U� U�!��)�L�&.�&6�&6�u� �f�X�Ua�bn�ao�>p�&q� q� �.�3�3�5�N�)�,�,�V�4� �B�K��^�+��^�+�"&�K��{�#�*�*�>�:�*� #�;�G�9�E� E�"�"�QI��!n�!r��& �?� �!:�A�>�>��?�s��F.�F �F�"F � F.� AF �#F�3F �:F.�;<F �7F.�8&F �F �;F � F �>F.�?F �F.�F �F � F+� F&� F+�!F.�&F+�+F.r�c��v# �[5nU(aU$[U5IShv�N n[U[5(aUR S5S:XaSS0$[ SUSU3[ RS9 UUS .n[ S U3[ RS9 [RS S US 3US9IShv�N nUR5n[ SU3[ RS9 [U[5(aG[U5S:�a8USR S5nUSR S5n USU SUSU3SUS.$[U[5(a9UR S5nUR S5n U(aUSU SUSU3SUS.$SUS.$GNlN�![an [SU 5sSn A $Sn A ff=f7f)z� Create an interface on a node Args: lab_id: ID of the lab node_id: ID of the node slot: Slot number for the interface (default: 4) Returns: Dictionary with interface ID and confirmation message Nrmr�r\zMCannot create interfaces while the lab is running. Please stop the lab first.zCreating interface on node z, slot r)r�r�zInterface creation payload: rwr�r�r*zInterface creation response: rrxr�zCreated interface z on node rz)r�r{r|r�z6Failed to create interface, unexpected response formatr��create_interface)r]r�r�r�r5r!r"r#rUr@r+r�ror6ra) rsr�r�r9r�r�r8rrr��interface_labelr:s r%r�r��s������J����48�+�F�3�3� � �k�4� (� (�[�_�_�W�-E��-R��l�m� m� �+�G�9�G�D�6�B����T��� �� �,�^�,<�=�C�J�J�O�"�)�)� ��F�8�;� /��*� � ������� �-�f�X�6�S�Z�Z�H� �f�d� #� #��F� �a��!�!�9�=�=��.�L�$�Q�i�m�m�G�4�O� ,�/��/@� �'��RY�Z^�Y_�`�#�!� � � ��� %� %�!�:�:�d�+�L�$�j�j��1�O��$0�!3�O�3D�I�g�Y�V]�^b�]c�d�'�%� ��R�_e�f�f�a4� ��D �8� �!3�Q�7�7��8�s}�F9�F�F�1F�F9�AF�2F�3B F�=F9�>A F� F9� F�F9�F�F� F6� F1�+F6�,F9�1F6�6F9c ��# �[5nU(aU$[RSSUSUS35IShv�N nUR5n[ U[ 5(aUR 5nO.[ U[5(a[UR55nU(dSSU30$UHhn[RSSUSUS 35IShv�N nUR5nURS 5S :XdMOURS 5S :XdMfUs $ SSU30$N�NQ![an[SU5sSnA$SnAff=f7f)z� Find an available physical interface on a node Args: lab_id: ID of the lab node_id: ID of the node Returns: Interface ID or error dictionary rcr�r�z/interfaces?operational=trueNr\zNo interfaces found for node r�z?operational=truer�r�� is_connectedFz/No available physical interface found for node �find_available_interface) r]rUr@r+r�r7�splitr�r�r�r5r6ra) rsr�r9r�r�r��interface_detailr�r:s r%r�r��sb�����J����"@�$,�$4�$4� ��F�8�7�7�)�3O� P�% � ��)�-�-�/� � �j�#� &� &�#�)�)�+�J� � �D� )� )��j�o�o�/�0�J���<�W�I�F�G� G�'�L�%-�%5�%5����x�|�L�>�AR�S�&� � �.�2�2�4�N��"�"�6�*�j�8��"�"�>�2�e�;�#�#�'��J�7�)�T�U�U�= �& �� �@� �!;�Q�?�?��@�s{�E � D'�D#�A5D'�-E �.%D'�D%�'D'�?D'�D'�E �D'�"E �#D'�%D'�' E�1 E�<E�=E �E�E �interface_id_a�interface_id_bc��n# �[5nU(aU$[SUSU3[RS9 UUS.nSS0n[R SSUS 3UUS 9IS hv�N nUR 5n[S U3[RS9 URS 5nU(dSUS.$USUSU3SUS.$NY![a�n [S[RS9 UUS.n [R SSUS 3U WS 9IS hv�N n U R 5n [SU 3[RS9 U RS 5n U (aU SUSUS3SU S.sS n A $SS0sS n A $![a?n[S[U53[RS9 [SU 5sS nAsS n A $S nAff=fS n A ff=f7f)z� Create a link between two interfaces in a lab Args: lab_id: ID of the lab interface_id_a: ID of the first interface interface_id_b: ID of the second interface Returns: Dictionary with link ID and confirmation message z!Creating link between interfaces z and r)�src_int�dst_intr�r�rwr��/linksr�NzLink creation response: rxz*Failed to create link, no link ID returnedr�z Created link between interfaces rz)�link_idr{r|r�z1First format failed, trying alternative format...)�i1�i2z%Link creation response (alt format): z using alternative formatr\z'Failed to create link with both formatsz Alternative format also failed: � create_link) r]r!r"r#rUr@r+r5r6r7ra)rsr�r�r9� link_datar3r8rrr�r:� link_data_alt� response_alt� result_alt� link_id_alt�alt_errs r%�create_link_v3r�s �����J����>7� �1�.�1A��~�FV�W�^a�^h�^h�i�&�%� � � "�#5�6��!�)�)� ��F�8�6� *��� *� � ������� �(���1�� � �C��*�*�T�"���I�W]�^� ^��9�.�9I��~�N^�_���  � � ��* �7� 7� �E�C�J�J� W�$�$��M� "*�!1�!1����x�v�.�"�� "2�"���L�&�*�*�,�J� �9�*��F�S�Z�Z� X�$�.�.��.�K��*�!A�.�AQ�QV�We�Vf�f� A�'�)� ���F�G� G��� 7� �4�S��\�N�C�#�*�*� U�$�]�A�6� 6� 6�� 7��;7�s��F5�AB7�B5�A B7�'F5�( B7�4F5�5B7�7 F2�:E!�<C?�=AE!�F2�F5�E!�F2�F5�! F*�+/F%�F*�F-�F2� F5�%F*�*F-�-F2�2F5� node_id_a� node_id_bc��l# �[5nU(aU$[X5IShv�N n[U[5(aSU;aU$[X5IShv�N n[U[5(aSU;aU$[ XU5IShv�N $NeN7N![ an[ SU5sSnA$SnAff=f7f)z� Create a link between two nodes by automatically selecting appropriate interfaces Args: lab_id: ID of the lab node_id_a: ID of the first node node_id_b: ID of the second node Returns: Dictionary with link ID and confirmation message Nr\� link_nodes)r]r�r�r�r�r6ra)rsr�r�r9� interface_a� interface_br:s r%r�r�ps������J���� 2�4�V�G�G� � �k�4� (� (�W� �-C�� �4�V�G�G� � �k�4� (� (�W� �-C�� �$�F��E�E�E�H�H� F�� �2� ��q�1�1��2�s��B4�B�B � B�B4�B�B � B�6B4�7B�B�B� B4� B� B�B� B1� B,�&B1�'B4�,B1�1B4c��# �[5nU(aUS$[RSSUS35IShv�N nUR5n[ U[ 5(aC[ S[RS9 0nUH!nURS5nU(dMXTU'M# U$U$Nn![anS [U53sSnA$SnAff=f7f) z� Get all links in a specific lab Args: lab_id: ID of the lab Returns: Dictionary of links in the lab or error message r\rcr�r�Nz#Converting links list to dictionaryrrxzError getting lab links: r�)rsr9r8�linksrr�linkr�r:s r%� get_lab_linksr��r�r�r�c���# �[5nU(aUS$[RSSUSU35IShv�N nSUS3$N ![anS[ U53sSnA$SnAff=f7f) z� Delete a link from a lab Args: lab_id: ID of the lab link_id: ID of the link to delete Returns: Confirmation message r\r�r�z/links/NzLink r�zError deleting link: �r]rUr@r6r7)rsr�r9r8r:s r%� delete_linkr��s{�����J���'�"�"�0�!�)�)�(�m�F�8�7�SZ�R[�4\�]�]���w�i�4�5�5�^�� �0�&�s�1�v�h�/�/��0�sD�A+�A�A� A�A+�A� A(� A#�A(�A+�#A(�(A+�configc���# �[5nU(aUS$[RSSUSUS3US9IShv�N nSU3$N ![anS [ U53sSnA$SnAff=f7f) z� Configure a node with the specified configuration Args: lab_id: ID of the lab node_id: ID of the node to configure config: Configuration text to apply Returns: Confirmation message r\�PUTr�r��/config)�contentNzConfiguration applied to node zError configuring node: r�)rsr�r�r9r8r:s r%�configure_noder��s������J���'�"�"� 3�!�)�)� ��F�8�7�7�)�7� ;��*� � �� 0��y�9�9�  �� �3�)�#�a�&��2�2��3�sD�A*�A�A�A�A*�A� A'� A"�A'�A*�"A'�'A*c���# �[5nU(aUS$[RSSUSUS35IShv�N nURnU$N![anS[ U53sSnA$SnAff=f7f)z� Get the current configuration of a node Args: lab_id: ID of the lab node_id: ID of the node Returns: Node configuration text or error message r\rcr�r�r�Nz"Error getting node configuration: )r]rUr@r1r6r7)rsr�r9r8r�r:s r%�get_node_configr��s}�����J���'�"�"�=�!�)�)�%�=����PW�y�X_�1`�a�a������� �b�� �=�3�C��F�8�<�<��=�sD�A4� A�A �A� A4� A� A1� A,�&A1�'A4�,A1�1A4c���# �[5nU(aUS$[RSSUS35IShv�N nSUS3$N ![anS[ U53sSnA$SnAff=f7f) zf Start the specified lab Args: lab_id: ID of the lab to start Returns: Confirmation message r\r�r�z/startNr�z started successfullyzError starting lab: r��rsr9r8r:s r%� start_labrsu�����J���'�"�"�/�!�)�)�%�=����1O�P�P���f�X�2�3�3�Q�� �/�%�c�!�f�X�.�.��/��D�A)�A�A� A�A)�A� A&� A!�A&�A)�!A&�&A)�timeoutc���# �[5nU(aUS$[U5IShv�N n[U[5(aUR S5S:wag[ SUS3[ RS9 [U5IShv�N n[U[5(aS U;aU$[R"5R5nS nU(Gd[R"5R5U- U:a�S nUR5H�upx[RS S USU35IShv�N n U R!5n U R SS5n [ SU R SS5SU 3[ RS9 U S:wdM�S nM� U(d[R""S5IShv�N U(d,[R"5R5U- U:aM�U(agSUS3$GN�GN{N�NM![$a^n [ S[U 53[ RS9 [&R("[ RS9 S[U 53sSn A $Sn A ff=f7f)z� Wait for all nodes in a lab to reach the STARTED state Args: lab_id: ID of the lab timeout: Maximum time to wait in seconds (default: 60) Returns: Status message r\Nrmr�z1Lab is not in STARTED state. Start the lab first.zWaiting for nodes in lab z to initialize...rr�FTrcr�r��UNKNOWNzNode r�rnz state: �z.All nodes in the lab are initialized and readyzTimeout reached (z3 seconds). Some nodes may not be fully initialized.zError waiting for nodes: )r]r�r�r�r5r!r"r#r�r7r��get_event_loop�timerprUr@r+r�r6rWrX) rsrr9r�r�� start_time� all_readyr�r�r�r�rmr:s r%�wait_for_lab_nodesr s�����J���'�"�"�'4�+�F�3�3� ��+�t�,�,� ����0H�I�0U�F� �)�&��1B�C�#�*�*�U�$�F�+�+�� �e�S� !� !�g��&6��L��+�+�-�2�2�4� �� ���!7�!7�!9�!>�!>�!@�:�!M�QX� X��I�!&���� ��"*�"2�"2�5�M�&��QX�Y`�Xa�:b�"c�c� �%�N�N�,� �!� � �g�y�9����i�m�m�G�Y�?�@����P�WZ�Wa�Wa�b��I�%� %�I�"/���m�m�A�&�&�&���!7�!7�!9�!>�!>�!@�:�!M�QX� X� �C�&�w�i�/b�c� c�C4�,�d�'�� �4� �)�#�a�&��2����D�������,�*�3�q�6�(�3�3��4�s��I/�H�G:�.H�I/�*H�G=� H�#I/�$B H�1H�2AH�&H�4H�55H�,H�3I/�4H�9I/�:H�=H�H�H� I,�AI'�!I,�"I/�'I,�,I/c���# �[5nU(aUS$[RSSUS35IShv�N nSUS3$N ![anS[ U53sSnA$SnAff=f7f) zd Stop the specified lab Args: lab_id: ID of the lab to stop Returns: Confirmation message r\r�r�z/stopNr�z stopped successfullyzError stopping lab: r�rs r%r�r�Ssu�����J���'�"�"�/�!�)�)�%�=����1N�O�O���f�X�2�3�3�P�� �/�%�c�!�f�X�.�.��/�rc���# �[5nU(aUS$[U5IShv�N n[U[5(a SU;aUS$[ U5IShv�N n[U[ 5(aSU;aU$[ U5IShv�N n[U[ 5(aSU;aU$SURSS5S3nUSURS S 5S3- nUS URS S 5S3- nUS- nUR5HSupgUSURSS5SUS3- nUSURSS 5S3- nUSURS S 5S3- nMU US- nUR5H�up�U RS5n U RS5n X�;adX�;a_X:RSU 5n X;RSU 5n USUSU SU RSS 5SU SU RS S 5S3 - nM�USUSU S!U RS5S"U S!U RS 5S3 - nM� U$GNGN�GN�![anS#[ U53sSnA$SnAff=f7f)$z� Get a detailed summary of the lab topology Args: lab_id: ID of the lab Returns: Formatted summary of the lab topology r\Nr�zLab Topology: rfrgrkzState: rmrnz Description: rj�Nonez zNodes: rer��Unnamedrhriz Type: r�rlz Links: �src_node�dst_nodez- Link r`z (r�u) → r��:u → zError getting lab topology: ) r]r�r�r�r�r7r�r5rpr6)rsr9r�r�r�rrr�r�r�r�� src_node_id� dst_node_idrrr:s r%�get_lab_topologyris������J���'�"�"�,7�+�F�3�3� � �k�4� (� (�W� �-C��w�'� '�$�F�+�+�� �e�S� !� !�g��&6��L�$�F�+�+�� �e�S� !� !�g��&6��L�"�+�/�/�'�:�"F�!G�r�J���G�K�O�O�G�Y�?�@��C�C���M�+�/�/�-��"H�!I��N�N�� �*���"�[�[�]�M�G� ��4�8�8�G�Y�7�8��w�i�s�K� K�F� �����*;�Y�!G� H��K� K�F� � �$�(�(�7�I�">�!?�r�B� B�F�+� �,���"�[�[�]�M�G��(�(�:�.�K��(�(�:�.�K��#� �(<� �-�1�1�'�;�G�� �-�1�1�'�;�G���W�W�I�R��z��D�H�H�Y�PY�<Z�;[�[a�&�Z�r�$�(�(�9�i�*H�)I��N�O���G�G�9�B�{�m�1�T�X�X�i�=P�<Q�QV�Wb�Vc�cd�ei�em�em�nw�ex�dy�y{�|�|��+�� �Q4� ,� ,��> �7�-�c�!�f�X�6�6��7�s��I-�I�H?�#I� I-� I�I� I�<I-�=I� I� I�,I-�-FI�>I-�?I�I�I� I*� I%�I*� I-�%I*�*I-c���# �[5nU(aU$[X5IShv�N nSU;aU$USn[USSS5IShv�N nSU;a SSUS30$[USSSS 5IShv�N nSU;a SS US30$[ XES US 5IShv�N nUUUS US S U;aS OSUS.$N�NnNIN!![ an[ SU5sSnA$SnAff=f7f)z� Create a simple network lab with a router and switch Args: title: Title for the new lab description: Optional description for the lab Returns: Dictionary with lab details Nr\rs�Router1�2zFailed to create router: �Switch1��zFailed to create switch: r�r�rz�failed)rsrf� router_id� switch_id� link_status� link_details�create_simple_network)r]r}r�r�r�r6ra) rfrjr9� lab_responsers� router_result� switch_result� link_resultr:s r%r!r!�s0�����J����=�'��;�;� � �l� "�� ��h�'��,�F�I�r�2�F�F� � �m� #��8��w�9O�8P�Q�R� R�+�F�I�q�"�c�J�J� � �m� #��8��w�9O�8P�Q�R� R�'�v�Y�/G��W`�Ia�b�b� ���&�y�1�&�y�1�(1�[�(@�9�h�'�  � �%<�G�K� c�� �=� �!8�!�<�<��=�s��C �B=�B5� B=�C �B=�B7� B=�C �B=�/B9�0B=�C �B=�B;�B=�4C �5B=�7B=�9B=�;B=�= C� C�C�C �C�C �mst�root)�rQ���(� switch_name�stp_mode�role�vlans�mst_instance_mappingc ��# �SUS3SSU3SS/nUH%nUS:XaM URSU3SU3S/5 M' URS 5 US :Xa�URS 5 URSS S SUS3S/5 U(aPUR5H;upxSR[ [ U55n URSUSU 35 M= OURSS/5 US:XaUR/SQ5 GO(US:XaUR/SQ5 GO UR/SQ5 O�US:XazURS5 US:XaUHnURSUS35 M O�US:XaUHnURSUS35 M O�UHnURSUS 35 M OyURS!5 US:XaUHnURSUS35 M OCUS:XaUHnURSUS35 M OUHnURSUS 35 M UR/S"Q5 UR/S#Q5 URSS$S%S&US'S(3S)SS*/5 S+RU5$7f),a� Generate Spanning Tree Protocol configuration for a switch Args: switch_name: Name of the switch stp_mode: STP mode to configure ("mst", "rapid-pvst", or "pvst") role: Role of the switch ("root", "secondary", or "normal") vlans: List of VLANs to configure mst_instance_mapping: For MST mode, mapping of MST instances to VLANs Returns: Configuration text for the switch z! z Configuration�!z hostname z! VLANs Configurationr(zvlan z name VLANz! Spanning-tree Configurationr&zspanning-tree mode mstz(! Configure MST instance to VLAN mappingzspanning-tree mst configurationz name z-REGIONz revision 1�,z instance z vlan z instance 1 vlan 10, 20z instance 2 vlan 30, 40r')r2z&! Set as MST root for instance 0 (CST)z!spanning-tree mst 0 priority 4096z!spanning-tree mst 1 priority 4096z!spanning-tree mst 2 priority 4096� secondary)r2z! Set as MST secondary rootz!spanning-tree mst 0 priority 8192z!spanning-tree mst 1 priority 8192z!spanning-tree mst 2 priority 8192)r2z! Normal switch (not root)z"spanning-tree mst 0 priority 32768z"spanning-tree mst 1 priority 32768z"spanning-tree mst 2 priority 32768z rapid-pvstzspanning-tree mode rapid-pvstzspanning-tree vlan z priority 4096z priority 8192z priority 32768zspanning-tree mode pvst)r2z! Common STP featureszspanning-tree extend system-idz#spanning-tree portfast edge defaultz(spanning-tree portfast bpduguard default)r2z! Configure interfacesr2z&interface range GigabitEthernet0/0 - 7z% switchport trunk encapsulation dot1qz switchport mode trunkz" switchport trunk allowed vlan all� no shutdownz! Management interfacezinterface Vlan1z ip address 10.0.0.rz 255.255.255.0r5z! End of configurationrk)�extendr�rp�join�mapr7) r,r-r.r/r0� config_lines�vlan_id�instance� mapped_vlans� vlan_lists r%�generate_switch_stp_configr>�s���. �[�M��(� � �K�=�!� �� �L��� �a�<� �����G�9� ��� � "� � � �����7�8��5�����4�5� ��� � 6� -��[�M�� )� �  � � �*>�*D�*D�*F�&���H�H�S��l�%;�<� ��#�#�j�� �&�� �$L�M�+G� � � �)�)�!� � �6�>� � � �!� ��[� � � � �!� � � � �!� � �\� !����;�<� �6�>� ���#�#�&9�'��.�$Q�R�!� �[� � ���#�#�&9�'��.�$Q�R�!�!���#�#�&9�'��/�$R�S�!� ���5�6� �6�>� ���#�#�&9�'��.�$Q�R�!� �[� � ���#�#�&9�'��.�$Q�R�!�!���#�#�&9�'��/�$R�S�!��������� � ���� � �� �e�A�h�Z�~�6�� � ��� �9�9�\� "�"�s�I?J� num_switches�interfaces_per_switchc ��� # �[5nU(aU$[X5IShv�N nSU;aU$USn/n[USUSSS9IShv�N nURSUSSS .5 [US US SS9IShv�N n URS U SSS .5 US :�aZ[US USSS9IShv�N n URS U SSS .5 [USUSSS9IShv�N n URSU SSS .5 US:�aZ[USUSS S9IShv�N n URSU SSS .5 [USUSS S9IShv�N n URSU SSS .5 /n[ U5S :�aP[ XgSSUSS5IShv�N nURUSSUSSUR S5S.5 [ U5S:�Ga�[ XgSSUS S5IShv�N nURUSSUS SUR S5S.5 [ XgSSUSS5IShv�N nURUSSUSSUR S5S.5 [ XgSSUS S5IShv�N nURUSSUS SUR S5S.5 [ XgSSUSS5IShv�N nURUSSUSSUR S5S.5 [ XgS SUSS5IShv�N nURUS SUSSUR S5S.5 [ U5S :�Ga�[ XgS SUSS5IShv�N nURUS SUSSUR S5S.5 [ XgS SUS!S5IShv�N nURUS SUS!SUR S5S.5 [ XgSSUSS5IShv�N nURUSSUSSUR S5S.5 [ XgSSUS!S5IShv�N nURUSSUS!SUR S5S.5 [ XgSSUS!S5IShv�N nURUSSUS!SUR S5S.5 UUUUS"S#[ U5S$US%3S&.$GN�GN�GN�GNmGNCGNGN�GN�GNFGN�GN�GN_GNGN�GNhGNN�N![an[S'U5sSnA$SnAff=f7f)(a@ Create a comprehensive Spanning Tree Protocol test lab Args: title: Title for the lab description: Description for the lab num_switches: Number of switches to create (default: 6) interfaces_per_switch: Number of interfaces per switch (default: 8) Returns: Dictionary with lab details and node IDs Nr\rszSW1-Core�d)r�r�r��core)�namerx�layerzSW2-Corei,r�zSW3-Distributionr��� distributionzSW4-Distributioni^�z SW5-Accessr�accessz SW6-Access��rrxr(rDr�)�from�torx��rrzzCreated STP lab with z switches, each having z interfaces)rsrf�switchesr�r|r{�create_stp_lab) r]r}r�r�ror�r5r6ra)rfrjr?r@r9r"rsrO� sw1_result� sw2_result� sw3_result� sw4_result� sw5_result� sw6_resultr��link1�link2�link3�link4�link5�link6�link7�link8�link9�link10�link11r:s r%rPrP{s9���&��J����~6�'��;�;� � �l� "�� ��h�'����)� � � !���  � � � ����:�i�3H�SY�Z�[�(� � � !���  � � � ����:�i�3H�SY�Z�[� �!� �,��"�%���  ��J� �O�O�%7�z�)�?T�_m�n� o�,��"�%���  ��J� �O�O�%7�z�)�?T�_m�n� o� �!� �,���%���  ��J� �O�O�\��I�9N�Ya�b� c�,���%���  ��J� �O�O�\��I�9N�Ya�b� c��� �x�=�A� �$�V�a�[��->��� �D�@Q�R�R�E� �L�L�(�1�+�f�"5�X�a�[��=P�X]�Xa�Xa�bk�Xl�m� n� �x�=�A� �$�V�a�[��->��� �D�@Q�R�R�E� �L�L�(�1�+�f�"5�X�a�[��=P�X]�Xa�Xa�bk�Xl�m� n�$�V�a�[��->��� �D�@Q�R�R�E� �L�L�(�1�+�f�"5�X�a�[��=P�X]�Xa�Xa�bk�Xl�m� n�%�V�a�[��->��� �D�@Q�R�R�E� �L�L�(�1�+�f�"5�X�a�[��=P�X]�Xa�Xa�bk�Xl�m� n�$�V�a�[��->��� �D�@Q�R�R�E� �L�L�(�1�+�f�"5�X�a�[��=P�X]�Xa�Xa�bk�Xl�m� n�%�V�a�[��->��� �D�@Q�R�R�E� �L�L�(�1�+�f�"5�X�a�[��=P�X]�Xa�Xa�bk�Xl�m� n� �x�=�A� �$�V�a�[��->��� �D�@Q�R�R�E� �L�L�(�1�+�f�"5�X�a�[��=P�X]�Xa�Xa�bk�Xl�m� n�$�V�a�[��->��� �D�@Q�R�R�E� �L�L�(�1�+�f�"5�X�a�[��=P�X]�Xa�Xa�bk�Xl�m� n�$�V�a�[��->��� �D�@Q�R�R�E� �L�L�(�1�+�f�"5�X�a�[��=P�X]�Xa�Xa�bk�Xl�m� n�%�f�q�k�$�.?��!��T�AR�S�S�F� �L�L�(�1�+�f�"5�X�a�[��=P�X^�Xb�Xb�cl�Xm�n� o�&�f�q�k�$�.?��!��T�AR�S�S�F� �L�L�(�1�+�f�"5�X�a�[��=P�X^�Xb�Xb�cl�Xm�n� o��� ���.�s�8�}�o�=T�Uj�Tk�kv�w�  � �g<� � �����S� S�S�S�S�S� S�S�S�T�T�� �6� �!1�1�5�5��6�s��U$�U�T � U�U$�U� T� ,U�6T�72U�)T�*,U�T�2U� T� ,U�6T�7AU�?T"�AU�T%� AU�/T(�0AU�?T+�AU�T.�AU�T1� AU�?T4�AU�T7�AU�T:� AU�/T=�0AU�?T?�A U� U$� U�U�U�U�U�U�U�"U�%U�(U�+U�.U�1U�4U�7U�:U�=U�?U� U!� U�U!�U$�U!�!U$c��^# �[5nU(aU$[X5IShv�N nSU;aU$USn[USSS5IShv�N nSU;a SSUS30$[USSS5IShv�N nSU;a SS US30$[XES US 5IShv�N nSU;a SS US30$S n[ XES U5IShv�N S n [ XFS U 5IShv�N UUUS US UR S5SSS.$N�N�N�NkNDN-![ an [SU 5sSn A $Sn A ff=f7f)a Create a complete OSPF lab with two routers properly configured Args: title: Title for the lab (default: "OSPF Network Lab") description: Lab description (default: "Two routers connected via OSPF") Returns: Dictionary with lab ID, router IDs, and access instructions Nr\rsrrzFailed to create Router1: �Router2rFzFailed to create Router2: r�zFailed to link routers: z� ! Basic Router1 Configuration with OSPF ! hostname Router1 ! interface GigabitEthernet0/0 ip address 10.0.0.1 255.255.255.0 no shutdown ! router ospf 1 network 10.0.0.0 0.0.0.255 area 0 ! z� ! Basic Router2 Configuration with OSPF ! hostname Router2 ! interface GigabitEthernet0/0 ip address 10.0.0.2 255.255.255.0 no shutdown ! router ospf 1 network 10.0.0.0 0.0.0.255 area 0 ! r�rzztLab created with OSPF routing between Router1 (10.0.0.1) and Router2 (10.0.0.2). Start the lab to test connectivity.)rsrf� router1_id� router2_idr�r|� instructions�create_ospf_lab)r]r}r�r�r�r5r6ra) rfrjr9r"rs�router1_result�router2_resultr%�router1_config�router2_configr:s r%rgrgs������J����B7�'��;�;� � �l� "�� ��h�'�� -�V�Y��B�G�G�� �n� $��9�.��:Q�9R�S�T� T�,�V�Y��R�H�H�� �n� $��9�.��:Q�9R�S�T� T�'�v�i�/H�.�Yb�Jc�d�d� � �k� !��7� �G�8L�7M�N�O� O� ���V�I�%>��O�O�O� ���V�I�%>��O�O�O���(��3�(��3�"���y�1��S� � �m<�H�I� e�& P�" P�� �7� �!2�A�6�6��7�s��D-�D �C>� D �D-�D �D� D �D-�D �.D�/D �D-�D �D�D �,D-�-D �D�D �D�"D �=D-�>D �D �D �D �D �D � D*� D%�D*� D-�%D*�*D-zcml://templates/basic-routerc��g)z#Basic router configuration templatez� ! Basic Router Configuration Template ! hostname {{hostname}} ! interface GigabitEthernet0/0 ip address {{interface_ip}} {{interface_mask}} no shutdown ! rMrMrNr%�basic_router_templatermjs�� rNzcml://templates/basic-switchc��g)z#Basic switch configuration templatezh ! Basic Switch Configuration Template ! hostname {{hostname}} ! vlan {{vlan_id}} name {{vlan_name}} ! rMrMrNr%�basic_switch_templateroys�� rNzcml://templates/ospf-configc��g)zOSPF configuration templatez~ ! OSPF Configuration Template ! router ospf {{process_id}} network {{network_address}} {{wildcard_mask}} area {{area_id}} ! rMrMrNr%� ospf_templaterq�s�� rNzcml-describe-topologyc��SUS3$)z$Prompt for describing a lab topologyzPPlease analyze the following network topology from Cisco Modeling Labs (Lab ID: z�). Describe the network elements, their connections, and the overall architecture. Suggest any improvements or potential issues with the design. rM)rss r%�describe_topology_promptrs�s��`�`f�_g�h� �rNzcml-create-labc��g)zPrompt for creating a new laba�I need you to help me create a network lab in Cisco Modeling Labs. Please design a lab that meets the following requirements: {{requirements}} For each device, specify: 1. Device type (router, switch, etc.) 2. Basic configuration 3. Network connections After designing the topology, you'll need to: 1. Create the lab in CML 2. Add the nodes 3. Create the links between nodes 4. Configure each node 5. Start the lab Please walk through this process step by step. rMrMrNr%�create_lab_promptru�s�� rN�__main__rD)r�)rrTNNN)rr)rrr)rH)�<)zSimple Networkz)A simple network with a router and switch)z STP Test Labz:Spanning Tree Protocol test lab with multiple STP versionsrNr)zOSPF Network LabzTwo routers connected via OSPF)BrI�osr"rr+�warningsr�rW�typingrrrrrr�fastmcpr r r �mcprUr�toolr7rJrZr]r6rarur}r�r�r�r��intr�r�r�r�r�r�r�r�r�r�r�r�r�rr r�rr!r>rPrg�resourcermrorq�promptrsrurE�runrMrNr%�<module>r�s��� � � � � ����:�:�+�+���!�#3�4��� ��d�d�R���� 4�c� 4�S� 4�C� 4�UY� 4�eh� 4� � 4�J �U�4��c�3�h��/�0� � @�� @�Y� @�4��S��>� @�$����/��/� �/�D����&2�C�&2�c�&2�4��S��>�&2� �&2�R����7�#�7�$�s�C�x�.�7� �7�,����/�S�/�S�/� �/�>����$;�U�4��S��>�3�+>�%?�$;� �$;�R����4��4��d�3��8�n�c�.A�(B�4� �4�B���� � � $��#�+/�O0� �O0� �O0��O0� � O0�  � O0� � O0� �#��O0���}�O0���c�3�h��(�O0� �#�s�(�^�O0� �O0�d����� � =� �=� �=� �=� � =�  �#�s�(�^� =� �=�4����� � � &5� �&5� �&5��&5� � &5�  � &5�  �#�s�(�^� &5� �&5�V����%:�c�%:�C�%:�E�$�s�C�x�.�RU�W[�\_�W`�B`�<a�%:� �%:�P����;?�#�;?��;?��d�3�PS�8�n�VZ�[_�`c�eh�`h�[i�Vj�lo�Fo�@p�;?� �;?�|����D8�3�D8��D8�C�D8��S�RU�X��D8� �D8�R1@�3�1@��1@��s�D�QT�VY�QY�N�GZ�A[�1@�h����N7��N7�c�N7�3�N7�SW�X[�]`�X`�Sa�N7� �N7�b����2�S�2�S�2�S�2�T�#�s�(�^�2� �2�@����4��4��d�3��8�n�c�.A�(B�4� �4�B����0�c�0�C�0�C�0� �0�0����3��3�s�3�C�3�C�3� �3�8����=�#�=��=��=� �=�2����/�C�/�C�/� �/�*����64�S�64�3�64��64� �64�r����/�3�/�3�/� �/�*����:7�3�:7�3�:7� �:7�~����!�B�/=� �/=��/=� �#�s�(�^�/=� �/=�d������*�;?� [#��[#��[#� �[#� ��9� [#� #�4��T�#�Y��#7�8� [#�  � [#� �[#�|�����S��!"� T6� �T6��T6��T6�� T6�  �#�s�(�^� T6� �T6�n����Q7��Q7��Q7�sw�x{�~A�yA�tB�Q7� �Q7�l���,�-� �s� �.� ����,�-� �s� �.� ����+�,��s��-����� #�$��S��S��%����� ���3����0 �z���G�G�I�rN

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/MediocreTriumph/claude-cml-toolkit'

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