MCP ExplorerExplorer

Mcp Server Graph Api

@MartinM85on 9 months ago
1 MIT
FreeCommunity
AI Systems
#claude-3-7-sonnet#claude-ai#graph-api#mcp#mcp-server#microsoft-graph-api#microsoft-graph-sdk
Model-context-protocol (MCP) server for the Microsoft Graph API in C#

Overview

What is Mcp Server Graph Api

The mcp-server-graph-api is a Model-context-protocol (MCP) server designed for interfacing with the Microsoft Graph API using C#. It facilitates communication between applications and Microsoft Graph services.

Use cases

Use cases for the mcp-server-graph-api include building applications that require user data retrieval, integrating AI functionalities with Microsoft Graph, and developing tools for managing organizational resources through the Microsoft Graph API.

How to use

To use the mcp-server-graph-api, you need to register an Entra ID application, grant necessary permissions like ‘User.Read.All’, and create a client secret. Configure the MCP server by editing the ‘claude_desktop_config.json’ file to include your project folder path and Entra ID application details.

Key features

Key features of the mcp-server-graph-api include support for multiple Microsoft Graph endpoints, customizable configurations for different environments, and the ability to integrate with various MCP clients such as the Claude Desktop app.

Where to use

The mcp-server-graph-api can be used in various fields including enterprise applications, data analysis, and AI-driven solutions that require access to Microsoft Graph services for user and organizational data.

Content

MCP Server for the Microsoft Graph Api

Model-context-protocol (MCP) server for the Microsoft Graph API in C#.

Prerequisites

Entra ID application

Register a new Entra ID application, add and grant at least the User.Read.All application permission and create a new client secret.

You can grant also another permissions, it depends on what you want to ask AI about your tenant through the Microsoft Graph API.

Claude Desktop app

I’m using the Claude Desktop app, but I think you can use any other MCP clients, including GitHub Copilot if they allow to add local MCP server.

MCP server

Open and build the solution.

MCP server configuration

Open the claude_desktop_config.json file. On Windows, the file should be located in %APPDATA%\Claude\ folder.

Add the MCP Server. Under the args section, specify the path to project folder. Don’t forget to set the details about the Entra ID application like tenant id, client id and client secret under the env section.

By default, Microsoft Graph global service is used. You can change it by modifying the NATIONAL_CLOUD environment variable.

Possible values for the NATIONAL_CLOUD are:

{
    "mcpServers": {
        "graphApi": {
            "command": "dotnet",
            "args": [
                "run",
                "--project",
                "path/to/folder/with/console_project",
                "--no-build"
            ],
            "env": {
                "TENANT_ID": "<tenant_id>",
                "CLIENT_ID": "<client_id>",
                "CLIENT_SECRET": "<client_secret>",
                "NATIONAL_CLOUD": "Global"
            }
        }
    }
}

Run MCP server

When you open Claude Desktop app, the MCP server should be automatically discovered and run. You can start new chat.

If Claude Desktop app was already open, you need to close (quit it in system tray) and reopen it.

In case of any issues, you can check logs in %APPDATA%\Claude\logs.

MCP Client

The MCP client allows you to connect the MCP server.

Tools exposed by the MCP server can be invoked either by Claude AI (via Anthropic Claude API) or by any model deployed to Azure OpenAI Service.

You need to set the Anthropic API key in the AnthropicService.GetAnthropicApiKey() method.

private static string GetAnthropicApiKey()
{
    return "<anthropic-api-key>";
}

For Azure OpenAI Service, you need to

  • API key: set either the AZURE_OPENAI_API_KEY environment variable or specify the key in the AzureOpenAIServiceGetOpenAIApiKey() method
  • Azure OpenAI endpoint: set either the AZURE_OPENAI_ENDPOINT environment variable or specify the endpoint in the AzureOpenAIService.GetOpenAIEndpoint() method

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers