Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: @gensx/mcp #358

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

feat: @gensx/mcp #358

wants to merge 17 commits into from

Conversation

jmoseley
Copy link
Contributor

Proposed changes

Add a new package, @gensx/mcp, that enables the creation of MCP contexts with a provider and a useContext helper. This provider manages the lifecycle of the server (spinning it up and shutting it down).

One thing that was required to make this work that I'm not super stoked about: Needed to add an onComplete to the Provider interface, so that we can perform tasks after the children of a provider have full resolved. This is necessary for us to close the connection (aka shutdown) the MCP server once that part of the workflow has finished.

Copy link

vercel bot commented Feb 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gensx-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2025 6:53pm
gensx-home ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2025 6:53pm

Copy link
Member

@EvanBoyle EvanBoyle left a comment

Choose a reason for hiding this comment

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

One thing that was required to make this work that I'm not super stoked about: Needed to add an onComplete to the Provider interface, so that we can perform tasks after the children of a provider have full resolved. This is necessary for us to close the connection (aka shutdown) the MCP server once that part of the workflow has finished.

Can we handle the lifecycle via node.js process hooks? This thing is a singleton across the node process, so can we just add a process.on(exit, ...) handler? (maybe other hooks/handler we need to attach to as well...).

@jmoseley
Copy link
Contributor Author

@EvanBoyle I tidied this up, but opted to keep the onComplete functionality. However, I did add support for passing a pre-connected Client, so that the developer has the option to manage the lifecycle themselves if they like.

@jmoseley jmoseley force-pushed the jeremy/mcp-provider branch from 4206ada to 978d6b1 Compare February 28, 2025 18:31
@vercel vercel bot temporarily deployed to Preview – gensx-home February 28, 2025 18:34 Inactive
@vercel vercel bot temporarily deployed to Preview – gensx-docs February 28, 2025 18:34 Inactive
@vercel vercel bot temporarily deployed to Preview – gensx-docs February 28, 2025 18:48 Inactive
@vercel vercel bot temporarily deployed to Preview – gensx-home February 28, 2025 18:48 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants