Skip to content

Commit 75eaf48

Browse files
committed
fix pre-commit issues
Signed-off-by: Jesse Sanford <108698+jessesanford@users.noreply.github.com>
1 parent 7b0e378 commit 75eaf48

File tree

3 files changed

+30
-39
lines changed

3 files changed

+30
-39
lines changed

examples/servers/proxy-auth/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ The servers can be configured using either:
2020
2. **Environment variables** (loaded from `.env` file when present)
2121

2222
Example `.env` file:
23-
```
23+
24+
```env
2425
# Auth Server Configuration
2526
AUTH_SERVER_HOST=localhost
2627
AUTH_SERVER_PORT=9000
@@ -58,6 +59,7 @@ uv run mcp-proxy-auth-as
5859
```
5960

6061
**What it provides:**
62+
6163
- OAuth 2.0 flows (authorization, token exchange)
6264
- Token introspection endpoint for Resource Servers (`/introspect`)
6365
- Client registration endpoint (`/register`)
@@ -87,9 +89,13 @@ uv run mcp-proxy-auth-combo
8789
## How It Works
8890

8991
The proxy OAuth server acts as a transparent proxy between:
92+
9093
1. Client applications requesting OAuth tokens
9194
2. Upstream OAuth providers (like GitHub, Google, etc.)
9295

9396
This allows MCP servers to leverage existing OAuth providers without implementing their own authentication systems.
9497

95-
The server code is organized in the `proxy_auth` package for better modularity.
98+
The server code is organized in the `proxy_auth` package for better modularity.
99+
100+
```text
101+
```

examples/servers/proxy-auth/proxy_auth/__init__.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
__version__ = "0.1.0"
44

55
# Import key components for easier access
6-
<<<<<<< HEAD
76
from .auth_server import auth_server as auth_server
87
from .auth_server import main as auth_server_main
98
from .combo_server import combo_server as combo_server
@@ -16,20 +15,6 @@
1615
"auth_server",
1716
"resource_server",
1817
"combo_server",
19-
=======
20-
from .auth_server import main as auth_server_main
21-
from .auth_server import run_server as run_auth_server
22-
from .combo_server import main as combo_server_main
23-
from .combo_server import mcp as proxy_server
24-
from .resource_server import main as resource_server_main
25-
from .resource_server import mcp as resource_server
26-
from .token_verifier import IntrospectionTokenVerifier
27-
28-
__all__ = [
29-
"run_auth_server",
30-
"resource_server",
31-
"proxy_server",
32-
>>>>>>> 37d81fe (renamed to proxy-oauth)
3318
"IntrospectionTokenVerifier",
3419
"auth_server_main",
3520
"resource_server_main",

examples/servers/proxy-auth/tests/test_proxy_oauth_endpoints.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,29 @@
2626
@pytest.fixture
2727
def proxy_server(monkeypatch):
2828
"""Import the proxy OAuth demo server with safe environment + stubs."""
29+
2930
import os
3031

3132
# Avoid real outbound calls by pretending the upstream endpoints were
3233
# supplied explicitly via env vars – this makes `fetch_upstream_metadata`
3334
# construct metadata locally instead of performing an HTTP GET.
34-
os.environ.setdefault("UPSTREAM_AUTHORIZATION_ENDPOINT", "https://upstream.example.com/authorize")
35-
os.environ.setdefault("UPSTREAM_TOKEN_ENDPOINT", "https://upstream.example.com/token")
35+
os.environ.setdefault(
36+
"UPSTREAM_AUTHORIZATION_ENDPOINT", "https://upstream.example.com/authorize"
37+
)
38+
os.environ.setdefault(
39+
"UPSTREAM_TOKEN_ENDPOINT", "https://upstream.example.com/token"
40+
)
3641
os.environ.setdefault("UPSTREAM_JWKS_URI", "https://upstream.example.com/jwks")
3742
os.environ.setdefault("UPSTREAM_CLIENT_ID", "client123")
3843
os.environ.setdefault("UPSTREAM_CLIENT_SECRET", "secret123")
3944

4045
# Deferred import so the env vars above are in effect.
41-
from proxy_auth import combo_server as proxy_server_module
42-
4346
# Stub library-level fetch_upstream_metadata to avoid network I/O.
4447
from mcp.server.auth.proxy import routes as proxy_routes
4548

46-
<<<<<<< HEAD
47-
=======
4849
# Import the module and the combo_server instance
4950
from proxy_auth import combo_server
5051

51-
>>>>>>> fbb3cb4 (fix imports)
5252
async def _fake_metadata() -> dict[str, Any]: # noqa: D401
5353
# Access module-level constants directly
5454
return {
@@ -59,17 +59,12 @@ async def _fake_metadata() -> dict[str, Any]: # noqa: D401
5959
"jwks_uri": "",
6060
}
6161

62-
<<<<<<< HEAD
63-
monkeypatch.setattr(proxy_routes, "fetch_upstream_metadata", _fake_metadata, raising=True)
64-
return proxy_server_module
65-
=======
6662
monkeypatch.setattr(
6763
proxy_routes, "fetch_upstream_metadata", _fake_metadata, raising=True
6864
)
6965

7066
# Return the combo_server instance
7167
return combo_server
72-
>>>>>>> fbb3cb4 (fix imports)
7368

7469

7570
@pytest.fixture
@@ -81,7 +76,9 @@ def app(proxy_server):
8176
@pytest.fixture
8277
async def client(app) -> AsyncGenerator[httpx.AsyncClient, None]:
8378
"""Async HTTP client bound to the in-memory ASGI application."""
84-
async with httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url="http://testserver") as c:
79+
async with httpx.AsyncClient(
80+
transport=httpx.ASGITransport(app=app), base_url="http://testserver"
81+
) as c:
8582
yield c
8683

8784

@@ -129,11 +126,7 @@ async def test_authorize_redirect(client):
129126
location = r.headers["location"]
130127
parsed = urllib.parse.urlparse(location)
131128
assert parsed.scheme.startswith("http")
132-
<<<<<<< HEAD
133-
assert parsed.netloc == urllib.parse.urlparse(proxy_server.UPSTREAM_AUTHORIZE).netloc
134-
=======
135129
assert parsed.netloc == urllib.parse.urlparse(UPSTREAM_AUTHORIZE).netloc
136-
>>>>>>> fbb3cb4 (fix imports)
137130

138131
qs = urllib.parse.parse_qs(parsed.query)
139132
# Proxy should inject client_id & default scope
@@ -150,7 +143,8 @@ async def test_revoke_proxy(client, monkeypatch):
150143
async def _mock_post(self, url, data=None, timeout=10, **kwargs): # noqa: D401
151144
if url.endswith("/revoke"):
152145
return httpx.Response(200, json={"revoked": True})
153-
# For the test client's own request to /revoke, delegate to original implementation
146+
# For the test client's own request to /revoke,
147+
# delegate to original implementation
154148
return await original_post(self, url, data=data, timeout=timeout, **kwargs)
155149

156150
monkeypatch.setattr(httpx.AsyncClient, "post", _mock_post, raising=True)
@@ -231,9 +225,13 @@ async def test_user_info_tool(monkeypatch, proxy_server):
231225
from mcp.server.auth.provider import AccessToken # local import to avoid cycles
232226

233227
def _fake_get_access_token(): # noqa: D401
234-
return AccessToken(token=dummy_token, client_id="client123", scopes=["openid"], expires_at=None)
228+
return AccessToken(
229+
token=dummy_token, client_id="client123", scopes=["openid"], expires_at=None
230+
)
235231

236-
monkeypatch.setattr(auth_context, "get_access_token", _fake_get_access_token, raising=True)
232+
monkeypatch.setattr(
233+
auth_context, "get_access_token", _fake_get_access_token, raising=True
234+
)
237235

238236
result = await proxy_server.call_tool("user_info", {})
239237

@@ -244,5 +242,7 @@ def _fake_get_access_token(): # noqa: D401
244242
raw = result # fallback
245243

246244
assert raw["authenticated"] is True
247-
assert ("userid" in raw and raw["userid"] == "test-user") or ("user_id" in raw and raw["user_id"] == "test-user")
248-
assert raw["username"] == "tester"
245+
assert ("userid" in raw and raw["userid"] == "test-user") or (
246+
"user_id" in raw and raw["user_id"] == "test-user"
247+
)
248+
assert raw["username"] == "tester"

0 commit comments

Comments
 (0)