{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Connecting to server at: http://0.0.0.0:7862/mcp\n", "\n", "Connected to server with tools: ['root__get', 'fetch_student_profile', 'fetch_student_profile_by_name', 'fetch_students', 'fetch_academic_history', 'fetch_financial_aid_eligibility', 'submit_note', 'get_course_plan', 'submit_course_plan']\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Error in sse_reader: peer closed connection without sending complete message body (incomplete chunked read)\n" ] } ], "source": [ "from clients.mcp_client import RegistrarMCPClient\n", "\n", "mcp_client = RegistrarMCPClient(base_url=\"http://0.0.0.0:7862/mcp\", auth_token=None)\n", "await mcp_client.connect_to_server()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " \"student_id\": \"S3CC01\",\n", " \"name\": \"Alice Jones\",\n", " \"email\": \"s3cc01@university.edu\",\n", " \"phone\": \"555-977-5249\",\n", " \"address\": \"507 University Ave, College Town, CT 73677\",\n", " \"enrollment_status\": \"Part-time\",\n", " \"major\": \"Nursing\",\n", " \"year\": \"Sophomore\",\n", " \"gpa\": 2.99,\n", " \"work_hours\": 15,\n", " \"goal\": \"finish program within 3 years\",\n", " \"past_terms\": [\n", " {\n", " \"term\": \"Summer 2024\",\n", " \"credits\": 10,\n", " \"stress\": \"low\",\n", " \"courses\": [\n", " {\n", " \"course_code\": \"NURS107\",\n", " \"title\": \"Fundamentals of Nursing\",\n", " \"credits\": 3,\n", " \"grade\": \"B-\"\n", " },\n", " {\n", " \"course_code\": \"NURS112\",\n", " \"title\": \"Anatomy & Physiology\",\n", " \"credits\": 4,\n", " \"grade\": \"B\"\n", " },\n", " {\n", " \"course_code\": \"NURS127\",\n", " \"title\": \"Pharmacology\",\n", " \"credits\": 3,\n", " \"grade\": \"B\"\n", " }\n", " ]\n", " }\n", " ],\n", " \"notes\": [],\n", " \"financial_status\": {\n", " \"efc\": 7343,\n", " \"dependency_status\": \"Independent\",\n", " \"household_income\": 55325,\n", " \"household_size\": 1\n", " },\n", " \"is_need_based_qualified\": false\n", "}\n" ] } ], "source": [ "print((await mcp_client.fetch_student_profile_by_name(\"Alice Jones\"))[0].text)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from agents.anthropic_agent import AnthropicAgent\n", "from config.settings import settings\n", "import logging\n", "\n", "logger = logging.getLogger(__name__)\n", "\n", "tools = await mcp_client.get_schema()\n", "\n", "agent = AnthropicAgent(\n", " api_key=settings.anthropic.ANTHROPIC_API_KEY,\n", " model=settings.anthropic.MODEL_ID,\n", " mcp_client=mcp_client,\n", " tools=tools,\n", " instructions=settings.agent.INSTRUCTIONS,\n", " logger=logger,\n", ")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Thank you for providing Alice Jones' name. I've retrieved her student profile. Let me summarize the key information for you:\n", "\n", "Student ID: S3CC01\n", "Name: Alice Jones\n", "Email: s3cc01@university.edu\n", "Phone: 555-977-5249\n", "Major: Nursing\n", "Year: Sophomore\n", "Enrollment Status: Part-time\n", "GPA: 2.99\n", "Work Hours: 15 hours per week\n", "Goal: Finish program within 3 years\n", "\n", "Alice's most recent term was Summer 2024, where she took 10 credits and reported a low stress level. Her courses included:\n", "1. NURS107: Fundamentals of Nursing (3 credits, B-)\n", "2. NURS112: Anatomy & Physiology (4 credits, B)\n", "3. NURS127: Pharmacology (3 credits, B)\n", "\n", "It's great to see that Alice completed her last term with a low stress level while balancing her studies and work commitments. \n", "\n", "Now that we have this information, how would you like to proceed with Alice's academic planning? Are you looking to plan for her upcoming term, or is there something specific you'd like to discuss regarding her academic progress?\n" ] } ], "source": [ "_, response = await agent.process_message(\"can i see the profile for Alice Jones?\")\n", "print(response)" ] } ], "metadata": { "kernelspec": { "display_name": "venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.3" } }, "nbformat": 4, "nbformat_minor": 2 }