How chy168/google-chat-mcp-server works
Project Type and Purpose
• This is a Python-based full-stack integration tool.
• It provides an MCP (Model Control Protocol) server extension with Google Chat capabilities and a standalone OAuth2 authentication service.
• The MCP server (server.py + google_chat.py) implements FastMCP commands to list spaces and messages.
• The auth server (server_auth.py) implements a FastAPI app to handle Google OAuth2 flows and persist tokens.
Top-Level Components
• Auth Server (FastAPI)
• Entry point: server_auth.py
• OAuth2 flow with Google’s auth endpoints
• Reads credentials.json, writes token.json
• MCP Server (FastMCP)
• Entry point: server.py
• Uses google_chat.py for API calls
• Exposes MCP tools: get_chat_spaces(), get_space_messages()
• Google Chat API (External Service)
• Token Store (Local JSON file: token.json)
• Client (Browser or MCP client issuing commands)
Relationships and Data Flows
a. User opens browser → hits Auth Server (/auth) → redirected to Google OAuth2 page
b. Google returns authorization code → Auth Server exchanges code for tokens → saves tokens in token.json
c. MCP Server reads token.json → google_chat.py uses refresh/access tokens to call Google Chat API
d. Google Chat API returns spaces or messages → MCP Server formats results for the MCP client
Architectural Patterns and Principles
• Separation of concerns: Auth logic isolated in FastAPI service; Chat logic in MCP server.
• Token persistence: Simple local JSON storage module.
• Pluggable commands: FastMCP decorators in server.py register Google Chat tools.
• Configurable via mcp.json for integration into larger MCP deployments.
Key Technologies and Libraries
• FastAPI (Auth Server)
• FastMCP (MCP Server framework)
• google-auth, google-auth-oauthlib (OAuth2 flows)
• requests (HTTP calls to Google APIs)
• Python 3.8+