Skip to content

ambient-code/mcp

Repository files navigation

MCP ACP Server

A Model Context Protocol (MCP) server for managing Ambient Code Platform (ACP) sessions on OpenShift/Kubernetes clusters.

Based on template-agent


Quick Start

Get started in 5 minutes:

# Install
git clone https://github.com/ambient-code/mcp
claude mcp add mcp-acp -t stdio mcp/mcp-acp-v0.1.0/mcp_acp-0.1.0-py3-none-any.whl

# Configure
mkdir -p ~/.config/acp
cat > ~/.config/acp/clusters.yaml <<EOF
clusters:
  my-cluster:
    server: https://api.your-cluster.example.com:443
    default_project: my-workspace
default_cluster: my-cluster
EOF

# Authenticate
oc login --server=https://api.your-cluster.example.com:443

# Add to Claude Desktop config
{
  "mcpServers": {
    "acp": {
      "command": "mcp-acp"
    }
  }
}

First Command: Use acp_whoami to check my authentication


Overview

This MCP server provides 27 comprehensive tools for interacting with the Ambient Code Platform, enabling:

  • Session Management: List, create, delete, restart, clone sessions
  • Label Management: Tag and organize sessions with custom labels
  • Bulk Operations: Efficiently manage multiple sessions at once
  • Advanced Filtering: Filter by status, age, display name, labels, and more
  • Debugging: Retrieve logs, transcripts, and metrics
  • Cluster Management: Multi-cluster support with easy switching
  • Safety First: Dry-run mode on all mutating operations

Security: This server implements comprehensive security measures including input validation, command injection prevention, timeout controls, and resource limits. See SECURITY.md for details.


Features

Session Management

  • acp_list_sessions: Enhanced filtering by status, display name, age, labels, and sorting
  • acp_delete_session: Delete sessions with dry-run preview
  • acp_restart_session: Restart stopped sessions
  • acp_clone_session: Clone existing session configurations
  • acp_create_session_from_template: Create sessions from predefined templates
  • acp_update_session: Update session metadata

Label Management

  • acp_label_resource: Add labels to sessions or other resources
  • acp_unlabel_resource: Remove labels from resources
  • acp_bulk_label_resources: Label multiple resources (max 3 with confirmation)
  • acp_bulk_unlabel_resources: Remove labels from multiple resources
  • acp_list_sessions_by_label: List sessions matching label selectors

Bulk Operations

  • acp_bulk_delete_sessions: Delete multiple sessions with confirmation
  • acp_bulk_stop_sessions: Stop multiple running sessions with confirmation
  • acp_bulk_delete_sessions_by_label: Delete sessions by label selector
  • acp_bulk_stop_sessions_by_label: Stop sessions by label selector
  • acp_bulk_restart_sessions: Restart multiple sessions (max 3)
  • acp_bulk_restart_sessions_by_label: Restart sessions by label selector

Debugging & Monitoring

  • acp_get_session_logs: Retrieve container logs for debugging
  • acp_get_session_transcript: Retrieve conversation history
  • acp_get_session_metrics: Get usage statistics and analytics
  • acp_export_session: Export session data for archival

Cluster Management

  • acp_list_clusters: List configured cluster aliases
  • acp_whoami: Check authentication status
  • acp_login: Web-based authentication flow
  • acp_switch_cluster: Switch between configured clusters
  • acp_add_cluster: Add new cluster configurations

Workflows

  • acp_list_workflows: Discover available workflows

Safety Features:

  • Dry-Run Mode: All mutating operations support a dry_run parameter for safe preview before executing
  • Bulk Operation Limits: Maximum 3 items per bulk operation with confirmation requirement
  • Label Format: acp.ambient-code.ai/label-{key}={value} for Kubernetes compatibility

Installation

From PyPI (when published)

From Source

git clone https://github.com/ambient-code/mcp
claude mcp add mcp-acp -t stdio mcp/mcp_acp-0.1.0-py3-none-any.whl

Requirements:

  • Python 3.10+
  • OpenShift CLI (oc) installed and in PATH
  • Access to an OpenShift cluster with ACP

See USAGE_GUIDE.md for detailed installation instructions.


Configuration

1. Create Cluster Configuration

Create ~/.config/acp/clusters.yaml:

clusters:
  vteam-stage:
    server: https://api.vteam-stage.xxxx.p3.openshiftapps.com:443
    description: "V-Team Staging Environment"
    default_project: jeder-workspace

  vteam-prod:
    server: https://api.vteam-prod.xxxx.p3.openshiftapps.com:443
    description: "V-Team Production"
    default_project: jeder-workspace

default_cluster: vteam-stage

2. Configure MCP Client

For Claude Desktop, edit your configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json Linux: ~/.config/claude/claude_desktop_config.json

Add the ACP server:

{
  "mcpServers": {
    "acp": {
      "command": "mcp-acp",
      "args": [],
      "env": {
        "ACP_CLUSTER_CONFIG": "${HOME}/.config/acp/clusters.yaml"
      }
    }
  }
}

3. Authenticate with OpenShift

oc login --server=https://api.your-cluster.example.com:443

Usage Examples

List Sessions with Filtering

# List only running sessions
acp_list_sessions(project="my-workspace", status="running")

# List sessions older than 7 days
acp_list_sessions(project="my-workspace", older_than="7d")

# List sessions by label
acp_list_sessions(project="my-workspace", label_selector="env=test,team=qa")

# List sessions sorted by creation date
acp_list_sessions(project="my-workspace", sort_by="created", limit=20)

Label Management

# Add labels to a session
acp_label_resource(
    resource_type="agenticsession",
    name="my-session",
    project="my-workspace",
    labels={"env": "test", "team": "qa"}
)

# List sessions by label
acp_list_sessions_by_label(
    project="my-workspace",
    labels={"env": "test"}
)

# Bulk delete sessions by label
acp_bulk_delete_sessions_by_label(
    project="my-workspace",
    label_selector="env=test",
    dry_run=True  # Preview first
)

Delete Session with Dry-Run

# Preview what would be deleted
acp_delete_session(project="my-workspace", session="test-session", dry_run=True)

# Actually delete
acp_delete_session(project="my-workspace", session="test-session")

Bulk Operations

# Stop multiple sessions
acp_bulk_stop_sessions(
    project="my-workspace",
    sessions=["session-1", "session-2", "session-3"]
)

# Delete old sessions with dry-run
acp_bulk_delete_sessions(
    project="my-workspace",
    sessions=["old-session-1", "old-session-2"],
    dry_run=True
)

Get Session Logs

# Get logs from runner container
acp_get_session_logs(
    project="my-workspace",
    session="debug-session",
    container="runner",
    tail_lines=100
)

See USAGE_GUIDE.md for 40+ detailed examples and workflow patterns.


Tool Reference

For complete API specifications, see API_REFERENCE.md.

Quick Reference

Category Tool Description
Session acp_list_sessions List/filter sessions with advanced options
acp_delete_session Delete session with dry-run support
acp_restart_session Restart stopped sessions
acp_clone_session Clone session configuration
acp_update_session Update session metadata
Labels acp_label_resource Add labels to sessions
acp_unlabel_resource Remove labels from sessions
acp_list_sessions_by_label Find sessions by label
Bulk Ops acp_bulk_delete_sessions Delete multiple sessions (max 3)
acp_bulk_stop_sessions Stop multiple sessions (max 3)
acp_bulk_restart_sessions Restart multiple sessions (max 3)
acp_bulk_delete_sessions_by_label Delete sessions by label
Debug acp_get_session_logs Get container logs
acp_get_session_transcript Get conversation history
acp_get_session_metrics Get usage statistics
acp_export_session Export session data
Cluster acp_list_clusters List configured clusters
acp_whoami Check authentication status
acp_login Authenticate to cluster
acp_switch_cluster Switch cluster context
acp_add_cluster Add cluster to config
Workflows acp_list_workflows Discover available workflows
acp_create_session_from_template Create from template

Architecture

The server is built using:

  • MCP SDK: Standard MCP protocol implementation
  • OpenShift CLI: Underlying oc commands for ACP operations
  • Async I/O: Non-blocking operations for performance
  • YAML Configuration: Flexible cluster management

See ARCHITECTURE.md for complete system design.


Security

This server implements defense-in-depth security:

  • Input Validation: DNS-1123 format validation for all resource names
  • Command Injection Prevention: Secure subprocess execution (never shell=True)
  • Resource Exhaustion Protection: Timeouts and limits on all operations
  • Secure Temporary Files: Random prefixes, 0600 permissions
  • Path Traversal Prevention: Configuration and workflow file validation
  • Resource Type Whitelist: Only agenticsession, pods, event resources
  • Sensitive Data Filtering: Tokens/passwords removed from logs

See SECURITY.md for complete security documentation.


Development

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=src/mcp_acp --cov-report=html

# Run security tests
pytest tests/test_security.py -v

Code Quality

# Format code
black src/ tests/
ruff check src/ tests/

# Type checking
mypy src/

# All checks
make check

See DEVELOPMENT.md for contributing guidelines.


Documentation


Roadmap

Current implementation provides all planned features (19 tools). Future enhancements may include:

  • Rate Limiting: Per-client request limits for HTTP exposure
  • Audit Logging: Structured audit trail and SIEM integration
  • Enhanced Authentication: OAuth2/OIDC support, MFA
  • Network Security: mTLS for MCP transport, certificate pinning
  • Advanced Metrics: Cost analysis, performance tracking

See the GitHub issue tracker for planned features and community requests.


Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass (pytest)
  5. Ensure code quality checks pass (make check)
  6. Submit a pull request

See DEVELOPMENT.md for detailed guidelines.


License

MIT License - See LICENSE file for details


Support

For issues and feature requests, please use the GitHub issue tracker.

For usage questions, see:


Status

Code: ✅ Production-Ready Tests: ✅ All Passing (13/13 security tests) Documentation: ✅ Complete Security: ✅ Hardened with defense-in-depth Tools: ✅ 27 tools fully implemented Features: ✅ Label management, bulk operations, advanced filtering

Ready for production use 🚀

About

MCP server for ACP (Ambient Code Platform)

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •