-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Enhancement Proposal] Agent Protocol Layer for DSPy for MCP and A2A Support #8273
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
Comments
Thanks for putting up the detailed feature request!
MCP is good and getting widely adopted, while I don't feel A2A has already gotten there. Furthermore, I don't have a good experience with A2A, but I am aware that A2A is still evolving.
I don't really get the benefit of introducing an extra wrapper of MCP inside DSPy over the simple integration between One way to help us understand better about your motivation is putting up a reproducible notebook/colab/github repo that compares your proposal against the current DSPy MCP approach on a demo workflow, e.g., building an agent that can handle github PR reviews (using the official github MCP server). |
Thanks @chenmoneygithub for your response and appreciate your views and clarification on your understanding of A2A. You are 100% right that current At the moment, based on the example in the docs and implementation in the react.py that you pointed, we are treating MCP is just yet another tool and want DSPy users to write DSPy MCP tools to fit into currently working ecosystem which is not bad idea from DSPy maintainers point of view. However, if you consider DSPy users, they have to write additional custom tools to fit into DSPy's Tools ecosystem. The whole point of the MCP is to avoid writing the custom tools that imposed by function calling approach and just use whatever available as service. IMO, current approach you are suggesting, defeats the purpose of MCP if we are asking users to write tools by hand. My understanding is protocol layer would recognize that MCP (and future protocols) have richer semantics than individual tools - they include context sharing, session management, capability negotiation, and standardized error handling that goes beyond what individual tool wrappers provide. I am not if optimisers would be able to reason about protocol layer patterns but hopefully there might be a way. As other agents frameworks are adopting protocol layer approach (at least embedding MCP) in them and taking advantage of huge reliable list of MCP servers and making themselves future-proof and extendible. I was thinking the same for DSPy as it is already modular and extensible but I am not the decision maker. If you think, allowing users to write custom MCP tools is right approach then its up to you. I totally understand your concern about added complexity, additional learning and additional overhead for project maintainer . However, the protocol layer could be designed as an optional enhancement - existing dspy.Tool usage would remain unchanged, but users who need protocol-level features could opt into the richer abstraction. I think, that's where industry is heading. In order for me to implement protocol layer, I need to implement minimal protocol interface and test out with some simple agent, I already forked DSPy and will try (not sure when though). I can see that the approach mentioned in the Docs here seems to work without any issues but I think, its not how MCP should be used. I would check, how CrewAI integrated MCP both as Tools and Server. Or OpenAI AgentSDK MCP integration .. And See if we can do something better here in DSPy. |
Thank you for the feature request and the detailed response.
I'm not sure if this is true. Users should be able to use any MCP servers (such as community servers here) with dspy.ReAct. They define MCP client session with the standard |
I spun up new package to enable the protocol-first agent design approach for DSPy. This approach skips the use React module like mentioned here and any other modules can be used here (Just returned the predictions at the moment). My plan is define the custom module that behaves in agentic manner. I can see the extendibility of this approach not only limit to MCP but this can be scaled to A2A as well without much effort. Few other benefits I saw here Automatic connection management, Session state management, Future protocol extensibility etc. One thing, I need to figure out is how it can work with DSPy optimizers. I don't see any issue as long as there is gold examples and clearly defined metric but I need to verify. I have tested this few examples with couple of agents including the PR review agent and seems to be working fine. I have a plan to test with more agents and more strategies. I am still working on it however posting the project here to get feedback from other contributors and code owners Agenspy (Agentic DSPy) https://github.com/SuperagenticAI/Agenspy Let me know what you think? I would like to get more feedback from others including @okhat .. How can I include other code-owners? |
What feature would you like to see?
Introduction
This proposal introduces a new Agent Protocol Layer in DSPy that provides a standardized framework for integrating various agent communication protocols. The layer will initially focus on Model Context Protocol (MCP) support while establishing extensible patterns for future protocols like Agent2Agent communication and many more those will emerge in the future.
Motivation
Everyone adopted MCP as standard these days (Google, OpenAI), why not DSPy?
Current Limitations
Who is Affected
Evidence
The DSPy is modular and has better abstraction, which aligns with protocol layer requirements provided it technically fits into the DSPy ecosystem
Proposed Solution
Architecture Overview
Create a new protocol layer that extends DSPy's existing module system while leveraging the client architecture patterns from Core Components as mentioned below .. Just psudo code for now
Core Components
Integration with Existing Systems
The protocol layer will integrate with DSPy's async capabilitie to handle network communication while maintaining compatibility with the synchronous execution model.
Impact
Benefits
Trade-offs
Potential Implementation
Alternatives Considered
Alternative 1: Extend ReAct Module
Alternative 2: Separate Protocol Package or Plugin Architecture
Open Questions
Technical
Would you like to contribute?
Additional Context
No response
The text was updated successfully, but these errors were encountered: