Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from starlette.requests import Request
from starlette.middleware import Middleware

from mcp.types import ToolAnnotations

from fastmcp import FastMCP
from fastmcp.server.auth.providers.google import GoogleProvider

Expand Down Expand Up @@ -657,7 +659,15 @@ async def legacy_oauth2_callback(request: Request) -> HTMLResponse:
return create_server_error_response(str(e))


@server.tool()
@server.tool(
title="Start Google Auth",
annotations=ToolAnnotations(
readOnlyHint=False,
destructiveHint=False,
idempotentHint=False,
openWorldHint=True,
),
)
async def start_google_auth(
service_name: str, user_google_email: str = USER_GOOGLE_EMAIL
) -> str:
Expand Down
151 changes: 136 additions & 15 deletions gappsscript/apps_script_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from auth.service_decorator import require_google_service
from core.server import server
from mcp.types import ToolAnnotations
from core.utils import handle_http_errors

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -69,7 +70,15 @@ async def _list_script_projects_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="List Script Projects",
annotations=ToolAnnotations(
readOnlyHint=True,
destructiveHint=False,
idempotentHint=True,
openWorldHint=True,
),
)
@handle_http_errors("list_script_projects", is_read_only=True, service_type="drive")
@require_google_service("drive", "drive_read")
async def list_script_projects(
Expand Down Expand Up @@ -141,7 +150,15 @@ async def _get_script_project_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="Get Script Project",
annotations=ToolAnnotations(
readOnlyHint=True,
destructiveHint=False,
idempotentHint=True,
openWorldHint=True,
),
)
@handle_http_errors("get_script_project", is_read_only=True, service_type="script")
@require_google_service("script", "script_readonly")
async def get_script_project(
Expand Down Expand Up @@ -199,7 +216,15 @@ async def _get_script_content_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="Get Script Content",
annotations=ToolAnnotations(
readOnlyHint=True,
destructiveHint=False,
idempotentHint=True,
openWorldHint=True,
),
)
@handle_http_errors("get_script_content", is_read_only=True, service_type="script")
@require_google_service("script", "script_readonly")
async def get_script_content(
Expand Down Expand Up @@ -256,7 +281,15 @@ async def _create_script_project_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="Create Script Project",
annotations=ToolAnnotations(
readOnlyHint=False,
destructiveHint=False,
idempotentHint=False,
openWorldHint=True,
),
)
@handle_http_errors("create_script_project", service_type="script")
@require_google_service("script", "script_projects")
async def create_script_project(
Expand Down Expand Up @@ -310,7 +343,15 @@ async def _update_script_content_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="Update Script Content",
annotations=ToolAnnotations(
readOnlyHint=False,
destructiveHint=True,
idempotentHint=False,
openWorldHint=True,
),
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
@handle_http_errors("update_script_content", service_type="script")
@require_google_service("script", "script_projects")
async def update_script_content(
Expand Down Expand Up @@ -381,7 +422,15 @@ async def _run_script_function_impl(
return f"Execution failed\nFunction: {function_name}\nError: {str(e)}"


@server.tool()
@server.tool(
title="Run Script Function",
annotations=ToolAnnotations(
readOnlyHint=False,
destructiveHint=True,
idempotentHint=False,
openWorldHint=True,
),
)
@handle_http_errors("run_script_function", service_type="script")
@require_google_service("script", "script_projects")
async def run_script_function(
Expand Down Expand Up @@ -463,7 +512,15 @@ async def _create_deployment_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="Manage Deployment",
annotations=ToolAnnotations(
readOnlyHint=False,
destructiveHint=True,
idempotentHint=False,
openWorldHint=True,
),
)
@handle_http_errors("manage_deployment", service_type="script")
@require_google_service("script", "script_deployments")
async def manage_deployment(
Expand Down Expand Up @@ -549,7 +606,15 @@ async def _list_deployments_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="List Deployments",
annotations=ToolAnnotations(
readOnlyHint=True,
destructiveHint=False,
idempotentHint=True,
openWorldHint=True,
),
)
@handle_http_errors("list_deployments", is_read_only=True, service_type="script")
@require_google_service("script", "script_deployments_readonly")
async def list_deployments(
Expand Down Expand Up @@ -670,7 +735,15 @@ async def _list_script_processes_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="List Script Processes",
annotations=ToolAnnotations(
readOnlyHint=True,
destructiveHint=False,
idempotentHint=True,
openWorldHint=True,
),
)
@handle_http_errors("list_script_processes", is_read_only=True, service_type="script")
@require_google_service("script", "script_readonly")
async def list_script_processes(
Expand Down Expand Up @@ -718,7 +791,15 @@ async def _delete_script_project_impl(
return f"Deleted Apps Script project: {script_id}"


@server.tool()
@server.tool(
title="Delete Script Project",
annotations=ToolAnnotations(
readOnlyHint=False,
destructiveHint=True,
idempotentHint=False,
openWorldHint=True,
),
)
@handle_http_errors("delete_script_project", is_read_only=False, service_type="drive")
@require_google_service("drive", "drive_full")
async def delete_script_project(
Expand Down Expand Up @@ -779,7 +860,15 @@ async def _list_versions_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="List Versions",
annotations=ToolAnnotations(
readOnlyHint=True,
destructiveHint=False,
idempotentHint=True,
openWorldHint=True,
),
)
@handle_http_errors("list_versions", is_read_only=True, service_type="script")
@require_google_service("script", "script_readonly")
async def list_versions(
Expand Down Expand Up @@ -837,7 +926,15 @@ async def _create_version_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="Create Version",
annotations=ToolAnnotations(
readOnlyHint=False,
destructiveHint=False,
idempotentHint=False,
openWorldHint=True,
),
)
@handle_http_errors("create_version", is_read_only=False, service_type="script")
@require_google_service("script", "script_full")
async def create_version(
Expand Down Expand Up @@ -898,7 +995,15 @@ async def _get_version_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="Get Version",
annotations=ToolAnnotations(
readOnlyHint=True,
destructiveHint=False,
idempotentHint=True,
openWorldHint=True,
),
)
@handle_http_errors("get_version", is_read_only=True, service_type="script")
@require_google_service("script", "script_readonly")
async def get_version(
Expand Down Expand Up @@ -995,7 +1100,15 @@ async def _get_script_metrics_impl(
return "\n".join(output)


@server.tool()
@server.tool(
title="Get Script Metrics",
annotations=ToolAnnotations(
readOnlyHint=True,
destructiveHint=False,
idempotentHint=True,
openWorldHint=True,
),
)
@handle_http_errors("get_script_metrics", is_read_only=True, service_type="script")
@require_google_service("script", "script_readonly")
async def get_script_metrics(
Expand Down Expand Up @@ -1246,7 +1359,15 @@ def _generate_trigger_code_impl(
return "\n".join(instructions) + "\n\n" + code


@server.tool()
@server.tool(
title="Generate Trigger Code",
annotations=ToolAnnotations(
readOnlyHint=True,
destructiveHint=False,
idempotentHint=True,
openWorldHint=False,
),
)
async def generate_trigger_code(
trigger_type: str,
function_name: str,
Expand Down
Loading
Loading