Metadata-Version: 2.5
Name: akeyless-agentcore-rta
Version: 0.3.0
Summary: Akeyless Agentic Runtime Authority (RTA/ARA) for AWS Bedrock AgentCore — secretless DB and cloud actions
Project-URL: Homepage, https://github.com/akeyless-community/bedrock-agentcore-akeyless-rta
Project-URL: Repository, https://github.com/akeyless-community/bedrock-agentcore-akeyless-rta
Author: Akeyless Community
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: agentcore,akeyless,ara,aws,bedrock,rta,runtime-authority
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Requires-Python: >=3.10
Requires-Dist: akeyless-cloud-id>=0.3.1
Requires-Dist: akeyless>=5.0.0
Provides-Extra: all
Requires-Dist: azure-identity>=1.15.0; extra == 'all'
Requires-Dist: boto3>=1.28.0; extra == 'all'
Requires-Dist: google-auth>=2.20.0; extra == 'all'
Requires-Dist: mcp<2,>=1.9.0; extra == 'all'
Requires-Dist: requests>=2.31.0; extra == 'all'
Provides-Extra: aws
Requires-Dist: boto3>=1.28.0; extra == 'aws'
Provides-Extra: azure
Requires-Dist: azure-identity>=1.15.0; extra == 'azure'
Provides-Extra: dev
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Provides-Extra: gcp
Requires-Dist: google-auth>=2.20.0; extra == 'gcp'
Requires-Dist: requests>=2.31.0; extra == 'gcp'
Provides-Extra: mcp
Requires-Dist: mcp<2,>=1.9.0; extra == 'mcp'
Description-Content-Type: text/markdown

# Akeyless Agentic Runtime Authority for Amazon Bedrock AgentCore

Python library and Model Context Protocol (MCP) server that gives Amazon Bedrock AgentCore agents access to protected resources through [Akeyless Agentic Runtime Authority (ARA)](https://docs.akeyless.io/docs/agentic-runtime-authority). AI agents can query databases, run actions on AWS, Azure, GCP and Kubernetes, and execute commands on Linux (SSH), Windows (WinRM) and LDAP / Active Directory servers, authenticating to the Akeyless Gateway with their AWS IAM role.

AgentCore orchestrates. Akeyless holds the credentials. **Secret values never enter the agent or the model context.**

## Requirements

- Python 3.10+
- Akeyless **Gateway with ARA enabled** (not `api.akeyless.io`)
- Auth method your AgentCore role can use (production: AWS IAM cloud identity)

## Install (local)

```bash
cd bedrock-agentcore-akeyless-rta
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[mcp,dev]"
```

Cloud identity auth also needs the extra for your provider: `aws` for `aws_iam` (installs `boto3`), `azure` for `azure_ad` (installs `azure-identity`) or `gcp` for `gcp` (installs `google-auth`), for example `pip install -e ".[mcp,aws]"`. The `all` extra installs MCP and every provider. For GCP, set `AKEYLESS_GCP_AUDIENCE` if your auth method does not use the default `akeyless.io`.

## Quick start — client

```python
from akeyless_agentcore_rta import AkeylessRtaClient

client = AkeylessRtaClient()  # reads AKEYLESS_* env
for s in client.list_secrets():
    print(s.name, s.target_type)  # never prints credentials

rows = client.query_db("SELECT 1", secret_name="/prod/db/readonly")
print(rows.results)
```

## Remote commands (SSH, Windows, LDAP)

`service_execute` (MCP: `service-execute`) also runs one non-interactive command on a remote host, with the credentials of the item you name. The Gateway decides how to run it from the item's target type:

| Item | `target_type` in list-secrets | Runs over |
|---|---|---|
| Rotated secret on an SSH target | `ssh` | SSH |
| Rotated secret on a Windows target | `windows` | WinRM |
| Rotated secret on a linked target | `linked` | SSH or WinRM, on one of the linked hosts |
| RDP dynamic secret | `rdp` | SSH or WinRM, as the temporary user |
| LDAP (Active Directory) rotated or dynamic secret | `ldap` | WinRM over HTTPS, as the domain user |
| SSH certificate issuer (`secret_type: ssh-cert-issuer`) | `ssh` | SSH, with a short-lived certificate signed for the call |

```python
out = client.service_execute("uptime", secret_name="/servers/web-ssh")
print(out.results[0]["stdout"], out.results[0]["exit_code"])

out = client.service_execute(
    '{"tool":"run","arguments":{"command":"ls","host":"web1.corp","cwd":"/var/log"}}',
    secret_name="/servers/web-ssh",
)
```

The payload is either a plain command line (`uptime`, `Get-Service`) or a sub-tool call for anything else:

```json
{"tool":"run","arguments":{"command":"systemctl status nginx","host":"web1.corp","cwd":"/var/log"}}
```

- `run` takes `command`, plus optional `host` (required when the item has more than one host; the error lists them), `cwd`, `shell` (`powershell` or `cmd`, WinRM only), `host_key_fingerprint` (`SHA256:<base64>`, SSH only), and `remote_user` (SSH certificate issuers only).
- `upload` (`remote_path`, base64 `content`, at most 512 KB) and `download` (`remote_path`) move one file.
- A run returns `stdout`, `stderr`, `exit_code`, `truncated`, and, when sent with `cwd` or run in PowerShell, the `cwd` the command ended in. Pass that `cwd` back on the next call, so a series of commands behaves like one shell session.
- `list_sub_tools` (MCP: `list-sub-tools`) on a remote item returns this catalog without connecting to the host.

The same ARA gates apply as for databases: `ara_allow_access`, input rules (the Gateway ships default rules per target type), AI validation, output rules, and an ARA session record. Remote commands need Gateway 5.6.0 or later; an older Gateway answers `unsupported secret type`. A remote call can take up to 3.5 minutes on the Gateway.

## Quick start — MCP on AgentCore

```bash
# env (required)
export AKEYLESS_GATEWAY_URL=https://gw.example.com:8000
export AKEYLESS_ACCESS_ID=p-xxxxx
export AKEYLESS_ACCESS_TYPE=aws_iam   # or access_key locally

python examples/mcp-server/server.py
# AgentCore: protocol MCP → examples/mcp-server/server.py
```

The MCP tools (`list-secrets`, `query-db`, `service-execute`, `list-sub-tools`) have the same names, parameters (`secret-name`, `payload`, `agent-id`, `original-user`, `original-prompt`, `auth-code`, `state`), required fields and descriptions as `akeyless mcp-runtime-authority`. The Gateway picks how to run each call from the item type.

## Environment

| Variable | Required | Notes |
|----------|----------|-------|
| `AKEYLESS_GATEWAY_URL` | **Yes** | Customer GW (`https://gw:8000` or `…/api/v2`). Public SaaS rejected. |
| `AKEYLESS_ACCESS_ID` | Yes* | Auth method access id |
| `AKEYLESS_ACCESS_TYPE` | No | Default `aws_iam`. Also: `access_key`, `oidc`, `saml`, `jwt`, … |
| `AKEYLESS_ACCESS_KEY` | For access_key | Local/dev only |
| (OIDC/SAML) | — | Browser login to Gateway; needs Access ID only |
| `AKEYLESS_AGENT_ID` | No | Default `bedrock-agentcore` |
| `AKEYLESS_MCP_ID` | No | Default `akeyless-agentcore-rta` |
| `AKEYLESS_DEFAULT_SECRET_NAME` | No | Optional default path for execute tools |

\* Or `AKEYLESS_TOKEN` for a pre-issued session token.

## Architecture

```mermaid
sequenceDiagram
    participant U as User
    participant C as Claude Desktop
    participant M as akeyless-claude-mcp
    participant A as Akeyless API
    participant G as Akeyless Gateway
    participant L as AI Quorum (LLMs)
    participant R as Database / Cloud

    U->>C: "Query prod postgres for user count"
    C->>M: list-secrets
    M->>A: list-items (authenticated, role-scoped)
    A-->>M: secret paths + target types (no values)
    M-->>C: /prod/db/postgres-ro
    C->>M: query-db (path + SQL)
    M->>G: POST /config/target_query
    Note over G: 1. RBAC: ARA execute permission on path
    Note over G: 2. Input rules (read-only, no multi-statement...)
    alt Input rule violated
        G-->>M: BLOCKED (never reaches target)
    end
    opt AI Quorum enabled
        G->>L: validate action
        L-->>G: verdicts (any deny = block)
        alt Any model denies
            G-->>M: BLOCKED
        end
    end
    Note over G: 3. Fetch JIT/rotated credential (stays in GW)
    G->>R: execute with credential
    R-->>G: raw results
    Note over G: 4. Output rules (PII, secrets...)
    alt Output rule violated
        G-->>M: BLOCKED / redacted
    end
    G-->>M: JSON results (no credentials)
    M-->>C: { count: 42 }
    C-->>U: "There are 42 users"
    Note over G: ARA session recorded for audit
```

## Docs

| Guide | Description |
|-------|-------------|
| [Akeyless setup](docs/AKEYLESS_SETUP.md) | Auth method, ARA RBAC, chicken-and-egg IAM bind |
| [AgentCore deploy](docs/AGENTCORE_DEPLOY.md) | MCP protocol, envVars, invoke |
| [Security](SECURITY.md) | Checklist |
| [Maintainer guide](docs/MAINTAINER.md) | Branch protection, approvals, PyPI environment |
| [Publishing to PyPI](docs/PYPI_PUBLISHING.md) | Trusted publishing setup |
| [Contributing](CONTRIBUTING.md) | Development setup |

**Repository:** [github.com/akeyless-community/bedrock-agentcore-akeyless-rta](https://github.com/akeyless-community/bedrock-agentcore-akeyless-rta)

## Development

```bash
pip install -e ".[mcp,dev]"
pytest
```

Run pytest **inside this package directory** so the workspace root does not collect unrelated tests.

## Related

- Secrets at runtime (values in agent): [`akeyless-agentcore-runtime`](https://github.com/akeyless-community/bedrock-agentcore-akeyless-runtime)
- Product docs: [Agentic Runtime Authority](https://docs.akeyless.io/docs/agentic-runtime-authority)
