Skip to content

Enable multithreaded tool calls by localizing use of MVar - #12

Open
JBetz wants to merge 2 commits into
dpella:mainfrom
JBetz:multithreaded-tool-calls
Open

JBetz wants to merge 2 commits into
dpella:mainfrom
JBetz:multithreaded-tool-calls

Conversation

@JBetz

@JBetz JBetz commented Sep 10, 2026 •

Copy link
Copy Markdown

Resolves #11, though not in the same way I described in the issue. It still achieves the objective of enabling tool calls to be multi-threaded.

Difference is that instead of having the application decide on the concurrency mechanism for server state, it just uses MVar. This does make things a little awkward for the Stdio implementation which is using IORef. I'm not sure how to resolve that other than creating some sort of abstraction over MVar and IORef or by switching the entire Stdio implementation to using MVar. UPDATE: I switched it to MVar since it's more capable than IORef for concurrency, and you might want tool handlers to spin new threads that modify server state.

Some awkwardness is also removed as the current authenticated user is now separated from server state.

This is a breaking change.

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.

Stateless MCP servers are unnecessarily single-threaded

1 participant