# Release Candidate 2 ## This PR: - [x] No more confusing 307 redirect logs when using `/mcp` instead of `/mcp/` (requested by @shubcodes) - [x] Fix bug in `arcade configure` for Python < 3.12 (reported by @evantahler - [x] Fix bug where tools with unsatisfied secret requirements could still be executed (reported by @evantahler, @shubcodes) - [x] Auth providers can now be imported via `from arcade_mcp_server.auth import Reddit` (requested by @shubcodes) - [x] Add complete E2E oauth flow for tool calls with informational errors about how to log into arcade and where to go to authorize (requested by @evantahler, @shubcodes) - [x] Add OAuth tool in `arcade new`'s generated server (requested by @shubcodes) - [x] Standardize on defaulting to running servers on port 8000 - [x] Improve credentials.yaml reading logic - [x] CLI user friendliness (requested by @Spartee) - [x] Remove `arcade serve` CLI command - [x] Fix race condition in `arcade logout` - [x] Update docs for desired developer onboarding flow ## Next PRs: - Get `arcade deploy` working for MCP servers. (Command is hidden for now) - Rename all occurrences of `toolkit` to `server`/`tools` and rename all occurrences of `worker` to `server`
24 lines
740 B
Python
24 lines
740 B
Python
from collections.abc import Awaitable
|
|
from typing import Callable, ClassVar
|
|
|
|
from fastapi import Request, Response
|
|
from starlette.middleware.base import BaseHTTPMiddleware
|
|
|
|
|
|
class AddTrailingSlashToPathMiddleware(BaseHTTPMiddleware):
|
|
"""Middleware that adds trailing slashes to specific paths.
|
|
|
|
Example:
|
|
- /mcp -> /mcp/
|
|
- /mcp/ -> /mcp/
|
|
"""
|
|
|
|
PATHS_TO_ADD_SLASH: ClassVar[list[str]] = ["/mcp"]
|
|
|
|
async def dispatch(
|
|
self, request: Request, call_next: Callable[[Request], Awaitable[Response]]
|
|
) -> Response:
|
|
path = request.scope["path"]
|
|
if path in self.PATHS_TO_ADD_SLASH and not path.endswith("/"):
|
|
request.scope["path"] = path + "/"
|
|
return await call_next(request)
|