Azure/ofp-ai-bootcamp2025-trtran
If you are the rightful owner of ofp-ai-bootcamp2025-trtran and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project implements a Model Context Protocol (MCP) Server using FastMCP to search for person information via Microsoft Graph API with Azure CLI authentication.
Microsoft WhoIs MCP Server
This project implements a Model Context Protocol (MCP) Server in Python using the FastMCP library. The server exposes tools for searching person information using the Microsoft Graph API with Azure CLI authentication.
Features
- š Person Search: Search for people by name using Microsoft Graph API
- š§ Contact Information: Retrieve email addresses, phone numbers, job titles, and aliases
- š¢ Organization Details: Get company, department, and office location information
- š Azure CLI Authentication: Seamless authentication using Azure CLI credentials
- š”ļø Error Handling: Comprehensive error handling and validation
- š FastMCP Integration: Built with the latest FastMCP library for optimal performance
API Endpoint
The server queries the Microsoft Graph API endpoint:
GET https://graph.microsoft.com/v1.0/users
Installation
Prerequisites
- Python 3.12
- Azure CLI installed and authenticated (
az login
) - Conda (recommended) or pip
Using Conda (Recommended)
-
Clone the repository:
git clone <repository-url> cd ofp-ai-bootcamp2025-trtran
-
Create and activate the conda environment:
conda env create -f environment.yml conda activate mcp_server_env
Using pip
- Install dependencies:
pip install -r requirements.txt
Configuration
Authentication Setup
The server uses Azure CLI authentication. No manual token configuration is required.
-
Install Azure CLI if not already installed:
- Windows: Download from Azure CLI releases
- macOS:
brew install azure-cli
- Linux: Follow Azure CLI installation guide
-
Authenticate with Azure:
az login
-
Verify authentication:
az account show
The server will automatically obtain and cache access tokens using your Azure CLI credentials.
Usage
Running the MCP Server
Method 1: Direct Python execution
python mcp_server.py
Method 2: Using the provided batch script (Windows)
start_server.bat
Testing the Server
Run the test suite to verify everything is working:
python test_server.py
Available Tools
1. search_person
Search for people by name using Microsoft Graph API.
Parameters:
name
(string): The name of the person to search for
Example:
{
"name": "Tri Tran"
}
Response:
{
"results": [
{
"display_name": "Tri Tran",
"email": "trtran@microsoft.com",
"alias": "trtran",
"job_title": "PRINCIPAL SOFTWARE ENGINEER",
"office_location": "STUDIO X/1310",
"phone": "+1 (425) 5382112"
}
],
"count": 1,
"total_count": 1,
"error": null
}
2. Person Information Fields
Each person result includes:
- display_name: Full name as it appears in Microsoft's directory
- email: Primary email address
- alias: Microsoft alias (username without @microsoft.com)
- job_title: Current job title
- office_location: Office location/building information
- phone: Business phone number (if available)
Using with MCP Clients
This server is compatible with any MCP client. Here are some examples:
Claude Desktop (Anthropic)
Add to your Claude Desktop configuration:
{
"mcpServers": {
"microsoft-whois": {
"command": "python",
"args": ["path/to/mcp_server.py"]
}
}
}
Custom Client
import asyncio
from fastmcp import Client
async def search_example():
client = Client("mcp_server.py")
async with client:
result = await client.call_tool("search_person", {"name": "Tri Tran"})
print(result)
asyncio.run(search_example())
Architecture
āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāā
ā MCP Client āāāāāŗā FastMCP Server āāāāāŗā Microsoft Graph ā
ā (Claude, etc.) ā ā (mcp_server) ā ā API + Azure ā
ā ā ā ā ā CLI Credentials ā
āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāā
Project Structure
ofp-ai-bootcamp2025-trtran/
āāā mcp_server.py # Main MCP server implementation
āāā test_server.py # Test suite for the server
āāā start_server.bat # Windows batch script to start server
āāā setup.bat # Windows batch script for setup
āāā requirements.txt # Python dependencies
āāā environment.yml # Conda environment configuration
āāā server_config.json # Server configuration
āāā README.md # This file
āāā LICENSE # License file
Dependencies
- fastmcp: Latest MCP server framework
- httpx: Modern HTTP client for API requests
- azure-identity: Azure authentication library for CLI credentials
Error Handling
The server includes comprehensive error handling for:
- Missing or invalid Azure CLI authentication
- Network timeouts and connectivity issues
- API rate limiting and quota errors
- Invalid input parameters
- Unexpected API responses
Security Considerations
- ļæ½ Uses Azure CLI credentials (no hardcoded tokens)
- š”ļø Input validation prevents injection attacks
- ā° Request timeouts prevent hanging connections
- š Detailed error logging without exposing sensitive information
- š Token caching for efficient authentication
Development
Running Tests
python test_server.py
Code Structure
GraphAPIClient
: Handles Microsoft Graph API interactions with Azure CLI authenticationsearch_person
: Main tool for person search functionality- Token caching mechanism for improved performance
Troubleshooting
Common Issues
-
"No access token available. Run 'az login' to authenticate"
- Run
az login
to authenticate with Azure CLI - Verify authentication with
az account show
- Run
-
"Import 'fastmcp' could not be resolved"
- Install dependencies:
pip install -r requirements.txt
- Install dependencies:
-
"Unauthorized" (401 error)
- Re-authenticate with Azure CLI:
az login
- Ensure you have access to Microsoft Graph API
- Re-authenticate with Azure CLI:
-
"Request timeout"
- Check your internet connection
- Verify Microsoft Graph API endpoint is accessible
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
License
See the file for details.
Support
For issues and questions:
- Check the troubleshooting section above
- Review Microsoft Graph API documentation
- Check FastMCP documentation at gofastmcp.com
- Open an issue in this repository