bowtie-mcp 0.2.0rc1__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.
Files changed (38) hide show
  1. bowtie_mcp-0.2.0rc1/.github/workflows/ci.yml +28 -0
  2. bowtie_mcp-0.2.0rc1/.github/workflows/publish.yml +29 -0
  3. bowtie_mcp-0.2.0rc1/.gitignore +34 -0
  4. bowtie_mcp-0.2.0rc1/CONTRIBUTING.md +98 -0
  5. bowtie_mcp-0.2.0rc1/LICENSE +21 -0
  6. bowtie_mcp-0.2.0rc1/PKG-INFO +229 -0
  7. bowtie_mcp-0.2.0rc1/README.md +198 -0
  8. bowtie_mcp-0.2.0rc1/TESTED.md +51 -0
  9. bowtie_mcp-0.2.0rc1/pyproject.toml +51 -0
  10. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/__init__.py +1 -0
  11. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/__main__.py +135 -0
  12. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/access_tools.py +172 -0
  13. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/app.py +132 -0
  14. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/aws.py +365 -0
  15. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/bootstrap.py +235 -0
  16. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/client.py +550 -0
  17. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/cloudinit.py +55 -0
  18. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/connection.py +100 -0
  19. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/controller.py +136 -0
  20. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/deploy.py +546 -0
  21. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/deploy_tools.py +138 -0
  22. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/gcp.py +355 -0
  23. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/local_client.py +398 -0
  24. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/policy.py +748 -0
  25. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/server.py +1339 -0
  26. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/state.py +188 -0
  27. bowtie_mcp-0.2.0rc1/src/bowtie_mcp/wizard.py +252 -0
  28. bowtie_mcp-0.2.0rc1/tests/__init__.py +0 -0
  29. bowtie_mcp-0.2.0rc1/tests/conftest.py +77 -0
  30. bowtie_mcp-0.2.0rc1/tests/fake_controller.py +184 -0
  31. bowtie_mcp-0.2.0rc1/tests/test_cli.py +51 -0
  32. bowtie_mcp-0.2.0rc1/tests/test_client.py +176 -0
  33. bowtie_mcp-0.2.0rc1/tests/test_deploy.py +306 -0
  34. bowtie_mcp-0.2.0rc1/tests/test_local_client.py +184 -0
  35. bowtie_mcp-0.2.0rc1/tests/test_policy.py +231 -0
  36. bowtie_mcp-0.2.0rc1/tests/test_server.py +333 -0
  37. bowtie_mcp-0.2.0rc1/tests/test_tools.py +134 -0
  38. bowtie_mcp-0.2.0rc1/tests/test_wizard.py +430 -0
@@ -0,0 +1,28 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: pip install -e ".[dev]"
26
+
27
+ - name: Run tests
28
+ run: pytest -v
@@ -0,0 +1,29 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ id-token: write
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.12"
21
+
22
+ - name: Install build tools
23
+ run: pip install build
24
+
25
+ - name: Build package
26
+ run: python -m build
27
+
28
+ - name: Publish to PyPI
29
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,34 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.egg-info/
5
+ *.egg
6
+ dist/
7
+ build/
8
+ .eggs/
9
+ *.whl
10
+
11
+ # Virtual environments
12
+ .venv/
13
+ venv/
14
+ env/
15
+
16
+ # IDE
17
+ .idea/
18
+ .vscode/
19
+ *.swp
20
+ *.swo
21
+ *~
22
+
23
+ # Testing
24
+ .pytest_cache/
25
+ .coverage
26
+ htmlcov/
27
+
28
+ # OS
29
+ .DS_Store
30
+ Thumbs.db
31
+
32
+ # Environment
33
+ .env
34
+ .env.local
@@ -0,0 +1,98 @@
1
+ # Contributing to bowtie-mcp
2
+
3
+ Thanks for your interest in contributing! This MCP server lets admins manage their Bowtie cluster through any MCP-capable LLM client.
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ # Clone the repo
9
+ git clone https://github.com/bowtieworks/bowtie-mcp.git
10
+ cd bowtie-mcp
11
+
12
+ # Create a virtual environment
13
+ python3 -m venv .venv
14
+ source .venv/bin/activate
15
+
16
+ # Install in development mode with test dependencies
17
+ pip install -e ".[dev]"
18
+ ```
19
+
20
+ ## Running Tests
21
+
22
+ ```bash
23
+ pytest
24
+ ```
25
+
26
+ Tests use `pytest-httpx` and a stand-in controller (`tests/fake_controller.py`) — no running Bowtie controller or cloud account needed.
27
+
28
+ ## Testing Against a Real Controller
29
+
30
+ ```bash
31
+ export BOWTIE_HOST="https://your-controller"
32
+ export BOWTIE_USERNAME="admin@example.com"
33
+ export BOWTIE_PASSWORD="your-password"
34
+ python -m bowtie_mcp
35
+ ```
36
+
37
+ To test an HTTP transport locally instead of stdio:
38
+
39
+ ```bash
40
+ python -m bowtie_mcp --transport streamable-http --port 8080
41
+ ```
42
+
43
+ Use `--transport sse` if you specifically need the legacy SSE transport.
44
+
45
+ ## Project Structure
46
+
47
+ ```
48
+ src/bowtie_mcp/
49
+ ├── __init__.py # Package metadata
50
+ ├── __main__.py # CLI: the server (stdio + HTTP transports), plus connect, show-login, list, status, destroy
51
+ ├── app.py # The one MCP server every tool registers on; shared helpers; staged changes
52
+ ├── connection.py # Which controller a call talks to and how it signs in (keychain, or BOWTIE_* variables)
53
+ ├── server.py # Controller tools and prompts: reads, logs, single-object writes
54
+ ├── client.py # Async HTTP client wrapping the Bowtie REST API, used by server.py
55
+ ├── access_tools.py # list_rules, check_access, propose_change, apply_change, recent_changes
56
+ ├── policy.py # Checks a set of rule changes, turns it into API steps, applies it
57
+ ├── controller.py # Sync session client used by policy.py and the deploy code; secret scrubbing
58
+ ├── deploy_tools.py # plan/apply/status/destroy a deployment; install_client, enroll_this_device
59
+ ├── deploy.py # The deployment state machine
60
+ ├── aws.py, gcp.py # What each cloud needs created and removed
61
+ ├── cloudinit.py # First-boot data for an unattended controller
62
+ ├── bootstrap.py # Settings applied the first time a new controller answers
63
+ ├── wizard.py # The setup wizard, for the bowtie.direct naming option
64
+ ├── local_client.py # Download, verify and install the Bowtie client on this computer; approve it
65
+ └── state.py # Deployment records, proposals, the change record, secrets
66
+ ```
67
+
68
+ - **`client.py`** is a thin HTTP wrapper. No business logic — just auth and request/response handling.
69
+ - **`server.py`** owns its tool definitions, input construction, and error formatting.
70
+ - **`policy.py`** is where a rule change is validated. The controller does not check that a rule points at things that exist, so that happens here.
71
+
72
+ ## How writes work
73
+
74
+ Nothing a tool does on first call changes the controller. A write tool returns a `change_id` and a preview; `apply_change` carries it out and appends to the local change record.
75
+
76
+ - Rule, destination, resource, user-group and device-approval changes go through `propose_change` in `access_tools.py`. Add new kinds in `policy.py`.
77
+ - Any other write is one API call, staged with `_change()` in `server.py`.
78
+
79
+ ## Adding a New Tool
80
+
81
+ 1. Add the HTTP method to `client.py`
82
+ 2. Add the tool handler to `server.py` with the `@app.tool()` decorator
83
+ 3. For write tools, end with `return await _change(tool_name, action, details, "client_method", [args])`. Do not send anything to the controller before that.
84
+ 4. If the tool takes a device id and assigns, deletes or otherwise changes the device, call `_refuse_controller()` first. Controllers appear in the device list and must never be assigned to a user.
85
+ 5. Add tests in `tests/test_client.py` and `tests/test_server.py`
86
+
87
+ ## Code Style
88
+
89
+ - Format with `ruff format`
90
+ - Lint with `ruff check`
91
+ - Type check with `mypy` (not enforced in CI yet, but appreciated)
92
+
93
+ ## Submitting Changes
94
+
95
+ 1. Fork the repo and create a feature branch
96
+ 2. Make your changes with tests
97
+ 3. Run `pytest` to verify
98
+ 4. Open a pull request with a clear description of what changed and why
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bowtie Works, Inc.
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.
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.5
2
+ Name: bowtie-mcp
3
+ Version: 0.2.0rc1
4
+ Summary: MCP server for Bowtie: deploy a controller in your own cloud, connect a computer, and manage who can reach what
5
+ Project-URL: Homepage, https://github.com/bowtieworks/bowtie-mcp
6
+ Project-URL: Repository, https://github.com/bowtieworks/bowtie-mcp
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: bowtie,mcp,network-access,zero-trust,ztna
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: System Administrators
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: System :: Networking
14
+ Requires-Python: >=3.11
15
+ Requires-Dist: argon2-cffi>=23.1.0
16
+ Requires-Dist: boto3>=1.34
17
+ Requires-Dist: google-auth>=2.30
18
+ Requires-Dist: httpx>=0.27.0
19
+ Requires-Dist: keyring>=25.0
20
+ Requires-Dist: mcp<3,>=2.3
21
+ Requires-Dist: pydantic>=2.0.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: requests>=2.32
24
+ Requires-Dist: websockets>=15.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: cryptography>=42; extra == 'dev'
27
+ Requires-Dist: pytest-asyncio>=0.25; extra == 'dev'
28
+ Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
29
+ Requires-Dist: pytest>=8.0; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # Bowtie MCP Server
33
+
34
+ [![CI](https://github.com/bowtieworks/bowtie-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/bowtieworks/bowtie-mcp/actions/workflows/ci.yml)
35
+ [![PyPI](https://img.shields.io/pypi/v/bowtie-mcp)](https://pypi.org/project/bowtie-mcp/)
36
+ [![Python](https://img.shields.io/pypi/pyversions/bowtie-mcp)](https://pypi.org/project/bowtie-mcp/)
37
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
38
+
39
+ An [MCP](https://modelcontextprotocol.io) server for [Bowtie](https://bowtie.works). From Claude Code, Claude Desktop, Cursor or any other MCP client, an AI agent can:
40
+
41
+ - **Deploy** a Bowtie controller into your own AWS or Google Cloud account.
42
+ - **Connect** the computer you are on: install the client and approve the device.
43
+ - **Manage** a running controller: access rules, devices, users, DNS, threat intelligence, traffic logs.
44
+
45
+ It runs on your computer, with your cloud credentials, against your controller. Bowtie hosts no part of it and it sends Bowtie nothing.
46
+
47
+ <!-- mcp-name: io.github.bowtieworks/bowtie-mcp -->
48
+
49
+ ## Install
50
+
51
+ Run it without installing, using [uvx](https://docs.astral.sh/uv/):
52
+
53
+ ```bash
54
+ uvx bowtie-mcp
55
+ ```
56
+
57
+ Or install it:
58
+
59
+ ```bash
60
+ pip install bowtie-mcp
61
+ ```
62
+
63
+ ## Quick start
64
+
65
+ ### Claude Code
66
+
67
+ ```bash
68
+ claude mcp add bowtie -- uvx bowtie-mcp
69
+ ```
70
+
71
+ ### Claude Desktop, Cursor, Windsurf
72
+
73
+ Add to `claude_desktop_config.json`, `.cursor/mcp.json` or your editor's MCP config:
74
+
75
+ ```json
76
+ {
77
+ "mcpServers": {
78
+ "bowtie": {
79
+ "command": "uvx",
80
+ "args": ["bowtie-mcp"]
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ Then ask, for example:
87
+
88
+ - *"Deploy Bowtie in AWS us-west-2 at bowtie.example.com, admin me@example.com."*
89
+ - *"I have no domain handy, use a bowtie.direct name. Org is Acme Rockets."*
90
+ - *"Connect this laptop."*
91
+ - *"Let the Engineering group reach the git server at 10.0.4.12 on 22 and 443."*
92
+ - *"Why can't alice@example.com reach the production database?"*
93
+ - *"List pending devices and approve the ones that belong to engineering."*
94
+ - *"Set up DNS for internal.example.com pointing at 10.0.0.53."*
95
+ - *"What traffic was dropped in the last 24 hours?"*
96
+
97
+ ## Pointing it at a controller
98
+
99
+ **A controller the agent deploys.** Nothing to configure. The admin password is generated on your computer and kept in the operating system keychain (a file only you can read where there is no keychain). Print it in your own terminal, outside the agent:
100
+
101
+ ```bash
102
+ uvx bowtie-mcp show-login <name>
103
+ ```
104
+
105
+ **A controller you already run.** Attach it once. The password is typed at a hidden prompt and goes to the keychain, so it never sits in an agent's configuration file:
106
+
107
+ ```bash
108
+ uvx bowtie-mcp connect prod --url https://bt0.example.com --email admin@example.com
109
+ ```
110
+
111
+ **Environment variables**, for CI or if you prefer them. This is the same approach as the [Bowtie Terraform provider](https://registry.terraform.io/providers/bowtieworks/bowtie/latest):
112
+
113
+ | Variable | Description |
114
+ |---|---|
115
+ | `BOWTIE_HOST` | Controller HTTPS endpoint (e.g., `https://bt0.example.com`) |
116
+ | `BOWTIE_USERNAME`, `BOWTIE_PASSWORD` | A local admin's email and password |
117
+ | `BOWTIE_API_KEY_ID`, `BOWTIE_API_KEY_SECRET` | An API key, instead of a password. Today's controllers accept API keys only for device approval, so most tools need the password. |
118
+ | `BOWTIE_MCP_DEPLOYMENT` | The name of a stored deployment to use, when more than one is set up |
119
+ | `BOWTIE_MCP_SKIP_CONFIRMATION` | Set to `true` to carry out single-object changes at once (see below) |
120
+
121
+ ```bash
122
+ claude mcp add bowtie \
123
+ -e BOWTIE_HOST="https://bt0.example.com" \
124
+ -e BOWTIE_USERNAME="admin@example.com" \
125
+ -e BOWTIE_PASSWORD="your-password" \
126
+ -- uvx bowtie-mcp
127
+ ```
128
+
129
+ With more than one controller, add the server once per controller and set `BOWTIE_MCP_DEPLOYMENT` (or `BOWTIE_HOST`) in each entry.
130
+
131
+ Credentials are used by the local server process. They are never returned to the model: every tool result has secret-looking fields (passwords, keys, tokens, hashes) blanked before it leaves.
132
+
133
+ ## How changes work
134
+
135
+ Anything that spends money or changes your network is two calls. The first changes nothing and says exactly what would happen. The second carries it out.
136
+
137
+ | First call (changes nothing) | Second call |
138
+ |---|---|
139
+ | `plan_deployment` lists every cloud resource, the cost and what Bowtie receives | `apply_deployment` |
140
+ | `propose_change` checks a whole set of rule changes and shows before and after | `apply_change` |
141
+ | Any other write tool (`upsert_dns_config`, `upsert_user`, ...) returns a `change_id` and a preview | `apply_change` |
142
+
143
+ So an MCP client can be told to allow everything except four tools, and ask you only for those: `apply_deployment`, `apply_change`, `destroy_deployment` and `install_client`.
144
+
145
+ `propose_change` is the way to change access. It takes names instead of ids, accepts changes in any order, refuses a rule that points at something that does not exist, warns when a change takes access away or opens a very large network, and `apply_change` refuses to run it if the controller changed in the meantime. Every applied change is written to a record on your computer (`recent_changes`), because the controller keeps none for rule edits.
146
+
147
+ For automation and CI, `BOWTIE_MCP_SKIP_CONFIRMATION=true` makes the single-object write tools act at once. `propose_change` and deployments stay two steps.
148
+
149
+ ## Tools
150
+
151
+ **Deploy and connect**
152
+
153
+ | Tool | What it does |
154
+ |---|---|
155
+ | `check_prerequisites`, `plan_deployment` | Read-only. The plan lists what would be created and what it costs. |
156
+ | `apply_deployment`, `deployment_status`, `deployment_console` | Create the planned resources and follow the boot. |
157
+ | `destroy_deployment` | Delete them. Needs the name repeated. |
158
+ | `install_client`, `enroll_this_device` | Install the client on this computer (the OS asks for admin rights) and approve it. |
159
+ | `list_deployments` | Controllers this computer knows about. |
160
+
161
+ **Access**
162
+
163
+ | Tool | What it does |
164
+ |---|---|
165
+ | `list_rules`, `list_people`, `list_devices` | The rules in the order they are checked, users and groups, and devices, in plain words. |
166
+ | `check_access` | Asks the controller how it would treat a connection, and which rule decides. |
167
+ | `propose_change`, `apply_change`, `recent_changes` | Change rules, destinations, resources, user groups and device approval; see above. |
168
+
169
+ **Everything else on the controller**
170
+
171
+ - **Read** — users, user groups, devices, device groups, the raw policy document, DNS configs, organization and its settings, sites, collections, DNS block lists, threat categories, API keys, controllers, route exclusions.
172
+ - **Write** (staged for `apply_change`) — users, device assignment and cleanup, pre-approval by serial number, device groups, DNS configs, collections, DNS block lists, threat intelligence, route exclusions.
173
+ - **Logs** — `query_verdict_logs`, `get_verdict_summary`, `query_dns_logs`, `get_verdict_logging_status`. Verdict logging must be switched on per controller.
174
+
175
+ **Guided workflows** (MCP prompts)
176
+
177
+ | Prompt | Description |
178
+ |---|---|
179
+ | `onboard_team` | Create a user group, resources, resource group, and access policy |
180
+ | `audit_policies` | Review all policies for overly permissive rules |
181
+ | `troubleshoot_access` | Diagnose why a user/device can or can't reach a destination |
182
+ | `review_pending_devices` | Batch approve or reject pending devices |
183
+ | `analyze_traffic` | Recommend rule changes from what the verdict logs show |
184
+
185
+ ## Naming a new controller
186
+
187
+ - **Your own domain (default).** If the hostname is in a Route 53 or Cloud DNS zone in the same account, the record is created for you. Otherwise you add one A record and the deployment carries on when it resolves.
188
+ - **bowtie.direct (opt-in).** No DNS work; Bowtie assigns `bt0.<org>-NNNN.bowtie.direct`. This sends the hostname, public IP and organization name to Bowtie, and the controller asks api.ipify.org for its own address. The plan says so before anything is created. Removing the deployment cannot remove the name from Bowtie's DNS.
189
+
190
+ ## What Bowtie receives
191
+
192
+ - From this server: nothing. The controller image is looked up in your own cloud account. The client installer is an anonymous download, checked against its published SHA-256.
193
+ - From a controller it deploys: the controller's normal licence check from first boot (organization name, domain, controller address). Telemetry is switched off as the first step after boot unless you ask to keep it; one report may go out first.
194
+ - With the bowtie.direct option: also the items listed above.
195
+
196
+ Your AI provider sees what the tools return.
197
+
198
+ ## HTTP mode
199
+
200
+ For clients that connect over HTTP instead of starting a local process:
201
+
202
+ ```bash
203
+ uvx bowtie-mcp --transport streamable-http --port 8080
204
+ ```
205
+
206
+ This listens on `127.0.0.1:8080` and serves Streamable HTTP at `http://127.0.0.1:8080/mcp`. Legacy SSE is `--transport sse`, at `/sse`. There is no sign-in on these endpoints, so keep them on this computer.
207
+
208
+ ## Limits
209
+
210
+ - Signing in is with a local admin's password, because controller API keys cover only device approval today.
211
+ - A dry run of a rule change is worked out here, not by the controller.
212
+ - No Azure. Linux client packages are x86_64 only.
213
+ - A computer's client belongs to one organization. If it is already set up for another controller, `install_client` changes nothing and says so.
214
+ - The tool list is long (70). Clients that load every tool up front may need some switched off.
215
+
216
+ ## Development
217
+
218
+ ```bash
219
+ git clone https://github.com/bowtieworks/bowtie-mcp.git
220
+ cd bowtie-mcp
221
+ pip install -e ".[dev]"
222
+ pytest
223
+ ```
224
+
225
+ State lives in `~/.bowtie-mcp` (override with `BOWTIE_MCP_HOME`; `BOWTIE_MCP_SECRETS=file` keeps secrets out of the keychain). See [CONTRIBUTING.md](CONTRIBUTING.md) for the layout and [TESTED.md](TESTED.md) for what has been run against real infrastructure.
226
+
227
+ ## License
228
+
229
+ [MIT](LICENSE)
@@ -0,0 +1,198 @@
1
+ # Bowtie MCP Server
2
+
3
+ [![CI](https://github.com/bowtieworks/bowtie-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/bowtieworks/bowtie-mcp/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/bowtie-mcp)](https://pypi.org/project/bowtie-mcp/)
5
+ [![Python](https://img.shields.io/pypi/pyversions/bowtie-mcp)](https://pypi.org/project/bowtie-mcp/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
+
8
+ An [MCP](https://modelcontextprotocol.io) server for [Bowtie](https://bowtie.works). From Claude Code, Claude Desktop, Cursor or any other MCP client, an AI agent can:
9
+
10
+ - **Deploy** a Bowtie controller into your own AWS or Google Cloud account.
11
+ - **Connect** the computer you are on: install the client and approve the device.
12
+ - **Manage** a running controller: access rules, devices, users, DNS, threat intelligence, traffic logs.
13
+
14
+ It runs on your computer, with your cloud credentials, against your controller. Bowtie hosts no part of it and it sends Bowtie nothing.
15
+
16
+ <!-- mcp-name: io.github.bowtieworks/bowtie-mcp -->
17
+
18
+ ## Install
19
+
20
+ Run it without installing, using [uvx](https://docs.astral.sh/uv/):
21
+
22
+ ```bash
23
+ uvx bowtie-mcp
24
+ ```
25
+
26
+ Or install it:
27
+
28
+ ```bash
29
+ pip install bowtie-mcp
30
+ ```
31
+
32
+ ## Quick start
33
+
34
+ ### Claude Code
35
+
36
+ ```bash
37
+ claude mcp add bowtie -- uvx bowtie-mcp
38
+ ```
39
+
40
+ ### Claude Desktop, Cursor, Windsurf
41
+
42
+ Add to `claude_desktop_config.json`, `.cursor/mcp.json` or your editor's MCP config:
43
+
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "bowtie": {
48
+ "command": "uvx",
49
+ "args": ["bowtie-mcp"]
50
+ }
51
+ }
52
+ }
53
+ ```
54
+
55
+ Then ask, for example:
56
+
57
+ - *"Deploy Bowtie in AWS us-west-2 at bowtie.example.com, admin me@example.com."*
58
+ - *"I have no domain handy, use a bowtie.direct name. Org is Acme Rockets."*
59
+ - *"Connect this laptop."*
60
+ - *"Let the Engineering group reach the git server at 10.0.4.12 on 22 and 443."*
61
+ - *"Why can't alice@example.com reach the production database?"*
62
+ - *"List pending devices and approve the ones that belong to engineering."*
63
+ - *"Set up DNS for internal.example.com pointing at 10.0.0.53."*
64
+ - *"What traffic was dropped in the last 24 hours?"*
65
+
66
+ ## Pointing it at a controller
67
+
68
+ **A controller the agent deploys.** Nothing to configure. The admin password is generated on your computer and kept in the operating system keychain (a file only you can read where there is no keychain). Print it in your own terminal, outside the agent:
69
+
70
+ ```bash
71
+ uvx bowtie-mcp show-login <name>
72
+ ```
73
+
74
+ **A controller you already run.** Attach it once. The password is typed at a hidden prompt and goes to the keychain, so it never sits in an agent's configuration file:
75
+
76
+ ```bash
77
+ uvx bowtie-mcp connect prod --url https://bt0.example.com --email admin@example.com
78
+ ```
79
+
80
+ **Environment variables**, for CI or if you prefer them. This is the same approach as the [Bowtie Terraform provider](https://registry.terraform.io/providers/bowtieworks/bowtie/latest):
81
+
82
+ | Variable | Description |
83
+ |---|---|
84
+ | `BOWTIE_HOST` | Controller HTTPS endpoint (e.g., `https://bt0.example.com`) |
85
+ | `BOWTIE_USERNAME`, `BOWTIE_PASSWORD` | A local admin's email and password |
86
+ | `BOWTIE_API_KEY_ID`, `BOWTIE_API_KEY_SECRET` | An API key, instead of a password. Today's controllers accept API keys only for device approval, so most tools need the password. |
87
+ | `BOWTIE_MCP_DEPLOYMENT` | The name of a stored deployment to use, when more than one is set up |
88
+ | `BOWTIE_MCP_SKIP_CONFIRMATION` | Set to `true` to carry out single-object changes at once (see below) |
89
+
90
+ ```bash
91
+ claude mcp add bowtie \
92
+ -e BOWTIE_HOST="https://bt0.example.com" \
93
+ -e BOWTIE_USERNAME="admin@example.com" \
94
+ -e BOWTIE_PASSWORD="your-password" \
95
+ -- uvx bowtie-mcp
96
+ ```
97
+
98
+ With more than one controller, add the server once per controller and set `BOWTIE_MCP_DEPLOYMENT` (or `BOWTIE_HOST`) in each entry.
99
+
100
+ Credentials are used by the local server process. They are never returned to the model: every tool result has secret-looking fields (passwords, keys, tokens, hashes) blanked before it leaves.
101
+
102
+ ## How changes work
103
+
104
+ Anything that spends money or changes your network is two calls. The first changes nothing and says exactly what would happen. The second carries it out.
105
+
106
+ | First call (changes nothing) | Second call |
107
+ |---|---|
108
+ | `plan_deployment` lists every cloud resource, the cost and what Bowtie receives | `apply_deployment` |
109
+ | `propose_change` checks a whole set of rule changes and shows before and after | `apply_change` |
110
+ | Any other write tool (`upsert_dns_config`, `upsert_user`, ...) returns a `change_id` and a preview | `apply_change` |
111
+
112
+ So an MCP client can be told to allow everything except four tools, and ask you only for those: `apply_deployment`, `apply_change`, `destroy_deployment` and `install_client`.
113
+
114
+ `propose_change` is the way to change access. It takes names instead of ids, accepts changes in any order, refuses a rule that points at something that does not exist, warns when a change takes access away or opens a very large network, and `apply_change` refuses to run it if the controller changed in the meantime. Every applied change is written to a record on your computer (`recent_changes`), because the controller keeps none for rule edits.
115
+
116
+ For automation and CI, `BOWTIE_MCP_SKIP_CONFIRMATION=true` makes the single-object write tools act at once. `propose_change` and deployments stay two steps.
117
+
118
+ ## Tools
119
+
120
+ **Deploy and connect**
121
+
122
+ | Tool | What it does |
123
+ |---|---|
124
+ | `check_prerequisites`, `plan_deployment` | Read-only. The plan lists what would be created and what it costs. |
125
+ | `apply_deployment`, `deployment_status`, `deployment_console` | Create the planned resources and follow the boot. |
126
+ | `destroy_deployment` | Delete them. Needs the name repeated. |
127
+ | `install_client`, `enroll_this_device` | Install the client on this computer (the OS asks for admin rights) and approve it. |
128
+ | `list_deployments` | Controllers this computer knows about. |
129
+
130
+ **Access**
131
+
132
+ | Tool | What it does |
133
+ |---|---|
134
+ | `list_rules`, `list_people`, `list_devices` | The rules in the order they are checked, users and groups, and devices, in plain words. |
135
+ | `check_access` | Asks the controller how it would treat a connection, and which rule decides. |
136
+ | `propose_change`, `apply_change`, `recent_changes` | Change rules, destinations, resources, user groups and device approval; see above. |
137
+
138
+ **Everything else on the controller**
139
+
140
+ - **Read** — users, user groups, devices, device groups, the raw policy document, DNS configs, organization and its settings, sites, collections, DNS block lists, threat categories, API keys, controllers, route exclusions.
141
+ - **Write** (staged for `apply_change`) — users, device assignment and cleanup, pre-approval by serial number, device groups, DNS configs, collections, DNS block lists, threat intelligence, route exclusions.
142
+ - **Logs** — `query_verdict_logs`, `get_verdict_summary`, `query_dns_logs`, `get_verdict_logging_status`. Verdict logging must be switched on per controller.
143
+
144
+ **Guided workflows** (MCP prompts)
145
+
146
+ | Prompt | Description |
147
+ |---|---|
148
+ | `onboard_team` | Create a user group, resources, resource group, and access policy |
149
+ | `audit_policies` | Review all policies for overly permissive rules |
150
+ | `troubleshoot_access` | Diagnose why a user/device can or can't reach a destination |
151
+ | `review_pending_devices` | Batch approve or reject pending devices |
152
+ | `analyze_traffic` | Recommend rule changes from what the verdict logs show |
153
+
154
+ ## Naming a new controller
155
+
156
+ - **Your own domain (default).** If the hostname is in a Route 53 or Cloud DNS zone in the same account, the record is created for you. Otherwise you add one A record and the deployment carries on when it resolves.
157
+ - **bowtie.direct (opt-in).** No DNS work; Bowtie assigns `bt0.<org>-NNNN.bowtie.direct`. This sends the hostname, public IP and organization name to Bowtie, and the controller asks api.ipify.org for its own address. The plan says so before anything is created. Removing the deployment cannot remove the name from Bowtie's DNS.
158
+
159
+ ## What Bowtie receives
160
+
161
+ - From this server: nothing. The controller image is looked up in your own cloud account. The client installer is an anonymous download, checked against its published SHA-256.
162
+ - From a controller it deploys: the controller's normal licence check from first boot (organization name, domain, controller address). Telemetry is switched off as the first step after boot unless you ask to keep it; one report may go out first.
163
+ - With the bowtie.direct option: also the items listed above.
164
+
165
+ Your AI provider sees what the tools return.
166
+
167
+ ## HTTP mode
168
+
169
+ For clients that connect over HTTP instead of starting a local process:
170
+
171
+ ```bash
172
+ uvx bowtie-mcp --transport streamable-http --port 8080
173
+ ```
174
+
175
+ This listens on `127.0.0.1:8080` and serves Streamable HTTP at `http://127.0.0.1:8080/mcp`. Legacy SSE is `--transport sse`, at `/sse`. There is no sign-in on these endpoints, so keep them on this computer.
176
+
177
+ ## Limits
178
+
179
+ - Signing in is with a local admin's password, because controller API keys cover only device approval today.
180
+ - A dry run of a rule change is worked out here, not by the controller.
181
+ - No Azure. Linux client packages are x86_64 only.
182
+ - A computer's client belongs to one organization. If it is already set up for another controller, `install_client` changes nothing and says so.
183
+ - The tool list is long (70). Clients that load every tool up front may need some switched off.
184
+
185
+ ## Development
186
+
187
+ ```bash
188
+ git clone https://github.com/bowtieworks/bowtie-mcp.git
189
+ cd bowtie-mcp
190
+ pip install -e ".[dev]"
191
+ pytest
192
+ ```
193
+
194
+ State lives in `~/.bowtie-mcp` (override with `BOWTIE_MCP_HOME`; `BOWTIE_MCP_SECRETS=file` keeps secrets out of the keychain). See [CONTRIBUTING.md](CONTRIBUTING.md) for the layout and [TESTED.md](TESTED.md) for what has been run against real infrastructure.
195
+
196
+ ## License
197
+
198
+ [MIT](LICENSE)