Skip to content

Repository files navigation

Agent Smith - Python Implementation

Modern Python implementation of Agent Smith, a terminal-based AI coding assistant.

Features

  • πŸ€– Multi-provider LLM support (Anthropic Claude, OpenAI GPT, AWS Bedrock, Google Vertex)
  • πŸ–₯️ Beautiful terminal UI with Textual
  • πŸ”§ Extensible tool system (16+ built-in tools)
  • πŸ” Secure credential management (OS keyring support)
  • βš™οΈ XDG-compliant configuration
  • πŸš€ Fast async I/O with asyncio
  • πŸ“ Type-safe with Pydantic
  • 🎯 Model Context Protocol (MCP) support - Connect to GitLab, Jira, databases, and more!

Installation

From PyPI (once published)

pip install agent-smith

From Source (Development)

cd python
pip install -e ".[dev]"

Quick Start

1. Install and Configure

# Install
pip install agent-smith

# Set API key
smith config set anthropic_api_key sk-ant-...

# Or use environment variable
export SMITH_ANTHROPIC_API_KEY=sk-ant-...

2. Run Agent Smith

# Start interactive mode
smith

# Use with specific model
smith --model claude-opus-4-20250514

# Verbose mode
smith --verbose --debug

3. Configuration

Agent Smith follows XDG Base Directory specification:

Linux/macOS:

  • Config: ~/.config/agent-smith/
  • Data: ~/.local/share/agent-smith/
  • Cache: ~/.cache/agent-smith/
  • Logs: ~/.local/state/agent-smith/

Windows:

  • Config: %APPDATA%\agent-smith\
  • Data: %LOCALAPPDATA%\agent-smith\

Configuration Files

~/.config/agent-smith/settings.toml

[default]
default_provider = "anthropic"
large_model = "claude-sonnet-4-5-20250929"
small_model = "claude-3-5-haiku-20241022"
show_cost = true
enable_prompt_caching = true
max_parallel_tools = 10

~/.config/agent-smith/.secrets.toml (gitignored)

[default]
anthropic_api_key = "sk-ant-..."
openai_api_key = "sk-..."

Commands

# Configuration
smith config show              # Show current configuration
smith config set KEY VALUE     # Set configuration value
smith config edit              # Edit config in $EDITOR
smith config path              # Show config paths

# Model Selection
smith model select             # Interactive model selector
smith model list               # List available models

# MCP Server
smith mcp serve                # Run as MCP server for Claude Desktop

# Utilities
smith doctor                   # Run diagnostics
smith version                  # Show version
smith --help                   # Show help

Environment Variables

All settings can be overridden with environment variables using SMITH_ prefix:

export SMITH_DEFAULT_PROVIDER=openai
export SMITH_LARGE_MODEL=gpt-4o
export SMITH_VERBOSE=true
export SMITH_ANTHROPIC_API_KEY=sk-ant-...
export SMITH_OPENAI_API_KEY=sk-...

Development

Setup

# Clone repository
git clone https://github.com/brandonrc/agent-smith.git
cd agent-smith/python

# Install with dev dependencies
pip install -e ".[dev]"

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=agent_smith --cov-report=html

# Run specific test
pytest tests/test_config.py -v

Type Checking

mypy src/agent_smith

Code Formatting

# Format code
black src/ tests/

# Check formatting
black --check src/ tests/

# Lint with ruff
ruff check src/ tests/

MCP (Model Context Protocol) Integration

Agent Smith supports MCP, allowing it to connect to external services and tools.

What is MCP?

MCP is an open standard that enables AI applications to connect to external data sources and tools in a standardized way. Think of it like "USB-C for AI" - one protocol to connect to many services.

Supported MCP Servers

Agent Smith can connect to any MCP-compatible server, including:

  • GitLab - Manage repositories, merge requests, issues
  • Jira - Create and manage tickets, projects, workflows
  • Filesystem - Secure file operations in allowed directories
  • Databases - PostgreSQL, MySQL, SQLite
  • And many more...

Quick Start with MCP

  1. Install Node.js (required for most MCP servers):
# macOS
brew install node

# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
  1. Configure MCP servers in ~/.config/agent-smith/settings.toml:
[mcp]
enabled = true

[mcp.servers.gitlab]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-gitlab"]
env = {
    GITLAB_TOKEN = "glpat-your-token-here",
    GITLAB_URL = "https://gitlab.com"
}
enabled = true
trusted = false  # Will prompt for approval on first use

[mcp.servers.jira]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-jira"]
env = {
    JIRA_URL = "https://your-company.atlassian.net",
    JIRA_EMAIL = "your-email@company.com",
    JIRA_API_TOKEN = "your-api-token"
}
enabled = true
trusted = false
  1. Start Agent Smith - it will prompt you to approve each MCP server on first use

  2. Use MCP tools - Claude can now use GitLab, Jira, etc.:

> "List my open GitLab merge requests"
> "Create a Jira ticket for this bug"
  1. Check MCP status with /mcp command in the REPL

MCP Commands

  • /mcp - Show MCP server status and tool counts
  • /tools - List all available tools (including MCP tools)

Security

  • Server Approval - First-time use requires explicit user approval
  • Trust Management - Approved servers are tracked in ~/.local/share/agent-smith/mcp_trust.json
  • Environment Isolation - Each server runs in its own subprocess
  • Configuration Changes - Reapproval required if server config changes

Available MCP Servers

Find more MCP servers at: https://github.com/modelcontextprotocol/servers

Architecture

src/agent_smith/
β”œβ”€β”€ cli.py              # CLI entry point
β”œβ”€β”€ config/             # Configuration management (dynaconf)
β”œβ”€β”€ mcp/                # MCP integration
β”‚   β”œβ”€β”€ client.py       # MCP client for single server
β”‚   β”œβ”€β”€ manager.py      # Multi-server management
β”‚   β”œβ”€β”€ discovery.py    # Tool discovery and registration
β”‚   └── trust.py        # Security and approval system
β”œβ”€β”€ models/             # Pydantic data models
β”œβ”€β”€ ui/                 # Textual UI components
β”‚   β”œβ”€β”€ app.py          # Main application
β”‚   β”œβ”€β”€ repl.py         # Interactive REPL screen
β”‚   └── help_screen.py  # Help screen
β”œβ”€β”€ tools/              # Tool system (13+ tools)
β”‚   β”œβ”€β”€ bash_tool.py
β”‚   β”œβ”€β”€ file_read_tool.py
β”‚   β”œβ”€β”€ file_write_tool.py
β”‚   β”œβ”€β”€ file_edit_tool.py
β”‚   β”œβ”€β”€ glob_tool.py
β”‚   β”œβ”€β”€ grep_tool.py
β”‚   β”œβ”€β”€ list_tool.py
β”‚   β”œβ”€β”€ agent_tool.py
β”‚   β”œβ”€β”€ think_tool.py
β”‚   β”œβ”€β”€ mcp_tool.py     # MCP tool wrapper
β”‚   └── ...
β”œβ”€β”€ services/           # LLM API clients
β”‚   β”œβ”€β”€ claude.py       # Anthropic Claude
β”‚   └── openai.py       # OpenAI GPT
β”œβ”€β”€ query.py            # Main query orchestration
└── mcp_integration.py  # MCP initialization

About

Ai Helper

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages