Skip to content

Commit 80dfe60

Browse files
authored
fix(mcp-server): make mcp-server lifespan and startup non-blocking for marimo server (#6545)
## 📝 Summary <!-- Provide a concise summary of what this pull request is addressing. If this PR fixes any issues, list them here by number (e.g., Fixes #123). --> Update lifespan function for mcp-server to handle errors rather than raising them to the parent server. Now if an error occurs it won't block marimo backend server from starting, but rather just log it like this: <img width="896" height="277" alt="Screenshot 2025-09-26 at 7 33 42 PM" src="https://github.com/user-attachments/assets/dcaa5081-c6c8-4453-851b-e7ac5403c6ba" /> ## 🔍 Description of Changes <!-- Detail the specific changes made in this pull request. Explain the problem addressed and how it was resolved. If applicable, provide before and after comparisons, screenshots, or any relevant details to help reviewers understand the changes easily. --> - Update except block in marimo/_mcp/server/lifespan.py to handle unknown errors internally rather than raising it to parent Starlette app. ## 📋 Checklist - [x] I have read the [contributor guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md). - [ ] For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on [Discord](https://marimo.io/discord?ref=pr), or the community [discussions](https://github.com/marimo-team/marimo/discussions) (Please provide a link if applicable). - [ ] I have added tests for the changes made. - [x] I have run the code and verified that it works as expected.
1 parent 69a3a84 commit 80dfe60

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

marimo/_mcp/server/lifespan.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ async def mcp_server_lifespan(app: Starlette) -> AsyncIterator[None]:
2828
return
2929
except Exception as e:
3030
LOGGER.error(f"Failed to start MCP server: {e}")
31-
raise
31+
yield
32+
return

0 commit comments

Comments
 (0)