Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

- `./bin/cagent run <config.yaml>` - Run agent with configuration
- `./bin/cagent run <config.yaml> -a <agent_name>` - Run specific agent
- `./bin/cagent mcp server --port 8080 --path /mcp --agents-dir <config_dir>` - Start MCP server mode
- `./bin/cagent init` - Initialize new project

### MCP Testing

- `cd examples/mcptesting && go run test-mcp-client.go` - Test MCP server functionality
- Test client verifies agent listing, pulling, and invocation via MCP protocol

### Single Test Execution

- `go test ./pkg/specific/package` - Run tests for specific package
Expand Down Expand Up @@ -72,7 +66,7 @@ cagent is a multi-agent AI system with hierarchical agent structure and pluggabl

#### Command Layer (`cmd/root/`)

- **Multiple interfaces**: CLI (`run.go`), TUI (`tui.go`), API (`api.go`), MCP server (`mcp.go`)
- **Multiple interfaces**: CLI (`run.go`), TUI (`tui.go`), API (`api.go`)
- **Interactive commands**: `/exit`, `/reset`, `/eval` during sessions
- **Debug support**: `--debug` flag for detailed logging
- **MCP server mode**: SSE-based transport for external MCP clients like Claude Code
Expand Down
107 changes: 0 additions & 107 deletions cmd/root/mcp.go

This file was deleted.

1 change: 0 additions & 1 deletion cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func NewRootCmd() *cobra.Command {
cmd.AddCommand(NewEvalCmd())
cmd.AddCommand(NewPushCmd())
cmd.AddCommand(NewPullCmd())
cmd.AddCommand(NewMCPCmd())
cmd.AddCommand(NewReadmeCmd())
cmd.AddCommand(NewDebugCmd())
cmd.AddCommand(NewFeedbackCmd())
Expand Down
1 change: 1 addition & 0 deletions cmd/root/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
)

var (
agentsDir string
autoApprove bool
attachmentPath string
workingDir string
Expand Down
104 changes: 1 addition & 103 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ agents with specialized capabilities and tools. It features:
- **🏗️ Multi-tenant architecture** with client isolation and session management
- **🔧 Rich tool ecosystem** via Model Context Protocol (MCP) integration
- **🤖 Hierarchical agent system** with intelligent task delegation
- **🌐 Multiple interfaces** including CLI, TUI, API server, and MCP server
- **🌐 Multiple interfaces** including CLI, TUI and API server
- **📦 Agent distribution** via Docker registry integration
- **🔒 Security-first design** with proper client scoping and resource isolation
- **⚡ Event-driven streaming** for real-time interactions
Expand Down Expand Up @@ -40,10 +40,6 @@ $ cagent run config.yaml
$ cagent run config.yaml -a agent_name # Run specific agent
$ cagent run config.yaml --debug # Enable debug logging

# MCP Server Mode (for external clients like Claude Code)
$ cagent mcp server --agents-dir ./config_directory
$ cagent mcp server --port 8080 --path /mcp --agents-dir ./config

# API Server (HTTP REST API)
$ cagent api config.yaml
$ cagent api config.yaml --port 8080
Expand Down Expand Up @@ -547,50 +543,6 @@ cagent supports distributing via, and running agents from, Docker registries:
- File agents: `my-agent.yaml` (relative path)
- Store agents: `docker.io/username/my-agent:latest` (full Docker reference)


### Session Management

**MCP Server Sessions:**

- Client-isolated sessions
- Session creation and management via MCP tools
- Real-time streaming responses
- Session timeout and cleanup

## Best Practices

### Agent Design

1. **Single Responsibility**: Each agent should have a clear, focused purpose
2. **Clear Instructions**: Provide detailed, specific instructions for each agent
3. **Appropriate Tools**: Give agents only the tools they need
4. **Hierarchy Design**: Use sub-agents for specialized tasks and clear delegation paths
5. **Model Selection**: Choose appropriate models for different capabilities (reasoning vs creativity)

### Configuration Management

1. **Validation**: Always validate your configuration before running
2. **Environment Variables**: Use environment variables for sensitive data
3. **Modularity**: Break complex configurations into smaller, reusable pieces
4. **Documentation**: Document your agent configurations and tool permissions
5. **Version Control**: Track agent configurations in git for reproducibility

### Tool Usage

1. **Minimal Permissions**: Give tools only necessary permissions
2. **Error Handling**: Consider how agents will handle tool failures
3. **Security**: Be cautious with shell access and file system permissions
4. **Testing**: Test tool combinations thoroughly in isolation
5. **MCP Tool Lifecycle**: Properly handle MCP tool start/stop lifecycle

### Production Deployment

1. **MCP Server Mode**: Use MCP server for external integrations
2. **Session Limits**: Configure appropriate session limits and timeouts
3. **Monitoring**: Enable debug logging for troubleshooting
4. **Resource Management**: Monitor memory and CPU usage for concurrent sessions
5. **Client Isolation**: Ensure proper client scoping in multi-tenant deployments

## Troubleshooting

### Common Issues
Expand Down Expand Up @@ -638,9 +590,6 @@ Enable debug logging for detailed information:
```bash
# CLI mode
./bin/cagent run config.yaml --debug

# MCP server
./bin/cagent mcp server --agents-dir ./config --debug
```

### Log Analysis
Expand All @@ -655,29 +604,9 @@ Check logs for:
- Session creation and cleanup events
- Client isolation boundary violations

### Testing MCP Integration

Test MCP server functionality:

```bash
# Start MCP server
./bin/cagent mcp server --agents-dir ./examples/config --port 8080 --debug

# Test with curl (check server is running)
curl -N http://localhost:8080/mcp/sse

# Run MCP test client
cd examples/mcptesting
go run test-mcp-client.go
```

### Agent Store Issues

```bash
# Check agent resolution
./bin/cagent mcp server --agents-dir ./config --debug
# Look for "Agent resolved" messages in logs

# Test Docker registry connectivity
docker pull docker.io/username/agent:latest

Expand All @@ -687,37 +616,6 @@ docker pull docker.io/username/agent:latest

## Integration Examples

### MCP Client Integration

Using cagent agents from external MCP clients:

```javascript
// Example: Using cagent from Claude Code or Cursor
const mcp = require("@modelcontextprotocol/client");

// Connect to cagent MCP server
const client = new mcp.Client({
url: "http://localhost:8080/mcp/sse",
transport: "sse",
});

// List available agents
const agents = await client.callTool("list_agents", {});

// Create a session with a specific agent
const session = await client.callTool("create_agent_session", {
agent_spec: "developer",
initial_message: "Help me debug this Python code",
});

// Send messages to the agent
const response = await client.callTool("send_message", {
session_id: session.session_id,
message:
"def fibonacci(n): return n if n <= 1 else fibonacci(n-1) + fibonacci(n-2)",
});
```

### Custom Memory Strategies

Implement persistent memory across sessions:
Expand Down
27 changes: 1 addition & 26 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,10 @@ graph TB

## Component Architecture

### 1. Transport Layer (`cmd/root/`, `pkg/mcpserver/`)
### 1. Transport Layer (`cmd/root/`)

The transport layer provides multiple interfaces for interacting with cagent:

#### MCP Server (`pkg/mcpserver/`)

- Full MCP (Model Context Protocol) implementation with SSE transport
- Multi-tenant client isolation with proper lifecycle management
- Tool handlers for agent operations: invoke_agent, list_agents, create_agent_session
- Session management tools: send_message, list_agent_sessions, close_agent_session
- Advanced session operations: get_agent_session_info, get_agent_session_history
- Docker registry integration: pull_agent for downloading agent images
- Structured responses with explicit agent_ref formatting

#### CLI Interface (`cmd/root/run.go`)

- Direct agent execution for local development and testing
Expand All @@ -132,21 +122,6 @@ The transport layer provides multiple interfaces for interacting with cagent:
- Terminal user interface for interactive agent sessions
- Local agent execution with enhanced UX

### 2. ServiceCore Layer (`pkg/servicecore/`)

The ServiceCore layer provides the core business logic with multi-tenant architecture:

```mermaid
graph LR
CLIENT[MCP/HTTP Client] --> MANAGER[ServiceManager]
MANAGER --> RESOLVER[Agent Resolver]
MANAGER --> EXECUTOR[Runtime Executor]
RESOLVER --> FILES[File Agents]
RESOLVER --> STORE[Store Agents]
EXECUTOR --> RUNTIME[Runtime Creation]
EXECUTOR --> SESSION[Session Management]
```

#### ServiceManager Interface

- **Client Management**: CreateClient, RemoveClient with proper isolation
Expand Down
Loading