feat: add mellea-mcp integration package#54
Conversation
|
I pinged everyone, but we should probably set up auto-assign reviewers on this repo like the others |
a8ca3db to
94ab69f
Compare
|
Please move under |
Bridges MCP server tools into Mellea's native tool-calling system using the mcp SDK. Provides a two-step API: discover_mcp_tools() returns MCPToolSpec objects for inspection and filtering; as_mellea_tool() instantiates a callable MelleaTool. Includes typed connection helpers (http_connection, sse_connection, stdio_connection), a GitHub activity summary example using react(), and 24 unit tests. Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
Everything should be up to date now, I picked this work up from a very old branch and didn't rebase until after I opened the PR |
|
It's also worth noting that this was written with the intention of easily moving it into mellea if desired there instead |
psschwei
left a comment
There was a problem hiding this comment.
on first glance, seems mostly fine. will try to do a more thorough review later, but for now a couple of minor nits
- Tighten as_mellea_tool() return type from Any to MelleaTool - Replace per-call ThreadPoolExecutor with a module-level one to avoid thread creation overhead on every tool invocation - Handle EmbeddedResource text contents and surface binary content types (ImageContent, BlobResourceContents) as [binary: <mime>] descriptors rather than silently dropping them Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
|
@psschwei pushed an update addressing all you comments if you want to take another look |
psschwei
left a comment
There was a problem hiding this comment.
there's a couple of things we may want to address, but I don't think any of them are blocking.
- Switch content block dispatch from hasattr to isinstance checks - Handle result.isError: surface error content as [tool error] prefix, falling back to a generic message when content is absent - Add tests for EmbeddedResource (text + blob), ImageContent, and isError cases; update existing sync wrapper tests to use real MCP types Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
|
@psschwei if you want to double check the fixes to your non-blockers before I merge this Also @jakelorocco And @nrfulton I know you're super busy atm, but this contrib might be worth moving into mellea if you want to take a look next time you have a moment. |
planetf1
left a comment
There was a problem hiding this comment.
Looks good generally - I just think there's some aspects of timeouts that need consideration
|
On example on ResourceLink being dropped - it's used by the github mcp server |
|
Would you update this line, too? if this is expected cutting a release soon. |
- Add configurable timeouts to all three transports: httpx.Timeout for streamable_http, timeout/sse_read_timeout for sse, asyncio.timeout for stdio - Expose connect_timeout/read_timeout on http_connection and sse_connection, and a single timeout param on stdio_connection - Handle AudioContent and ResourceLink content block types - Register atexit cleanup for the module-level thread pool executor - Fix _make_sync_call return type annotation to Callable[..., str] - Bump dependency floors to tested versions: mellea>=0.4.2, mcp>=1.27.0 - Add mcp_tools to skip_ollama allowlist in build-package.yml CI workflow Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
|
All review items should be addressed now |
Falls back to a [resource: <uri>] placeholder if the read fails, since the MCP spec does not guarantee resource links are readable. Also adds AudioContent handling and tests for both new content types. Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
jakelorocco
left a comment
There was a problem hiding this comment.
this looks nice; I will leave the final review for others. We should bring this up in the next Monday meeting that has everyone. I think it's a good candidate for being in Mellea itself, given that MCP servers are a common way to add tools to agents.
- Add mellea-mcp / mcp_tools entries to README.md, RELEASING.md, RELEASE_QUICK_START.md (package tables, directory tree, Ollama lists) - Tighten mcp_tools description to "Expose MCP server tools as Mellea tools" in pyproject.toml and propagate to docs - Remove README_mellea_contrib.md, an accidental near-duplicate of README.md introduced in generative-computing#47 - Drop stale "5 packages" counts in RELEASE_TESTING.md to avoid future drift when packages are added - Fix build-package.yml skip_ollama list: tools_package tests require Ollama (per ci.yml and test usage of start_session), so do not skip it at release time. Release path for mellea-tools has never been exercised upstream, so no prior release was affected. Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
|
Was looking at the repo page and realized I did not update any of the docs, so I just pushed an update to the docs, but while making that update I found a couple issues than I also addressed in c08be06:
@akihikokuroda can you double check my changes? |
|
If we are going to bring into core (which I am on board with) maybe we don't merge this and then rip it right back out? |
That is fair, if my proposal to move to core would be implemented this sprint, but @serjikibm also made a comment in a recent call that this would be a great example of the contribs -> mellea pipeline |
|
Am ok with this being in core (but would re-review that pr in the mellea context) |
I think that applies if it lived in contribs for a while, we saw it was useful, and decided that we should move it over to core. Since we've already decided to move it to core, that doesn't really apply here. Now as you mentioned earlier, if it's going to take a while to get into core, then I could see having it here in the interim. I'd be inclined to at least see where the discussion goes Monday before making a decision (it's not like we're cutting a new version of contribs this week afaik). |
|
Discussed verbally; I am okay with this being in core. It's a smaller sized change that enables some good tool functionality. We should make sure to add some comments in the docs along side the current example though. |
|
Per team consensus I've opened generative-computing/mellea#1042 to add this to core instead of contribs and will close this. |
Summary
mellea-mcp, a new integration package that bridges MCP server tools into Mellea's native tool-calling system using themcpSDKdiscover_mcp_tools()for inspection/filtering,MCPToolSpec.as_mellea_tool()for instantiationhttp_connection,sse_connection,stdio_connectionreact()test_tools.pyandtest_connections.pyTest plan
uv sync --extra dev && uv run python -m pytest tests/ -vpasses (24 tests)uv run python examples/github_activity_summary.pyruns end-to-end with a validGITHUB_TOKEN