feat: add MCP tool integration#1042
Open
ajbozarth wants to merge 1 commit intogenerative-computing:mainfrom
Open
feat: add MCP tool integration#1042ajbozarth wants to merge 1 commit intogenerative-computing:mainfrom
ajbozarth wants to merge 1 commit intogenerative-computing:mainfrom
Conversation
Adds mellea/stdlib/tools/mcp.py, a new module that bridges MCP server tools into Mellea's native tool-calling system. MCPToolSpec.as_mellea_tool() wraps each discovered tool as a MelleaTool ready to pass via ModelOption.TOOLS or to react(). Public API: - discover_mcp_tools(connection) -> list[MCPToolSpec] - MCPToolSpec.as_mellea_tool() -> MelleaTool - http_connection, sse_connection, stdio_connection helpers Each tool invocation opens a short-lived MCP session and runs on mellea's shared background event loop via _run_async_in_thread, so callers do not need to manage session lifetime. Verified end-to-end against the hosted GitHub MCP server. Adds mcp>=1.27.0 and httpx>=0.27 to the mellea[tools] extra. httpx is already transitive via smolagents and langchain-core. Assisted-by: Claude Code Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
This was referenced May 8, 2026
Contributor
Author
|
cc @akihikokuroda @psschwei @planetf1 @jakelorocco as reviewers from the original contribs PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tool PR
Description
Adds
mellea/stdlib/tools/mcp.py, bridging MCPserver tools into Mellea's native tool-calling system. Any MCP server's tools
can now be discovered and used inside a Mellea agent.
Public API:
discover_mcp_tools(connection) -> list[MCPToolSpec]MCPToolSpec.as_mellea_tool() -> MelleaToolhttp_connection,sse_connection,stdio_connectiontransport helpersRuntime: each tool invocation opens a short-lived MCP session and runs on
mellea's shared background event loop via
_run_async_in_thread. Verifiedend-to-end against the hosted GitHub MCP server.
Deps:
mcp>=1.27.0andhttpx>=0.27added to themellea[tools]extra.httpxis already transitive viasmolagentsandlangchain-core.Supersedes
mellea-contribs#54,which will be closed rather than merged. Jake suggested during review
that this belongs in core.
Issue #1032 point 2 (generalizing the async-to-sync wrapper onto
MelleaTool.from_callable) is handled by #1041.Implementation Checklist
Protocol Compliance
MelleaToolinstances via the constructor; no backend changes required.Integration
mellea/stdlib/tools/__init__.pyor, if you are adding a library of components, from your sub-modulemellea.stdlib.tools.mcpsubmodule. Not added to__init__.pybecause the module importsmcpandhttpxat top level and should only be loaded when thetoolsextra is installed.Testing
tests/stdlib/tools/Attribution