Skip to main content

MCP server for Google Chat integration

Project description

gchat-mcp

MCP (Model Context Protocol) server for Google Chat integration. This server provides tools to interact with Google Chat spaces and messages.

Features

  • List all Google Chat spaces you're a member of
  • Retrieve recent messages from any space
  • Search messages by text content

Installation

Using uv

# Create virtual environment
uv venv

# Activate it
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
uv pip install -e ".[dev]"

Or with pip

pip install -e ".[dev]"

Setup

  1. Create a Google Cloud project: https://console.cloud.google.com/

  2. Enable Google Chat API:

    gcloud services enable chat.googleapis.com
    
  3. Create a service account:

    • Go to IAM & Admin > Service Accounts
    • Click "Create Service Account"
    • Give it a name (e.g., "gchat-mcp")
    • Click "Generate Key" and select JSON format
    • Download the JSON file
  4. Place credentials: Put your service account JSON as credentials.json in the project root

  5. Validate credentials:

    make oauth
    # or
    uv run python oauth_setup.py credentials.json
    

Usage

As an MCP Server

# Start the MCP server
uv run python -m src.apps.gchat_mcp.server

Available Tools

list_spaces()

Returns a list of Google Chat spaces the authenticated user is a member of.

Example:

from src.apps.gchat_mcp.server import app

# In MCP context
spaces = await app.call_tool("list_spaces")
print(spaces)
# [{'spaceId': 'abc123', 'name': 'General', 'iconLink': 'https://...'}]

list_messages(space_id, limit=20)

Retrieves recent messages from a specific space.

Arguments:

  • space_id (str): The unique identifier of the space
  • limit (int, optional): Maximum number of messages to retrieve (default: 20)

Example:

messages = await app.call_tool("list_messages", {"space_id": "abc123", "limit": 10})
print(messages)
# [{'messageId': 'msg1', 'text': 'Hello!', 'authorName': 'User1', ...}]

search_messages(space_id, query)

Searches for messages containing specific text in a space.

Arguments:

  • space_id (str): The unique identifier of the space to search in
  • query (str): The text query to search for

Example:

results = await app.call_tool("search_messages", {"space_id": "abc123", "query": "meeting"})
print(results)
# [{'messageId': 'msg1', 'text': 'Meeting at 3pm...', 'authorName': 'User1', ...}]

Project Structure

ai-meetup-demo/
├── pyproject.toml
├── README.md
├── src/
│   ├── config/           # Configuration files
│   │   └── __init__.py
│   ├── apps/
│   │   └── gchat_mcp/    # MCP server application
│   │       ├── __init__.py
│   │       └── server.py
│   └── manage.py         # Entry point
├── credentials.json      # Google Cloud service account (add to .gitignore)
├── oauth_setup.py        # OAuth setup helper script
├── examples/
│   └── example_usage.py  # Usage examples
└── tests/
    └── test_server.py    # Unit tests

Configuration

Service Account

Place your Google Cloud service account JSON as credentials.json in the project root. This file is excluded from git.

Development

# Install dev dependencies
uv pip install -e ".[dev]"

# Run tests
uv run pytest

# Check code quality
uv run ruff check src/
uv run ruff format src/ --check

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gchat_mcp-0.1.0.tar.gz (134.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gchat_mcp-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file gchat_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: gchat_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 134.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for gchat_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b9bb621f2b6eb9ecffb1c59c14c61884fdb7a73635d1719712f52c648038f7a9
MD5 655b732b9a099cbcb596042d892d7862
BLAKE2b-256 0247ca00eca4a0e325ba1b1907f787205f30797897e2bb35cef56f6e76dfa992

See more details on using hashes here.

File details

Details for the file gchat_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gchat_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for gchat_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4036c4daa2be9f738dabbd67e24ce0894a276c417c518539113341538559e33
MD5 a4779a2d652db34fb962b9f4af7be671
BLAKE2b-256 ddd5c35ab447c12e7f1f555ada96c87e3f64bce5679eaf1ea9ce2ec099e3c2a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page