Skip to content

Commit a651858

Browse files
authored
Merge pull request #14 from inmydata/fix/oauth-header-fastmcp-compat
2 parents dd2a1c1 + d65240a commit a651858

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

server_remote.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,18 @@ async def get_tenant(token: str) -> str:
185185
async def utils() -> mcp_utils:
186186
try:
187187
if INMYDATA_USE_OAUTH:
188-
# OAuth flow - use bearer token and extract tenant from token
189-
headers = get_http_headers(include={"authorization"})
190-
api_key = headers.get('authorization', '').replace('Bearer ', '')
188+
# OAuth flow - use bearer token and extract tenant from token.
189+
# get_http_headers() strips the authorization header by default; the
190+
# include= kwarg to keep it only exists in fastmcp 3.x, but the pinned
191+
# runtime is 2.12.4. Read the bearer token straight off the request so
192+
# this works regardless of fastmcp version. The non-authorization
193+
# x-inmydata-* headers are not stripped, so get_http_headers() is fine
194+
# for those.
195+
req = get_http_request()
196+
api_key = (
197+
req.headers.get('authorization', '') if req is not None else ''
198+
).replace('Bearer ', '')
199+
headers = get_http_headers()
191200
tenant = await get_tenant(api_key)
192201
server = headers.get('x-inmydata-server', await get_server())
193202
calendar = headers.get('x-inmydata-calendar', 'Default')

0 commit comments

Comments
 (0)