Skip to content

Conversation

@bjornslib
Copy link
Contributor

@bjornslib bjornslib commented Dec 31, 2025

Summary

Fixes the MCP server lifespan not being properly chained with the FastAPI app's lifespan, causing the MCP server to not start/stop correctly when mounted as a sub-application.

Problem

When the MCP server is mounted as a sub-application, its lifespan context was not being invoked, causing initialization issues.

Solution

  • Create MCP app before FastAPI app to access its lifespan
  • Chain MCP lifespan context with FastAPI's lifespan context using asynccontextmanager
  • Ensures MCP server lifecycle is properly managed

Testing

Verified with Claude Code MCP integration - the server now starts and stops correctly.

The MCP server's lifespan was not being properly chained with the
FastAPI app's lifespan, causing the MCP server to not start/stop
correctly when mounted as a sub-application.

Changes:
- Create MCP app before FastAPI app to access its lifespan
- Chain MCP lifespan context with FastAPI's lifespan context
- Ensures MCP server lifecycle is properly managed

This fix is required for the MCP server to function correctly when
used with Claude Code and other MCP clients.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@bjornslib
Copy link
Contributor Author

Needed to make this change for MCP in CC to work.

Copy link
Collaborator

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

we need to an integration test for MCP before cutting the next release

@nicoloboschi nicoloboschi merged commit 6b78f7d into vectorize-io:main Jan 1, 2026
16 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants