workspace-ai
Enables AI assistants to interact with Gmail accounts via MCP, providing tools for listing labels, searching, reading, drafting, and sending emails with OAuth2 authentication.
README
workspace-ai — a reusable AI Integration Platform
An internal, self-hostable version of "ChatGPT Connectors / Claude Integrations." An AI assistant (Claude Code) discovers and calls your tools over MCP; those tools securely access your accounts via OAuth2; a web dashboard lets you watch every layer happen. Gmail is the first provider — the architecture lets new providers (Drive, Slack, GitHub…) plug in without touching the core.
Built as a learning-first, production-quality project: clean architecture, strict typing, full test coverage, and an observability dashboard.
What it does
- Sign in with Google (OAuth2 + OpenID Connect), with refresh tokens encrypted at rest and transparently auto-refreshed.
- Five Gmail tools — list labels, search, read, draft, send — each self-describing via JSON Schema.
- An MCP server so Claude Code (or Claude Desktop) can discover and call those tools on real Gmail.
- A LangGraph agent (
run_gmail_agent) that plans → executes → reflects in a loop for multi-step tasks, powered by a local or cloud Ollama model. - An observability dashboard (Next.js) — system status, the tool registry, OAuth/token state (never secrets), a live event feed, and a React Flow visualizer of the agent's graph.
Architecture
Everything hangs off one Tool Registry (the single source of truth). Providers register tools into it; two independent adapters expose those same tools to two "brains."
flowchart TD
subgraph Clients
CC[Claude Code / Desktop]
DASH[Next.js Dashboard<br/>read-only observability]
end
subgraph Platform
REG[(Tool Registry<br/>single source of truth)]
MCP[MCP Adapter]
AGENT[LangGraph Agent<br/>plan → execute → reflect]
AUTH[Auth: OAuth2/OIDC<br/>JWT · encrypted tokens]
DB[(Database<br/>users · tokens · sessions)]
API[FastAPI backend]
end
subgraph Providers
GMAIL[Gmail provider<br/>5 tools]
end
CC -- MCP/stdio --> MCP
CC -- delegates multi-step --> AGENT
MCP --> REG
AGENT --> REG
GMAIL -- registers tools --> REG
MCP --> AUTH
AGENT --> AUTH
AUTH --> DB
GMAIL -- calls --> GAPI[Gmail API]
AGENT -- LLM calls --> OLLAMA[Ollama<br/>local / cloud]
DASH -- GET /api/* --> API
API --> REG
API --> DB
Dependency rule: core depends on nothing; providers and both adapters
depend on core; the adapters never depend on each other. That one-directional
rule is what makes the platform extensible.
See docs/architecture/ for the full blueprint, request
lifecycles (with sequence diagrams), and per-subsystem design notes.
Tech stack
Backend: Python 3.11 · FastAPI · SQLAlchemy 2.0 + Alembic · Pydantic ·
LangGraph · MCP SDK · Ollama · structlog · uv · ruff · mypy --strict
Frontend: Next.js 16 · React 19 · TypeScript · Tailwind v4 · React Flow
Quick start
uv sync # install Python deps
cp .env.example .env # then fill in Google OAuth creds + secrets
uv run alembic upgrade head # create the database
uv run uvicorn apps.api.main:app --reload # backend at http://localhost:8000
# open http://localhost:8000 → "Connect Gmail" (one-time login)
cd apps/dashboard && npm install && npm run dev # dashboard at http://localhost:3000
Try things without a browser:
uv run python scripts/try_gmail.py # call Gmail tools on your inbox
uv run python scripts/mcp_smoke.py # talk MCP like Claude Code does
OLLAMA_MODEL=llama3.2 uv run python scripts/try_agent.py "list my gmail labels"
The MCP server is registered in .mcp.json; Claude Code launches it
automatically (approve the workspace-ai server when prompted), then you can ask
it to search your Gmail, draft an email, or run_gmail_agent on a multi-step task.
Quality gates
uv run pytest -q # 53 tests
uv run ruff check . # lint
uv run mypy packages config apps # strict type-check
Project layout
| Path | Responsibility |
|---|---|
packages/core/ |
Contracts (Tool, Provider, AuthContext) + ToolRegistry. Depends on nothing. |
packages/auth/ |
OAuth2/OIDC, JWT, sessions, refresh-token encryption, TokenStore. |
packages/database/ |
SQLAlchemy models, Alembic migrations, repositories. |
packages/providers/ |
One folder per integration (gmail/), on a shared BaseProvider/BaseTool. |
packages/mcp_adapter/ |
Exposes the Registry to Claude Code over MCP. |
packages/langgraph_agent/ |
The plan→execute→reflect agent, exposed as one MCP tool. |
packages/observability/ |
Structured logging + event bus + in-memory store. |
apps/api/ |
FastAPI: OAuth routes, auth middleware, dashboard API. |
apps/dashboard/ |
Next.js observability dashboard (read-only). |
docs/ · tests/ · config/ · scripts/ |
Docs, test suite, settings, dev scripts. |
Status
Milestones 0–6 complete — contracts, database, Google login, Gmail tools, the MCP server, the LangGraph agent + visualizer, and the dashboard. All verified end-to-end against real Gmail.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。