Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
22 changes: 22 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# AGENTS.md

## Build & Validation

- Install: `bun install`
- Typecheck: `bun run check`
- Lint: `bun run lint`
- Build: `bun run build`

## Project Intent

This package is an OpenCode plugin that enforces a secure MCP installation workflow:

1. never hardcode MCP secrets in `opencode.json`
2. store MCP credentials in OpenBao first
3. wire MCP processes through `openbao-mcp-exec` or an equivalent absolute path

## Conventions

- Keep public docs path-agnostic: do not reference personal home directories in README examples
- Treat the TUI module as a first-class surface for OpenCode plugin UX
- Prefer minimal, deterministic plugin hooks over complex magic
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

## 0.3.0

- fix HARDCODED_SECRET_RE bypass by scanning raw string values instead of JSON.stringify'd args
- fix Bun.file().exists() for directory checks by using node:fs/promises stat
- move OPENBAO_EXECUTABLE constant to top of file near other constants
- fix TUI command trigger by removing leading slash from 'add-secure-mcp'
- add recursive hasSecretInValue() to detect secrets in nested objects and arrays
- rewrite all commits with correct author identity (papastanb)

## 0.2.0

- replace hardcoded personal `openbao-mcp-exec` paths with path-agnostic guidance
- add fuller public package metadata for npm and GitHub
- add dedicated documentation for setup, releases, and LLM-facing usage
- keep TUI integration and `/add-secure-mcp` as the primary onboarding surface

## 0.1.1

- remove dependency on a separate local instructions file in `opencode.json`

## 0.1.0

- initial public release of the OpenBao-backed MCP guard plugin for OpenCode
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Stan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
145 changes: 145 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# opencode-openbao-mcp-guard

OpenCode plugin that standardizes secure MCP installation when an MCP needs an API key or token.

This package is self-contained from the OpenCode side: it does not require a separate local instruction file in `opencode.json`. Guidance is embedded in the plugin behavior, the TUI surface, and the `/add-secure-mcp` command.

## Version

- Current package version: `0.2.0`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 README displays stale version 0.2.0 while package.json is at 0.3.0

The README at line 9 states Current package version: 0.2.0, but package.json:3 has "version": "0.3.0" and CHANGELOG.md:3 lists 0.3.0 as the latest release. This was likely missed when bumping the version in commit 89e759e. Users and integrations that check the README for the current version will see outdated information.

Suggested change
- Current package version: `0.2.0`
- Current package version: `0.3.0`
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

- npm: `https://www.npmjs.com/package/opencode-openbao-mcp-guard`
- GitHub: `https://github.com/papastanb/Bao_MCP`

## What it does

- blocks obvious hardcoded secrets in `opencode.json` and `opencode.jsonc`
- injects a secure MCP reminder into relevant chats
- registers a guided `/add-secure-mcp` command
- exposes a TUI module for OpenCode plugin integration
- keeps the OpenBao-first workflow embedded in the plugin behavior

## Security model

For MCPs that need an API key:

1. store the key in OpenBao first
2. configure the MCP to fetch the key at runtime through `openbao-mcp-exec`
3. never write the key directly into `opencode.json`

OpenBao storage example:

```bash
bao kv put -address=http://127.0.0.1:8200 -tls-skip-verify -mount=secret context7/api_key key=TA_CLE_API
```

OpenCode MCP example:

```json
"context7": {
"type": "local",
"command": [
"openbao-mcp-exec",
"secret",
"context7/api_key",
"key",
"--",
"npx",
"-y",
"@upstash/context7-mcp",
"--api-key"
]
}
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.

If `openbao-mcp-exec` is not on `PATH`, replace it with an absolute path in your local config.

## Install in OpenCode

Add the plugin to your global OpenCode config:

```json
{
"plugin": [
"opencode-openbao-mcp-guard"
]
}
```

OpenCode will install the package automatically.

## TUI integration

This package ships both:

- a server plugin entrypoint
- a TUI plugin entrypoint (`./tui`)

The TUI module registers a visible command launcher and shows a first-load toast so the plugin is discoverable in the TUI plugin list and command picker.

## Slash command

- `/add-secure-mcp`: guided secure MCP installation flow

The command tells the model to:

- avoid hardcoded secrets
- ask for the MCP package/launcher details
- remind the user to store the key in OpenBao first
- generate the correct `command` array using `openbao-mcp-exec`

## OpenBao setup

Minimal pattern:

```bash
bao kv put -address=http://127.0.0.1:8200 -tls-skip-verify -mount=secret <mcp>/api_key key=TA_CLE_API
```

More details:

- [`docs/OPENBAO_SETUP.md`](./docs/OPENBAO_SETUP.md)

## Setup for LLMs

If an LLM or coding agent is using this plugin, it should follow these rules:

1. never hardcode API keys in `opencode.json`
2. always ask the user to store the secret in OpenBao first
3. prefer `openbao-mcp-exec` on `PATH`
4. if the helper is not on `PATH`, request or use an explicit absolute path locally

Dedicated guide:

- [`docs/LLM_SETUP.md`](./docs/LLM_SETUP.md)

## Development

```bash
bun install
bun run check
bun run lint
bun run build
```

## Local development install

```json
{
"plugin": [
"file:///absolute/path/to/Bao_MCP"
]
}
```

During development, loading the package root is preferred over pointing to a single built file because it keeps the server and TUI plugin surfaces together.

## Release process

See:

- [`CHANGELOG.md`](./CHANGELOG.md)
- [`RELEASE.md`](./RELEASE.md)

## License

MIT
36 changes: 36 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Release Guide

## Validate

```bash
bun install
bun run check
bun run lint
bun run build
```

## Publish npm

```bash
npm publish --access public
```

## Create Git tag

```bash
git tag vX.Y.Z
git push origin vX.Y.Z
```

## Create GitHub release

```bash
gh release create vX.Y.Z --generate-notes
```

## Post-release checks

```bash
npm view opencode-openbao-mcp-guard version
gh release view vX.Y.Z
```
Loading