Skip to content

feat: add mellea-mcp integration package#54

Closed
ajbozarth wants to merge 6 commits into
generative-computing:mainfrom
ajbozarth:mcp-integration
Closed

feat: add mellea-mcp integration package#54
ajbozarth wants to merge 6 commits into
generative-computing:mainfrom
ajbozarth:mcp-integration

Conversation

@ajbozarth
Copy link
Copy Markdown

Summary

  • Adds mellea-mcp, a new integration package that bridges MCP server tools into Mellea's native tool-calling system using the mcp SDK
  • Two-step public API: discover_mcp_tools() for inspection/filtering, MCPToolSpec.as_mellea_tool() for instantiation
  • Typed connection helpers: http_connection, sse_connection, stdio_connection
  • GitHub activity summary example demonstrating the full workflow with react()
  • 24 unit tests across test_tools.py and test_connections.py

Test plan

  • uv sync --extra dev && uv run python -m pytest tests/ -v passes (24 tests)
  • uv run python examples/github_activity_summary.py runs end-to-end with a valid GITHUB_TOKEN

@github-actions github-actions Bot added the enhancement New feature or request label May 4, 2026
@ajbozarth ajbozarth self-assigned this May 4, 2026
@ajbozarth
Copy link
Copy Markdown
Author

I pinged everyone, but we should probably set up auto-assign reviewers on this repo like the others

@ajbozarth ajbozarth force-pushed the mcp-integration branch 2 times, most recently from a8ca3db to 94ab69f Compare May 4, 2026 23:22
@akihikokuroda
Copy link
Copy Markdown
Member

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>
@ajbozarth
Copy link
Copy Markdown
Author

Please move under mellea_contribs and follow https://github.com/generative-computing/mellea-contribs/blob/main/README.md#setting-up-a-new-subpackage-for-ci

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

@ajbozarth
Copy link
Copy Markdown
Author

It's also worth noting that this was written with the intention of easily moving it into mellea if desired there instead

Copy link
Copy Markdown
Member

@akihikokuroda akihikokuroda left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@psschwei psschwei left a comment

Choose a reason for hiding this comment

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

on first glance, seems mostly fine. will try to do a more thorough review later, but for now a couple of minor nits

Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py Outdated
Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py
Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py Outdated
- 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>
@ajbozarth
Copy link
Copy Markdown
Author

@psschwei pushed an update addressing all you comments if you want to take another look

Copy link
Copy Markdown
Member

@psschwei psschwei left a comment

Choose a reason for hiding this comment

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

there's a couple of things we may want to address, but I don't think any of them are blocking.

Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py Outdated
Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py
Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py
Comment thread mellea_contribs/mcp_tools/tests/test_tools.py
- 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>
@ajbozarth
Copy link
Copy Markdown
Author

@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.

Copy link
Copy Markdown

@planetf1 planetf1 left a comment

Choose a reason for hiding this comment

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

Looks good generally - I just think there's some aspects of timeouts that need consideration

Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py Outdated
Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py
Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py
Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py
Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py
Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py
Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py Outdated
Comment thread mellea_contribs/mcp_tools/pyproject.toml Outdated
@planetf1
Copy link
Copy Markdown

planetf1 commented May 5, 2026

On example on ResourceLink being dropped - it's used by the github mcp server
Could be a followon pr if needed?

@akihikokuroda
Copy link
Copy Markdown
Member

Would you update this line, too?

if [[ "$PACKAGE_DIR" == *"mellea-integration-core"* ]] || [[ "$PACKAGE_DIR" == *"reqlib_package"* ]] || [[ "$PACKAGE_DIR" == *"tools_package"* ]]; then
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>
@ajbozarth
Copy link
Copy Markdown
Author

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>
Copy link
Copy Markdown

@jakelorocco jakelorocco left a comment

Choose a reason for hiding this comment

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

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.

Comment thread mellea_contribs/mcp_tools/src/mellea_mcp/tools.py
@ajbozarth ajbozarth requested a review from planetf1 May 6, 2026 15:03
- 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>
@ajbozarth
Copy link
Copy Markdown
Author

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:

  1. There was a stale duplicate README committed by mistake
  2. The README and CI were out of sync on tools_package so I fixed those (they were on the same lines I was already editing)

@akihikokuroda can you double check my changes?

@psschwei
Copy link
Copy Markdown
Member

psschwei commented May 6, 2026

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?

@ajbozarth ajbozarth disabled auto-merge May 6, 2026 20:12
@ajbozarth
Copy link
Copy Markdown
Author

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

Copy link
Copy Markdown

@planetf1 planetf1 left a comment

Choose a reason for hiding this comment

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

Looks superb now -

@planetf1
Copy link
Copy Markdown

planetf1 commented May 7, 2026

Am ok with this being in core (but would re-review that pr in the mellea context)

@psschwei
Copy link
Copy Markdown
Member

psschwei commented May 7, 2026

this would be a great example of the contribs -> mellea pipeline

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).

@jakelorocco
Copy link
Copy Markdown

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.

@ajbozarth
Copy link
Copy Markdown
Author

Per team consensus I've opened generative-computing/mellea#1042 to add this to core instead of contribs and will close this.

@ajbozarth ajbozarth closed this May 8, 2026
@ajbozarth ajbozarth deleted the mcp-integration branch May 8, 2026 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants