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

Unpack tool output and hoist artifacts #2

Closed
wants to merge 0 commits into from

Conversation

isaacwasserman
Copy link

Previously, langchain-mcp was making the ToolMessage content the entire output from MCP. MCP servers deliver tool output as a list of content objects, but not all of this object is for the LLM to see.

This change extracts the text from the tool output so that it is the only thing that the LLM sees. It also extracts artifacts from the tool output and places them in the ToolMessage's artifact attribute.

There doesn't seem to be any recommended way to perform this extraction from the maintainers of MCP itself, so this change (naively) concatenates text blocks. I'm not sure how we are meant to deal with image and resource content blocks.

@rectalogic
Copy link
Owner

Thanks. I made some changes to your branch here https://github.com/rectalogic/langchain-mcp/compare/tools

We can just partition TextContent from the other pydantic MCP types, then jsonify the TextContent list and return the list of artifact MCP objects as-is.

However, the standard tests fail on your branch and mine. It looks like the standard langchain tests don't properly handle content_and_artifact, I'll file a bug report.

@rectalogic
Copy link
Owner

Filed langchain-ai/langchain#29391

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.

2 participants