gchat-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,47 @@
1
+ # Sensitive files
2
+ credentials.json
3
+ token.json
4
+
5
+ # Python
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+ *.so
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
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # Virtual environments
28
+ .venv/
29
+ env/
30
+ ENV/
31
+
32
+ # IDE
33
+ .idea/
34
+ .vscode/
35
+ *.swp
36
+ *.swo
37
+ *~
38
+
39
+ # OS
40
+ .DS_Store
41
+ Thumbs.db
42
+
43
+ # Project specific
44
+ .env
45
+ .env.local
46
+
47
+ .pytest_cache
@@ -0,0 +1,60 @@
1
+ # gchat-mcp Agent Guide
2
+
3
+ ## Setup & Environment
4
+
5
+ ### Installation (using uv)
6
+ ```bash
7
+ uv venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
8
+ uv pip install -e ".[dev]"
9
+ ```
10
+
11
+ ### OAuth Flow (required first run)
12
+ ```bash
13
+ uv run python -c "from src.apps.gchat_mcp.server import get_chat_client; client = get_chat_client()"
14
+ ```
15
+ This generates `token.json` in project root.
16
+
17
+ ## Commands
18
+
19
+ ### Run server
20
+ ```bash
21
+ uv run python -m src.apps.gchat_mcp.server
22
+ # or
23
+ uv run gchat-mcp
24
+ ```
25
+
26
+ ### Run tests
27
+ ```bash
28
+ uv run pytest
29
+ ```
30
+
31
+ ### Code quality
32
+ ```bash
33
+ uv run ruff check src/
34
+ uv run ruff format src/ --check
35
+ ```
36
+
37
+ ## Architecture
38
+
39
+ - **Package**: `gchat-mcp` (FastMCP-based MCP server)
40
+ - **Entrypoint**: `src/apps/gchat_mcp/server.py`
41
+ - **Tools**: `list_spaces()`, `list_messages(space_id, limit=20)`, `search_messages(space_id, query)`
42
+ - **Auth**: OAuth2 via `credentials.json` (service account) + `token.json` (user tokens)
43
+
44
+ ## Critical Constraints
45
+
46
+ ### Never commit secrets
47
+ - `.gitignore` excludes: `credentials.json`, `token.json`, `.env*`
48
+ - These files contain sensitive Google Cloud credentials
49
+
50
+ ### Token storage location
51
+ OAuth tokens are saved to `token.json` in project root (not inside `src/`)
52
+
53
+ ### Test imports
54
+ Tests add `src` to path via `sys.path.insert(0, str(Path(__file__).parent.parent))`
55
+
56
+ ## Testing Notes
57
+
58
+ - Tests verify module structure and tool registration, not actual Google Chat API calls
59
+ - No fixtures or external service prerequisites for unit tests
60
+ - Test suite is small (~5 tests in `tests/test_server.py`)
@@ -0,0 +1,227 @@
1
+ # GChat MCP Server Setup Guide
2
+
3
+ This guide shows you how to run the GChat MCP server in WSL and connect it to LM Studio on Windows.
4
+
5
+ ## Prerequisites
6
+
7
+ - WSL (Ubuntu) installed on Windows
8
+ - Python environment with `uv` package manager
9
+ - LM Studio installed on Windows
10
+
11
+ ## Project Structure
12
+
13
+ ```
14
+ ai-meetup-demo/
15
+ ├── src/
16
+ │ └── apps/gchat_mcp/
17
+ │ └── server.py # MCP server implementation
18
+ ├── oauth_setup.py # OAuth setup script
19
+ ├── credentials.json # Google Cloud credentials (already exists)
20
+ └── Makefile # Project make targets
21
+ ```
22
+
23
+ ## Step 1: Install Dependencies
24
+
25
+ ```bash
26
+ make install
27
+ ```
28
+
29
+ This installs all development dependencies using `uv`.
30
+
31
+ ## Step 2: Set Up OAuth Credentials
32
+
33
+ Run the OAuth flow to generate credentials:
34
+
35
+ ```bash
36
+ make oauth
37
+ ```
38
+
39
+ Or manually:
40
+
41
+ ```bash
42
+ uv run python oauth_setup.py credentials.json
43
+ ```
44
+
45
+ This creates `credentials.json` with Google Cloud service account credentials.
46
+
47
+ ## Step 3: Create MCP Token
48
+
49
+ Generate the OAuth token for the MCP server:
50
+
51
+ ```bash
52
+ make create-token
53
+ ```
54
+
55
+ Or manually:
56
+
57
+ ```bash
58
+ uv run python -c "from src.apps.gchat_mcp.server import get_chat_client; client = get_chat_client()"
59
+ ```
60
+
61
+ This creates `token.json` in your project root. **Never commit this file.**
62
+
63
+ ## Step 4: Run the MCP Server (WSL)
64
+
65
+ Start the server in WSL:
66
+
67
+ ```bash
68
+ make run-server
69
+ ```
70
+
71
+ Or manually:
72
+
73
+ ```bash
74
+ uv run python -m src.apps.gchat_mcp.server
75
+ ```
76
+
77
+ The server will start on `http://localhost:2390` by default.
78
+
79
+ ## Step 5: Configure LM Studio (Windows)
80
+
81
+ Create or edit the MCP config file at:
82
+
83
+ ```
84
+ %APPDATA%\lm-studio\mcp.json
85
+ ```
86
+
87
+ ### Option A: Using WSL Command (Python Direct)
88
+
89
+ ```json
90
+ {
91
+ "mcpServers": {
92
+ "gchat-mcp": {
93
+ "command": "wsl",
94
+ "args": [
95
+ "-d", "Ubuntu",
96
+ "-e", "python",
97
+ "-m", "src.apps.gchat_mcp.server"
98
+ ]
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ ### Option B: Using Full Path (Recommended)
105
+
106
+ ```json
107
+ {
108
+ "mcpServers": {
109
+ "gchat-mcp": {
110
+ "command": "wsl",
111
+ "args": [
112
+ "-d", "Ubuntu",
113
+ "-e", "cd",
114
+ "-e", "/home/leins275/Projects/its/ai-meetup-demo",
115
+ "-e", "python",
116
+ "-m", "src.apps.gchat_mcp.server"
117
+ ]
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Option C: HTTP Transport (Alternative)
124
+
125
+ If you prefer HTTP transport instead of stdio:
126
+
127
+ ```json
128
+ {
129
+ "mcpServers": {
130
+ "gchat-mcp": {
131
+ "command": "wsl",
132
+ "args": [
133
+ "-d", "Ubuntu",
134
+ "-e", "python",
135
+ "-m", "fastmcp",
136
+ "-m", "src.apps.gchat_mcp.server",
137
+ "--transport=http",
138
+ "--host=0.0.0.0",
139
+ "--port=2390"
140
+ ]
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ ## Step 6: Connect LM Studio to MCP Server
147
+
148
+ 1. Open LM Studio on Windows
149
+ 2. Go to **Settings** → **MCP Servers**
150
+ 3. Add a new server named `gchat-mcp`
151
+ 4. Paste the config from Step 5
152
+ 5. Click **Save** and **Restart** LM Studio
153
+
154
+ ## Available Make Targets
155
+
156
+ | Target | Command | Description |
157
+ |--------|---------|-------------|
158
+ | `install` | `make install` | Install dependencies |
159
+ | `setup` | `make setup` | Full setup (install + oauth) |
160
+ | `oauth` | `make oauth` | Run OAuth flow |
161
+ | `create-token` | `make create-token` | Generate MCP token |
162
+ | `run-server` | `make run-server` | Start MCP server |
163
+ | `run-server-cli` | `make run-server-cli` | Start server with CLI |
164
+ | `run-tests` | `make run-tests` | Run pytest tests |
165
+ | `lint` | `make lint` | Run ruff linter |
166
+ | `format` | `make format` | Check code formatting |
167
+
168
+ ## Troubleshooting
169
+
170
+ ### Server won't start in WSL
171
+
172
+ 1. Ensure you're in the project directory:
173
+ ```bash
174
+ cd /home/leins275/Projects/its/ai-meetup-demo
175
+ ```
176
+
177
+ 2. Activate virtual environment:
178
+ ```bash
179
+ source .venv/bin/activate
180
+ ```
181
+
182
+ 3. Reinstall dependencies:
183
+ ```bash
184
+ make install
185
+ ```
186
+
187
+ ### LM Studio can't connect
188
+
189
+ 1. Check that the server is running in WSL:
190
+ ```bash
191
+ wsl python -m src.apps.gchat_mcp.server &
192
+ ```
193
+
194
+ 2. Verify port 2390 is listening:
195
+ ```bash
196
+ netstat -tlnp | grep 2390
197
+ ```
198
+
199
+ 3. Check LM Studio logs for connection errors
200
+
201
+ ### OAuth token issues
202
+
203
+ 1. Delete existing token and recreate:
204
+ ```bash
205
+ rm token.json
206
+ make create-token
207
+ ```
208
+
209
+ 2. Ensure `credentials.json` exists and is valid
210
+
211
+ ## Security Notes
212
+
213
+ - **Never commit** `token.json`, `credentials.json`, or `.env*` files
214
+ - These files are excluded in `.gitignore`
215
+ - Keep your Google Cloud credentials secure
216
+
217
+ ## Architecture Overview
218
+
219
+ ```
220
+ Windows (LM Studio)
221
+ ↓ [wsl command]
222
+ WSL (Ubuntu)
223
+ ↓ [Python MCP Server]
224
+ Google Chat API
225
+ ```
226
+
227
+ The `wsl` command bridges Windows and WSL, allowing LM Studio to communicate with the Python server running in Ubuntu.
@@ -0,0 +1,27 @@
1
+ .PHONY: install setup run-server run-tests lint format oauth
2
+
3
+ install:
4
+ uv pip install -e ".[dev]"
5
+
6
+ setup: install oauth
7
+
8
+ run-server:
9
+ uv run fastmcp run src/apps/gchat_mcp/server.py --transport http --host 0.0.0.0 --port 2390 &
10
+
11
+ run-server-cli:
12
+ uv run gchat-mcp
13
+
14
+ oauth:
15
+ uv run python oauth_setup.py credentials.json
16
+
17
+ create-token:
18
+ uv run python -c "from src.apps.gchat_mcp.server import get_chat_client; client = get_chat_client()"
19
+
20
+ run-tests:
21
+ uv run pytest
22
+
23
+ lint:
24
+ uv run ruff check src/
25
+
26
+ format:
27
+ uv run ruff format src/ --check
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.4
2
+ Name: gchat-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for Google Chat integration
5
+ Author-email: Your Name <your.email@example.com>
6
+ License: MIT
7
+ Keywords: chatbot,google-chat,mcp
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: fastmcp>=1.0.0
17
+ Requires-Dist: google-apps-chat>=0.10.0
18
+ Requires-Dist: google-auth>=2.0.0
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
21
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
22
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # gchat-mcp
26
+
27
+ MCP (Model Context Protocol) server for Google Chat integration. This server provides tools to interact with Google Chat spaces and messages.
28
+
29
+ ## Features
30
+
31
+ - List all Google Chat spaces you're a member of
32
+ - Retrieve recent messages from any space
33
+ - Search messages by text content
34
+
35
+ ## Installation
36
+
37
+ ### Using uv
38
+
39
+ ```bash
40
+ # Create virtual environment
41
+ uv venv
42
+
43
+ # Activate it
44
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
45
+
46
+ # Install dependencies
47
+ uv pip install -e ".[dev]"
48
+ ```
49
+
50
+ ### Or with pip
51
+
52
+ ```bash
53
+ pip install -e ".[dev]"
54
+ ```
55
+
56
+ ## Setup
57
+
58
+ 1. **Create a Google Cloud project**: [https://console.cloud.google.com/](https://console.cloud.google.com/)
59
+
60
+ 2. **Enable Google Chat API**:
61
+ ```bash
62
+ gcloud services enable chat.googleapis.com
63
+ ```
64
+
65
+ 3. **Create a service account**:
66
+ - Go to IAM & Admin > Service Accounts
67
+ - Click "Create Service Account"
68
+ - Give it a name (e.g., "gchat-mcp")
69
+ - Click "Generate Key" and select JSON format
70
+ - Download the JSON file
71
+
72
+ 4. **Place credentials**: Put your service account JSON as `credentials.json` in the project root
73
+
74
+ 5. **Validate credentials**:
75
+ ```bash
76
+ make oauth
77
+ # or
78
+ uv run python oauth_setup.py credentials.json
79
+ ```
80
+
81
+ ## Usage
82
+
83
+ ### As an MCP Server
84
+
85
+ ```bash
86
+ # Start the MCP server
87
+ uv run python -m src.apps.gchat_mcp.server
88
+ ```
89
+
90
+ ### Available Tools
91
+
92
+ #### `list_spaces()`
93
+
94
+ Returns a list of Google Chat spaces the authenticated user is a member of.
95
+
96
+ **Example:**
97
+ ```python
98
+ from src.apps.gchat_mcp.server import app
99
+
100
+ # In MCP context
101
+ spaces = await app.call_tool("list_spaces")
102
+ print(spaces)
103
+ # [{'spaceId': 'abc123', 'name': 'General', 'iconLink': 'https://...'}]
104
+ ```
105
+
106
+ #### `list_messages(space_id, limit=20)`
107
+
108
+ Retrieves recent messages from a specific space.
109
+
110
+ **Arguments:**
111
+ - `space_id` (str): The unique identifier of the space
112
+ - `limit` (int, optional): Maximum number of messages to retrieve (default: 20)
113
+
114
+ **Example:**
115
+ ```python
116
+ messages = await app.call_tool("list_messages", {"space_id": "abc123", "limit": 10})
117
+ print(messages)
118
+ # [{'messageId': 'msg1', 'text': 'Hello!', 'authorName': 'User1', ...}]
119
+ ```
120
+
121
+ #### `search_messages(space_id, query)`
122
+
123
+ Searches for messages containing specific text in a space.
124
+
125
+ **Arguments:**
126
+ - `space_id` (str): The unique identifier of the space to search in
127
+ - `query` (str): The text query to search for
128
+
129
+ **Example:**
130
+ ```python
131
+ results = await app.call_tool("search_messages", {"space_id": "abc123", "query": "meeting"})
132
+ print(results)
133
+ # [{'messageId': 'msg1', 'text': 'Meeting at 3pm...', 'authorName': 'User1', ...}]
134
+ ```
135
+
136
+ ## Project Structure
137
+
138
+ ```
139
+ ai-meetup-demo/
140
+ ├── pyproject.toml
141
+ ├── README.md
142
+ ├── src/
143
+ │ ├── config/ # Configuration files
144
+ │ │ └── __init__.py
145
+ │ ├── apps/
146
+ │ │ └── gchat_mcp/ # MCP server application
147
+ │ │ ├── __init__.py
148
+ │ │ └── server.py
149
+ │ └── manage.py # Entry point
150
+ ├── credentials.json # Google Cloud service account (add to .gitignore)
151
+ ├── oauth_setup.py # OAuth setup helper script
152
+ ├── examples/
153
+ │ └── example_usage.py # Usage examples
154
+ └── tests/
155
+ └── test_server.py # Unit tests
156
+ ```
157
+
158
+ ## Configuration
159
+
160
+ ### Service Account
161
+
162
+ Place your Google Cloud service account JSON as `credentials.json` in the project root. This file is excluded from git.
163
+
164
+ ## Development
165
+
166
+ ```bash
167
+ # Install dev dependencies
168
+ uv pip install -e ".[dev]"
169
+
170
+ # Run tests
171
+ uv run pytest
172
+
173
+ # Check code quality
174
+ uv run ruff check src/
175
+ uv run ruff format src/ --check
176
+ ```
177
+
178
+ ## License
179
+
180
+ MIT
@@ -0,0 +1,156 @@
1
+ # gchat-mcp
2
+
3
+ MCP (Model Context Protocol) server for Google Chat integration. This server provides tools to interact with Google Chat spaces and messages.
4
+
5
+ ## Features
6
+
7
+ - List all Google Chat spaces you're a member of
8
+ - Retrieve recent messages from any space
9
+ - Search messages by text content
10
+
11
+ ## Installation
12
+
13
+ ### Using uv
14
+
15
+ ```bash
16
+ # Create virtual environment
17
+ uv venv
18
+
19
+ # Activate it
20
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
21
+
22
+ # Install dependencies
23
+ uv pip install -e ".[dev]"
24
+ ```
25
+
26
+ ### Or with pip
27
+
28
+ ```bash
29
+ pip install -e ".[dev]"
30
+ ```
31
+
32
+ ## Setup
33
+
34
+ 1. **Create a Google Cloud project**: [https://console.cloud.google.com/](https://console.cloud.google.com/)
35
+
36
+ 2. **Enable Google Chat API**:
37
+ ```bash
38
+ gcloud services enable chat.googleapis.com
39
+ ```
40
+
41
+ 3. **Create a service account**:
42
+ - Go to IAM & Admin > Service Accounts
43
+ - Click "Create Service Account"
44
+ - Give it a name (e.g., "gchat-mcp")
45
+ - Click "Generate Key" and select JSON format
46
+ - Download the JSON file
47
+
48
+ 4. **Place credentials**: Put your service account JSON as `credentials.json` in the project root
49
+
50
+ 5. **Validate credentials**:
51
+ ```bash
52
+ make oauth
53
+ # or
54
+ uv run python oauth_setup.py credentials.json
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ ### As an MCP Server
60
+
61
+ ```bash
62
+ # Start the MCP server
63
+ uv run python -m src.apps.gchat_mcp.server
64
+ ```
65
+
66
+ ### Available Tools
67
+
68
+ #### `list_spaces()`
69
+
70
+ Returns a list of Google Chat spaces the authenticated user is a member of.
71
+
72
+ **Example:**
73
+ ```python
74
+ from src.apps.gchat_mcp.server import app
75
+
76
+ # In MCP context
77
+ spaces = await app.call_tool("list_spaces")
78
+ print(spaces)
79
+ # [{'spaceId': 'abc123', 'name': 'General', 'iconLink': 'https://...'}]
80
+ ```
81
+
82
+ #### `list_messages(space_id, limit=20)`
83
+
84
+ Retrieves recent messages from a specific space.
85
+
86
+ **Arguments:**
87
+ - `space_id` (str): The unique identifier of the space
88
+ - `limit` (int, optional): Maximum number of messages to retrieve (default: 20)
89
+
90
+ **Example:**
91
+ ```python
92
+ messages = await app.call_tool("list_messages", {"space_id": "abc123", "limit": 10})
93
+ print(messages)
94
+ # [{'messageId': 'msg1', 'text': 'Hello!', 'authorName': 'User1', ...}]
95
+ ```
96
+
97
+ #### `search_messages(space_id, query)`
98
+
99
+ Searches for messages containing specific text in a space.
100
+
101
+ **Arguments:**
102
+ - `space_id` (str): The unique identifier of the space to search in
103
+ - `query` (str): The text query to search for
104
+
105
+ **Example:**
106
+ ```python
107
+ results = await app.call_tool("search_messages", {"space_id": "abc123", "query": "meeting"})
108
+ print(results)
109
+ # [{'messageId': 'msg1', 'text': 'Meeting at 3pm...', 'authorName': 'User1', ...}]
110
+ ```
111
+
112
+ ## Project Structure
113
+
114
+ ```
115
+ ai-meetup-demo/
116
+ ├── pyproject.toml
117
+ ├── README.md
118
+ ├── src/
119
+ │ ├── config/ # Configuration files
120
+ │ │ └── __init__.py
121
+ │ ├── apps/
122
+ │ │ └── gchat_mcp/ # MCP server application
123
+ │ │ ├── __init__.py
124
+ │ │ └── server.py
125
+ │ └── manage.py # Entry point
126
+ ├── credentials.json # Google Cloud service account (add to .gitignore)
127
+ ├── oauth_setup.py # OAuth setup helper script
128
+ ├── examples/
129
+ │ └── example_usage.py # Usage examples
130
+ └── tests/
131
+ └── test_server.py # Unit tests
132
+ ```
133
+
134
+ ## Configuration
135
+
136
+ ### Service Account
137
+
138
+ Place your Google Cloud service account JSON as `credentials.json` in the project root. This file is excluded from git.
139
+
140
+ ## Development
141
+
142
+ ```bash
143
+ # Install dev dependencies
144
+ uv pip install -e ".[dev]"
145
+
146
+ # Run tests
147
+ uv run pytest
148
+
149
+ # Check code quality
150
+ uv run ruff check src/
151
+ uv run ruff format src/ --check
152
+ ```
153
+
154
+ ## License
155
+
156
+ MIT
@@ -0,0 +1,9 @@
1
+ Create a Python MCP server called `gchat-mcp` with these tools:
2
+ - list_spaces() — returns list of Google Chat spaces the user is member of
3
+ - list_messages(space_id, limit=20) — returns recent messages from a space
4
+ - search_messages(space_id, query) — filters messages by text
5
+
6
+ Use `uv` tool for python environment management.
7
+ Use `mcp` Python library (FastMCP), google-apps-chat for API access.
8
+ Auth via OAuth2 with token.json / credentials.json.
9
+ Package it as pypi-ready: pyproject.toml, README.md.