Skip to content

Commit a940ff1

Browse files
committed
chore: add samples
1 parent 5717b13 commit a940ff1

28 files changed

Lines changed: 1096 additions & 0 deletions

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,11 @@ cython_debug/
178178
**/.uipath
179179
**/**.nupkg
180180
**/__uipath/
181+
182+
183+
**/samples/**/.agent/
184+
**/samples/**/.claude/
185+
**/samples/**/AGENTS.md
186+
**/samples/**/CLAUDE.md
187+
**/samples/**/entry-points.json
188+
**/samples/**/uv.lock
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# MCP DateTime Server
2+
3+
A sample MCP server that exposes date and time utility tools over Streamable HTTP transport, built with the UiPath MCP SDK (`FastMCP`).
4+
5+
## Tools
6+
7+
| Tool | Description |
8+
|------|-------------|
9+
| `current_utc_time` | Returns the current UTC date/time in ISO 8601 format |
10+
| `days_between` | Calculates absolute days between two dates |
11+
| `add_days` | Adds or subtracts days from a date |
12+
| `day_of_week` | Returns the day name for a given date |
13+
| `is_leap_year` | Checks if a year is a leap year |
14+
| `days_in_month` | Returns the number of days in a given month/year |
15+
| `time_difference` | Calculates difference between two datetimes (days, hours, minutes, seconds) |
16+
| `is_weekend` | Checks if a date falls on Saturday or Sunday |
17+
18+
## Running
19+
20+
```bash
21+
uipath run mcp-datetime-server
22+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "2.0",
3+
"resources": []
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"servers": {
3+
"mcp-datetime-server": {
4+
"transport": "streamable-http",
5+
"command": "uv",
6+
"args": ["run", "python", "server.py"],
7+
"url": "http://127.0.0.1:8080/mcp"
8+
}
9+
}
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[project]
2+
name = "mcp-datetime-server"
3+
version = "0.0.1"
4+
description = "DateTime Operations MCP Server"
5+
authors = [{ name = "John Doe" }]
6+
dependencies = [
7+
"uipath-mcp>=0.1.1",
8+
]
9+
requires-python = ">=3.11"
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
"""Date and time operations MCP server running over streamable HTTP."""
2+
3+
from datetime import datetime, timedelta, timezone
4+
from typing import Dict
5+
6+
from mcp.server.fastmcp import FastMCP
7+
8+
mcp = FastMCP("DateTime Operations Server", host="127.0.0.1", port=8080)
9+
10+
11+
@mcp.tool()
12+
def current_utc_time() -> str:
13+
"""Get the current UTC date and time in ISO 8601 format.
14+
15+
Returns:
16+
Current UTC datetime as an ISO 8601 string
17+
"""
18+
return datetime.now(timezone.utc).isoformat()
19+
20+
21+
@mcp.tool()
22+
def days_between(date1: str, date2: str) -> int:
23+
"""Calculate the number of days between two dates.
24+
25+
Args:
26+
date1: First date in ISO 8601 format
27+
date2: Second date in ISO 8601 format
28+
29+
Returns:
30+
Absolute number of days between the two dates
31+
"""
32+
dt1 = datetime.fromisoformat(date1)
33+
dt2 = datetime.fromisoformat(date2)
34+
return abs((dt2 - dt1).days)
35+
36+
37+
@mcp.tool()
38+
def add_days(date_string: str, days: int) -> str:
39+
"""Add or subtract days from a date.
40+
41+
Args:
42+
date_string: Starting date in ISO 8601 format
43+
days: Number of days to add (negative to subtract)
44+
45+
Returns:
46+
The resulting date in ISO 8601 format
47+
"""
48+
dt = datetime.fromisoformat(date_string)
49+
result = dt + timedelta(days=days)
50+
return result.isoformat()
51+
52+
53+
@mcp.tool()
54+
def day_of_week(date_string: str) -> str:
55+
"""Get the day of the week for a given date.
56+
57+
Args:
58+
date_string: Date in ISO 8601 format
59+
60+
Returns:
61+
Name of the day of the week (e.g. "Monday")
62+
"""
63+
dt = datetime.fromisoformat(date_string)
64+
return dt.strftime("%A")
65+
66+
67+
@mcp.tool()
68+
def is_leap_year(year: int) -> bool:
69+
"""Check if a given year is a leap year.
70+
71+
Args:
72+
year: The year to check
73+
74+
Returns:
75+
True if the year is a leap year
76+
"""
77+
return (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
78+
79+
80+
@mcp.tool()
81+
def days_in_month(year: int, month: int) -> int:
82+
"""Get the number of days in a given month.
83+
84+
Args:
85+
year: The year
86+
month: The month (1-12)
87+
88+
Returns:
89+
Number of days in the month
90+
91+
Raises:
92+
ValueError: If month is not between 1 and 12
93+
"""
94+
if month < 1 or month > 12:
95+
raise ValueError("Month must be between 1 and 12")
96+
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
97+
if month == 2 and is_leap_year(year):
98+
return 29
99+
return days[month - 1]
100+
101+
102+
@mcp.tool()
103+
def time_difference(datetime1: str, datetime2: str) -> Dict[str, int]:
104+
"""Calculate the difference between two datetimes.
105+
106+
Args:
107+
datetime1: First datetime in ISO 8601 format
108+
datetime2: Second datetime in ISO 8601 format
109+
110+
Returns:
111+
Dictionary with days, hours, minutes, and seconds of difference
112+
"""
113+
dt1 = datetime.fromisoformat(datetime1)
114+
dt2 = datetime.fromisoformat(datetime2)
115+
diff = abs(dt2 - dt1)
116+
total_seconds = int(diff.total_seconds())
117+
days = diff.days
118+
hours = (total_seconds % 86400) // 3600
119+
minutes = (total_seconds % 3600) // 60
120+
seconds = total_seconds % 60
121+
return {"days": days, "hours": hours, "minutes": minutes, "seconds": seconds}
122+
123+
124+
@mcp.tool()
125+
def is_weekend(date_string: str) -> bool:
126+
"""Check if a given date falls on a weekend.
127+
128+
Args:
129+
date_string: Date in ISO 8601 format
130+
131+
Returns:
132+
True if the date is Saturday or Sunday
133+
"""
134+
dt = datetime.fromisoformat(date_string)
135+
return dt.weekday() >= 5
136+
137+
138+
if __name__ == "__main__":
139+
mcp.run(transport="streamable-http")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://cloud.uipath.com/draft/2024-12/uipath",
3+
"runtimeOptions": {
4+
"isConversational": false
5+
},
6+
"packOptions": {
7+
"fileExtensionsIncluded": [],
8+
"filesIncluded": [],
9+
"filesExcluded": [],
10+
"directoriesExcluded": [],
11+
"includeUvLock": true
12+
},
13+
"functions": {}
14+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# MCP String Server
2+
3+
A sample MCP server that exposes string manipulation tools over Streamable HTTP transport, built with the UiPath MCP SDK (`FastMCP`).
4+
5+
## Tools
6+
7+
| Tool | Description |
8+
|------|-------------|
9+
| `reverse_string` | Reverses the input string |
10+
| `to_uppercase` | Converts a string to uppercase |
11+
| `to_lowercase` | Converts a string to lowercase |
12+
| `count_words` | Counts the number of words in a string |
13+
| `replace_text` | Replaces all occurrences of a substring |
14+
| `trim` | Removes leading and trailing whitespace |
15+
| `split_string` | Splits a string by a delimiter |
16+
| `join_strings` | Joins a list of strings with a delimiter |
17+
| `is_palindrome` | Checks if a string is a palindrome (ignoring case/spaces) |
18+
| `char_frequency` | Returns character frequency counts |
19+
20+
## Running
21+
22+
```bash
23+
uipath run mcp-string-server
24+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "2.0",
3+
"resources": []
4+
}

samples/mcp-string-server/mcp.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"servers": {
3+
"mcp-string-server": {
4+
"transport": "streamable-http",
5+
"command": "uv",
6+
"args": ["run", "python", "server.py"],
7+
"url": "http://127.0.0.1:8080/mcp"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)