Metadata-Version: 2.4
Name: eai-oauth-proxy
Version: 0.2.0
Summary: Local client for oauth2-proxy session cookies: browser login, HTTP, and an MCP stdio bridge
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: browser-cookie3>=0.20
Requires-Dist: click>=8.1
Requires-Dist: httpx>=0.28
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Provides-Extra: publish
Requires-Dist: twine>=5; extra == "publish"
Requires-Dist: keyring>=24; extra == "publish"
Requires-Dist: keyrings.google-artifactregistry-auth>=0.0.3; extra == "publish"

# eai-oauth-proxy

Local client for apps behind oauth2-proxy. The credential is the `_oauth2_proxy` session cookie. The default browser signs you in; this process reads that cookie and sends it as `Cookie`.

## Install

```bash
uv tool install eai-oauth-proxy
```

## Login

```bash
eai-oauth-proxy login https://testymctestface.staging.extensile.store/
```

Writes `~/.config/eai-oauth-proxy/staging.extensile.store.cookie` (mode `0600`). An existing browser session for that site is saved immediately. Re-running replaces the file.

`mcp-proxy` and `OAuthProxyHTTP` open the browser themselves when the cookie is missing or rejected, then retry once.

## OAuthProxyCookieManager

Opens the default browser and stores the cookie.

```python
from eai_oauth_proxy import OAuthProxyCookieManager

manager = OAuthProxyCookieManager()
path = manager.login("https://testymctestface.staging.extensile.store/")
value = manager.cookie_for("https://testymctestface.staging.extensile.store/api/v1/users/me")
```

`login` returns the file path. `cookie_for` reads the stored value for that host. `path_for` returns the file path when one exists.

## OAuthProxyHTTP

Calls an oauth2-proxy API with the stored cookie. Paths are app paths.

```python
from eai_oauth_proxy import OAuthProxyHTTP

with OAuthProxyHTTP("https://testymctestface.staging.extensile.store") as api:
    response = api.get("/api/v1/users/me")
    response.raise_for_status()
    print(response.json())
```

`request`, `get`, `post`, `put`, `patch`, and `delete` return an `httpx.Response`. Pass a `manager` to share one cookie directory.

## OAuthProxyMCPBridge

Forwards MCP stdio to a Streamable HTTP server. stdout is MCP traffic; logs go to stderr.

```python
from eai_oauth_proxy import OAuthProxyMCPBridge

OAuthProxyMCPBridge("https://testymctestface.staging.extensile.store/mcp").run()
```

The CLI does the same thing:

```bash
eai-oauth-proxy mcp-proxy https://testymctestface.staging.extensile.store/mcp
```

## MCP client

```json
{
  "mcpServers": {
    "testy-mctestface": {
      "command": "eai-oauth-proxy",
      "args": ["mcp-proxy", "https://testymctestface.staging.extensile.store/mcp"]
    }
  }
}
```
