Skip to main content

amcp: Lego-style coding agent CLI. Core: rg grep/find and read; editing & web search via MCP.

Project description

AMCP

PyPI version CI Python 3.11+ License: Apache-2.0

tags:

  • building-mcp-track-creative
  • mcp-in-action-track-consumer
  • mcp-in-action-track-creative

AMCP

A Lego-style coding agent CLI with built-in tools (grep, read files, bash execution) and MCP server integration for extended capabilities (web search, etc.).

X: https://x.com/zhangjintao9020/status/1995170132973466018?s=20 Demo: https://drive.google.com/file/d/1FGoY4I_JFQ1FSz19XlVJZ6Z4lWUucD7a/view?usp=sharing

Features

  • Built-in Tools: read_file, grep, bash, think, todo, write_file, edit_file
  • MCP Integration: Connect to any MCP server for extended capabilities
  • Conversation History: Persistent sessions across runs
  • Flexible Configuration: YAML-based agent specifications
  • Tool Calling: Automatic tool selection and execution
  • ACP Support: Full Agent Client Protocol support for IDE integration (Zed, etc.)
  • AGENTS.md Support: Auto-load project-specific rules from AGENTS.md files
  • Smart Context Compaction: Intelligent context management with dynamic thresholds
  • Multi-Agent System: Primary/Subagent architecture with built-in agent types (coder, explorer, planner)
  • Event Bus: Publish/subscribe system for agent communication and extensibility
  • Hooks System: Extensible hooks for tool validation, logging, and custom behaviors

Installation

Quick Run with uvx (no install needed)

# Run directly without installation (like npx)
uvx amcp-agent

From PyPI

# Install from PyPI
pip install amcp-agent

# Or with uv
uv pip install amcp-agent

# With Anthropic Claude support
pip install amcp-agent[anthropic]

From Source (development)

# Clone the repository
git clone https://github.com/tao12345666333/amcp.git
cd amcp

# using uv (recommended)
uv venv && source .venv/bin/activate
uv pip install -e .

# or with pip
python -m venv .venv && source .venv/bin/activate
pip install -e .

Usage

# Initialize config
amcp init

# Agent with tool calling (default command)
amcp  # interactive mode with conversation history
amcp --once "create a hello.py file with a hello function"  # single message
amcp --list  # list available agent specifications
amcp --agent path/to/agent.yaml  # use custom agent spec
amcp --session my-session  # use specific session ID
amcp --clear  # clear conversation history

# MCP server management
amcp mcp tools --server exa
amcp mcp call --server exa --tool web_search_exa --args '{"query":"rust async"}'

# Run as ACP agent (for IDE integration)
amcp-acp

ACP (Agent Client Protocol) Support

AMCP fully supports the Agent Client Protocol for integration with IDEs like Zed.

Features

  • Session Management: Create, load, and list sessions
  • Session Modes: Switch between ask, architect, and code modes
    • ask: Request permission before making changes
    • architect: Design and plan without implementation
    • code: Full tool access for implementation
  • Slash Commands: /clear, /plan, /search, /help
  • Agent Plans: Visual execution plans for complex tasks
  • Permission Requests: User approval for sensitive operations
  • Client Capabilities: Use client's filesystem and terminal when available

Running as ACP Agent

# Start the ACP agent server (stdio transport)
amcp-acp

Zed Integration

Add to your Zed settings (~/.config/zed/settings.json):

{
  "agent": {
    "profiles": {
      "amcp": {
        "name": "AMCP",
        "provider": {
          "type": "acp",
          "command": "amcp-acp"
        }
      }
    },
    "default_profile": "amcp"
  }
}

Built-in Tools

  • read_file: Read text files from the workspace
  • grep: Search for patterns in files using ripgrep
  • bash: Execute bash commands for file operations and system tasks
  • think: Internal reasoning and planning
  • todo: Manage a todo list to track tasks during complex operations
  • write_file: Write content to files (can be disabled via config)
  • edit_file: Edit files with search and replace (can be disabled via config)
  • task: Spawn sub-agents for parallel task execution

Config

The CLI loads MCP servers from ~/.config/amcp/config.toml. Generate a starter config:

amcp init

Example (OpenAI-compatible API):

[servers.exa]
url = "https://mcp.exa.ai/mcp"

[servers.custom]
command = "npx"
args = ["-y", "@some/mcp-server"]
env.API_KEY = "your-key"

[chat]
api_type = "openai"  # "openai" (default) or "anthropic"
base_url = "https://api.openai.com/v1"
model = "gpt-4o"
api_key = "your-api-key"
mcp_tools_enabled = true
write_tool_enabled = true  # Enable/disable built-in write_file tool
edit_tool_enabled = true   # Enable/disable built-in edit_file tool

Example (OpenAI Responses API):

[chat]
api_type = "openai_responses"
model = "gpt-4o"
api_key = "your-api-key"

Example (Anthropic Claude):

[chat]
api_type = "anthropic"
model = "claude-sonnet-4-20250514"
api_key = "your-anthropic-api-key"  # or set ANTHROPIC_API_KEY env var

To use Anthropic, install with: pip install amcp-agent[anthropic]

Hooks System

AMCP provides a flexible hooks system to extend and customize agent behavior. Hooks can:

  • Validate and modify tool inputs before execution
  • Process tool outputs after execution
  • Block dangerous operations
  • Log and audit agent activities

Quick Example

Create .amcp/hooks.toml in your project:

[hooks.PreToolUse]
[[hooks.PreToolUse.handlers]]
matcher = "write_file|edit_file"
type = "python"
script = "./scripts/validate-writes.py"
timeout = 30

[[hooks.PostToolUse.handlers]]
matcher = "*"
type = "command"
command = "echo 'Tool executed' >> /tmp/tool_log.txt"

See docs/hooks.md for full documentation.

Development

Setup Development Environment

# Clone the repository
git clone <repo-url>
cd AMCP

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

# Install pre-commit hooks
pre-commit install

Running Tests

# Run all tests
make test

# Run with coverage
make test-cov

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

Code Quality

# Lint code
make lint

# Format code
make format

# Type check
make type-check

See CONTRIBUTING.md for detailed development guidelines.

Notes

  • rg (ripgrep) must be installed and on PATH for the grep tool.
  • MCP servers must be installed separately and runnable (stdio transport).

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amcp_agent-0.5.0.tar.gz (84.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amcp_agent-0.5.0-py3-none-any.whl (95.9 kB view details)

Uploaded Python 3

File details

Details for the file amcp_agent-0.5.0.tar.gz.

File metadata

  • Download URL: amcp_agent-0.5.0.tar.gz
  • Upload date:
  • Size: 84.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for amcp_agent-0.5.0.tar.gz
Algorithm Hash digest
SHA256 39f41cb6f7d03c4facf3e5e67f0f27f36839b7d13c83375ed32defb2e44f409a
MD5 89d45debe748e35b7d28febb10509783
BLAKE2b-256 185531c7fd792aea0a1b052128bc9b20212b4921db6f5bc6a9cc23c1ae872bea

See more details on using hashes here.

Provenance

The following attestation bundles were made for amcp_agent-0.5.0.tar.gz:

Publisher: release.yml on tao12345666333/amcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amcp_agent-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: amcp_agent-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 95.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for amcp_agent-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38682cd0f2fa99c8b25baa8cf9da57ec79d9b772ce9359f06e20bc8a0c8766bf
MD5 6f8ec4513085cb3407abb3d0e810bfb9
BLAKE2b-256 dc2991a0520f463833cfa1c98cbcc92a624f4243cbca47c2a9a757a72e9fa289

See more details on using hashes here.

Provenance

The following attestation bundles were made for amcp_agent-0.5.0-py3-none-any.whl:

Publisher: release.yml on tao12345666333/amcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page