graph-mcp 0.1.0__tar.gz

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.
@@ -0,0 +1,40 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ # Alternatively, you can trigger on push to a specific tag:
7
+ # push:
8
+ # tags:
9
+ # - 'v*'
10
+
11
+ jobs:
12
+ pypi-publish:
13
+ name: Build and publish Python distribution to PyPI
14
+ runs-on: ubuntu-latest
15
+
16
+ # REQUIRED: environment and permissions for Trusted Publishing
17
+ environment:
18
+ name: pypi
19
+ url: https://pypi.org/p/graph-mcp
20
+ permissions:
21
+ id-token: write # IMPORTANT: mandatory for trusted publishing
22
+ contents: read
23
+
24
+ steps:
25
+ - name: Checkout repository
26
+ uses: actions/checkout@v4
27
+
28
+ - name: Set up Python
29
+ uses: actions/setup-python@v5
30
+ with:
31
+ python-version: "3.11"
32
+
33
+ - name: Install build dependencies
34
+ run: python -m pip install --upgrade pip build
35
+
36
+ - name: Build a binary wheel and a source tarball
37
+ run: python -m build
38
+
39
+ - name: Publish package distributions to PyPI
40
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,214 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+
210
+ temp.md
211
+
212
+ # Token persistence
213
+ *.tokens.enc
214
+ .tokens.enc
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 JustStas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: graph-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for Microsoft Teams, Outlook Calendar, and Mail via Microsoft Graph API
5
+ Project-URL: Homepage, https://github.com/JustStas/Graph-MCP
6
+ Project-URL: Repository, https://github.com/JustStas/Graph-MCP.git
7
+ Author: JustStas
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.10
11
+ Requires-Dist: cryptography>=42.0
12
+ Requires-Dist: fastmcp>=2.0
13
+ Requires-Dist: httpx>=0.27
14
+ Requires-Dist: pydantic-settings>=2.0
15
+ Requires-Dist: pydantic>=2.0
16
+ Description-Content-Type: text/markdown
17
+
18
+ # Graph MCP
19
+
20
+ An MCP server that connects Claude to Microsoft Teams, Outlook Calendar, and Mail through the Microsoft Graph API.
21
+
22
+ ## What it does
23
+
24
+ Gives Claude access to 29 tools:
25
+
26
+ | Category | Tools |
27
+ |---|---|
28
+ | **Auth** | Check status, login (browser OAuth), logout |
29
+ | **Chats** | List chats, read/send messages, create chats, list members |
30
+ | **Teams & Channels** | List teams, list channels, read/send messages, list members, read/send replies |
31
+ | **Calendar** | List calendars, list events (with date range), get event details |
32
+ | **Mail** | List emails, read email, search emails, send email, reply to email |
33
+ | **Users** | Search organization directory |
34
+ | **Presence** | Get/set your presence, get another user's presence |
35
+ | **Search** | Search messages across all chats and channels |
36
+
37
+ ## Prerequisites
38
+
39
+ You need an Azure App Registration:
40
+
41
+ 1. Go to [Azure Portal](https://portal.azure.com) > App registrations > New registration
42
+ 2. Set platform to **Mobile and desktop applications**
43
+ 3. Set redirect URI to `http://localhost:3000/auth/callback`
44
+ 4. Mark as **Public client** (no client secret needed)
45
+ 5. Under API permissions, add these **delegated** permissions:
46
+
47
+ - `offline_access`, `openid`, `profile`, `User.Read`
48
+ - `User.ReadBasic.All`
49
+ - `Chat.Read`, `Chat.ReadWrite`, `ChatMessage.Send`
50
+ - `ChannelMessage.Read.All`, `ChannelMessage.Send`
51
+ - `Team.ReadBasic.All`, `Channel.ReadBasic.All`, `ChannelMember.Read.All`
52
+ - `Calendars.Read`
53
+ - `Mail.Read`, `Mail.Send`
54
+ - `Presence.Read`, `Presence.Read.All`, `Presence.ReadWrite`
55
+
56
+ ## Install
57
+
58
+ ```
59
+ pip install graph-mcp
60
+ ```
61
+
62
+ Or from a cloned repo:
63
+
64
+ ```
65
+ pip install -e .
66
+ ```
67
+
68
+ ## Setup
69
+
70
+ ```
71
+ graph-mcp setup
72
+ ```
73
+
74
+ This asks for your Azure Client ID and Tenant ID, then gives you the exact command:
75
+
76
+ ```
77
+ claude mcp add graph -e AZURE_CLIENT_ID=your-id -e AZURE_TENANT_ID=your-tenant -- /path/to/graph-mcp
78
+ ```
79
+
80
+ Paste it, start Claude Code, and ask Claude to log in. It opens your browser for OAuth sign-in — that's it.
81
+
82
+ ## How it works
83
+
84
+ ```
85
+ Claude Code ──stdio──> graph-mcp ──HTTPS──> Microsoft Graph API
86
+
87
+ ~/.graph-mcp/
88
+ tokens.enc (encrypted)
89
+ .key (auto-generated)
90
+ ```
91
+
92
+ - **Auth**: OAuth2 Authorization Code flow with PKCE. Login opens your browser, a local callback server captures the token. No secrets stored in config.
93
+ - **Token persistence**: Tokens are encrypted with Fernet and stored in `~/.graph-mcp/tokens.enc`. The encryption key is auto-generated on first use. Logins survive server restarts.
94
+ - **Token refresh**: Access tokens are refreshed automatically before they expire. You only need to log in again if the refresh token itself expires.
95
+ - **Rate limiting**: Sliding window counter with exponential backoff. Respects `Retry-After` headers on 429 responses.
96
+
97
+ ## Configuration
98
+
99
+ All configuration is passed via environment variables (set in the MCP config's `env` block):
100
+
101
+ | Variable | Required | Default | Description |
102
+ |---|---|---|---|
103
+ | `AZURE_CLIENT_ID` | Yes | — | From your Azure App Registration |
104
+ | `AZURE_TENANT_ID` | No | `common` | Your Azure tenant ID, or `common` for multi-tenant |
105
+ | `GRAPH_REDIRECT_URI` | No | `http://localhost:3000/auth/callback` | Must match Azure app registration |
106
+ | `GRAPH_TOKEN_ENCRYPTION_KEY` | No | auto-generated | Fernet key for token encryption |
107
+ | `GRAPH_DEBUG` | No | `false` | Enable verbose logging |
108
+
109
+ ## Troubleshooting
110
+
111
+ **"Approval required" error during login**
112
+ Your Azure app is requesting scopes that aren't registered or need admin consent. Check the API permissions in the Azure portal match the list above.
113
+
114
+ **403 Forbidden on specific tools**
115
+ The endpoint needs a permission that's not in your Azure app registration, or requires admin consent.
116
+
117
+ **Login works but tools say "not authenticated"**
118
+ Restart the MCP server (`claude mcp restart graph`) — it may be running an old version.
119
+
120
+ ## Disclaimer
121
+
122
+ This project is an independent open-source effort and is **not affiliated with, endorsed by, or sponsored by Microsoft Corporation**. Microsoft, Microsoft Teams, Outlook, Microsoft 365, Microsoft Graph, and Azure are trademarks of the Microsoft group of companies.
123
+
124
+ This software is provided "as is", without warranty of any kind. Use it at your own risk. The authors accept no liability for any damages, data loss, or security issues arising from the use of this software. You are responsible for complying with your organization's policies and Microsoft's [API Terms of Use](https://learn.microsoft.com/en-us/legal/microsoft-apis/terms-of-use) when using this tool.
125
+
126
+ This software accesses Microsoft services on your behalf using your own credentials and Azure app registration. Data retrieved from Microsoft Graph (emails, messages, calendar events, etc.) is passed to the LLM that invoked the tool. Be mindful of your organization's data handling policies when using this with cloud-hosted AI models.
127
+
128
+ ## License
129
+
130
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,113 @@
1
+ # Graph MCP
2
+
3
+ An MCP server that connects Claude to Microsoft Teams, Outlook Calendar, and Mail through the Microsoft Graph API.
4
+
5
+ ## What it does
6
+
7
+ Gives Claude access to 29 tools:
8
+
9
+ | Category | Tools |
10
+ |---|---|
11
+ | **Auth** | Check status, login (browser OAuth), logout |
12
+ | **Chats** | List chats, read/send messages, create chats, list members |
13
+ | **Teams & Channels** | List teams, list channels, read/send messages, list members, read/send replies |
14
+ | **Calendar** | List calendars, list events (with date range), get event details |
15
+ | **Mail** | List emails, read email, search emails, send email, reply to email |
16
+ | **Users** | Search organization directory |
17
+ | **Presence** | Get/set your presence, get another user's presence |
18
+ | **Search** | Search messages across all chats and channels |
19
+
20
+ ## Prerequisites
21
+
22
+ You need an Azure App Registration:
23
+
24
+ 1. Go to [Azure Portal](https://portal.azure.com) > App registrations > New registration
25
+ 2. Set platform to **Mobile and desktop applications**
26
+ 3. Set redirect URI to `http://localhost:3000/auth/callback`
27
+ 4. Mark as **Public client** (no client secret needed)
28
+ 5. Under API permissions, add these **delegated** permissions:
29
+
30
+ - `offline_access`, `openid`, `profile`, `User.Read`
31
+ - `User.ReadBasic.All`
32
+ - `Chat.Read`, `Chat.ReadWrite`, `ChatMessage.Send`
33
+ - `ChannelMessage.Read.All`, `ChannelMessage.Send`
34
+ - `Team.ReadBasic.All`, `Channel.ReadBasic.All`, `ChannelMember.Read.All`
35
+ - `Calendars.Read`
36
+ - `Mail.Read`, `Mail.Send`
37
+ - `Presence.Read`, `Presence.Read.All`, `Presence.ReadWrite`
38
+
39
+ ## Install
40
+
41
+ ```
42
+ pip install graph-mcp
43
+ ```
44
+
45
+ Or from a cloned repo:
46
+
47
+ ```
48
+ pip install -e .
49
+ ```
50
+
51
+ ## Setup
52
+
53
+ ```
54
+ graph-mcp setup
55
+ ```
56
+
57
+ This asks for your Azure Client ID and Tenant ID, then gives you the exact command:
58
+
59
+ ```
60
+ claude mcp add graph -e AZURE_CLIENT_ID=your-id -e AZURE_TENANT_ID=your-tenant -- /path/to/graph-mcp
61
+ ```
62
+
63
+ Paste it, start Claude Code, and ask Claude to log in. It opens your browser for OAuth sign-in — that's it.
64
+
65
+ ## How it works
66
+
67
+ ```
68
+ Claude Code ──stdio──> graph-mcp ──HTTPS──> Microsoft Graph API
69
+
70
+ ~/.graph-mcp/
71
+ tokens.enc (encrypted)
72
+ .key (auto-generated)
73
+ ```
74
+
75
+ - **Auth**: OAuth2 Authorization Code flow with PKCE. Login opens your browser, a local callback server captures the token. No secrets stored in config.
76
+ - **Token persistence**: Tokens are encrypted with Fernet and stored in `~/.graph-mcp/tokens.enc`. The encryption key is auto-generated on first use. Logins survive server restarts.
77
+ - **Token refresh**: Access tokens are refreshed automatically before they expire. You only need to log in again if the refresh token itself expires.
78
+ - **Rate limiting**: Sliding window counter with exponential backoff. Respects `Retry-After` headers on 429 responses.
79
+
80
+ ## Configuration
81
+
82
+ All configuration is passed via environment variables (set in the MCP config's `env` block):
83
+
84
+ | Variable | Required | Default | Description |
85
+ |---|---|---|---|
86
+ | `AZURE_CLIENT_ID` | Yes | — | From your Azure App Registration |
87
+ | `AZURE_TENANT_ID` | No | `common` | Your Azure tenant ID, or `common` for multi-tenant |
88
+ | `GRAPH_REDIRECT_URI` | No | `http://localhost:3000/auth/callback` | Must match Azure app registration |
89
+ | `GRAPH_TOKEN_ENCRYPTION_KEY` | No | auto-generated | Fernet key for token encryption |
90
+ | `GRAPH_DEBUG` | No | `false` | Enable verbose logging |
91
+
92
+ ## Troubleshooting
93
+
94
+ **"Approval required" error during login**
95
+ Your Azure app is requesting scopes that aren't registered or need admin consent. Check the API permissions in the Azure portal match the list above.
96
+
97
+ **403 Forbidden on specific tools**
98
+ The endpoint needs a permission that's not in your Azure app registration, or requires admin consent.
99
+
100
+ **Login works but tools say "not authenticated"**
101
+ Restart the MCP server (`claude mcp restart graph`) — it may be running an old version.
102
+
103
+ ## Disclaimer
104
+
105
+ This project is an independent open-source effort and is **not affiliated with, endorsed by, or sponsored by Microsoft Corporation**. Microsoft, Microsoft Teams, Outlook, Microsoft 365, Microsoft Graph, and Azure are trademarks of the Microsoft group of companies.
106
+
107
+ This software is provided "as is", without warranty of any kind. Use it at your own risk. The authors accept no liability for any damages, data loss, or security issues arising from the use of this software. You are responsible for complying with your organization's policies and Microsoft's [API Terms of Use](https://learn.microsoft.com/en-us/legal/microsoft-apis/terms-of-use) when using this tool.
108
+
109
+ This software accesses Microsoft services on your behalf using your own credentials and Azure app registration. Data retrieved from Microsoft Graph (emails, messages, calendar events, etc.) is passed to the LLM that invoked the tool. Be mindful of your organization's data handling policies when using this with cloud-hosted AI models.
110
+
111
+ ## License
112
+
113
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "graph-mcp"
7
+ version = "0.1.0"
8
+ description = "MCP server for Microsoft Teams, Outlook Calendar, and Mail via Microsoft Graph API"
9
+ readme = "README.md"
10
+ authors = [
11
+ { name = "JustStas" }
12
+ ]
13
+ license = "MIT"
14
+ requires-python = ">=3.10"
15
+
16
+ dependencies = [
17
+ "fastmcp>=2.0",
18
+ "httpx>=0.27",
19
+ "pydantic>=2.0",
20
+ "pydantic-settings>=2.0",
21
+ "cryptography>=42.0",
22
+ ]
23
+
24
+ [project.scripts]
25
+ graph-mcp = "graph_mcp:main"
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/JustStas/Graph-MCP"
29
+ Repository = "https://github.com/JustStas/Graph-MCP.git"
@@ -0,0 +1,3 @@
1
+ from graph_mcp.server import main
2
+
3
+ __all__ = ["main"]
@@ -0,0 +1,3 @@
1
+ from graph_mcp.server import main
2
+
3
+ main()
@@ -0,0 +1,20 @@
1
+ """$select field constants for Graph API resource types."""
2
+
3
+ EVENT_LIST_FIELDS = (
4
+ "id,subject,start,end,location,organizer,attendees,isAllDay,"
5
+ "isCancelled,showAs,isOnlineMeeting,onlineMeeting,categories,"
6
+ "responseStatus,bodyPreview,recurrence,type"
7
+ )
8
+
9
+ CHAT_FIELDS = "id,chatType,topic,createdDateTime,lastUpdatedDateTime"
10
+
11
+ TEAM_FIELDS = "id,displayName,description"
12
+
13
+ CHANNEL_FIELDS = "id,displayName,description,membershipType"
14
+
15
+ MAIL_LIST_FIELDS = (
16
+ "id,subject,from,toRecipients,receivedDateTime,bodyPreview,"
17
+ "isRead,hasAttachments,importance,flag"
18
+ )
19
+
20
+ USER_PROFILE_FIELDS = "id,displayName,mail,jobTitle,department,officeLocation"