Open Source • Protocol-First • Future Ready

Agenspy

Protocol-First AI Agents for Next Generation Agentic Systems

Build smarter AI agents with protocol intelligence on top of DSPy. Support for MCP, A2A, and future agentic protocols with automatic connection management.

Quick Start

Get started with Agenspy in seconds

install.shBasic Installation
bash
pip install agenspy
install_mcp.shWith MCP Support
bash
pip install "agenspy[mcp]"
quick_start.pyQuick Example - Protocol-Aware Agent
python
import dspy
from agenspy import create_mcp_pr_review_agent

# Configure DSPy
lm = dspy.LM('openai/gpt-4o-mini')
dspy.configure(lm=lm)

# Create protocol-aware agent
agent = create_mcp_pr_review_agent("mcp://github-server:8080")

# Use the agent
result = agent(
    pr_url="https://github.com/org/repo/pull/123",
    review_focus="security"
)

print(f"Review: {result.review_comment}")
print(f"Status: {result.approval_status}")

Why Protocol-First?

Agenspy brings protocol intelligence to DSPy agents, enabling seamless integration with modern agentic systems

Protocol-First Architecture

Built-in support for MCP, Agent2Agent, and future protocols with automatic connection management

DSPy Integration & Optimization

Seamless integration with DSPy framework for optimized agent performance and prompt engineering

Full-featured CLI & Servers

Complete command-line interface with Python/Node servers for development and production

Automatic Connection Management

Handle complex protocol connections, session state, and error recovery automatically

Future Protocol Extensibility

Designed to support WebSocket, gRPC, and emerging protocols as they develop

Session State Management

Persistent session handling across protocol connections with automatic state recovery

Protocol Intelligence Architecture

How Agenspy bridges DSPy agents with protocol ecosystems

Protocol-First Architecture

How Agenspy enables seamless protocol integration

DSPy Agent Layer

ChainOfThought
ReAct Patterns
Optimized Prompts

Protocol Intelligence

Auto Connection
Session Management
Future Protocols
MCP Support

Model Context Protocol for tool integration

A2A Protocol

Agent-to-Agent communication

Future Protocols

WebSocket, gRPC, and more

MCP Integration Example

See how Agenspy seamlessly integrates with Model Context Protocol

mcp_agent_example.pyAdvanced MCP Agent with DSPy
python
from agenspy import MCPAgent
import dspy

# Initialize with automatic connection management
agent = MCPAgent(
    server_uri="mcp://github-server:8080",
    capabilities=["tools", "resources"]
)

# DSPy integration with protocol intelligence
class PRReviewAgent(dspy.Module):
    def __init__(self):
        super().__init__()
        self.review = dspy.ChainOfThought("context, pr_url -> review, status")
    
    def forward(self, pr_url, context="security"):
        return self.review(context=context, pr_url=pr_url)

# Protocol-first usage
review_agent = PRReviewAgent()
result = review_agent(pr_url="https://github.com/org/repo/pull/123")

CLI Commands

Powerful command-line interface for agent development and testing

agenspy agent run

Run an agent with real MCP server integration

agenspy agent run "Review PR https://github.com/stanfordnlp/dspy/pull/8277" --real-mcp
agenspy protocol test

Test protocol server connectivity and capabilities

agenspy protocol test mcp
agenspy demo github-pr

Run the GitHub PR review demo

agenspy demo github-pr --pr-url https://github.com/org/repo/pull/123

Example Projects

Ready-to-run examples to get you started

basic_mcp_demo.py

View

Simple MCP agent implementation with DSPy

comprehensive_mcp_demo.py

View

Full-featured agent with advanced capabilities

github_pr_review.py

View

GitHub pull request review agent

multi_protocol_demo.py

View

Experimental multi-protocol support

python_server_demo.py

View

Python MCP server example

Resources & Links

GitHub Repository

View Code

PyPI Package

Install

Examples

Browse

DSPy Framework

Learn More

Build the Future of Agent Communication

Join the protocol-first revolution. Start building agents that communicate seamlessly across any protocol.