Skip to content

feat: multi-workspace support via X-Weeek-Token + Claude Desktop compatibility#1

Open
ainurminibaev wants to merge 4 commits intoAlekMel:mainfrom
ainurminibaev:feature/multi-workspace
Open

feat: multi-workspace support via X-Weeek-Token + Claude Desktop compatibility#1
ainurminibaev wants to merge 4 commits intoAlekMel:mainfrom
ainurminibaev:feature/multi-workspace

Conversation

@ainurminibaev
Copy link
Copy Markdown

Summary

  • Multi-workspace support: Single server instance serves multiple Weeek workspaces. Each client passes their own Weeek API token via X-Weeek-Token header — the server uses it per-request instead of the server-level WEEEK_TOKEN env var (which is now optional).
  • Query parameter auth: Added support for ?api_key=...&weeek_token=... URL query parameters, since Claude Desktop's connector UI doesn't support custom headers.
  • Deploy docs: Added deploy/ folder with production-ready docker-compose, nginx HTTPS reverse proxy config template, and comprehensive setup documentation for Claude Code CLI, Claude Desktop (via mcp-remote bridge), and Cursor IDE.

Changes

File What changed
src/config.py WEEEK_TOKEN is now optional (default empty)
src/weeek_client.py Added ContextVar for per-request token override
src/server.py Added WeeekTokenMiddleware, query param support in APIKeyAuthMiddleware
deploy/ docker-compose, nginx template, .env.example, full README

How it works

  1. Client connects to SSE with Authorization: Bearer <MCP_API_KEY> (server access) and X-Weeek-Token: <personal_token> (Weeek API access)
  2. WeeekTokenMiddleware extracts the token and stores it in a ContextVar
  3. WeeekClient._request() picks up the per-request token and overrides the Authorization header for Weeek API calls
  4. Each user gets their own workspace view through the same server instance

Claude Desktop integration

Claude Desktop connector UI only supports URL + OAuth — no custom headers. Workaround using mcp-remote:

{
  "mcpServers": {
    "weeek": {
      "command": "npx",
      "args": [
        "-y", "mcp-remote",
        "https://your-domain.com/sse",
        "--header", "Authorization: Bearer YOUR_MCP_API_KEY",
        "--header", "X-Weeek-Token: YOUR_WEEEK_TOKEN"
      ]
    }
  }
}

Test plan

  • Verified multi-workspace: two different Weeek tokens through one server, each sees their own workspace
  • Verified query param auth: ?api_key=... accepted, wrong key returns 401
  • Verified backwards compatibility: header-based auth still works
  • Health endpoint works without auth
  • Running in production behind nginx HTTPS for 4+ days

🤖 Generated with Claude Code

ainurminibaev and others added 4 commits April 6, 2026 22:54
…auth

- Make WEEEK_TOKEN optional (token comes per-request via header)
- Add WeeekTokenMiddleware for per-request token override using contextvars
- Support query params (api_key, weeek_token) for Claude Desktop connector
- Add deploy/ with docker-compose, nginx HTTPS config, and setup docs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add `streamable-http` as new transport option (alongside stdio and sse)
- Streamable HTTP is more reliable than SSE over reverse proxies —
  each tool call is a single HTTP request/response, no persistent connection
- Preserve base_app lifespan for MCP session manager initialization
- Config: TRANSPORT=streamable-http to enable

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant