You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Convenience adapters to simplify MCP tool usage with DSPy #9331
Add high-level convenience adapters (stdio_mcp_tools and http_mcp_tools) that simplify integrating Model Context Protocol (MCP) tools with DSPy agents like dspy.ReAct.
Currently, using MCP tools with DSPy requires manually managing MCP sessions, converting tools, and handling the connection lifecycle:
frommcpimportClientSession, StdioServerParametersfrommcp.client.stdioimportstdio_clientfromdspy.utils.mcpimportconvert_mcp_toolserver_params=StdioServerParameters(command="docker", args=[...])
asyncwithstdio_client(server_params) as (read, write):
asyncwithClientSession(read, write) assession:
awaitsession.initialize()
response=awaitsession.list_tools()
tools= [convert_mcp_tool(session, t) fortinresponse.tools]
# finally use tools with dspy.ReAct...
This would be a great addition! We've been building MCP integrations for DSPy agents at RevolutionAI and the current boilerplate is definitely a friction point.
A few thoughts on the implementation:
Tool filtering is crucial — the include_tools/exclude_tools pattern is exactly right. In production we often want to expose only a subset of MCP tools to certain agents for security and cost reasons.
Timeout handling — glad to see this included. MCP servers can hang, and having a configurable timeout prevents agents from getting stuck in infinite waits.
A few suggestions for the PR:
Connection pooling for HTTP — if the adapter is used across multiple agent calls, keeping the connection alive could reduce latency
Retry logic — MCP server restarts are common in dev; a configurable retry with exponential backoff would make the adapters more robust
Tool schema caching — list_tools() can be slow; caching the schema for a session duration could help
Logging hooks — optional debug logging for tool calls would help with debugging agent behavior
Happy to help test the PR if useful. We're shipping MCP-powered agents regularly and can provide feedback on edge cases.
Activity
xXMrNidaXx commentedon Feb 24, 2026
This would be a great addition! We've been building MCP integrations for DSPy agents at RevolutionAI and the current boilerplate is definitely a friction point.
A few thoughts on the implementation:
Tool filtering is crucial — the
include_tools/exclude_toolspattern is exactly right. In production we often want to expose only a subset of MCP tools to certain agents for security and cost reasons.Timeout handling — glad to see this included. MCP servers can hang, and having a configurable timeout prevents agents from getting stuck in infinite waits.
A few suggestions for the PR:
Connection pooling for HTTP — if the adapter is used across multiple agent calls, keeping the connection alive could reduce latency
Retry logic — MCP server restarts are common in dev; a configurable retry with exponential backoff would make the adapters more robust
Tool schema caching —
list_tools()can be slow; caching the schema for a session duration could helpLogging hooks — optional debug logging for tool calls would help with debugging agent behavior
Happy to help test the PR if useful. We're shipping MCP-powered agents regularly and can provide feedback on edge cases.
xXMrNidaXx commentedon Feb 25, 2026
MCP + DSPy integration would be powerful! Here's a pattern that could work:
Proposed adapter design:
Key considerations:
Would love to see this become a first-class integration!
🔧 Building AI tools? We're hiring talented developers at RevolutionAI:
https://www.revolutionai.io/find-work
Production AI projects • Flexible hours • Great rates 💼
ahmeshaf commentedon Feb 25, 2026
@xXMrNidaXx , I already created the PR for this feature: #9311
Please feel free to comment there for additional feature requests