⚠
️ DEPRECATED GITLAB INSTANCE
⚠
️ This GitLab is now read-only for reference. Please use
https://gitlab.iauro.co
for all new work.
Migration completed on September 17, 2025
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Pratiksha-Patil
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pratiksha Patil
Pratiksha-Patil
Commits
309e6111
Commit
309e6111
authored
Jul 23, 2025
by
Pratiksha Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
9th Assignment of MCP client
parent
07403da6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
147 additions
and
0 deletions
+147
-0
mcp_client_assignment/.env.example
mcp_client_assignment/.env.example
+4
-0
mcp_client_assignment/README.md
mcp_client_assignment/README.md
+27
-0
mcp_client_assignment/mcp-client.py
mcp_client_assignment/mcp-client.py
+83
-0
mcp_client_assignment/mcp-server.py
mcp_client_assignment/mcp-server.py
+28
-0
mcp_client_assignment/requirements.txt
mcp_client_assignment/requirements.txt
+5
-0
No files found.
mcp_client_assignment/.env.example
0 → 100644
View file @
309e6111
SMTP_SERVER=smtp.example.com
SMTP_USER=your-email@example.com
SMTP_PASSWORD=yourpassword
mcp_client_assignment/README.md
0 → 100644
View file @
309e6111
# MCP Client
## Overview
This project contains a simple MCP client and a mock MCP server that:
-
Fetches user email context
-
Queries calendar events via Outlook tool endpoint
-
Sends a summary email
## Setup
### Install dependencies
```
bash
pip
install
-r
requirements.txt
```
### Run the MCP server
```
bash
uvicorn mcp-server:app
--reload
```
### Run the client
Update
`.env`
with your SMTP credentials, then:
```
bash
python mcp-client.py
```
mcp_client_assignment/mcp-client.py
0 → 100644
View file @
309e6111
import
httpx
import
smtplib
import
os
from
email.mime.text
import
MIMEText
from
datetime
import
datetime
,
timedelta
from
dotenv
import
load_dotenv
load_dotenv
()
MCP_SERVER_URL
=
"http://localhost:8000"
SMTP_SERVER
=
os
.
getenv
(
"SMTP_SERVER"
)
SMTP_PORT
=
587
SMTP_USER
=
os
.
getenv
(
"SMTP_USER"
)
SMTP_PASS
=
os
.
getenv
(
"SMTP_PASSWORD"
)
FROM_EMAIL
=
os
.
getenv
(
"SMTP_USER"
)
def
get_user_context
():
try
:
response
=
httpx
.
post
(
f
"{MCP_SERVER_URL}/context"
,
json
=
{})
response
.
raise_for_status
()
context
=
response
.
json
()
return
context
.
get
(
"email"
)
except
Exception
as
e
:
print
(
f
"[ERROR] Failed to fetch user context: {e}"
)
return
None
def
get_calendar_events
(
user_email
:
str
):
today
=
datetime
.
utcnow
()
start
=
today
.
replace
(
hour
=
0
,
minute
=
0
,
second
=
0
,
microsecond
=
0
)
.
isoformat
()
+
"Z"
end
=
(
today
+
timedelta
(
days
=
1
))
.
replace
(
hour
=
0
,
minute
=
0
,
second
=
0
,
microsecond
=
0
)
.
isoformat
()
+
"Z"
payload
=
{
"tool_name"
:
"get_upcoming_events"
,
"tool_input"
:
{
"email"
:
user_email
,
"start_datetime"
:
start
,
"end_datetime"
:
end
}
}
try
:
response
=
httpx
.
post
(
f
"{MCP_SERVER_URL}/tool"
,
json
=
payload
)
response
.
raise_for_status
()
return
response
.
json
()
.
get
(
"events"
,
[])
except
Exception
as
e
:
print
(
f
"[ERROR] Failed to fetch calendar events: {e}"
)
return
[]
def
send_email_summary
(
to_email
,
events
):
if
not
events
:
body
=
"You have no events scheduled for today."
else
:
summary
=
"
\n
"
.
join
(
f
"- {e['subject']} at {e['start']['dateTime']} (location: {e.get('location', {}).get('displayName', '-')})"
for
e
in
events
)
body
=
f
"Hello,
\n\n
Here is your schedule for today:
\n\n
{summary}
\n\n
Regards,
\n
MCP Client"
msg
=
MIMEText
(
body
)
msg
[
"Subject"
]
=
"Today's Outlook Calendar Summary"
msg
[
"From"
]
=
FROM_EMAIL
msg
[
"To"
]
=
to_email
try
:
with
smtplib
.
SMTP
(
SMTP_SERVER
,
SMTP_PORT
)
as
server
:
server
.
starttls
()
server
.
login
(
SMTP_USER
,
SMTP_PASS
)
server
.
send_message
(
msg
)
print
(
f
"[INFO] Email sent to {to_email}"
)
except
Exception
as
e
:
print
(
f
"[ERROR] Failed to send email: {e}"
)
if
__name__
==
"__main__"
:
print
(
"[INFO] Starting MCP Client..."
)
user_email
=
get_user_context
()
if
not
user_email
:
print
(
"[ERROR] No user email found. Exiting."
)
exit
(
1
)
print
(
f
"Found user: {user_email}"
)
events
=
get_calendar_events
(
user_email
)
print
(
f
"Fetched {len(events)} events."
)
send_email_summary
(
user_email
,
events
)
mcp_client_assignment/mcp-server.py
0 → 100644
View file @
309e6111
from
fastapi
import
FastAPI
from
pydantic
import
BaseModel
from
datetime
import
datetime
,
timedelta
app
=
FastAPI
()
@
app
.
post
(
"/context"
)
def
get_context
():
return
{
"email"
:
"dummy.user@example.com"
}
class
ToolInput
(
BaseModel
):
email
:
str
start_datetime
:
str
end_datetime
:
str
class
ToolRequest
(
BaseModel
):
tool_name
:
str
tool_input
:
ToolInput
@
app
.
post
(
"/tool"
)
def
get_tool_data
(
req
:
ToolRequest
):
now
=
datetime
.
utcnow
()
events
=
[
{
"subject"
:
"Team Standup"
,
"start"
:
{
"dateTime"
:
(
now
+
timedelta
(
hours
=
1
))
.
isoformat
()},
"location"
:
{
"displayName"
:
"Zoom"
}},
{
"subject"
:
"Client Call"
,
"start"
:
{
"dateTime"
:
(
now
+
timedelta
(
hours
=
3
))
.
isoformat
()},
"location"
:
{
"displayName"
:
"MS Teams"
}}
]
return
{
"events"
:
events
}
mcp_client_assignment/requirements.txt
0 → 100644
View file @
309e6111
httpx
python-dotenv
fastapi
uvicorn
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment