Graph API MCP Server
A FastMCP server that provides access to Microsoft Graph API documentation via the Model Context Protocol (MCP). The server runs in Docker and exposes Graph API documentation through a Streamable-HTTP MCP interface.
Features
- FastMCP Server: Implements MCP protocol using FastMCP with Streamable-HTTP transport
- Offline Documentation: Reads from local
graph_docs.jsonlfile for fast, offline access - Search Tools: Provides multiple tools for querying Graph API documentation
- Docker Support: Containerized deployment for easy setup and portability
- Documentation Importer: Script to parse and extract metadata from Microsoft Graph docs
MCP Tools
The server exposes the following tools via MCP:
1. searchDocs
Search documentation by keyword across titles, paths, and content.
Parameters:
- query (string): Search query string
- max_results (int, optional): Maximum number of results (default: 10)
Example:```json
{
"query": "user",
"max_results": 5
}
### 2. `getDocByPath`
Get complete documentation for a specific file path.
**Parameters:**
- `path` (string): File path of the documentation
**Example:**```json
{
"path": "api-reference/v1.0/api/user-get.md"
}
3. getApiSchema
Get JSON schema for a specific API endpoint.
Parameters:
- endpoint (string): API endpoint path (e.g., "/users" or "users")
Example:```json
{
"endpoint": "/users"
}
### 4. `getExamples`
Get code examples for a specific topic or API.
**Parameters:**
- `topic` (string): Topic or API to get examples for
- `language` (string, optional): Filter by programming language
**Example:**```json
{
"topic": "users",
"language": "javascript"
}
Setup
Prerequisites
- Docker and Docker Compose
- Python 3.11+ (for running locally without Docker)
Quick Start with Docker
-
Clone the repository:
bash git clone https://github.com/jacklatrobe/GRAPH_API_MCP.git cd GRAPH_API_MCP -
Build and run with Docker Compose:
bash docker-compose up --build -
The server will be available at:
http://localhost:8000
Local Development
-
Install dependencies:
bash pip install -r requirements.txt -
Run the server:
bash python server.py
Importing Documentation
To import documentation from the Microsoft Graph docs repository:
-
Clone the Microsoft Graph documentation:
bash git clone https://github.com/microsoftgraph/microsoft-graph-docs-contrib.git -
Run the importer script:
bash python import_graph_docs.py microsoft-graph-docs-contrib graph_docs.jsonl -
The script will:
- Parse all markdown files in the repository
- Extract metadata (title, version, HTTP methods, examples, permissions, schema)
- Output a normalized JSONL file
Data Format
The graph_docs.jsonl file contains one JSON object per line with the following structure:```json
{
"path": "api-reference/v1.0/api/user-get.md",
"title": "Get user",
"version": "v1.0",
"http_methods": [
{"method": "GET", "path": "/users/{id}"}
],
"examples": [
{"language": "http", "code": "GET https://graph.microsoft.com/v1.0/users/{id}"}
],
"permissions": ["User.Read", "User.ReadBasic.All"],
"schema": {"@odata.type": "microsoft.graph.user", "id": "string"},
"content": "First 5000 characters of markdown content..."
}
## Architecture```
┌─────────────────────┐
│ MCP Client │
│ (LLM Agent) │
└──────────┬──────────┘
│ MCP Protocol
│ (Streamable-HTTP)
▼
┌─────────────────────┐
│ FastMCP Server │
│ (server.py) │
├─────────────────────┤
│ - searchDocs │
│ - getDocByPath │
│ - getApiSchema │
│ - getExamples │
└──────────┬──────────┘
│ Read
▼
┌─────────────────────┐
│ graph_docs.jsonl │
│ (Documentation DB) │
└─────────────────────┘
Development
Project Structure```
GRAPH_API_MCP/
├── server.py # FastMCP server implementation
├── import_graph_docs.py # Documentation importer script
├── graph_docs.jsonl # Sample documentation data
├── requirements.txt # Python dependencies
├── Dockerfile # Docker image definition
├── docker-compose.yml # Docker Compose configuration
└── README.md # This file
```
Running Tests
The server includes sample data in graph_docs.jsonl. You can test the tools by:
- Starting the server
- Connecting with an MCP client
- Calling the available tools
License
MIT License - See LICENSE file for details
Acknowledgments
- Built with FastMCP
- Documentation from Microsoft Graph API
