chore: format

This commit is contained in:
Chris Coutinho
2025-07-29 09:09:10 +02:00
parent 13ba9ef2e6
commit 02ad283a01
+20 -16
View File
@@ -3,6 +3,8 @@ from mcp.server.fastmcp import FastMCP, Context
from nextcloud_mcp_server.client import NextcloudClient from nextcloud_mcp_server.client import NextcloudClient
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def configure_calendar_tools(mcp: FastMCP): def configure_calendar_tools(mcp: FastMCP):
# Calendar tools # Calendar tools
@mcp.tool() @mcp.tool()
@@ -11,7 +13,6 @@ def configure_calendar_tools(mcp: FastMCP):
client: NextcloudClient = ctx.request_context.lifespan_context.client client: NextcloudClient = ctx.request_context.lifespan_context.client
return await client.calendar.list_calendars() return await client.calendar.list_calendars()
@mcp.tool() @mcp.tool()
async def nc_calendar_create_event( async def nc_calendar_create_event(
calendar_name: str, calendar_name: str,
@@ -87,7 +88,6 @@ def configure_calendar_tools(mcp: FastMCP):
return await client.calendar.create_event(calendar_name, event_data) return await client.calendar.create_event(calendar_name, event_data)
@mcp.tool() @mcp.tool()
async def nc_calendar_list_events( async def nc_calendar_list_events(
calendar_name: str, calendar_name: str,
@@ -162,7 +162,6 @@ def configure_calendar_tools(mcp: FastMCP):
return events return events
@mcp.tool() @mcp.tool()
async def nc_calendar_get_event( async def nc_calendar_get_event(
calendar_name: str, calendar_name: str,
@@ -174,7 +173,6 @@ def configure_calendar_tools(mcp: FastMCP):
event_data, etag = await client.calendar.get_event(calendar_name, event_uid) event_data, etag = await client.calendar.get_event(calendar_name, event_uid)
return event_data return event_data
@mcp.tool() @mcp.tool()
async def nc_calendar_update_event( async def nc_calendar_update_event(
calendar_name: str, calendar_name: str,
@@ -247,7 +245,6 @@ def configure_calendar_tools(mcp: FastMCP):
calendar_name, event_uid, event_data, etag calendar_name, event_uid, event_data, etag
) )
@mcp.tool() @mcp.tool()
async def nc_calendar_delete_event( async def nc_calendar_delete_event(
calendar_name: str, calendar_name: str,
@@ -258,7 +255,6 @@ def configure_calendar_tools(mcp: FastMCP):
client: NextcloudClient = ctx.request_context.lifespan_context.client client: NextcloudClient = ctx.request_context.lifespan_context.client
return await client.calendar.delete_event(calendar_name, event_uid) return await client.calendar.delete_event(calendar_name, event_uid)
@mcp.tool() @mcp.tool()
async def nc_calendar_create_meeting( async def nc_calendar_create_meeting(
title: str, title: str,
@@ -325,7 +321,6 @@ def configure_calendar_tools(mcp: FastMCP):
return await client.calendar.create_event(calendar_name, event_data) return await client.calendar.create_event(calendar_name, event_data)
@mcp.tool() @mcp.tool()
async def nc_calendar_get_upcoming_events( async def nc_calendar_get_upcoming_events(
ctx: Context, ctx: Context,
@@ -378,7 +373,6 @@ def configure_calendar_tools(mcp: FastMCP):
all_events.sort(key=lambda x: x.get("start_datetime", "")) all_events.sort(key=lambda x: x.get("start_datetime", ""))
return all_events[:limit] return all_events[:limit]
@mcp.tool() @mcp.tool()
async def nc_calendar_find_availability( async def nc_calendar_find_availability(
duration_minutes: int, duration_minutes: int,
@@ -440,7 +434,6 @@ def configure_calendar_tools(mcp: FastMCP):
constraints=constraints, constraints=constraints,
) )
@mcp.tool() @mcp.tool()
async def nc_calendar_bulk_operations( async def nc_calendar_bulk_operations(
operation: str, # "update", "delete", "move" operation: str, # "update", "delete", "move"
@@ -501,7 +494,9 @@ def configure_calendar_tools(mcp: FastMCP):
if title_contains is not None: if title_contains is not None:
filter_criteria["title_contains"] = title_contains filter_criteria["title_contains"] = title_contains
if categories is not None: if categories is not None:
filter_criteria["categories"] = [cat.strip() for cat in categories.split(",")] filter_criteria["categories"] = [
cat.strip() for cat in categories.split(",")
]
if status is not None: if status is not None:
filter_criteria["status"] = status filter_criteria["status"] = status
if location_contains is not None: if location_contains is not None:
@@ -515,10 +510,14 @@ def configure_calendar_tools(mcp: FastMCP):
# Find matching events and delete them # Find matching events and delete them
if calendar_name: if calendar_name:
events = await client.calendar.get_calendar_events( events = await client.calendar.get_calendar_events(
calendar_name=calendar_name, start_date=start_date, end_date=end_date calendar_name=calendar_name,
start_date=start_date,
end_date=end_date,
) )
if filter_criteria: if filter_criteria:
events = client.calendar._apply_event_filters(events, filter_criteria) events = client.calendar._apply_event_filters(
events, filter_criteria
)
else: else:
events = await client.calendar.search_events_across_calendars( events = await client.calendar.search_events_across_calendars(
start_date=start_date, end_date=end_date, filters=filter_criteria start_date=start_date, end_date=end_date, filters=filter_criteria
@@ -579,7 +578,9 @@ def configure_calendar_tools(mcp: FastMCP):
if not update_data: if not update_data:
raise ValueError("No update data provided for update operation") raise ValueError("No update data provided for update operation")
return await client.calendar.bulk_update_events(filter_criteria, update_data) return await client.calendar.bulk_update_events(
filter_criteria, update_data
)
elif operation == "move": elif operation == "move":
if not target_calendar: if not target_calendar:
@@ -588,10 +589,14 @@ def configure_calendar_tools(mcp: FastMCP):
# Find matching events # Find matching events
if calendar_name: if calendar_name:
events = await client.calendar.get_calendar_events( events = await client.calendar.get_calendar_events(
calendar_name=calendar_name, start_date=start_date, end_date=end_date calendar_name=calendar_name,
start_date=start_date,
end_date=end_date,
) )
if filter_criteria: if filter_criteria:
events = client.calendar._apply_event_filters(events, filter_criteria) events = client.calendar._apply_event_filters(
events, filter_criteria
)
else: else:
events = await client.calendar.search_events_across_calendars( events = await client.calendar.search_events_across_calendars(
start_date=start_date, end_date=end_date, filters=filter_criteria start_date=start_date, end_date=end_date, filters=filter_criteria
@@ -654,7 +659,6 @@ def configure_calendar_tools(mcp: FastMCP):
"results": results, "results": results,
} }
@mcp.tool() @mcp.tool()
async def nc_calendar_manage_calendar( async def nc_calendar_manage_calendar(
action: str, # "create", "delete", "update", "list" action: str, # "create", "delete", "update", "list"