Lokka (Microsoft Graph) MCP server

Provides a bridge between Microsoft Graph API and natural language interaction, enabling conversational management of Microsoft 365 tenants without complex API calls.
Back to servers
Setup instructions
Provider
Merill Fernando
Release date
Mar 15, 2025
Language
TypeScript
Package
Stats
4.8K downloads
170 stars

Lokka is a model-context-protocol server that enables you to manage Microsoft 365 and Azure resources using natural language through AI assistants. It acts as a bridge between AI models and Microsoft APIs, allowing you to perform tasks like creating security groups, finding conditional access policies, or analyzing Azure costs with simple English commands.

Installation Options

Interactive Authentication

The simplest way to install Lokka is with interactive authentication, which uses the default Lokka app:

{
  "mcpServers": {
    "Lokka-Microsoft": {
      "command": "npx",
      "args": ["-y", "@merill/lokka"]
    }
  }
}

Using a Custom Microsoft Entra App

If you prefer to use your own app registration:

{
  "mcpServers": {
    "Lokka-Microsoft": {
      "command": "npx",
      "args": ["-y", "@merill/lokka"],
      "env": {
        "TENANT_ID": "<tenant-id>",
        "CLIENT_ID": "<client-id>",
        "USE_INTERACTIVE": "true"
      }
    }
  }
}

App-Only Authentication with Certificate

For more secure deployments, certificate-based authentication is recommended:

{
  "mcpServers": {
    "Lokka-Microsoft": {
      "command": "npx",
      "args": ["-y", "@merill/lokka"],
      "env": {
        "TENANT_ID": "<tenant-id>",
        "CLIENT_ID": "<client-id>",
        "CERTIFICATE_PATH": "/path/to/certificate.pem",
        "CERTIFICATE_PASSWORD": "<optional-certificate-password>",
        "USE_CERTIFICATE": "true"
      }
    }
  }
}

To convert a PFX certificate to PEM format:

openssl pkcs12 -in /path/to/cert.pfx -out /path/to/cert.pem -nodes -clcerts

App-Only Authentication with Client Secret

{
  "mcpServers": {
    "Lokka-Microsoft": {
      "command": "npx",
      "args": ["-y", "@merill/lokka"],
      "env": {
        "TENANT_ID": "<tenant-id>",
        "CLIENT_ID": "<client-id>",
        "CLIENT_SECRET": "<client-secret>"
      }
    }
  }
}

Client-Provided Token Authentication

{
  "mcpServers": {
    "Lokka-Microsoft": {
      "command": "npx",
      "args": ["-y", "@merill/lokka"],
      "env": {
        "USE_CLIENT_TOKEN": "true"
      }
    }
  }
}

Using Lokka

Available Tools

Lokka-Microsoft

The main tool for interacting with Microsoft APIs. Examples of what you can ask:

  • "Create a new security group called 'Sales and HR' with a dynamic rule based on the department attribute."
  • "Find all the conditional access policies that haven't excluded the emergency access account"
  • "Show me all the Intune device configuration policies assigned to the 'Call center' group"
  • "What was the most expensive service in Azure last month?"

Token Management Tools

  • set-access-token: Updates access tokens when using client-provided token mode
  • get-auth-status: Checks current authentication status and capabilities
  • add-graph-permission: Requests additional Microsoft Graph permission scopes interactively

Graph API Version Control

You can control which version of the Microsoft Graph API is used:

  • By default, Lokka uses the beta version for access to the latest features
  • Set USE_GRAPH_BETA=false to force all requests to use the stable v1.0 version
  • You can specify graphApiVersion parameter in individual requests (unless USE_GRAPH_BETA=false)

Configuration Options

Lokka supports various environment variables for configuration:

Variable Purpose Required
TENANT_ID Microsoft Entra tenant ID Yes (except for client token mode)
CLIENT_ID Microsoft Entra application ID Yes (except for client token mode)
CLIENT_SECRET Application client secret For client credentials mode only
USE_INTERACTIVE Enable interactive login No
USE_CLIENT_TOKEN Enable client-provided token mode No
USE_CERTIFICATE Enable certificate authentication No
CERTIFICATE_PATH Path to PEM certificate file For certificate mode only
CERTIFICATE_PASSWORD Certificate password (if encrypted) No
REDIRECT_URI Custom redirect URI (default: http://localhost:3200) No
USE_GRAPH_BETA Force Graph API version (default: true) No

For more detailed information, visit Lokka.dev.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "Lokka-Microsoft" '{"command":"npx","args":["-y","@merill/lokka"],"env":{"TENANT_ID":"<tenant-id>","CLIENT_ID":"<client-id>","CLIENT_SECRET":"<client-secret>"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "Lokka-Microsoft": {
            "command": "npx",
            "args": [
                "-y",
                "@merill/lokka"
            ],
            "env": {
                "TENANT_ID": "<tenant-id>",
                "CLIENT_ID": "<client-id>",
                "CLIENT_SECRET": "<client-secret>"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "Lokka-Microsoft": {
            "command": "npx",
            "args": [
                "-y",
                "@merill/lokka"
            ],
            "env": {
                "TENANT_ID": "<tenant-id>",
                "CLIENT_ID": "<client-id>",
                "CLIENT_SECRET": "<client-secret>"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later