@bugroger/lokka 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,252 @@
1
+ # Lokka
2
+
3
+ [![npm version](https://badge.fury.io/js/@merill%2Flokka.svg)](https://badge.fury.io/js/@merill%2Flokka)
4
+
5
+ Lokka is a model-context-protocol server for the Microsoft Graph and Azure RM APIs that allows you to query and manage your Azure and Microsoft 365 tenants with AI.
6
+
7
+ <img src="https://github.com/merill/lokka/blob/main/assets/lokka-demo-1.gif?raw=true" alt="Lokka Demo - user create demo" width="500"/>
8
+
9
+ Please see [Lokka.dev](https://lokka.dev) for how to use Lokka with your favorite AI model and chat client.
10
+
11
+ Lokka lets you use Claude Desktop, or any MCP Client, to use natural language to accomplish things in your Azure and Microsoft 365 tenant through the Microsoft APIs.
12
+
13
+ e.g.:
14
+
15
+ - `Create a new security group called 'Sales and HR' with a dynamic rule based on the department attribute.`
16
+ - `Find all the conditional access policies that haven't excluded the emergency access account`
17
+ - `Show me all the Intune device configuration policies assigned to the 'Call center' group`
18
+ - `What was the most expensive service in Azure last month?`
19
+
20
+ ![How does Lokka work?](https://github.com/merill/lokka/blob/main/website/docs/assets/how-does-lokka-mcp-server-work.png?raw=true)
21
+
22
+ ## Authentication Methods
23
+
24
+ Lokka now supports multiple authentication methods to accommodate different deployment scenarios:
25
+
26
+ ### Interactive Auth
27
+
28
+ For user-based authentication with interactive login, you can use the following configuration:
29
+
30
+ This is the simplest config and uses the default Lokka app.
31
+
32
+ ```json
33
+ {
34
+ "mcpServers": {
35
+ "Lokka-Microsoft": {
36
+ "command": "npx",
37
+ "args": ["-y", "@merill/lokka"]
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ #### Interactive auth with custom app
44
+
45
+ If you wish to use a custom Microsoft Entra app, you can create a new app registration in Microsoft Entra and configure it with the following environment variables:
46
+
47
+ ```json
48
+ {
49
+ "mcpServers": {
50
+ "Lokka-Microsoft": {
51
+ "command": "npx",
52
+ "args": ["-y", "@merill/lokka"],
53
+ "env": {
54
+ "TENANT_ID": "<tenant-id>",
55
+ "CLIENT_ID": "<client-id>",
56
+ "USE_INTERACTIVE": "true"
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ ### App-Only Auth
64
+
65
+ Traditional app-only authentication. You can use either certificate (recommended) or client secret authentication with the following configuration.
66
+
67
+ See [Install Guide](https://lokka.dev/docs/install) for more details on how to create an Entra app.
68
+
69
+ #### App-Only Auth with Certificate
70
+
71
+ App only authentication using a PEM-encoded client certificate:
72
+
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "Lokka-Microsoft": {
77
+ "command": "npx",
78
+ "args": ["-y", "@merill/lokka"],
79
+ "env": {
80
+ "TENANT_ID": "<tenant-id>",
81
+ "CLIENT_ID": "<client-id>",
82
+ "CERTIFICATE_PATH": "/path/to/certificate.pem",
83
+ "CERTIFICATE_PASSWORD": "<optional-certificate-password>",
84
+ "USE_CERTIFICATE": "true"
85
+ }
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
91
+ For comfort, in order to convert a PFX client certificate to a PEM-encoded certificate:
92
+
93
+ ```bash
94
+ openssl pkcs12 -in /path/to/cert.pfx -out /path/to/cert.pem -nodes -clcerts
95
+ ```
96
+
97
+ #### #### App-Only Auth with Client Secret
98
+
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "Lokka-Microsoft": {
103
+ "command": "npx",
104
+ "args": ["-y", "@merill/lokka"],
105
+ "env": {
106
+ "TENANT_ID": "<tenant-id>",
107
+ "CLIENT_ID": "<client-id>",
108
+ "CLIENT_SECRET": "<client-secret>"
109
+ }
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ ### Client-Provided Token
116
+
117
+ Token-based authentication where the MCP Client provides access tokens:
118
+
119
+ ```json
120
+ {
121
+ "mcpServers": {
122
+ "Lokka-Microsoft": {
123
+ "command": "npx",
124
+ "args": ["-y", "@merill/lokka"],
125
+ "env": {
126
+ "USE_CLIENT_TOKEN": "true"
127
+ }
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ When using client-provided token mode:
134
+
135
+ 1. Start the MCP server with `USE_CLIENT_TOKEN=true`
136
+ 2. Use the `set-access-token` tool to provide a valid Microsoft Graph access token
137
+ 3. Use the `get-auth-status` tool to verify authentication status
138
+ 4. Refresh tokens as needed using `set-access-token`
139
+
140
+ ## New Tools
141
+
142
+ ### Token Management Tools
143
+
144
+ - **`set-access-token`**: Set or update access tokens for Microsoft Graph authentication
145
+ - **`get-auth-status`**: Check current authentication status and capabilities
146
+ - **`add-graph-permission`**: Request additional Microsoft Graph permission scopes interactively
147
+
148
+ ### Graph API Version Control
149
+
150
+ Lokka now supports controlling the default Microsoft Graph API version used for all requests:
151
+
152
+ - **Default behavior**: Uses `beta` version for access to latest features
153
+ - **Production mode**: Set `USE_GRAPH_BETA=false` to force all requests to use `v1.0` version
154
+ - **Per-request override**: You can still specify `graphApiVersion` parameter in individual requests (unless `USE_GRAPH_BETA=false`)
155
+
156
+ When `USE_GRAPH_BETA=false`, all Graph API calls will use the stable `v1.0` version, even if `beta` is explicitly requested in the `graphApiVersion` parameter.
157
+
158
+ ## Getting started
159
+
160
+ See the docs for more information on how to install and configure Lokka.
161
+
162
+ - [Introduction](https://lokka.dev/)
163
+ - [Install guide](https://lokka.dev/docs/install)
164
+ - [Developer guide](https://lokka.dev/docs/developer-guide)
165
+
166
+ ## Components
167
+
168
+ ### Tools
169
+
170
+ 1. `Lokka-Microsoft`
171
+ - Call Microsoft Graph & Azure APIs. Supports querying Azure and Microsoft 365 tenants. Updates are also supported if permissions are provided.
172
+ - Input:
173
+ - `apiType` (string): Type of Microsoft API to query. Options: 'graph' for Microsoft Graph (Entra) or 'azure' for Azure Resource Management.
174
+ - `path` (string): The Azure or Graph API URL path to call (e.g. '/users', '/groups', '/subscriptions').
175
+ - `method` (string): HTTP method to use (e.g., get, post, put, patch, delete)
176
+ - `apiVersion` (string): Azure Resource Management API version (required for apiType Azure)
177
+ - `subscriptionId` (string): Azure Subscription ID (for Azure Resource Management).
178
+ - `queryParams` (string): Array of query parameters like $filter, $select, etc. All parameters are strings.
179
+ - `body` (JSON): The request body (for POST, PUT, PATCH)
180
+ - Returns: Results from the Azure or Graph API call.
181
+
182
+ 2. `set-access-token` *(New in v0.2.0)*
183
+ - Set or update an access token for Microsoft Graph authentication when using client-provided token mode.
184
+ - Input:
185
+ - `accessToken` (string): The access token obtained from Microsoft Graph authentication
186
+ - `expiresOn` (string, optional): Token expiration time in ISO format
187
+ - Returns: Confirmation of token update
188
+
189
+ 3. `get-auth-status` *(New in v0.2.0)*
190
+ - Check the current authentication status and mode of the MCP Server
191
+ - Returns: Authentication mode, readiness status, and capabilities
192
+
193
+ ### Environment Variables
194
+
195
+ The configuration of the server is done using environment variables. The following environment variables are supported:
196
+
197
+ | Name | Description | Required |
198
+ |------|-------------|----------|
199
+ | `TENANT_ID` | The ID of the Microsoft Entra tenant. | Yes (except for client-provided token mode) |
200
+ | `CLIENT_ID` | The ID of the application registered in Microsoft Entra. | Yes (except for client-provided token mode) |
201
+ | `CLIENT_SECRET` | The client secret of the application registered in Microsoft Entra. | Yes (for client credentials mode only) |
202
+ | `USE_INTERACTIVE` | Set to "true" to enable interactive authentication mode. | No |
203
+ | `USE_CLIENT_TOKEN` | Set to "true" to enable client-provided token authentication mode. | No |
204
+ | `USE_CERTIFICATE` | Set to "true" to enable certificate authentication mode. | No |
205
+ | `CERTIFICATE_PATH` | Path to the PEM-encoded certificate file for certificate authentication. | Yes (for certificate mode only) |
206
+ | `CERTIFICATE_PASSWORD` | Password for the certificate file (if encrypted). | No |
207
+ | `REDIRECT_URI` | Redirect URI for interactive authentication (default: `http://localhost:3200`). | No |
208
+ | `ACCESS_TOKEN` | Initial access token for client-provided token mode. | No |
209
+ | `USE_GRAPH_BETA` | Set to "false" to force all Graph API calls to use v1.0 instead of beta (default: true, allows beta). | No |
210
+
211
+ ## Contributors
212
+
213
+ - Interactive and Token-based Authentication (v0.2.0) - [@darrenjrobinson](https://github.com/darrenjrobinson)
214
+ - Certificate Authentication (v0.2.1) - [@nitzpo](https://github.com/nitzpo)
215
+
216
+ ## Installation
217
+
218
+ To use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your
219
+ `claude_desktop_config.json`:
220
+
221
+ ### Interactive Authentication
222
+
223
+ ```json
224
+ {
225
+ "mcpServers": {
226
+ "Lokka-Microsoft": {
227
+ "command": "npx",
228
+ "args": ["-y", "@merill/lokka"]
229
+ }
230
+ }
231
+ }
232
+ ```
233
+
234
+ ### Client Credentials Authentication
235
+
236
+ ```json
237
+ {
238
+ "mcpServers": {
239
+ "Lokka-Microsoft": {
240
+ "command": "npx",
241
+ "args": ["-y", "@merill/lokka"],
242
+ "env": {
243
+ "TENANT_ID": "<tenant-id>",
244
+ "CLIENT_ID": "<client-id>",
245
+ "CLIENT_SECRET": "<client-secret>"
246
+ }
247
+ }
248
+ }
249
+ }
250
+ ```
251
+
252
+ Make sure to replace `<tenant-id>`, `<client-id>`, and `<client-secret>` with the actual values from your Microsoft Entra application. (See [Install Guide](https://lokka.dev/docs/install) for more details on how to create an Entra app and configure the agent.)