#!/bin/bash
# Microsoft Graph MCP Server - Installation Script
# This script automates the setup process
set -e # Exit on error
echo "π Microsoft Graph MCP Server - Installation"
echo "============================================="
echo ""
# Check Python version
echo "π Checking Python version..."
if ! command -v python3 &> /dev/null; then
echo "β Python 3 is not installed. Please install Python 3.10 or higher."
exit 1
fi
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1,2)
REQUIRED_VERSION="3.10"
if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" != "$REQUIRED_VERSION" ]; then
echo "β Python $REQUIRED_VERSION or higher is required. You have $PYTHON_VERSION"
exit 1
fi
echo "β
Python $PYTHON_VERSION detected"
echo ""
# Check if uv is installed
echo "π Checking for uv package manager..."
if ! command -v uv &> /dev/null; then
echo "β οΈ uv is not installed. Installing uv..."
if [[ "$OSTYPE" == "darwin"* ]] || [[ "$OSTYPE" == "linux-gnu"* ]]; then
curl -LsSf https://astral.sh/uv/install.sh | sh
else
echo "β Automatic uv installation is not supported on this platform."
echo " Please install uv manually from: https://github.com/astral-sh/uv"
exit 1
fi
else
echo "β
uv is already installed"
fi
echo ""
# Create virtual environment
echo "π¦ Creating virtual environment..."
uv venv
echo "β
Virtual environment created"
echo ""
# Activate virtual environment
echo "π Activating virtual environment..."
source .venv/bin/activate
echo "β
Virtual environment activated"
echo ""
# Install dependencies
echo "π₯ Installing dependencies..."
uv pip install -e .
echo "β
Dependencies installed"
echo ""
# Setup .env file
echo "βοΈ Setting up environment configuration..."
if [ ! -f .env ]; then
if [ -f .env.example ]; then
cp .env.example .env
echo "β
.env file created from template"
echo ""
echo "β οΈ IMPORTANT: Edit the .env file with your Azure credentials:"
echo " - MICROSOFT_TENANT_ID"
echo " - MICROSOFT_CLIENT_ID"
echo " - MICROSOFT_CLIENT_SECRET"
echo ""
echo " You can edit it now or later using:"
echo " nano .env (or your preferred editor)"
echo ""
else
echo "β οΈ .env.example not found. Please create .env manually."
fi
else
echo "βΉοΈ .env file already exists"
fi
echo ""
# Print next steps
echo "β
Installation complete!"
echo ""
echo "π Next Steps:"
echo "============="
echo ""
echo "1. Configure your Azure credentials in .env:"
echo " nano .env"
echo ""
echo "2. Set up Claude Desktop configuration:"
echo " - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json"
echo " - Windows: %APPDATA%\\Claude\\claude_desktop_config.json"
echo ""
echo " Add this configuration (update the path):"
echo ' {'
echo ' "mcpServers": {'
echo ' "microsoft-graph": {'
echo ' "command": "uv",'
echo ' "args": ['
echo ' "--directory",'
echo " \"$(pwd)\","
echo ' "run",'
echo ' "mcp_graph_server.py"'
echo ' ],'
echo ' "env": {'
echo ' "MICROSOFT_TENANT_ID": "your-tenant-id",'
echo ' "MICROSOFT_CLIENT_ID": "your-client-id",'
echo ' "MICROSOFT_CLIENT_SECRET": "your-client-secret"'
echo ' }'
echo ' }'
echo ' }'
echo ' }'
echo ""
echo "3. Restart Claude Desktop"
echo ""
echo "4. Test by asking Claude: 'List all available Microsoft 365 licenses'"
echo ""
echo "π Documentation:"
echo " - QUICKSTART.md - Fast 10-minute setup guide"
echo " - README.md - Complete documentation"
echo " - AZURE_SETUP.md - Azure configuration help"
echo " - EXAMPLES.md - Usage examples"
echo ""
echo "π Happy automating!"