agenza-graph-mcp
v1.6.5
Published
Microsoft Graph MCP Server with LINE confirmation workflow for calendar management
Downloads
6,657
Maintainers
Readme
microsoft-graph-mcp
Microsoft Graph MCP Server with LINE confirmation workflow for calendar management
✨ Features
- 📅 Calendar Management - Create, update, delete Microsoft 365 calendar events
- ✅ LINE Confirmation - Require LINE approval before creating/updating events
- 🔄 Redis Storage - Shared pending events across multiple processes
- 🕐 Availability Check - Check free/busy slots and working hours (9 AM - 5 PM)
- 📧 Email Integration - Send emails via Microsoft Graph
- 🎯 Appointment Tracking - Unique appointment numbers for easy reference
- 🔔 Real-time Notifications - LINE notifications for all event changes
📦 Installation
# Using bun (recommended)
bun add microsoft-graph-mcp
# Using npm
npm install microsoft-graph-mcp
# Using pnpm
pnpm add microsoft-graph-mcp🚀 Quick Start
As MCP Server (Claude Desktop)
Add to your Claude Desktop configuration:
{
"mcpServers": {
"agenza-graph": {
"command": "bunx",
"args": ["microsoft-graph-mcp"],
"env": {
"TENANT_ID": "your-azure-tenant-id",
"CLIENT_ID": "your-azure-client-id",
"CLIENT_SECRET": "your-azure-client-secret",
"USER_PRINCIPAL_NAME": "[email protected]",
"GRAPH_SCOPES": "https://graph.microsoft.com/.default",
"LINE_CHANNEL_ACCESS_TOKEN": "your-line-channel-token",
"LINE_USER_IDS": "user-id-1,user-id-2",
"REDIS_URL": "redis://localhost:6379"
}
}
}
}As Library
import { MCPGraphServer } from 'microsoft-graph-mcp/server';
import { AuthManager } from 'microsoft-graph-mcp/auth';
const auth = new AuthManager(['https://graph.microsoft.com/.default']);
const server = new MCPGraphServer(auth);
await server.start();🔧 Configuration
Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| TENANT_ID | ✅ | Azure AD Tenant ID |
| CLIENT_ID | ✅ | Azure AD Application (Client) ID |
| CLIENT_SECRET | ✅ | Azure AD Client Secret |
| USER_PRINCIPAL_NAME | ✅ | User email (e.g., [email protected]) |
| GRAPH_SCOPES | ✅ | Microsoft Graph scopes (typically https://graph.microsoft.com/.default) |
| LINE_CHANNEL_ACCESS_TOKEN | ✅ | LINE Messaging API channel access token |
| LINE_USER_IDS | ✅ | Comma-separated LINE user IDs for notifications |
| REDIS_URL | ✅ | Redis connection URL (e.g., redis://localhost:6379) |
Azure AD Setup
- Register an application in Azure AD
- Add API permissions:
Calendars.ReadWrite,Mail.Send,User.Read - Create a client secret
- Grant admin consent for your organization
LINE Setup
- Create a LINE Messaging API channel
- Get your channel access token
- Get user IDs by having users add your LINE bot
🛠️ Available Tools
Calendar Tools
get_user_profile- Get Microsoft 365 user profile informationget_calendar_events- Get calendar events for a date rangeget_available_slots- Get available time slots (9 AM - 5 PM, excluding lunch 12-1 PM)check_availability- Check if a specific time slot is availablecreate_event- Create calendar event (requires LINE confirmation)update_event- Update existing event (requires LINE confirmation)delete_event- Delete calendar event (sends LINE notification)
Email Tools
send_email- Send email via Microsoft Graph
📝 Usage Examples
Create Event
// This will send LINE confirmation before creating
await callTool('create_event', {
subject: 'Team Meeting',
start: {
dateTime: '2025-01-20T10:00:00',
timeZone: 'Asia/Bangkok'
},
end: {
dateTime: '2025-01-20T11:00:00',
timeZone: 'Asia/Bangkok'
},
appointment: 'Meeting',
description: 'Quarterly review meeting',
email: '[email protected]'
});Check Availability
const result = await callTool('check_availability', {
start: {
dateTime: '2025-01-20T14:00:00',
timeZone: 'Asia/Bangkok'
},
end: {
dateTime: '2025-01-20T15:00:00',
timeZone: 'Asia/Bangkok'
}
});Get Available Slots
const slots = await callTool('get_available_slots', {
startDateTime: '2025-01-20T00:00:00',
endDateTime: '2025-01-20T23:59:59',
timezone: 'Asia/Bangkok'
});🔄 LINE Confirmation Workflow
- Create/Update Request - MCP server receives request
- Validation - Check time slot availability
- LINE Message - Send confirmation request to configured LINE users
- User Action - User confirms or rejects via LINE
- Execution - If confirmed, event is created/updated in Microsoft 365
- Notification - LINE notification sent with appointment number
🏗️ Architecture
src/
├── handlers/ # Tool handlers
│ ├── user-profile.handler.ts
│ ├── calendar-events.handler.ts
│ ├── available-slots.handler.ts
│ ├── check-availability.handler.ts
│ ├── create-event.handler.ts
│ ├── update-event.handler.ts
│ ├── delete-event.handler.ts
│ └── send-email.handler.ts
├── tools/ # Tool definitions
│ └── definitions.ts
├── types/ # TypeScript types
│ └── tool-args.ts
├── shared/ # Shared services
│ ├── calendar-service.ts
│ └── pending-events-store.ts
├── auth/ # Authentication
│ └── index.ts
├── utils/ # Utilities
│ ├── index.ts
│ ├── calendar-helpers.ts
│ ├── line-notify.ts
│ └── appointment-utils.ts
├── mcp-server.ts # MCP server
└── index.ts # Entry point🧪 Development
# Install dependencies
bun install
# Build
bun run build
# Development mode with auto-reload
bun run dev
# Type check
bun run type-check
# Clean build directory
bun run clean📄 License
MIT © OSD
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
