Skip to content

Commit d46f82d

Browse files
authored
Merge pull request #176 from nextcloud/backport/174/stable34
[stable34] Fix: MCP streamable-http transport for initializing
2 parents f0cf50f + bc2521d commit d46f82d

4 files changed

Lines changed: 2361 additions & 1693 deletions

File tree

.github/workflows/integration_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ jobs:
273273
run: |
274274
tail data/nextcloud.log
275275
276-
- name: Show context_chat logs
276+
- name: Show context_agent logs
277277
if: always()
278278
run: |
279279
[ -f ${{ env.APP_NAME }}/logs ] && cat ${{ env.APP_NAME }}/logs || echo "No context_chat logs"

ex_app/lib/mcp_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from fastmcp.server.dependencies import get_context
99
from nc_py_api import AsyncNextcloudApp, NextcloudApp
1010
from fastmcp.server.middleware import Middleware, MiddlewareContext, CallNext
11+
from fastmcp.server.dependencies import get_http_headers
1112
from fastmcp.tools import Tool
1213
from mcp import types as mt
1314
from ex_app.lib.tools import get_tools
@@ -30,7 +31,7 @@ def get_user(authorization_header: str, nc: AsyncNextcloudApp) -> str:
3031
class UserAuthMiddleware(Middleware):
3132
async def on_message(self, context: MiddlewareContext, call_next):
3233
# Middleware stores user info in context state
33-
authorization_header = context.fastmcp_context.request_context.request.headers.get("Authorization")
34+
authorization_header = get_http_headers().get("authorization")
3435
if authorization_header is None:
3536
raise Exception("Authorization header is missing/invalid")
3637
nc = AsyncNextcloudApp()

0 commit comments

Comments
 (0)