Get the FREE Ultimate OpenClaw Setup Guide →

threat-model-for-stateful-auth-for s

Attacking an MCP server to demonstrate the need of stateful auth.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio sirkanaad26-threat-model-for-stateful-auth-for-mcp-servers python mcp_server.py \
  --env GOOGLE_APPLICATION_CREDENTIALS="path/to/credentials.json"

How to use

This MCP server provides a JSON-RPC 2.0 interface that integrates Gmail and Google Calendar. It offers tools to read recent emails, and to create, update, delete, and fetch calendar events. The service authenticates with Google using OAuth 2.0 and retains credentials for session persistence. You can invoke read_emails to fetch messages, then use create_calendar_event, update_calendar_event, delete_calendar_event, and get_calendar_events to manage your calendar based on the input data. Be mindful that the server’s design assumes trust in the AI model consuming the Gmail content before issuing calendar modifications.

To use the API tools, establish a JSON-RPC connection to the server, send requests with the appropriate method names, and supply the required parameters. For example, read_emails with optional max_results and query, create_calendar_event with summary, start_time, end_time, and an optional description, or delete_calendar_event with an event_id. The server returns structured objects representing emails or calendar events, enabling you to workflow automations or model-driven calendar management.

How to install

Prerequisites:

  • Python 3.8+
  • Google Cloud project with Gmail and Google Calendar APIs enabled
  • OAuth 2.0 credentials (credentials.json) in the project root

Installation steps:

  1. Clone the repository and navigate to the project directory:
git clone <repository-url>
cd Threat-model-for-Stateful-Auth
  1. Create a virtual environment (optional but recommended) and activate it:
python -m venv venv
# On Windows
venv\Scripts\activate.bat
# On macOS/Linux
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Place credentials in the project root:
  • Download credentials.json from Google Cloud Console and place as credentials.json in the project root.
  1. Run the server:
python mcp_server.py

Notes:

  • Ensure Gmail and Calendar APIs are enabled in the Google Cloud Console and that OAuth credentials are configured for a desktop application.

Additional notes

Tips and caveats:

  • The server reads Gmail content and passes it to the connected AI model. If the model is trusted to modify the calendar, ensure the overall workflow includes safeguards or validation steps.
  • The scope configuration used by the server includes https://www.googleapis.com/auth/gmail.readonly and https://www.googleapis.com/auth/calendar. Be aware of the security implications of granting full calendar access.
  • If you encounter authentication issues, verify credentials.json exists in the project root and that you have successfully completed the OAuth flow to generate a token. You may need to delete token.pickle and re-authenticate.
  • When debugging prompt-injection concerns, consider implementing content sanitization boundaries or isolating read data from action commands before handing data to the model.
  • Review and audit calendar changes via logs or audit history to detect suspicious activity.

Related MCP Servers

Sponsor this space

Reach thousands of developers