Skip to content

Commit c18fc38

Browse files
committed
format
1 parent f0c22fc commit c18fc38

5 files changed

Lines changed: 64 additions & 57 deletions

File tree

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Todo MCP Agent with Azure AI
1+
# To-do MCP Agent with Azure AI
22

3-
A FastAPI-based todo list application with Azure AI Agents integration and Model Context Protocol (MCP) server functionality.
3+
A FastAPI-based to-do list application with Azure AI Agents integration and Model Context Protocol (MCP) server functionality.
44

55
## Features
66

7-
- 🤖 **AI-Powered Chat**: Azure AI Agents with GPT-4o for natural language todo management
7+
- 🤖 **AI-Powered Chat**: Azure AI Agents with GPT-4o for natural language to-do management
88
- 🔧 **MCP Integration**: Model Context Protocol server for AI tool access
9-
-**Todo Management**: Full CRUD operations with priority levels
9+
-**To-do Management**: Full CRUD operations with priority levels
1010
- 🌐 **Web Interface**: Clean, responsive UI with chat functionality
1111
- ☁️ **Azure Deployment**: Ready for Azure App Service with AI Foundry
1212

@@ -35,7 +35,7 @@ A FastAPI-based todo list application with Azure AI Agents integration and Model
3535
```
3636

3737
3. **Access the app**:
38-
- Todo List: http://localhost:8000
38+
- To-do List: http://localhost:8000
3939
- AI Chat: http://localhost:8000/chat
4040
- Health Check: http://localhost:8000/health
4141

@@ -57,23 +57,23 @@ This creates:
5757

5858
The application combines three key components:
5959

60-
1. **Todo Management**: Standard CRUD operations for managing tasks
61-
2. **MCP Server**: Exposes todo operations as tools that AI agents can use
62-
3. **AI Chat Interface**: Azure AI Agents that can interact with your todos through natural language
60+
1. **To-do Management**: Standard CRUD operations for managing tasks
61+
2. **MCP Server**: Exposes to-do operations as tools that AI agents can use
62+
3. **AI Chat Interface**: Azure AI Agents that can interact with your to-dos through natural language
6363

6464
### Example Chat Interactions
6565

66-
- "Create a high priority todo to finish the project"
67-
- "Show me all my incomplete todos"
68-
- "Mark the project todo as complete"
69-
- "What todos do I have for today?"
66+
- "Create a high priority to-do to finish the project"
67+
- "Show me all my incomplete to-dos"
68+
- "Mark the project to-do as complete"
69+
- "What to-dos do I have for today?"
7070

7171
## Architecture
7272

7373
```
7474
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
7575
│ Chat UI │────│ FastAPI App │────│ In-Memory │
76-
│ (AI Agent) │ │ + MCP Server │ │ Todo Store
76+
│ (AI Agent) │ │ + MCP Server │ │ To-do Store │
7777
└─────────────────┘ └──────────────────┘ └─────────────────┘
7878
7979
┌──────────────────┐
@@ -85,7 +85,7 @@ The application combines three key components:
8585

8686
## Model Context Protocol (MCP)
8787

88-
This application implements a complete MCP server following the [MCP specification](https://modelcontextprotocol.io/introduction). The MCP server exposes todo management functionality as tools that AI agents can discover and use.
88+
This application implements a complete MCP server following the [MCP specification](https://modelcontextprotocol.io/introduction). The MCP server exposes to-do management functionality as tools that AI agents can discover and use.
8989

9090
### MCP Documentation and Resources
9191

@@ -107,10 +107,10 @@ See **[Connect to Model Context Protocol servers (preview)](https://learn.micros
107107

108108
The application exposes these tools for AI agents:
109109

110-
- `create_todo` - Create new todos with title, description, and priority
111-
- `list_todos` - List all todos or filter by completion status
112-
- `update_todo` - Update existing todo properties
113-
- `delete_todo` - Delete todos by ID
110+
- `create_todo` - Create new to-dos with title, description, and priority
111+
- `list_todos` - List all to-dos or filter by completion status
112+
- `update_todo` - Update existing to-do properties
113+
- `delete_todo` - Delete to-dos by ID
114114
- `mark_todo_complete` - Toggle completion status
115115

116116
### Testing MCP Locally
@@ -130,15 +130,15 @@ curl -X POST http://localhost:8000/mcp/stream \
130130
## API Endpoints
131131

132132
### Web Interface
133-
- `GET /` - Todo list page
133+
- `GET /` - To-do list page
134134
- `GET /chat` - AI chat interface
135135
- `GET /health` - Health check
136136

137137
### REST API
138-
- `GET /api/todos` - List todos
139-
- `POST /api/todos` - Create todo
140-
- `PUT /api/todos/{id}` - Update todo
141-
- `DELETE /api/todos/{id}` - Delete todo
138+
- `GET /api/todos` - List to-dos
139+
- `POST /api/todos` - Create to-do
140+
- `PUT /api/todos/{id}` - Update to-do
141+
- `DELETE /api/todos/{id}` - Delete to-do
142142

143143
### AI Chat API
144144
- `POST /api/chat/session` - Create chat session

main.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
import logging
77
import traceback
88
from datetime import datetime
9-
from typing import Dict, List, Optional, Any
9+
from typing import Dict, List, Option # Default instructions for MCP-enabled agent
10+
instructions = """
11+
You are a helpful agent with access to to-do management tools via MCP.
12+
You can help users create, list, update, and delete to-do items using the available MCP tools.
13+
When users ask about to-dos, use the MCP tools to perform the requested actions.
14+
Always be helpful and provide clear feedback about what actions you've taken.
15+
"""
1016
from contextlib import asynccontextmanager
1117

1218
from fastapi import FastAPI, HTTPException, Request
@@ -165,9 +171,9 @@ async def create_agent_with_mcp(self, instructions: str = None) -> Optional[str]
165171
# Default instructions if none provided
166172
if not instructions:
167173
instructions = """
168-
You are a helpful agent that can use MCP tools to assist users with todo management.
174+
You are a helpful agent that can use MCP tools to assist users with to-do management.
169175
Use the available MCP tools to answer questions and perform tasks like creating,
170-
listing, updating, and deleting todos.
176+
listing, updating, and deleting to-dos.
171177
"""
172178

173179
# Create agent with MCP tool definitions
@@ -210,9 +216,9 @@ async def chat_with_agent(self, message: str) -> ChatResponse:
210216

211217
# Default instructions for MCP-enabled agent
212218
instructions = """
213-
You are a helpful AI agent with access to todo management tools via MCP.
214-
You can help users create, list, update, and delete todo items using the available MCP tools.
215-
When users ask about todos, use the MCP tools to perform the requested actions.
219+
You are a helpful agent with access to to-do management tools via MCP.
220+
You can help users create, list, update, and delete to-do items using the available MCP tools.
221+
When users ask about to-dos, use the MCP tools to perform the requested actions.
216222
Always be helpful and provide clear feedback about what actions you've taken.
217223
"""
218224

static/css/style.css

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,10 @@ select.form-control {
399399

400400
.chat-messages .message.user-message {
401401
margin-left: auto;
402-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
402+
background: #3498db;
403403
color: white;
404404
border-radius: 20px 20px 6px 20px;
405-
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
405+
box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
406406
}
407407

408408
.chat-messages .message.assistant-message {
@@ -489,7 +489,7 @@ select.form-control {
489489

490490
.send-button {
491491
padding: 14px 20px;
492-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
492+
background: #3498db;
493493
color: white;
494494
border: none;
495495
border-radius: 20px;
@@ -500,20 +500,21 @@ select.form-control {
500500
display: flex;
501501
align-items: center;
502502
justify-content: center;
503-
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
503+
box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
504504
}
505505

506506
.send-button:hover:not(:disabled) {
507+
background: #2980b9;
507508
transform: translateY(-1px);
508-
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
509+
box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
509510
}
510511

511512
.send-button:active:not(:disabled) {
512513
transform: translateY(0);
513514
}
514515

515516
.send-button:disabled {
516-
background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
517+
background: #cbd5e1;
517518
cursor: not-allowed;
518519
transform: none;
519520
box-shadow: 0 2px 8px rgba(203, 213, 225, 0.3);
@@ -640,16 +641,17 @@ select.form-control {
640641
}
641642
}
642643

643-
/* Navigation Tabs - Enhanced Design */
644+
/* Navigation Tabs - Clean Design */
644645
.navigation-tabs {
645646
display: flex;
646647
margin-bottom: 0;
647-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
648+
background: white;
648649
border-radius: 12px 12px 0 0;
649-
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
650+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
650651
padding: 4px;
651652
position: relative;
652653
overflow: hidden;
654+
border-bottom: 1px solid #e2e8f0;
653655
}
654656

655657
.navigation-tabs::before {
@@ -659,7 +661,7 @@ select.form-control {
659661
left: 0;
660662
right: 0;
661663
bottom: 0;
662-
background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
664+
background: linear-gradient(135deg, rgba(52, 152, 219, 0.02) 0%, rgba(44, 62, 80, 0.02) 100%);
663665
pointer-events: none;
664666
}
665667

@@ -670,7 +672,7 @@ select.form-control {
670672
border: none;
671673
cursor: pointer;
672674
text-decoration: none;
673-
color: rgba(255,255,255,0.8);
675+
color: #64748b;
674676
font-weight: 600;
675677
font-size: 15px;
676678
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
@@ -679,20 +681,19 @@ select.form-control {
679681
text-align: center;
680682
position: relative;
681683
z-index: 2;
682-
backdrop-filter: blur(10px);
683684
}
684685

685686
.nav-tab:hover:not(.active) {
686-
background: rgba(255,255,255,0.1);
687-
color: rgba(255,255,255,0.95);
687+
background: #f8fafc;
688+
color: #2c3e50;
688689
transform: translateY(-1px);
689690
}
690691

691692
.nav-tab.active {
692-
background: white;
693-
color: #4a5568;
693+
background: #3498db;
694+
color: white;
694695
font-weight: 700;
695-
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
696+
box-shadow: 0 4px 12px rgba(52, 152, 219, 0.25);
696697
transform: translateY(-2px);
697698
}
698699

@@ -704,7 +705,7 @@ select.form-control {
704705
transform: translateX(-50%);
705706
width: 40px;
706707
height: 3px;
707-
background: linear-gradient(90deg, #667eea, #764ba2);
708+
background: #2980b9;
708709
border-radius: 2px;
709710
}
710711

templates/chat.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ <h1>App Service MCP To-do List App</h1>
1414
<p>With chat powered by AI Foundry Agent MCP server integration</p>
1515
</div>
1616

17-
<!-- Navigation -->
17+
<!-- Navigation Tabs -->
1818
<div class="navigation-tabs">
19-
<a href="/" class="nav-tab">Todo List</a>
19+
<a href="/" class="nav-tab">To-do List</a>
2020
<a href="/chat" class="nav-tab active">AI Chat</a>
2121
</div>
2222

@@ -25,7 +25,7 @@ <h1>App Service MCP To-do List App</h1>
2525
<div class="chat-messages" id="chatMessages">
2626
<div class="message assistant-message">
2727
<div class="message-content">
28-
<strong>Agent:</strong> Hi! I'm your AI agent powered by Azure AI Foundry with MCP integration. I can help you manage your todos through natural language. Try asking me to "create a new todo" or "show me all my todos"!
28+
<strong>agent:</strong> Hi! I'm your AI agent powered by Azure AI Foundry with MCP integration. I can help you manage your to-dos through natural language. Try asking me to "create a new to-do" or "show me all my to-dos"!
2929
</div>
3030
<div class="message-time" id="initialTime"></div>
3131
</div>
@@ -37,7 +37,7 @@ <h1>App Service MCP To-do List App</h1>
3737
<input
3838
type="text"
3939
id="chatInput"
40-
placeholder="Ask me to manage your todos... (e.g., 'Create a high priority todo to finish the project')"
40+
placeholder="Ask me to manage your to-dos... (e.g., 'Create a high priority to-do to finish the project')"
4141
class="chat-input"
4242
disabled
4343
>

templates/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ <h1>App Service MCP To-do List App</h1>
1616

1717
<!-- Navigation Tabs -->
1818
<div class="navigation-tabs">
19-
<a href="/" class="nav-tab active">Todo List</a>
19+
<a href="/" class="nav-tab active">To-do List</a>
2020
<a href="/chat" class="nav-tab">AI Chat</a>
2121
</div>
2222

23-
<!-- Add Todo Section -->
23+
<!-- Add To-do Section -->
2424
<div class="add-todo-section">
25-
<h2>Add New Todo</h2>
25+
<h2>Add New To-do</h2>
2626
<form id="addTodoForm">
2727
<div class="form-group">
2828
<label for="todoTitle">Title *</label>
@@ -40,7 +40,7 @@ <h2>Add New Todo</h2>
4040
<option value="high">High</option>
4141
</select>
4242
</div>
43-
<button type="submit" class="btn btn-primary">Add Todo</button>
43+
<button type="submit" class="btn btn-primary">Add To-do</button>
4444
</form>
4545
</div>
4646

@@ -51,9 +51,9 @@ <h2>Add New Todo</h2>
5151
<button class="filter-btn" data-filter="completed">Completed</button>
5252
</div>
5353

54-
<!-- Todo List Section -->
54+
<!-- To-do List Section -->
5555
<div class="todo-list-section">
56-
<h2>Your Todos</h2>
56+
<h2>Your To-dos</h2>
5757
<div id="todoList">
5858
<p class="no-todos">Loading todos...</p>
5959
</div>

0 commit comments

Comments
 (0)