updsts 0.8.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- updsts-0.8.9/.claude/CLAUDE.md +1 -0
- updsts-0.8.9/.claude/settings.local.json +5 -0
- updsts-0.8.9/.claude-plugin/plugin.json +10 -0
- updsts-0.8.9/.gitignore +18 -0
- updsts-0.8.9/.mcp.json +13 -0
- updsts-0.8.9/.python-version +1 -0
- updsts-0.8.9/.vscode/launch.json +56 -0
- updsts-0.8.9/.vscode/mcp.json +19 -0
- updsts-0.8.9/.vscode/settings.json +17 -0
- updsts-0.8.9/.vscode/task.json +6 -0
- updsts-0.8.9/AGENTS.md +89 -0
- updsts-0.8.9/LICENSE +21 -0
- updsts-0.8.9/PKG-INFO +268 -0
- updsts-0.8.9/README.md +257 -0
- updsts-0.8.9/README_ja.md +257 -0
- updsts-0.8.9/pyproject.toml +62 -0
- updsts-0.8.9/pytest.ini +15 -0
- updsts-0.8.9/src/updsts/__init__.py +1 -0
- updsts-0.8.9/src/updsts/__main__.py +71 -0
- updsts-0.8.9/src/updsts/awsutil.py +308 -0
- updsts-0.8.9/src/updsts/cmd_handler.py +81 -0
- updsts-0.8.9/src/updsts/cmdparam.py +90 -0
- updsts-0.8.9/src/updsts/logutil.py +109 -0
- updsts-0.8.9/src/updsts/mcp_impl.py +102 -0
- updsts-0.8.9/src/updsts/mcp_server.py +147 -0
- updsts-0.8.9/src/updsts/py.typed +0 -0
- updsts-0.8.9/src/updsts/upcred.py +177 -0
- updsts-0.8.9/src/updsts_main.py +19 -0
- updsts-0.8.9/test/README.md +190 -0
- updsts-0.8.9/test/__init__.py +5 -0
- updsts-0.8.9/test/conftest.py +82 -0
- updsts-0.8.9/test/run_all_tests.py +35 -0
- updsts-0.8.9/test/run_pytest.py +43 -0
- updsts-0.8.9/test/test_awsutil.py +144 -0
- updsts-0.8.9/test/test_cmd_handler.py +183 -0
- updsts-0.8.9/test/test_integration.py +216 -0
- updsts-0.8.9/test/test_main.py +194 -0
- updsts-0.8.9/test/test_upcred.py +240 -0
- updsts-0.8.9/updsts.code-workspace +8 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@../AGENTS.md
|
updsts-0.8.9/.gitignore
ADDED
updsts-0.8.9/.mcp.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
// プラグインデバッグ用
|
|
5
|
+
{
|
|
6
|
+
"name": "Python Plugin Debug (Attach)",
|
|
7
|
+
"type": "debugpy",
|
|
8
|
+
"request": "attach",
|
|
9
|
+
"connect": {
|
|
10
|
+
"host": "localhost", // replace this with remote machine name
|
|
11
|
+
"port": 5678
|
|
12
|
+
},
|
|
13
|
+
"justMyCode": false
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "Python debug current file",
|
|
17
|
+
"type": "debugpy",
|
|
18
|
+
"request": "launch",
|
|
19
|
+
"program": "${file}",
|
|
20
|
+
"console" : "integratedTerminal",
|
|
21
|
+
// "stopOnEntry": true,
|
|
22
|
+
"env": {
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Python: 'updsts'",
|
|
28
|
+
"type": "debugpy",
|
|
29
|
+
"request": "launch",
|
|
30
|
+
"module": "updsts",
|
|
31
|
+
"args": [
|
|
32
|
+
|
|
33
|
+
],
|
|
34
|
+
"console": "integratedTerminal",
|
|
35
|
+
// "stopOnEntry": true,
|
|
36
|
+
"env": {
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "Python: 'updsts help'",
|
|
42
|
+
"type": "debugpy",
|
|
43
|
+
"request": "launch",
|
|
44
|
+
"module": "updsts",
|
|
45
|
+
"args": [
|
|
46
|
+
"-h",
|
|
47
|
+
],
|
|
48
|
+
"console": "integratedTerminal",
|
|
49
|
+
// "stopOnEntry": true,
|
|
50
|
+
"env": {
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"compounds": []
|
|
56
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
// 単体テストツールとしてpytestを有効化
|
|
3
|
+
"python.testing.pytestEnabled": true,
|
|
4
|
+
// ファイル保存時にテスト対象コードを自動的に探索
|
|
5
|
+
"python.testing.autoTestDiscoverOnSaveEnabled": true,
|
|
6
|
+
"python.testing.pytestArgs": [
|
|
7
|
+
"test"
|
|
8
|
+
],
|
|
9
|
+
"python.testing.unittestEnabled": false,
|
|
10
|
+
"python-envs.pythonProjects": [
|
|
11
|
+
{
|
|
12
|
+
"path": ".",
|
|
13
|
+
"envManager": "ms-python.python:venv",
|
|
14
|
+
"packageManager": "ms-python.python:pip"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
}
|
updsts-0.8.9/AGENTS.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# updsts project
|
|
2
|
+
|
|
3
|
+
既存の AWS プロファイルと MFA の TOTP トークンから一時的な STS 認証情報を取得し、AWS の credentials ファイルを更新する CUI ツール兼ローカル MCP サーバー。
|
|
4
|
+
MCP 経由で操作される前提のため、アクセスキーやシークレットキーなどの秘密情報をマスクせずに LLM 側へ返さないことを設計上の原則としている。
|
|
5
|
+
|
|
6
|
+
## 技術スタック
|
|
7
|
+
|
|
8
|
+
- Python 3.12 以上、パッケージ管理は uv、ビルドは hatchling
|
|
9
|
+
- 主な依存: `boto3`(STS の `get_session_token`)、`fastmcp`(MCP サーバー)、`pydantic`
|
|
10
|
+
- テスト: pytest(マーカー: `slow` / `integration` / `unit` / `aws`。AWS 呼び出しはモック)
|
|
11
|
+
|
|
12
|
+
## ディレクトリ構成
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
src/updsts/
|
|
16
|
+
__main__.py CLI エントリポイント(main)。引数解析と例外のメッセージ化
|
|
17
|
+
cmdparam.py argparse のサブコマンド定義(get / list / mcp)
|
|
18
|
+
cmd_handler.py サブコマンドのハンドラ
|
|
19
|
+
awsutil.py 業務ロジック: credentials ファイルの読み込み、STS トークン取得、マスク処理
|
|
20
|
+
upcred.py CredentialUpdater: credentials ファイルの該当ブロックを書き換える
|
|
21
|
+
logutil.py ロガー(コンソール出力は stderr。MCP の stdio を汚さないため)
|
|
22
|
+
mcp_server.py FastMCP のツール定義(薄いラッパー)
|
|
23
|
+
mcp_impl.py MCP ツールの実装、例外を ValueError に揃える共通処理
|
|
24
|
+
src/updsts_main.py Claude プラグイン用の MCP 起動スクリプト(PEP 723 のインライン依存を持つ)
|
|
25
|
+
test/ モジュールごとの pytest
|
|
26
|
+
.claude-plugin/ Claude Code プラグインのマニフェスト
|
|
27
|
+
.mcp.json プラグイン用 MCP サーバー設定(uv run src/updsts_main.py mcp --mcp-server)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
処理の流れは、CLI なら `__main__.py` → `cmd_handler.py` → `awsutil.py` → `upcred.py`、MCP なら `mcp_server.py` → `mcp_impl.py` → `awsutil.py` → `upcred.py` となる。
|
|
31
|
+
|
|
32
|
+
## CLI
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
updsts get -n <profile> -t <totp_token> # STS 認証情報を取得して credentials ファイルを更新
|
|
36
|
+
updsts get -n <profile> -t <totp> -sn <sts_profile> # 書き込み先のプロファイル名を指定(既定は <profile>_sts)
|
|
37
|
+
updsts get -n <profile> -t <totp> -d 7200 # 有効期間(秒)を指定(既定は 3600)
|
|
38
|
+
updsts list # プロファイル一覧(秘密情報はマスク表示)
|
|
39
|
+
updsts mcp --mcp-server # MCP サーバーとして起動(オプションなしならツール一覧を表示)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
共通オプションは `-v, --verbose`(0: 通常、1: 詳細、2: デバッグ)と `-c, --credential_file`。
|
|
43
|
+
|
|
44
|
+
## MCP ツール
|
|
45
|
+
|
|
46
|
+
| ツール | 内容 |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `updsts_update_sts_credential` | TOTP トークンで STS 認証情報を取得し、credentials ファイルを更新 |
|
|
49
|
+
| `updsts_get_credential_info` | 指定プロファイルの情報(秘密情報はマスク済み) |
|
|
50
|
+
| `updsts_get_credential_info_list` | 全プロファイルの情報(秘密情報はマスク済み) |
|
|
51
|
+
|
|
52
|
+
各ツールの `cred_file` と `sts_profile_name` は、空文字列なら既定値を使う。
|
|
53
|
+
TOTP トークンは mktotp などで生成する前提で、プロファイルの `totp_secret_name` がその対応付けに使われる。
|
|
54
|
+
|
|
55
|
+
## credentials ファイル
|
|
56
|
+
|
|
57
|
+
- 既定の場所は `~/.aws/credentials`
|
|
58
|
+
- 元になるプロファイルには `aws_access_key_id` / `aws_secret_access_key` / `mfa_device_arn` が必要。`totp_secret_name` は任意
|
|
59
|
+
- 取得した STS 認証情報は、次のタグで囲まれたブロックを丸ごと書き換える。`key` は元のプロファイル名。ブロックがなければ末尾に追加する
|
|
60
|
+
|
|
61
|
+
```ini
|
|
62
|
+
# ${{{ key=<profile> [auto update by updsts]
|
|
63
|
+
[<profile>_sts]
|
|
64
|
+
aws_access_key_id=...
|
|
65
|
+
aws_secret_access_key=...
|
|
66
|
+
aws_session_token=...
|
|
67
|
+
expiration_datetime=...
|
|
68
|
+
# $}}} [auto update by updsts]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- 書き換えは `.tmp` に書いてから置き換える。元ファイルの権限を引き継ぐ
|
|
72
|
+
- `expiration_datetime` はローカルタイムゾーンの ISO 8601 形式
|
|
73
|
+
- プロキシは環境変数 `http_proxy` / `https_proxy` から読む
|
|
74
|
+
- ログファイルは `~/.awscm/log/awscm.log`
|
|
75
|
+
|
|
76
|
+
## 開発
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
uv sync # 依存のインストール
|
|
80
|
+
uv run pytest # テスト実行
|
|
81
|
+
uv run updsts --help # ローカル実行
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 変更時の注意
|
|
85
|
+
|
|
86
|
+
- MCP ツールの戻り値やログに秘密情報を生の値で含めない。`get_profile_info` / `get_profile_list` を MCP から呼ぶときは `secret_mask=True` を渡す
|
|
87
|
+
- ログは stderr に出す。stdout は MCP の stdio 通信に使われる
|
|
88
|
+
- 依存を変えるときは `pyproject.toml` と `src/updsts_main.py` のインライン依存の両方を更新する
|
|
89
|
+
- バージョンは `pyproject.toml` と `.claude-plugin/plugin.json` の両方にある
|
updsts-0.8.9/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 kanok-one
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
updsts-0.8.9/PKG-INFO
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: updsts
|
|
3
|
+
Version: 0.8.9
|
|
4
|
+
Summary: Get and update AWS STS credential using existing AWS profile.
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Requires-Dist: boto3>=1.40.39
|
|
8
|
+
Requires-Dist: fastmcp>=2.12.4
|
|
9
|
+
Requires-Dist: pydantic>=2.11.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# updsts
|
|
13
|
+
|
|
14
|
+
A simple CUI tool and local MCP server for reflecting AWS STS credentials into the credentials file
|
|
15
|
+
|
|
16
|
+
English | [日本語](README_ja.md)
|
|
17
|
+
|
|
18
|
+
<!-- TOC tocDepth:2..3 chapterDepth:2..6 -->
|
|
19
|
+
|
|
20
|
+
- [updsts](#updsts)
|
|
21
|
+
- [1. Overview](#1-overview)
|
|
22
|
+
- [2. Features](#2-features)
|
|
23
|
+
- [3. Runtime Environment](#3-runtime-environment)
|
|
24
|
+
- [4. Installation/Usage](#4-installationusage)
|
|
25
|
+
- [4-1. Install as a uv tool](#4-1-install-as-a-uv-tool)
|
|
26
|
+
- [4-1-1. Installation](#4-1-1-installation)
|
|
27
|
+
- [4-1-2. Registering as an MCP server](#4-1-2-registering-as-an-mcp-server)
|
|
28
|
+
- [4-2. Registering as an MCP server via the Claude plugin](#4-2-registering-as-an-mcp-server-via-the-claude-plugin)
|
|
29
|
+
- [5. CUI Tool Command Options](#5-cui-tool-command-options)
|
|
30
|
+
- [5-1. Common Options](#5-1-common-options)
|
|
31
|
+
- [5-2. `get` Command](#5-2-get-command)
|
|
32
|
+
- [5-3. `list` Command](#5-3-list-command)
|
|
33
|
+
- [5-4. `mcp` Command](#5-4-mcp-command)
|
|
34
|
+
- [6. Credentials File](#6-credentials-file)
|
|
35
|
+
- [6-1. Credentials File Format](#6-1-credentials-file-format)
|
|
36
|
+
- [6-2. Credentials File Location](#6-2-credentials-file-location)
|
|
37
|
+
- [7. Available MCP Tools](#7-available-mcp-tools)
|
|
38
|
+
- [`updsts_update_sts_credential`](#updsts_update_sts_credential)
|
|
39
|
+
- [`updsts_get_credential_info`](#updsts_get_credential_info)
|
|
40
|
+
- [`updsts_get_credential_info_list`](#updsts_get_credential_info_list)
|
|
41
|
+
- [8. Security Notes](#8-security-notes)
|
|
42
|
+
- [9. License](#9-license)
|
|
43
|
+
|
|
44
|
+
<!-- /TOC -->
|
|
45
|
+
|
|
46
|
+
## 1. Overview
|
|
47
|
+
|
|
48
|
+
updsts is a command-line tool that retrieves AWS STS (Security Token Service) credentials using the credentials already registered in an existing credentials file (~/.aws/credentials). The retrieved credentials are automatically reflected in the same file.
|
|
49
|
+
It also works as a local MCP server that automatically updates the temporary credentials in the credentials file, so it can be operated from common Agent tools.
|
|
50
|
+
|
|
51
|
+
## 2. Features
|
|
52
|
+
|
|
53
|
+
- Obtain temporary AWS STS credentials using MFA authentication
|
|
54
|
+
- Automatically update the STS profile in the credentials file with the new credentials
|
|
55
|
+
- Support for TOTP-based MFA devices
|
|
56
|
+
- List all AWS profiles in the credentials file
|
|
57
|
+
- Leave profiles other than the one being updated untouched
|
|
58
|
+
- Can be operated from common Agent tools when running as a local MCP server
|
|
59
|
+
(Of course, care is taken to ensure that confidential information such as secret keys and session tokens is not sent to the LLM.)
|
|
60
|
+
- Support for proxy environments
|
|
61
|
+
|
|
62
|
+
## 3. Runtime Environment
|
|
63
|
+
|
|
64
|
+
This project uses uv as the package manager.
|
|
65
|
+
Using uv allows you to reproduce the runtime environment automatically.
|
|
66
|
+
|
|
67
|
+
For how to install uv, see:
|
|
68
|
+
|
|
69
|
+
- [Installing uv](https://docs.astral.sh/uv/getting-started/installation/)
|
|
70
|
+
|
|
71
|
+
## 4. Installation/Usage
|
|
72
|
+
|
|
73
|
+
### 4-1. Install as a uv tool
|
|
74
|
+
|
|
75
|
+
Install updsts into a uv environment and use it.
|
|
76
|
+
Use this method when you use updsts as a CUI tool.
|
|
77
|
+
|
|
78
|
+
#### 4-1-1. Installation
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Install directly from git repository
|
|
82
|
+
uv tool install git+{repository_url}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
After installation, you can run the `updsts` command directly.
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
updsts --help
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### 4-1-2. Registering as an MCP server
|
|
92
|
+
|
|
93
|
+
By registering updsts as an MCP server, you can operate it from common Agent tools.
|
|
94
|
+
|
|
95
|
+
```jsonc
|
|
96
|
+
{
|
|
97
|
+
// Example configuration for registering as an MCP server
|
|
98
|
+
//
|
|
99
|
+
// (Note)
|
|
100
|
+
// Registration keys may differ depending on the Agent tool used,
|
|
101
|
+
// so please refer to the manual of the Agent tool you use for detailed procedures.
|
|
102
|
+
"mcpServers": {
|
|
103
|
+
// Configuration for starting updsts as an MCP server using uv
|
|
104
|
+
"updsts-uv": {
|
|
105
|
+
"type": "stdio",
|
|
106
|
+
"command": "updsts",
|
|
107
|
+
"args": [
|
|
108
|
+
"mcp",
|
|
109
|
+
"--mcp-server"
|
|
110
|
+
],
|
|
111
|
+
"env": {}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 4-2. Registering as an MCP server via the Claude plugin
|
|
118
|
+
|
|
119
|
+
updsts can be installed as a Claude plugin.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Add the marketplace
|
|
123
|
+
/plugin marketplace add zv-louis/zv-plugin-marketplace
|
|
124
|
+
# Install from the marketplace
|
|
125
|
+
/plugin install updsts-mcp@zv-plugins
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 5. CUI Tool Command Options
|
|
129
|
+
|
|
130
|
+
### 5-1. Common Options
|
|
131
|
+
|
|
132
|
+
- `-v, --verbose LEVEL`: Set the output verbosity (0: normal, 1: verbose, 2: debug)
|
|
133
|
+
- `-c, --credential_file FILE`: Path to the credentials file (default: ~/.aws/credentials)
|
|
134
|
+
|
|
135
|
+
### 5-2. `get` Command
|
|
136
|
+
|
|
137
|
+
Get and update the STS credentials for the specified AWS profile.
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
updsts get -n <profile_name> -t <totp_token>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
- `-n, --profile_name`: AWS profile name to get the STS token for (required)
|
|
144
|
+
- `-t, --totp_token`: TOTP token generated by the MFA device (required)
|
|
145
|
+
- `-sn, --sts_profile_name`: STS profile name to create in the credentials file (optional, default: AWS profile name + "_sts")
|
|
146
|
+
- `-d, --duration`: Token duration in seconds (optional, default: 3600)
|
|
147
|
+
- `-c, --credential_file`: Path to the credentials file (optional, default: ~/.aws/credentials)
|
|
148
|
+
|
|
149
|
+
### 5-3. `list` Command
|
|
150
|
+
|
|
151
|
+
Display all AWS profiles in the credentials file.
|
|
152
|
+
Secrets (`aws_access_key_id`, `aws_secret_access_key`, `aws_session_token`) are displayed masked.
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
updsts list
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 5-4. `mcp` Command
|
|
159
|
+
|
|
160
|
+
Start updsts as a local MCP server.
|
|
161
|
+
You can operate updsts from Agent tools.
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
updsts mcp --mcp-server
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
If the `--mcp-server` option is not specified, the MCP tool list is output.
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
updsts mcp
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 6. Credentials File
|
|
174
|
+
|
|
175
|
+
### 6-1. Credentials File Format
|
|
176
|
+
|
|
177
|
+
updsts works with the standard AWS CLI credentials file format.
|
|
178
|
+
It preserves existing profiles while updating only the specified section.
|
|
179
|
+
|
|
180
|
+
Example credentials file:
|
|
181
|
+
|
|
182
|
+
```ini
|
|
183
|
+
[default]
|
|
184
|
+
# Access Key ID (required)
|
|
185
|
+
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
|
|
186
|
+
# Secret Access Key (required)
|
|
187
|
+
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLE
|
|
188
|
+
# IAM user's MFA device ARN (required. The user must add this)
|
|
189
|
+
mfa_device_arn = arn:aws:iam::123456789012:mfa/user
|
|
190
|
+
# TOTP secret name managed by the mktotp MCP server (optional. The user can add this)
|
|
191
|
+
# If this is set and the `mktotp` MCP server is available, the Agent will automatically generate and use the TOTP token.
|
|
192
|
+
totp_secret_name = my_totp_secret
|
|
193
|
+
|
|
194
|
+
# The section enclosed by the following tags is automatically created/updated by updsts.
|
|
195
|
+
# ${{{ key=<name of the profile that requested STS> [auto update by updsts]
|
|
196
|
+
[default_sts]
|
|
197
|
+
aws_access_key_id = ASIAIOSFODNN7EXAMPLE
|
|
198
|
+
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYtempKEY
|
|
199
|
+
aws_session_token = IQoJb3JpZ2luX2VjE...
|
|
200
|
+
expiration_datetime = 2025-10-05T15:30:00+09:00
|
|
201
|
+
# $}}} [auto update by updsts]
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
updsts automatically manages the section between the special tags and leaves other profiles intact.
|
|
205
|
+
The tags are added automatically on the first run, so there is no need to add them manually.
|
|
206
|
+
|
|
207
|
+
### 6-2. Credentials File Location
|
|
208
|
+
|
|
209
|
+
By default, the credentials file is stored in the following location.
|
|
210
|
+
※ This is the same file used by the AWS CLI.
|
|
211
|
+
|
|
212
|
+
```text
|
|
213
|
+
~/.aws/credentials
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
You can specify a different location with the `-c` option.
|
|
217
|
+
|
|
218
|
+
## 7. Available MCP Tools
|
|
219
|
+
|
|
220
|
+
When started as an MCP server, the following tools are available from Agent tools.
|
|
221
|
+
|
|
222
|
+
### `updsts_update_sts_credential`
|
|
223
|
+
|
|
224
|
+
Get the STS credentials for the specified AWS profile and create/update the STS profile in the credentials file.
|
|
225
|
+
|
|
226
|
+
- Parameters:
|
|
227
|
+
- `profile_name` (str): AWS profile name to update (required)
|
|
228
|
+
- `totp_token` (str): TOTP token from the MFA device (required)
|
|
229
|
+
- `sts_profile_name` (str | None): STS profile name to create in the credentials file (optional)
|
|
230
|
+
- If None or an empty string, `<profile_name>_sts` is used (default: None)
|
|
231
|
+
- `cred_file` (str | None): Path to the credentials file (optional)
|
|
232
|
+
- If None or an empty string, the default location (~/.aws/credentials) is used (default: None)
|
|
233
|
+
- `duration` (int): STS token duration in seconds (optional, default: 3600)
|
|
234
|
+
- Returns (dict[str, str] | None): A dictionary containing the update result, or None on failure
|
|
235
|
+
- `updated_profile_name`: Name of the STS profile that was updated
|
|
236
|
+
- `aws_access_key_id`: Access key ID of the retrieved STS credentials (masked)
|
|
237
|
+
- `aws_token_expiration`: Expiration of the STS credentials (ISO 8601 format in the local time zone)
|
|
238
|
+
- The secret access key and the session token are not returned
|
|
239
|
+
|
|
240
|
+
### `updsts_get_credential_info`
|
|
241
|
+
|
|
242
|
+
Get the information of the specified AWS profile in the credentials file.
|
|
243
|
+
For security reasons, `aws_access_key_id`, `aws_secret_access_key` and `aws_session_token` are returned masked.
|
|
244
|
+
|
|
245
|
+
- Parameters:
|
|
246
|
+
- `profile_name` (str): AWS profile name to retrieve (required)
|
|
247
|
+
- `cred_file` (str | None): Path to the credentials file (optional)
|
|
248
|
+
- If None or an empty string, the default location (~/.aws/credentials) is used (default: None)
|
|
249
|
+
- Returns (dict[str, str] | None): A dictionary containing the credential details, or None if not found
|
|
250
|
+
|
|
251
|
+
### `updsts_get_credential_info_list`
|
|
252
|
+
|
|
253
|
+
Get the information of all AWS profiles in the credentials file.
|
|
254
|
+
For security reasons, `aws_access_key_id`, `aws_secret_access_key` and `aws_session_token` are returned masked.
|
|
255
|
+
|
|
256
|
+
- Parameters:
|
|
257
|
+
- `cred_file` (str | None): Path to the credentials file (optional)
|
|
258
|
+
- If None or an empty string, the default location (~/.aws/credentials) is used (default: None)
|
|
259
|
+
- Returns (list[dict[str, str]]): A list of dictionaries containing the credential details, or an empty list if no profiles are found
|
|
260
|
+
|
|
261
|
+
## 8. Security Notes
|
|
262
|
+
|
|
263
|
+
- The credentials file contains sensitive information, so protect it with appropriate permissions (recommended: 600)
|
|
264
|
+
|
|
265
|
+
## 9. License
|
|
266
|
+
|
|
267
|
+
This project is licensed under the MIT License.
|
|
268
|
+
See the [LICENSE](LICENSE) file for details.
|