@selfagency/beans-mcp 0.1.1 → 0.1.2

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 (44) hide show
  1. package/{dist/beans-mcp-server.cjs → beans-mcp-server.cjs} +8 -4
  2. package/{dist/index.cjs → index.cjs} +8 -4
  3. package/{dist/index.d.ts → index.d.ts} +2 -1
  4. package/{dist/index.js → index.js} +8 -4
  5. package/package.json +27 -64
  6. package/.beans.yml +0 -6
  7. package/.claude/settings.local.json +0 -18
  8. package/.editorconfig +0 -13
  9. package/.github/workflows/release.yml +0 -235
  10. package/.github/workflows/test.yml +0 -80
  11. package/.husky/pre-commit +0 -1
  12. package/.nvmrc +0 -1
  13. package/.oxfmtrc.json +0 -11
  14. package/.oxlintrc.json +0 -37
  15. package/.vscode/settings.json +0 -3
  16. package/CHANGELOG.md +0 -140
  17. package/CONTRIBUTING.md +0 -139
  18. package/dist/README.md +0 -307
  19. package/dist/beans-mcp-server.cjs.map +0 -1
  20. package/dist/index.cjs.map +0 -1
  21. package/dist/index.js.map +0 -1
  22. package/dist/package.json +0 -43
  23. package/pnpm-workspace.yaml +0 -2
  24. package/scripts/release.js +0 -433
  25. package/scripts/write-dist-package.js +0 -53
  26. package/src/cli.ts +0 -14
  27. package/src/index.ts +0 -21
  28. package/src/internal/graphql.ts +0 -33
  29. package/src/internal/queryHelpers.ts +0 -157
  30. package/src/server/BeansMcpServer.ts +0 -600
  31. package/src/server/backend.ts +0 -358
  32. package/src/test/BeansMcpServer.test.ts +0 -514
  33. package/src/test/handlers.unit.test.ts +0 -184
  34. package/src/test/parseCliArgs.test.ts +0 -69
  35. package/src/test/protocol.e2e.test.ts +0 -884
  36. package/src/test/queryHelpers.test.ts +0 -524
  37. package/src/test/startBeansMcpServer.test.ts +0 -146
  38. package/src/test/tools-integration.test.ts +0 -912
  39. package/src/test/utils.test.ts +0 -80
  40. package/src/types.ts +0 -46
  41. package/src/utils.ts +0 -20
  42. package/tsconfig.json +0 -24
  43. package/tsup.config.ts +0 -42
  44. package/vitest.config.ts +0 -18
package/CHANGELOG.md DELETED
@@ -1,140 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [Unreleased]
9
-
10
- ## [0.1.1] - 2026-02-25
11
-
12
- **Full Changelog**: https://github.com/selfagency/beans-mcp/compare/v0.1.0...v0.1.1
13
-
14
- _Source: changes from v0.1.0 to v0.1.1._
15
-
16
-
17
- ## [0.1.0] - 2026-02-25
18
-
19
- **Full Changelog**: https://github.com/selfagency/beans-mcp/commits/v0.1.0
20
-
21
-
22
- Initial public release. Extracted and substantially reworked from the
23
- [selfagency.beans-vscode](https://marketplace.visualstudio.com/items?itemName=selfagency.beans-vscode)
24
- VS Code extension's embedded MCP server into a standalone, independently
25
- installable package.
26
-
27
- ### Added
28
-
29
- #### MCP Tools
30
-
31
- All 14 Beans MCP tools are implemented and registered:
32
-
33
- - `beans_init` — Initialize the workspace (optional prefix).
34
- - `beans_list` — List beans with filtering by status, type, tags, and search.
35
- - `beans_view` — View a single bean by ID.
36
- - `beans_create` — Create a new bean.
37
- - `beans_update` / `beans_edit` — Update an existing bean (aliases).
38
- - `beans_reopen` — Reopen a completed or scrapped bean.
39
- - `beans_delete` — Delete a draft or scrapped bean.
40
- - `beans_set_status` — Set a bean's status directly.
41
- - `beans_query` — Run llm_context, refresh, and workspace-instructions operations.
42
- - `beans_bean_file` — Read, edit, create, or delete raw bean markdown files.
43
- - `beans_output` — Read the Beans CLI output log.
44
- - `beans_open_config` — Return the workspace config file path and content.
45
- - `beans_graphql_schema` — Return the Beans GraphQL schema.
46
-
47
- #### Public API
48
-
49
- - `createBeansMcpServer(opts)` — Programmatic factory for embedding a Beans
50
- MCP server in other applications; accepts an optional `backend` parameter
51
- for dependency injection.
52
- - `startBeansMcpServer(argv)` — CLI entrypoint; launches the server with a
53
- `StdioServerTransport`.
54
- - `parseCliArgs(argv)` — Parse and validate CLI arguments; returns a
55
- `workspaceExplicit` flag so callers can distinguish user-supplied roots from
56
- the cwd default.
57
- - `BeansCliBackend` — Concrete backend that shells out to the `beans` CLI.
58
- - `BackendInterface` — Interface for custom backend implementations.
59
- - `MutableBackend` — Thin delegation wrapper whose inner backend can be
60
- hot-swapped after MCP roots discovery without re-registering tools.
61
- - `resolveWorkspaceFromRoots(server)` — Queries the connected client's
62
- declared MCP roots and returns the first `file://` path as a local workspace
63
- path, or `null` if none are declared.
64
- - `sortBeans`, `isPathWithinRoot`, `makeTextAndStructured` — Utility helpers.
65
-
66
- #### Workspace Resolution
67
-
68
- The server resolves its workspace in priority order:
69
-
70
- 1. `--workspace-root` / positional CLI argument (explicit)
71
- 2. MCP roots declared by the connected client (`roots/list`)
72
- 3. `process.cwd()` (fallback)
73
-
74
- This enables using the server without CLI arguments: AI clients that declare
75
- MCP roots (e.g. Cursor, Claude Desktop) automatically provide the workspace
76
- path after connecting.
77
-
78
- #### CLI
79
-
80
- - `beans-mcp` binary accepts:
81
- - Positional or `--workspace-root` for the workspace path.
82
- - `--cli-path` — path to the `beans` executable (default: `beans`).
83
- - `--port` — MCP server port (default: 39173).
84
- - `--log-dir` — log directory (defaults to workspace root).
85
- - `-h` / `--help` — print usage and exit.
86
-
87
- #### Build
88
-
89
- - Multi-config `tsup.config.ts` produces three outputs:
90
- - ESM library (`dist/index.js` + `dist/index.d.ts`)
91
- - CJS library (`dist/index.cjs`)
92
- - CJS CLI binary (`dist/beans-mcp-server.cjs`) with `#!/usr/bin/env node` shebang
93
- - All CJS configs use `target: 'node18'`, `splitting: false`, `cjsInterop: true`.
94
- - `postbuild` script writes a trimmed `dist/package.json` with correct `bin`,
95
- `exports`, `main`, `module`, and `types` fields.
96
-
97
- #### Tests
98
-
99
- - **Protocol E2E tests** (`src/test/protocol.e2e.test.ts`) — 52 tests using
100
- `InMemoryTransport` + MCP `Client` to exercise the full JSON-RPC wire format,
101
- Zod input validation, backend error surfacing as `{ isError: true }` tool
102
- results, and the MCP roots protocol.
103
- - **`startBeansMcpServer` integration tests** (`src/test/startBeansMcpServer.test.ts`)
104
- — mocked dynamic imports for `BeansCliBackend` and `StdioServerTransport`.
105
- - Handler unit tests — exported handler factories tested in isolation.
106
- - `MutableBackend` unit tests — delegation and `setInner` swap behaviour.
107
- - `resolveWorkspaceFromRoots` unit tests — all branches (found, skipped,
108
- empty list, throws).
109
- - `parseCliArgs` tests — `workspaceExplicit` flag, `--help`/`-h` output and
110
- exit code.
111
- - Statement and function coverage: **100%** for `BeansMcpServer.ts`.
112
-
113
- #### CI
114
-
115
- - GitHub Actions workflow runs lint, type-check, build, and test on Node 18
116
- and 22 across Ubuntu and macOS.
117
- - pnpm store cache keyed on lockfile hash with `~/.pnpm-store` fallback.
118
-
119
- ### Changed
120
-
121
- - Tool IDs renamed to remove the `_vscode` suffix carried over from the
122
- extension (e.g. `beans_init_vscode` → `beans_init`).
123
- - `--log-dir` now defaults to the workspace root when omitted.
124
- - `cli.ts` simplified: removed the `isMainModule` guard; always invokes
125
- `startBeansMcpServer`.
126
- - Bin command renamed from `beans-mcp-server` to `beans-mcp`.
127
-
128
- ### Fixed
129
-
130
- - Build script was overriding `tsup.config.ts` with inline CLI flags, causing
131
- the CLI binary to never be produced. Fixed by setting `"build": "tsup"`.
132
- - `package.json` exports paths corrected to include the `dist/` prefix.
133
- - Eliminated all `any` types: `queryHandler` opts, `backend.ts` filter
134
- parameter, and `queryHelpers.ts` return type narrowed to
135
- `Record<string, unknown>`.
136
- - README: corrected package import name (`@selfagency/beans-mcp`), server
137
- default name (`beans-mcp-server`), removed the non-existent `allowedRoots`
138
- option from the `createBeansMcpServer` docs.
139
-
140
- [Unreleased]: https://github.com/selfagency/beans-mcp/compare/v0.1.0...HEAD
package/CONTRIBUTING.md DELETED
@@ -1,139 +0,0 @@
1
- # Contributing to beans-mcp-server
2
-
3
- Thank you for your interest in contributing to the Beans MCP server! This document provides guidelines and instructions for contributing.
4
-
5
- ## Development Setup
6
-
7
- ### Prerequisites
8
-
9
- - Node.js 18+
10
- - pnpm 9+
11
- - Beans CLI installed and in PATH (or specify via `--cli-path`)
12
-
13
- ### Getting Started
14
-
15
- 1. Clone the repository
16
- 2. Install dependencies:
17
-
18
- ```bash
19
- pnpm install
20
- ```
21
-
22
- 3. Build the project:
23
-
24
- ```bash
25
- pnpm build
26
- ```
27
-
28
- 4. Run tests:
29
-
30
- ```bash
31
- pnpm test
32
- ```
33
-
34
- ## Development Workflow
35
-
36
- ### Running Tests
37
-
38
- ```bash
39
- # Run all tests
40
- pnpm test
41
-
42
- # Run specific test file
43
- pnpm test src/test/utils.test.ts
44
-
45
- # Run with coverage
46
- pnpm test --coverage
47
- ```
48
-
49
- ### Building
50
-
51
- The project uses `tsup` for bundling:
52
-
53
- ```bash
54
- # Build all formats (ESM, CJS, CLI)
55
- pnpm build
56
-
57
- # Watch mode (development)
58
- pnpm build --watch
59
- ```
60
-
61
- Build outputs:
62
-
63
- - `dist/index.js` - ESM entry point
64
- - `dist/index.cjs` - CommonJS entry point
65
- - `dist/beans-mcp-server.cjs` - CLI executable (with shebang)
66
- - `dist/index.d.ts` - TypeScript type definitions
67
-
68
- ### Code Style
69
-
70
- - Use TypeScript for all source code
71
- - Format with Prettier (configured in project)
72
- - Lint with ESLint
73
- - Follow existing patterns in the codebase
74
-
75
- ### Testing Requirements
76
-
77
- - All changes should include tests
78
- - Use Vitest for unit tests
79
- - Tests should use Arrange-Act-Assert pattern
80
- - Aim for high test coverage
81
-
82
- ## Architecture
83
-
84
- ### Project Structure
85
-
86
- ```text
87
- src/
88
- ├── index.ts # Public API exports
89
- ├── cli.ts # CLI entry point
90
- ├── types.ts # TypeScript types and constants
91
- ├── utils.ts # Utility functions
92
- ├── server/
93
- │ ├── BeansMcpServer.ts # Main MCP server implementation
94
- │ └── backend.ts # Backend interface and Beans CLI backend
95
- ├── internal/
96
- │ ├── graphql.ts # GraphQL queries/mutations
97
- │ └── queryHelpers.ts # Query and sorting utilities
98
- └── test/
99
- ├── utils.test.ts
100
- └── parseCliArgs.test.ts
101
- ```
102
-
103
- ### Key Modules
104
-
105
- - **BeansMcpServer.ts**: Main server class that manages MCP tools and backend interaction
106
- - **backend.ts**: Interface for backend implementations; includes BeansCliBackend that wraps Beans CLI
107
- - **graphql.ts**: GraphQL queries and mutations for bean operations
108
- - **queryHelpers.ts**: Sorting, filtering, and query handling utilities
109
-
110
- ## Submitting Changes
111
-
112
- 1. Create a feature branch from `main`
113
- 2. Make your changes with clear, atomic commits
114
- 3. Add or update tests as needed
115
- 4. Run `pnpm test` to ensure all tests pass
116
- 5. Run `pnpm build` to verify the build succeeds
117
- 6. Submit a pull request with a clear description
118
-
119
- ## Pull Request Guidelines
120
-
121
- - Include a clear description of what changed and why
122
- - Reference any related issues
123
- - Ensure all tests pass
124
- - Update documentation if needed
125
- - Keep commits focused and atomic
126
-
127
- ## Reporting Issues
128
-
129
- When reporting bugs, please include:
130
-
131
- - Steps to reproduce
132
- - Expected behavior
133
- - Actual behavior
134
- - Node.js and pnpm versions
135
- - Relevant error messages or logs
136
-
137
- ## License
138
-
139
- By contributing, you agree that your contributions will be licensed under the MIT License.
package/dist/README.md DELETED
@@ -1,307 +0,0 @@
1
- # @selfagency/beans-mcp 🫘
2
-
3
- [![Test & Build](https://github.com/selfagency/beans-mcp/actions/workflows/test.yml/badge.svg)](https://github.com/selfagency/beans-mcp/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/selfagency/beans-mcp/graph/badge.svg?token=udeAJyu8Nu)](https://codecov.io/gh/selfagency/beans-mcp)
4
-
5
- MCP (Model Context Protocol) server for [Beans](https://github.com/hmans/beans) issue tracker. Provides programmatic and CLI interfaces for AI-powered interactions with Beans workspaces.
6
-
7
- > 🤖 **Try Beans fully-integrated with GitHub Copilot in VS Code! Install the <a href="https://marketplace.visualstudio.com/items?itemName=selfagency.beans-vscode">selfagency.beans-vscode</a> extension.**
8
-
9
- ## Usage
10
-
11
- ```bash
12
- npx @selfagency/beans-mcp /path/to/workspace
13
- ```
14
-
15
- ### Parameters
16
-
17
- - `--workspace-root` or positional arg: Workspace root path
18
- - `--cli-path`: Path to Beans CLI
19
- - `--port`: MCP server port (default: 39173)
20
- - `--log-dir`: Log directory
21
- - `-h`, `--help`: Print usage and exit
22
-
23
- ## Summary of public MCP tools
24
-
25
- - `beans_init` — Initialize the workspace (optional `prefix`).
26
- - `beans_view` — Fetch full bean details by `beanId`.
27
- - `beans_create` — Create a new bean (title/type + optional fields).
28
- - `beans_update` — Consolidated metadata updates (status/type/priority/parent/clearParent/blocking/blockedBy).
29
- - `beans_delete` — Delete a bean (`beanId`, optional `force`).
30
- - `beans_reopen` — Reopen a completed or scrapped bean to an active status.
31
- - `beans_query` — Unified list/search/filter/sort/llm_context/open_config operations.
32
- - `beans_bean_file` — Read/edit/create/delete files under `.beans`.
33
- - `beans_output` — Read extension output logs or show guidance.
34
-
35
- ### Notes
36
-
37
- - The `beans_query` tool is intentionally broad: prefer it for listing, searching, filtering or sorting beans, and for generating Copilot instructions (`operation: 'llm_context'`).
38
- - All file and log operations validate paths to keep them within the workspace or the VS Code log directory.
39
- - `beans_update` replaces many fine-grained update tools; callers should use it to keep the public tool surface small and predictable.
40
-
41
- ## Examples
42
-
43
- ### beans_init
44
-
45
- Request:
46
-
47
- ```json
48
- { "prefix": "project" }
49
- ```
50
-
51
- Response (structuredContent):
52
-
53
- ```json
54
- { "initialized": true }
55
- ```
56
-
57
- ### beans_view
58
-
59
- Request:
60
-
61
- ```json
62
- { "beanId": "bean-abc" }
63
- ```
64
-
65
- Response (structuredContent):
66
-
67
- ```json
68
- {
69
- "bean": {
70
- "id": "bean-abc",
71
- "title": "Fix login timeout",
72
- "status": "todo",
73
- "type": "bug",
74
- "priority": "critical",
75
- "body": "...markdown...",
76
- "createdAt": "2025-12-01T12:00:00Z",
77
- "updatedAt": "2025-12-02T08:00:00Z"
78
- }
79
- }
80
- ```
81
-
82
- ### beans_create
83
-
84
- Request:
85
-
86
- ```json
87
- {
88
- "title": "Add dark mode",
89
- "type": "feature",
90
- "status": "todo",
91
- "priority": "normal",
92
- "description": "Implement theme toggle and styles"
93
- }
94
- ```
95
-
96
- Response (structuredContent):
97
-
98
- ```json
99
- {
100
- "bean": {
101
- "id": "new-1",
102
- "title": "Add dark mode",
103
- "status": "todo",
104
- "type": "feature"
105
- }
106
- }
107
- ```
108
-
109
- ### beans_update
110
-
111
- Request (change status and add blocking):
112
-
113
- ```json
114
- {
115
- "beanId": "bean-abc",
116
- "status": "in-progress",
117
- "blocking": ["bean-def"]
118
- }
119
- ```
120
-
121
- Response (structuredContent):
122
-
123
- ```json
124
- {
125
- "bean": {
126
- "id": "bean-abc",
127
- "status": "in-progress",
128
- "blockingIds": ["bean-def"]
129
- }
130
- }
131
- ```
132
-
133
- ### beans_delete
134
-
135
- Request:
136
-
137
- ```json
138
- { "beanId": "bean-old", "force": false }
139
- ```
140
-
141
- Response:
142
-
143
- ```json
144
- { "deleted": true, "beanId": "bean-old" }
145
- ```
146
-
147
- ### beans_reopen
148
-
149
- Request:
150
-
151
- ```json
152
- {
153
- "beanId": "bean-closed",
154
- "requiredCurrentStatus": "completed",
155
- "targetStatus": "todo"
156
- }
157
- ```
158
-
159
- Response:
160
-
161
- ```json
162
- { "bean": { "id": "bean-closed", "status": "todo" } }
163
- ```
164
-
165
- ### beans_query — examples
166
-
167
- Refresh (list all beans):
168
-
169
- ```json
170
- { "operation": "refresh" }
171
- ```
172
-
173
- Response (partial):
174
-
175
- ```json
176
- { "count": 12, "beans": [] }
177
- ```
178
-
179
- Filter (statuses/types/tags):
180
-
181
- ```json
182
- {
183
- "operation": "filter",
184
- "statuses": ["in-progress", "todo"],
185
- "types": ["bug", "feature"],
186
- "tags": ["auth"]
187
- }
188
- ```
189
-
190
- Search (full-text):
191
-
192
- ```json
193
- { "operation": "search", "search": "authentication", "includeClosed": false }
194
- ```
195
-
196
- Sort (modes: `status-priority-type-title`, `updated`, `created`, `id`):
197
-
198
- ```json
199
- { "operation": "sort", "mode": "updated" }
200
- ```
201
-
202
- LLM context (generate Copilot instructions; optional write-to-workspace):
203
-
204
- ```json
205
- { "operation": "llm_context", "writeToWorkspaceInstructions": true }
206
- ```
207
-
208
- Response (structuredContent):
209
-
210
- ```json
211
- {
212
- "graphqlSchema": "...",
213
- "generatedInstructions": "...",
214
- "instructionsPath": "/workspace/.github/instructions/tasks.instructions.md"
215
- }
216
- ```
217
-
218
- ### beans_bean_file
219
-
220
- Request (read):
221
-
222
- ```json
223
- { "operation": "read", "path": "beans-vscode-123--title.md" }
224
- ```
225
-
226
- Response:
227
-
228
- ```json
229
- {
230
- "path": "/workspace/.beans/beans-vscode-123--title.md",
231
- "content": "---\n...frontmatter...\n---\n# Title\n"
232
- }
233
- ```
234
-
235
- ### beans_output
236
-
237
- Request (read last 200 lines):
238
-
239
- ```json
240
- { "operation": "read", "lines": 200 }
241
- ```
242
-
243
- Response:
244
-
245
- ```json
246
- {
247
- "path": "/workspace/.vscode/logs/beans-output.log",
248
- "content": "...log lines...",
249
- "linesReturned": 200
250
- }
251
- ```
252
-
253
- ## Programmatic usage
254
-
255
- ### Installation
256
-
257
- ```bash
258
- npm install beans-mcp
259
- ```
260
-
261
- ### Example
262
-
263
- ```typescript
264
- import { createBeansMcpServer, parseCliArgs } from "@selfagency/beans-mcp";
265
-
266
- const server = await createBeansMcpServer({
267
- workspaceRoot: "/path/to/workspace",
268
- cliPath: "beans", // or path to beans CLI
269
- });
270
-
271
- // Connect to stdio transport or your own transport
272
- ```
273
-
274
- ### API
275
-
276
- #### createBeansMcpServer(opts)
277
-
278
- Creates and initializes a Beans MCP server instance.
279
-
280
- **Options:**
281
-
282
- - `workspaceRoot` (string): Path to the Beans workspace
283
- - `cliPath` (string, optional): Path to Beans CLI executable (default: 'beans')
284
- - `name` (string, optional): Server name (default: 'beans-mcp-server')
285
- - `version` (string, optional): Server version
286
- - `logDir` (string, optional): Directory for server logs
287
- - `backend` (BackendInterface, optional): Custom backend implementation
288
-
289
- **Returns:** `{ server: McpServer; backend: BackendInterface }`
290
-
291
- #### startBeansMcpServer(argv)
292
-
293
- CLI-compatible entrypoint for launching the server.
294
-
295
- ### Utility Functions
296
-
297
- - `parseCliArgs(argv: string[])`: Parse CLI arguments
298
- - `isPathWithinRoot(root: string, target: string): boolean`: Check if path is contained within root
299
- - `sortBeans(beans, mode)`: Sort beans by specified mode
300
-
301
- ### Types & Schemas
302
-
303
- Export of GraphQL schema, Zod validation schemas, and TypeScript types for Beans records and operations.
304
-
305
- ## License
306
-
307
- MIT